Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
reyraa committed Dec 9, 2021
1 parent 5e74371 commit 8a9db1e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/store/actions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/utils/hwManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const signTransactionByHW = async (
transactionObject,
transactionBytes,
) => {
const transaction = {
const data = {
deviceId: account.hwInfo.deviceId,
index: account.hwInfo.derivationIndex,
networkIdentifier,
transactionBytes,
};

try {
const signature = await signTransaction(transaction);
const signature = await signTransaction(data);
if (Array.isArray(transactionObject.signatures)) {
transactionObject.signatures.push(signature);
} else {
Expand Down
19 changes: 11 additions & 8 deletions src/utils/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8a9db1e

Please sign in to comment.