From fa40ff54a5946e98b68b8485af06096be2fa0c32 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Jan 2020 17:56:37 +0100 Subject: [PATCH] Add todos for token mapping logic --- src/cosmoscodec.ts | 1 + src/decode.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cosmoscodec.ts b/src/cosmoscodec.ts index ba449e4e..920211a9 100644 --- a/src/cosmoscodec.ts +++ b/src/cosmoscodec.ts @@ -81,6 +81,7 @@ 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); } diff --git a/src/decode.ts b/src/decode.ts index c368c804..46f00d0b 100644 --- a/src/decode.ts +++ b/src/decode.ts @@ -45,7 +45,9 @@ export function decodeFullSignature(signature: amino.StdSignature, nonce: number }; } -export function decodeAmount(amount: amino.Coin): Amount { + // 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. + export function decodeAmount(amount: amino.Coin): Amount { // TODO: more uglyness here (breaks unit tests) if (amount.denom !== "uatom") { throw new Error("Only ATOM amounts are supported"); @@ -74,6 +76,7 @@ export function parseMsg(msg: amino.Msg, chainId: ChainId): SendTransaction { chainId: chainId, sender: msgValue.from_address as Address, recipient: msgValue.to_address as Address, + // TODO: this needs access to token list amount: decodeAmount(msgValue.amount[0]), }; } @@ -98,7 +101,9 @@ export function parseTx(tx: amino.Tx, chainId: ChainId, nonce: Nonce): SignedTra } const [primarySignature] = txValue.signatures.map(signature => decodeFullSignature(signature, nonce)); + // TODO: this needs access to token list const msg = parseMsg(txValue.msg[0], chainId); + // TODO: this needs access to token list const fee = parseFee(txValue.fee); const transaction = {