From 1f91005c8eabd627700dd0fcce7ec77a58dec0bc Mon Sep 17 00:00:00 2001 From: wa-aal <93649819+wa-aal@users.noreply.github.com> Date: Mon, 14 Mar 2022 09:06:22 +0100 Subject: [PATCH] Cosmos JS (#1804) * be more conform between optimistic and final operation * use old code logic * fix senders/recipients regression * fix duplicate data * fix duplicate data (again) * append block height * fix specific empty amount case in reward transaction * temporary debug operation broadcasted * use toOperationRaw method * return patchedOperation * restore broadcast operation * Update js-synchronisation.ts * remove block height support * Revert "remove block height support" This reverts commit eb7198f9ab1edef8a82a1edcccaefc9907e99868. * More strict type * reverse order of validators * fix validators type in createTransmission * add sequence to ops * strict output getAccount type * fix operations sequence Co-authored-by: Alexandre Alouit --- src/families/cosmos/api/Cosmos.ts | 4 +++- src/families/cosmos/js-createTransaction.ts | 4 ++-- src/families/cosmos/js-signOperation.ts | 1 + src/families/cosmos/js-synchronisation.ts | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/families/cosmos/api/Cosmos.ts b/src/families/cosmos/api/Cosmos.ts index e179aa04ee..19f0d878b9 100644 --- a/src/families/cosmos/api/Cosmos.ts +++ b/src/families/cosmos/api/Cosmos.ts @@ -46,7 +46,9 @@ export const getAccountInfo = async (address: string): Promise => { } }; -export const getAccount = async (address: string): Promise => { +export const getAccount = async ( + address: string +): Promise<{ address: string; accountNumber: number; sequence: number }> => { const response = { address: address, accountNumber: 0, diff --git a/src/families/cosmos/js-createTransaction.ts b/src/families/cosmos/js-createTransaction.ts index 0da7675ffb..1027809f3a 100644 --- a/src/families/cosmos/js-createTransaction.ts +++ b/src/families/cosmos/js-createTransaction.ts @@ -1,5 +1,5 @@ import { BigNumber } from "bignumber.js"; -import type { Transaction } from "./types"; +import type { CosmosDelegationInfo, Transaction } from "./types"; /** * Create an empty transaction @@ -17,7 +17,7 @@ const createTransaction = (): Transaction => ({ networkInfo: null, memo: null, cosmosSourceValidator: null, - validators: [], + validators: [] as CosmosDelegationInfo[], }); export default createTransaction; diff --git a/src/families/cosmos/js-signOperation.ts b/src/families/cosmos/js-signOperation.ts index 8ede2b5a0b..d8fb56515e 100644 --- a/src/families/cosmos/js-signOperation.ts +++ b/src/families/cosmos/js-signOperation.ts @@ -154,6 +154,7 @@ const signOperation = ({ recipients, accountId, date: new Date(), + transactionSequenceNumber: sequence, }; o.next({ diff --git a/src/families/cosmos/js-synchronisation.ts b/src/families/cosmos/js-synchronisation.ts index 5e19f25b74..d5eb008b08 100644 --- a/src/families/cosmos/js-synchronisation.ts +++ b/src/families/cosmos/js-synchronisation.ts @@ -33,6 +33,9 @@ const txToOps = (info: any, id: string, txs: any): Operation[] => { extra: { validators: [] as CosmosDelegationInfo[], }, + transactionSequenceNumber: parseInt( + tx.tx.auth_info.signer_infos[0].sequence + ), }; tx.logs[0].events.forEach((message) => {