Move TokenInfo into sdk

This commit is contained in:
Simon Warta 2020-02-01 16:23:08 +01:00
parent eb72f0e175
commit 4377fdd8ab
10 changed files with 37 additions and 37 deletions

View File

@ -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;

View File

@ -1,4 +1,3 @@
export { CosmWasmCodec } from "./cosmwasmcodec";
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
export { createCosmWasmConnector } from "./cosmwasmconnector";
export { TokenInfo } from "./types";

View File

@ -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???

View File

@ -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;
})[];

View File

@ -1,4 +1,3 @@
export { CosmWasmCodec } from "./cosmwasmcodec";
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
export { createCosmWasmConnector } from "./cosmwasmconnector";
export { TokenInfo } from "./types";

View File

@ -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;

View File

@ -1,2 +1,2 @@
export { RestClient, TxsResponse } from "./restclient";
export { AminoTx, isAminoStdTx } from "./types";
export { AminoTx, isAminoStdTx, TokenInfo } from "./types";

View File

@ -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;
}

View File

@ -1,2 +1,2 @@
export { RestClient, TxsResponse } from "./restclient";
export { AminoTx, isAminoStdTx } from "./types";
export { AminoTx, isAminoStdTx, TokenInfo } from "./types";

View File

@ -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;
}