Skip to content

Commit

Permalink
[DDW-534] Fix outputs (unsigned) order
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomislav Horaček committed Jan 14, 2021
1 parent f5f2783 commit 70d6880
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/common/types/hardware-wallets.types.js
Expand Up @@ -109,7 +109,7 @@ export type StakingBlockchainPointer = {|

export type LedgerSignTransactionInputsType = Array<LedgerSignTransactionInputType>;

export type LedgerSignTransactionOutputsType = Array<
export type LedgerSignTransactionOutputsType = [] | Array<
LedgerOutputTypeAddress | LedgerOutputTypeChange
>;

Expand Down
25 changes: 19 additions & 6 deletions source/renderer/app/stores/HardwareWalletsStore.js
Expand Up @@ -1268,22 +1268,31 @@ export default class HardwareWalletsStore extends Store {
});

const unsignedTxOutputs = [];
const _outputsData = map(outputs, async (output) => {
const outputsData = [];
for (const output of outputs) {
// eslint-disable-next-line
console.debug('>>> ADDRESS: ', output.address);
const {
address_style: addressStyle,
} = await this.stores.addresses._inspectAddress({
addressId: output.address,
});
// eslint-disable-next-line
console.debug('>>> ADDRESS Details: ', addressStyle);

const shelleyTxOutput = ShelleyTxOutput(output, addressStyle);
unsignedTxOutputs.push(shelleyTxOutput);
// eslint-disable-next-line
console.debug('>>> _outputsData addresses: ', {
console.debug('>>> Store to output: ', {
addressStyle,
address: output.address,
})
return prepareLedgerOutput(output, addressStyle);
});
const outputsData = await Promise.all(_outputsData);
const ledgerOutput = prepareLedgerOutput(output, addressStyle);
outputsData.push(ledgerOutput);
}

// eslint-disable-next-line
console.debug('>>> outputsData: ', outputsData);

const unsignedTxCerts = [];
const _certificatesData = map(certificates, async (certificate) => {
Expand Down Expand Up @@ -1343,6 +1352,7 @@ export default class HardwareWalletsStore extends Store {
metadataHashHex,
devicePath,
});

// Prepare unsigned transaction structure for serialzation
const unsignedTx = prepareTxAux({
txInputs: unsignedTxInputs,
Expand All @@ -1353,6 +1363,9 @@ export default class HardwareWalletsStore extends Store {
withdrawals,
});

// eslint-disable-next-line
console.debug('>> UnsignetTX: ', JSON.stringify(unsignedTx));

const signedWitnesses = await this._signWitnesses(
signedTransaction.witnesses
);
Expand All @@ -1364,7 +1377,7 @@ export default class HardwareWalletsStore extends Store {
// Prepare serialized transaction with unsigned data and signed witnesses
const txBody = await prepareBody(unsignedTx, txWitnesses);

// eslint-disable-next-line
// eslint-disable-next-line
console.debug('>> txBody: ', txBody);

runInAction('HardwareWalletsStore:: set Transaction verified', () => {
Expand Down

0 comments on commit 70d6880

Please sign in to comment.