From 8a9db1e8f9bea32e5d16400efaa143d302b70064 Mon Sep 17 00:00:00 2001 From: Ali Haghighatkhah Date: Thu, 9 Dec 2021 23:07:58 +0100 Subject: [PATCH] temp --- src/store/actions/transactions.js | 2 +- src/utils/hwManager.js | 4 ++-- src/utils/transaction.js | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/store/actions/transactions.js b/src/store/actions/transactions.js index 62883583fae..9bbe7c0dad2 100644 --- a/src/store/actions/transactions.js +++ b/src/store/actions/transactions.js @@ -5,7 +5,7 @@ import { } from '@constants'; import { isEmpty } from '@utils/helpers'; import { getTransactions, create, broadcast } from '@api/transaction'; -import { selectActiveTokenAccount, selectNetworkIdentifier } from '@store/selectors'; +import { selectNetworkIdentifier } from '@store/selectors'; import { signMultisigTransaction, transformTransaction } from '@utils/transaction'; import { getTransactionSignatureStatus } from '@screens/signMultiSignTransaction/helpers'; import { timerReset } from './account'; diff --git a/src/utils/hwManager.js b/src/utils/hwManager.js index 23a06981e72..40781c8762c 100644 --- a/src/utils/hwManager.js +++ b/src/utils/hwManager.js @@ -43,7 +43,7 @@ const signTransactionByHW = async ( transactionObject, transactionBytes, ) => { - const transaction = { + const data = { deviceId: account.hwInfo.deviceId, index: account.hwInfo.derivationIndex, networkIdentifier, @@ -51,7 +51,7 @@ const signTransactionByHW = async ( }; try { - const signature = await signTransaction(transaction); + const signature = await signTransaction(data); if (Array.isArray(transactionObject.signatures)) { transactionObject.signatures.push(signature); } else { diff --git a/src/utils/transaction.js b/src/utils/transaction.js index 46b1a738d16..ebbf4b39403 100644 --- a/src/utils/transaction.js +++ b/src/utils/transaction.js @@ -227,26 +227,26 @@ const flattenTransaction = ({ moduleAssetId, asset, ...rest }) => { }; switch (moduleAssetId) { - case MODULE_ASSETS_NAME_ID_MAP.transfer: { + case transfer: { transaction.recipientAddress = asset.recipient.address; transaction.amount = asset.amount; transaction.data = asset.data; break; } - case MODULE_ASSETS_NAME_ID_MAP.voteDelegate: + case voteDelegate: transaction.votes = asset.votes; break; - case MODULE_ASSETS_NAME_ID_MAP.registerDelegate: + case registerDelegate: transaction.username = asset.username; break; - case MODULE_ASSETS_NAME_ID_MAP.unlockToken: + case unlockToken: transaction.unlockObjects = asset.unlockObjects; break; - case MODULE_ASSETS_NAME_ID_MAP.registerMultisignatureGroup: { + case registerMultisignatureGroup: { transaction.numberOfSignatures = asset.numberOfSignatures; transaction.mandatoryKeys = asset.mandatoryKeys; transaction.optionalKeys = asset.optionalKeys; @@ -499,13 +499,17 @@ const signUsingPrivateKey = (schema, transaction, networkIdentifier, privateKey) ); const signUsingHW = async (schema, transaction, account, networkIdentifier, network) => { + console.log('INFO 1', transaction); + console.log('INFO 2', schema); const signingBytes = transactions.getSigningBytes(schema, transaction); + console.log('INFO 3', signingBytes); const [error, signedTransaction] = await to(signTransactionByHW( account, networkIdentifier, transaction, signingBytes, )); + console.log('INFO 4', error, signedTransaction); if (error) { throw error; } @@ -556,8 +560,7 @@ const signMultisigTransaction = async ( * Define keys. * Since the sender is different, the keys are defined based on that */ - const isGroupRegistration = transaction.moduleAssetId - === MODULE_ASSETS_NAME_ID_MAP.registerMultisignatureGroup; + const isGroupRegistration = transaction.moduleAssetId === registerMultisignatureGroup; const schema = network.networks.LSK.moduleAssetSchemas[transaction.moduleAssetId]; const networkIdentifier = Buffer.from(network.networks.LSK.networkIdentifier, 'hex'); @@ -607,7 +610,7 @@ const signMultisigTransaction = async ( * @returns {number} the number of signatures required */ const getNumberOfSignatures = (account, transaction) => { - if (transaction?.moduleAssetId === MODULE_ASSETS_NAME_ID_MAP.registerMultisignatureGroup) { + if (transaction?.moduleAssetId === registerMultisignatureGroup) { return transaction.optionalKeys.length + transaction.mandatoryKeys.length + 1; } if (account?.summary?.isMultisignature) {