diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index dd288a7d..a87e91a0 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { RestClient, TokenInfo, TxsResponse } from "@cosmwasm/sdk"; +import { RestClient, TxsResponse, types } from "@cosmwasm/sdk"; import { Account, AccountQuery, @@ -68,7 +68,7 @@ function buildQueryString({ return components.filter(Boolean).join("&"); } -export type TokenConfiguration = readonly (TokenInfo & { readonly name: string })[]; +export type TokenConfiguration = readonly (types.TokenInfo & { readonly name: string })[]; export class CosmWasmConnection implements BlockchainConnection { // we must know prefix and tokens a priori to understand the chain @@ -90,7 +90,7 @@ export class CosmWasmConnection implements BlockchainConnection { private readonly restClient: RestClient; private readonly chainData: ChainData; private readonly _prefix: CosmosBech32Prefix; - private readonly tokenInfo: readonly TokenInfo[]; + private readonly tokenInfo: readonly types.TokenInfo[]; // these are derived from arguments (cached for use in multiple functions) private readonly primaryToken: Token; diff --git a/packages/bcp/src/decode.ts b/packages/bcp/src/decode.ts index f06b1e49..c3323e97 100644 --- a/packages/bcp/src/decode.ts +++ b/packages/bcp/src/decode.ts @@ -1,4 +1,4 @@ -import { coinToDecimal, isAminoStdTx, TxsResponse } from "@cosmwasm/sdk"; +import { coinToDecimal, TxsResponse, types } from "@cosmwasm/sdk"; import { Address, Algorithm, @@ -96,7 +96,7 @@ export function parseFee(fee: amino.StdFee, tokens: TokenInfos): Fee { export function parseTx(tx: amino.Tx, chainId: ChainId, nonce: Nonce, tokens: TokenInfos): SignedTransaction { const txValue = tx.value; - if (!isAminoStdTx(txValue)) { + if (!types.isAminoStdTx(txValue)) { throw new Error("Only Amino StdTx is supported"); } if (txValue.msg.length !== 1) { diff --git a/packages/bcp/src/encode.ts b/packages/bcp/src/encode.ts index 5fb4b842..5da2da07 100644 --- a/packages/bcp/src/encode.ts +++ b/packages/bcp/src/encode.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/camelcase */ -import { AminoTx, decimalToCoin } from "@cosmwasm/sdk"; +import { decimalToCoin, types } from "@cosmwasm/sdk"; import { Algorithm, Amount, @@ -67,7 +67,7 @@ export function encodeFullSignature(fullSignature: FullSignature): amino.StdSign }; } -export function buildUnsignedTx(tx: UnsignedTransaction, tokens: TokenInfos): AminoTx { +export function buildUnsignedTx(tx: UnsignedTransaction, tokens: TokenInfos): types.AminoTx { if (!isSendTransaction(tx)) { throw new Error("Received transaction of unsupported kind"); } @@ -96,7 +96,7 @@ export function buildUnsignedTx(tx: UnsignedTransaction, tokens: TokenInfos): Am }; } -export function buildSignedTx(tx: SignedTransaction, tokens: TokenInfos): AminoTx { +export function buildSignedTx(tx: SignedTransaction, tokens: TokenInfos): types.AminoTx { const built = buildUnsignedTx(tx.transaction, tokens); return { ...built, diff --git a/packages/bcp/src/types.ts b/packages/bcp/src/types.ts index 07003e90..eb90b68f 100644 --- a/packages/bcp/src/types.ts +++ b/packages/bcp/src/types.ts @@ -1,7 +1,7 @@ -import { TokenInfo } from "@cosmwasm/sdk"; +import { types } from "@cosmwasm/sdk"; import { Nonce } from "@iov/bcp"; -export type TokenInfos = ReadonlyArray; +export type TokenInfos = ReadonlyArray; // tslint:disable-next-line:no-bitwise const maxAcct = 1 << 23; diff --git a/packages/bcp/types/cosmwasmconnection.d.ts b/packages/bcp/types/cosmwasmconnection.d.ts index 4a8a3d83..b84557df 100644 --- a/packages/bcp/types/cosmwasmconnection.d.ts +++ b/packages/bcp/types/cosmwasmconnection.d.ts @@ -1,4 +1,4 @@ -import { TokenInfo } from "@cosmwasm/sdk"; +import { types } from "@cosmwasm/sdk"; import { Account, AccountQuery, @@ -22,7 +22,7 @@ import { } from "@iov/bcp"; import { Stream } from "xstream"; import { CosmosBech32Prefix } from "./address"; -export declare type TokenConfiguration = readonly (TokenInfo & { +export declare type TokenConfiguration = readonly (types.TokenInfo & { readonly name: string; })[]; export declare class CosmWasmConnection implements BlockchainConnection { diff --git a/packages/bcp/types/encode.d.ts b/packages/bcp/types/encode.d.ts index 1068443a..99feed23 100644 --- a/packages/bcp/types/encode.d.ts +++ b/packages/bcp/types/encode.d.ts @@ -1,4 +1,4 @@ -import { AminoTx } from "@cosmwasm/sdk"; +import { types } from "@cosmwasm/sdk"; import { Amount, Fee, FullSignature, PubkeyBundle, SignedTransaction, UnsignedTransaction } from "@iov/bcp"; import amino from "@tendermint/amino-js"; import { TokenInfos } from "./types"; @@ -6,5 +6,5 @@ export declare function encodePubkey(pubkey: PubkeyBundle): amino.PubKey; export declare function encodeAmount(amount: Amount, tokens: TokenInfos): amino.Coin; export declare function encodeFee(fee: Fee, tokens: TokenInfos): amino.StdFee; export declare function encodeFullSignature(fullSignature: FullSignature): amino.StdSignature; -export declare function buildUnsignedTx(tx: UnsignedTransaction, tokens: TokenInfos): AminoTx; -export declare function buildSignedTx(tx: SignedTransaction, tokens: TokenInfos): AminoTx; +export declare function buildUnsignedTx(tx: UnsignedTransaction, tokens: TokenInfos): types.AminoTx; +export declare function buildSignedTx(tx: SignedTransaction, tokens: TokenInfos): types.AminoTx; diff --git a/packages/bcp/types/types.d.ts b/packages/bcp/types/types.d.ts index 8bdcbf3b..b419ece0 100644 --- a/packages/bcp/types/types.d.ts +++ b/packages/bcp/types/types.d.ts @@ -1,6 +1,6 @@ -import { TokenInfo } from "@cosmwasm/sdk"; +import { types } from "@cosmwasm/sdk"; import { Nonce } from "@iov/bcp"; -export declare type TokenInfos = ReadonlyArray; +export declare type TokenInfos = ReadonlyArray; export interface NonceInfo { readonly account_number: string; readonly sequence: string; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 888fb6c3..e664c4a5 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,4 +1,5 @@ export { coinToDecimal } from "./decoding"; export { decimalToCoin } from "./encoding"; export { RestClient, TxsResponse } from "./restclient"; -export { AminoTx, isAminoStdTx, TokenInfo } from "./types"; +// export { AminoTx, isAminoStdTx, TokenInfo } from "./types"; +export { default as types } from "./types"; diff --git a/packages/sdk/types/index.d.ts b/packages/sdk/types/index.d.ts index 888fb6c3..d85cdb7b 100644 --- a/packages/sdk/types/index.d.ts +++ b/packages/sdk/types/index.d.ts @@ -1,4 +1,4 @@ export { coinToDecimal } from "./decoding"; export { decimalToCoin } from "./encoding"; export { RestClient, TxsResponse } from "./restclient"; -export { AminoTx, isAminoStdTx, TokenInfo } from "./types"; +export { default as types } from "./types";