From 7440bfb6f14365067df51ff9a598a4c0b2dc5338 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Thu, 23 Jan 2020 14:29:02 +0100 Subject: [PATCH] Removed obsolete TODOS --- src/cosmoscodec.ts | 1 - src/cosmosconnection.ts | 9 ++++----- src/decode.ts | 6 ------ src/types.ts | 3 ++- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/cosmoscodec.ts b/src/cosmoscodec.ts index 9e122a8f..944737ea 100644 --- a/src/cosmoscodec.ts +++ b/src/cosmoscodec.ts @@ -91,7 +91,6 @@ export class CosmosCodec implements TxCodec { throw new Error("Nonce is required"); } const parsed = unmarshalTx(bytes); - // TODO: this needs access to token list return parseTx(parsed, chainId, nonce, this.tokens); } diff --git a/src/cosmosconnection.ts b/src/cosmosconnection.ts index 76f67f45..5948e528 100644 --- a/src/cosmosconnection.ts +++ b/src/cosmosconnection.ts @@ -89,14 +89,13 @@ export class CosmosConnection implements BlockchainConnection { private readonly restClient: RestClient; private readonly chainData: ChainData; - private readonly primaryToken: Token; - - // TODO: deprecate this??? - private readonly supportedTokens: readonly Token[]; - private readonly _prefix: CosmosBech32Prefix; private readonly tokenInfo: TokenInfos; + // these are derived from arguments (cached for use in multiple functions) + private readonly primaryToken: Token; + private readonly supportedTokens: readonly Token[]; + private get prefix(): CosmosBech32Prefix { return this._prefix; } diff --git a/src/decode.ts b/src/decode.ts index af0f2187..ad5a8284 100644 --- a/src/decode.ts +++ b/src/decode.ts @@ -45,9 +45,6 @@ export function decodeFullSignature(signature: amino.StdSignature, nonce: number }; } -// TODO: this needs access to token list - we need something more like amountToCoin and coinToAmount here -// and wire that info all the way from both connection and codec. - // TODO: return null vs throw exception for undefined??? export const decodeAmount = (tokens: TokenInfos) => (coin: amino.Coin): Amount => { return coinToAmount(tokens, coin); @@ -69,7 +66,6 @@ export function parseMsg(msg: amino.Msg, chainId: ChainId, tokens: TokenInfos): chainId: chainId, sender: msgValue.from_address as Address, recipient: msgValue.to_address as Address, - // TODO: this needs access to token list amount: decodeAmount(tokens)(msgValue.amount[0]), }; } @@ -94,9 +90,7 @@ export function parseTx(tx: amino.Tx, chainId: ChainId, nonce: Nonce, tokens: To } const [primarySignature] = txValue.signatures.map(signature => decodeFullSignature(signature, nonce)); - // TODO: this needs access to token list const msg = parseMsg(txValue.msg[0], chainId, tokens); - // TODO: this needs access to token list const fee = parseFee(txValue.fee, tokens); const transaction = { diff --git a/src/types.ts b/src/types.ts index 03996413..5e44a030 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,7 +16,7 @@ export interface TokenInfo extends Token { export type TokenInfos = ReadonlyArray; -// TODO: alias amino types +// TODO: return null vs throw exception for undefined??? export function amountToCoin(lookup: ReadonlyArray, amount: Amount): amino.Coin { const match = lookup.find(({ tokenTicker }) => tokenTicker === amount.tokenTicker); if (!match) { @@ -28,6 +28,7 @@ export function amountToCoin(lookup: ReadonlyArray, amount: Amount): }; } +// TODO: return null vs throw exception for undefined??? export function coinToAmount(tokens: TokenInfos, coin: amino.Coin): Amount { const match = tokens.find(({ denom }) => denom === coin.denom); if (!match) {