Simplify codecImplementation() and establishConnection()
This commit is contained in:
@@ -5,7 +5,7 @@ import Koa from "koa";
|
||||
import bodyParser from "koa-bodyparser";
|
||||
|
||||
import { creditAmount, setFractionalDigits } from "../../cashflow";
|
||||
import { codecDefaultFractionalDigits, codecImplementation, createChainConnector } from "../../codec";
|
||||
import { codecDefaultFractionalDigits, codecImplementation, establishConnection } from "../../codec";
|
||||
import * as constants from "../../constants";
|
||||
import { logAccountsState, logSendJob } from "../../debugging";
|
||||
import {
|
||||
@@ -44,7 +44,7 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
|
||||
throw new Error("The FAUCET_MNEMONIC environment variable is not set");
|
||||
}
|
||||
console.info(`Connecting to blockchain ${blockchainBaseUrl} ...`);
|
||||
const connection = await createChainConnector(blockchainBaseUrl).establishConnection();
|
||||
const connection = await establishConnection(blockchainBaseUrl);
|
||||
|
||||
const connectedChainId = connection.chainId();
|
||||
console.info(`Connected to network: ${connectedChainId}`);
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import { createCosmWasmConnector, TokenInfo } from "@cosmwasm/bcp";
|
||||
import { ChainConnector, TokenTicker, TxCodec } from "@iov/bcp";
|
||||
import { CosmWasmCodec, CosmWasmConnection, TokenInfo } from "@cosmwasm/bcp";
|
||||
import { TokenTicker, TxCodec } from "@iov/bcp";
|
||||
|
||||
export function createChainConnector(url: string): ChainConnector {
|
||||
const tokens: readonly TokenInfo[] = [
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Fee Token",
|
||||
tokenTicker: "COSM" as TokenTicker,
|
||||
denom: "cosm",
|
||||
},
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Staking Token",
|
||||
tokenTicker: "STAKE" as TokenTicker,
|
||||
denom: "stake",
|
||||
},
|
||||
];
|
||||
return createCosmWasmConnector(url, "cosmos", tokens);
|
||||
const prefix = "cosmos";
|
||||
const tokens: readonly TokenInfo[] = [
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Fee Token",
|
||||
tokenTicker: "COSM" as TokenTicker,
|
||||
denom: "cosm",
|
||||
},
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Staking Token",
|
||||
tokenTicker: "STAKE" as TokenTicker,
|
||||
denom: "stake",
|
||||
},
|
||||
];
|
||||
|
||||
export async function establishConnection(url: string): Promise<CosmWasmConnection> {
|
||||
return CosmWasmConnection.establish(url, prefix, tokens);
|
||||
}
|
||||
|
||||
export function codecImplementation(): TxCodec {
|
||||
return createChainConnector("unused dummy url").codec;
|
||||
return new CosmWasmCodec(prefix, tokens);
|
||||
}
|
||||
|
||||
export function codecDefaultFractionalDigits(): number {
|
||||
|
||||
Reference in New Issue
Block a user