diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index 05a87fdf..2cd19fe1 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { RestClient, TxsResponse } from "@cosmwasm/sdk"; +import { RestClient, TokenInfo, TxsResponse } from "@cosmwasm/sdk"; import { Account, AccountQuery, @@ -38,7 +38,7 @@ import { Stream } from "xstream"; import { CosmosBech32Prefix, decodeCosmosPubkey, pubkeyToAddress } from "./address"; import { Caip5 } from "./caip5"; import { decodeAmount, parseTxsResponse } from "./decode"; -import { accountToNonce, TokenInfo, TokenInfos } from "./types"; +import { accountToNonce } from "./types"; interface ChainData { readonly chainId: ChainId; @@ -90,7 +90,7 @@ export class CosmWasmConnection implements BlockchainConnection { private readonly restClient: RestClient; private readonly chainData: ChainData; private readonly _prefix: CosmosBech32Prefix; - private readonly tokenInfo: TokenInfos; + private readonly tokenInfo: readonly TokenInfo[]; // these are derived from arguments (cached for use in multiple functions) private readonly primaryToken: Token; diff --git a/packages/bcp/src/index.ts b/packages/bcp/src/index.ts index 000a7e80..8402859d 100644 --- a/packages/bcp/src/index.ts +++ b/packages/bcp/src/index.ts @@ -1,4 +1,3 @@ export { CosmWasmCodec } from "./cosmwasmcodec"; export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection"; export { createCosmWasmConnector } from "./cosmwasmconnector"; -export { TokenInfo } from "./types"; diff --git a/packages/bcp/src/types.ts b/packages/bcp/src/types.ts index f3f46653..26b080b7 100644 --- a/packages/bcp/src/types.ts +++ b/packages/bcp/src/types.ts @@ -1,21 +1,7 @@ +import { TokenInfo } from "@cosmwasm/sdk"; import { Amount, Nonce, TokenTicker } from "@iov/bcp"; import amino from "@tendermint/amino-js"; -export interface TokenInfo { - readonly denom: string; - readonly ticker: string; - /** - * The number of fractional digits the token supports. - * - * A quantity is expressed as atomic units. 10^fractionalDigits of those - * atomic units make up 1 token. - * - * E.g. in Ethereum 10^18 wei are 1 ETH and from the quantity 123000000000000000000 - * the last 18 digits are the fractional part and the rest the wole part. - */ - readonly fractionalDigits: number; -} - export type TokenInfos = ReadonlyArray; // TODO: return null vs throw exception for undefined??? diff --git a/packages/bcp/types/cosmwasmconnection.d.ts b/packages/bcp/types/cosmwasmconnection.d.ts index 764e9512..4a8a3d83 100644 --- a/packages/bcp/types/cosmwasmconnection.d.ts +++ b/packages/bcp/types/cosmwasmconnection.d.ts @@ -1,3 +1,4 @@ +import { TokenInfo } from "@cosmwasm/sdk"; import { Account, AccountQuery, @@ -21,7 +22,6 @@ import { } from "@iov/bcp"; import { Stream } from "xstream"; import { CosmosBech32Prefix } from "./address"; -import { TokenInfo } from "./types"; export declare type TokenConfiguration = readonly (TokenInfo & { readonly name: string; })[]; diff --git a/packages/bcp/types/index.d.ts b/packages/bcp/types/index.d.ts index 000a7e80..8402859d 100644 --- a/packages/bcp/types/index.d.ts +++ b/packages/bcp/types/index.d.ts @@ -1,4 +1,3 @@ export { CosmWasmCodec } from "./cosmwasmcodec"; export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection"; export { createCosmWasmConnector } from "./cosmwasmconnector"; -export { TokenInfo } from "./types"; diff --git a/packages/bcp/types/types.d.ts b/packages/bcp/types/types.d.ts index 14cd95cf..7191f61c 100644 --- a/packages/bcp/types/types.d.ts +++ b/packages/bcp/types/types.d.ts @@ -1,19 +1,6 @@ +import { TokenInfo } from "@cosmwasm/sdk"; import { Amount, Nonce } from "@iov/bcp"; import amino from "@tendermint/amino-js"; -export interface TokenInfo { - readonly denom: string; - readonly ticker: string; - /** - * The number of fractional digits the token supports. - * - * A quantity is expressed as atomic units. 10^fractionalDigits of those - * atomic units make up 1 token. - * - * E.g. in Ethereum 10^18 wei are 1 ETH and from the quantity 123000000000000000000 - * the last 18 digits are the fractional part and the rest the wole part. - */ - readonly fractionalDigits: number; -} export declare type TokenInfos = ReadonlyArray; export declare function amountToCoin(lookup: ReadonlyArray, amount: Amount): amino.Coin; export declare function coinToAmount(tokens: TokenInfos, coin: amino.Coin): Amount; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index f8dbdc95..d4162d90 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,2 +1,2 @@ export { RestClient, TxsResponse } from "./restclient"; -export { AminoTx, isAminoStdTx } from "./types"; +export { AminoTx, isAminoStdTx, TokenInfo } from "./types"; diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index c8a0ef72..83be077d 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -8,3 +8,18 @@ export function isAminoStdTx(txValue: amino.TxValue): txValue is amino.StdTx { typeof memo === "string" && Array.isArray(msg) && typeof fee === "object" && Array.isArray(signatures) ); } + +export interface TokenInfo { + readonly denom: string; + readonly ticker: string; + /** + * The number of fractional digits the token supports. + * + * A quantity is expressed as atomic units. 10^fractionalDigits of those + * atomic units make up 1 token. + * + * E.g. in Ethereum 10^18 wei are 1 ETH and from the quantity 123000000000000000000 + * the last 18 digits are the fractional part and the rest the wole part. + */ + readonly fractionalDigits: number; +} diff --git a/packages/sdk/types/index.d.ts b/packages/sdk/types/index.d.ts index f8dbdc95..d4162d90 100644 --- a/packages/sdk/types/index.d.ts +++ b/packages/sdk/types/index.d.ts @@ -1,2 +1,2 @@ export { RestClient, TxsResponse } from "./restclient"; -export { AminoTx, isAminoStdTx } from "./types"; +export { AminoTx, isAminoStdTx, TokenInfo } from "./types"; diff --git a/packages/sdk/types/types.d.ts b/packages/sdk/types/types.d.ts index cb5a44a9..e41597e4 100644 --- a/packages/sdk/types/types.d.ts +++ b/packages/sdk/types/types.d.ts @@ -3,3 +3,17 @@ export declare type AminoTx = amino.Tx & { readonly value: amino.StdTx; }; export declare function isAminoStdTx(txValue: amino.TxValue): txValue is amino.StdTx; +export interface TokenInfo { + readonly denom: string; + readonly ticker: string; + /** + * The number of fractional digits the token supports. + * + * A quantity is expressed as atomic units. 10^fractionalDigits of those + * atomic units make up 1 token. + * + * E.g. in Ethereum 10^18 wei are 1 ETH and from the quantity 123000000000000000000 + * the last 18 digits are the fractional part and the rest the wole part. + */ + readonly fractionalDigits: number; +}