mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Move TokenInfo into sdk
This commit is contained in:
parent
eb72f0e175
commit
4377fdd8ab
@ -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;
|
||||
|
@ -1,4 +1,3 @@
|
||||
export { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmWasmConnector } from "./cosmwasmconnector";
|
||||
export { TokenInfo } from "./types";
|
||||
|
@ -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<TokenInfo>;
|
||||
|
||||
// TODO: return null vs throw exception for undefined???
|
||||
|
2
packages/bcp/types/cosmwasmconnection.d.ts
vendored
2
packages/bcp/types/cosmwasmconnection.d.ts
vendored
@ -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;
|
||||
})[];
|
||||
|
1
packages/bcp/types/index.d.ts
vendored
1
packages/bcp/types/index.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
export { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmWasmConnector } from "./cosmwasmconnector";
|
||||
export { TokenInfo } from "./types";
|
||||
|
15
packages/bcp/types/types.d.ts
vendored
15
packages/bcp/types/types.d.ts
vendored
@ -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<TokenInfo>;
|
||||
export declare function amountToCoin(lookup: ReadonlyArray<TokenInfo>, amount: Amount): amino.Coin;
|
||||
export declare function coinToAmount(tokens: TokenInfos, coin: amino.Coin): Amount;
|
||||
|
@ -1,2 +1,2 @@
|
||||
export { RestClient, TxsResponse } from "./restclient";
|
||||
export { AminoTx, isAminoStdTx } from "./types";
|
||||
export { AminoTx, isAminoStdTx, TokenInfo } from "./types";
|
||||
|
@ -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;
|
||||
}
|
||||
|
2
packages/sdk/types/index.d.ts
vendored
2
packages/sdk/types/index.d.ts
vendored
@ -1,2 +1,2 @@
|
||||
export { RestClient, TxsResponse } from "./restclient";
|
||||
export { AminoTx, isAminoStdTx } from "./types";
|
||||
export { AminoTx, isAminoStdTx, TokenInfo } from "./types";
|
||||
|
14
packages/sdk/types/types.d.ts
vendored
14
packages/sdk/types/types.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user