From 5cd89e61708f7913b37619484dfabfd8b44cc104 Mon Sep 17 00:00:00 2001 From: wa-aal <93649819+wa-aal@users.noreply.github.com> Date: Wed, 9 Mar 2022 11:27:58 +0100 Subject: [PATCH] be more conform between optimistic and final operation (#1786) Co-authored-by: Alexandre Alouit --- src/families/cosmos/js-signOperation.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/families/cosmos/js-signOperation.ts b/src/families/cosmos/js-signOperation.ts index ffd71f8804..ddf1d8d5cf 100644 --- a/src/families/cosmos/js-signOperation.ts +++ b/src/families/cosmos/js-signOperation.ts @@ -120,11 +120,6 @@ const signOperation = ({ const senders: string[] = []; const recipients: string[] = []; - if (type === "OUT") { - senders.push(account.freshAddress); - recipients.push(transaction.recipient); - } - // build optimistic operation const operation: Operation = { id: encodeOperationId(accountId, hash, type), @@ -143,6 +138,22 @@ const signOperation = ({ date: new Date(), }; + switch (type) { + case "OUT": + operation.senders.push(account.freshAddress); + operation.recipients.push(transaction.recipient); + break; + + case "REWARD": + case "DELEGATE": + case "UNDELEGATE": + operation.value = new BigNumber(fee); + operation.extra.validators = transaction.validators; + operation.extra.cosmosSourceValidator = + transaction.cosmosSourceValidator; + break; + } + o.next({ type: "signed", signedOperation: {