Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.14.400] Canonical inputs sorting before submitting to Ledger #2888

Merged
merged 6 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ export async function createLedgerSignTxPayload(request: {|
};
}

/**
* Canonical inputs sorting: by tx hash and then by index
*/
function compareInputs(a: TxInput, b: TxInput): number {
if (a.txHashHex !== b.txHashHex) {
return a.txHashHex < b.txHashHex ? -1 : 1;
}
return a.outputIndex - b.outputIndex;
}

function _transformToLedgerInputs(
inputs: Array<CardanoAddressedUtxo>
): Array<TxInput> {
Expand All @@ -143,7 +153,7 @@ function _transformToLedgerInputs(
txHashHex: input.tx_hash,
outputIndex: input.tx_index,
path: input.addressing.path,
}));
})).sort(compareInputs);
}

function toLedgerTokenBundle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ test('Create Ledger transaction', async () => {
44 + HARD_DERIVATION_START,
1815 + HARD_DERIVATION_START,
0 + HARD_DERIVATION_START,
1,
2,
0,
7,
],
txHashHex: '3677e75c7ba699bfdc6cd57d42f246f86f69aefd76025006ac78313fad2bba20',
outputIndex: 1,
txHashHex: '1029eef5bb0f06979ab0b9530a62bac11e180797d08cab980fe39389d42b3657',
outputIndex: 0,
}, {
path: [
44 + HARD_DERIVATION_START,
Expand All @@ -390,18 +390,18 @@ test('Create Ledger transaction', async () => {
0,
7,
],
txHashHex: '1029eef5bb0f06979ab0b9530a62bac11e180797d08cab980fe39389d42b3657',
txHashHex: '2029eef5bb0f06979ab0b9530a62bac11e180797d08cab980fe39389d42b3658',
outputIndex: 0,
}, {
path: [
44 + HARD_DERIVATION_START,
1815 + HARD_DERIVATION_START,
0 + HARD_DERIVATION_START,
0,
7,
1,
2,
],
txHashHex: '2029eef5bb0f06979ab0b9530a62bac11e180797d08cab980fe39389d42b3658',
outputIndex: 0,
txHashHex: '3677e75c7ba699bfdc6cd57d42f246f86f69aefd76025006ac78313fad2bba20',
outputIndex: 1,
}],
outputs: [{
destination: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class WalletSummary extends Component<Props> {
} = this.props;

let pendingAmount = null;
if (unitOfAccountSetting.enabled) {
if (false /* temporarily disabled */ && unitOfAccountSetting.enabled) {
const { currency } = unitOfAccountSetting;
if (!currency) {
throw new Error(`unexpected unit of account ${String(currency)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class SignTxPage extends Component<Props, State> {

let fiatAmountDisplay = null;

if (this.props.unitOfAccountSetting.enabled === true) {
if (false && this.props.unitOfAccountSetting.enabled === true) {
const { currency } = this.props.unitOfAccountSetting;
const price = this.props.getCurrentPrice(
getTokenName(tokenInfo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CardanoUtxoDetails extends Component<Props> {

let fiatAmountDisplay = null;

if (this.props.unitOfAccountSetting.enabled === true) {
if (false && this.props.unitOfAccountSetting.enabled === true) {
const { currency } = this.props.unitOfAccountSetting;
const price = this.props.getCurrentPrice(
tokenInfo ? getTokenName(tokenInfo) : nameFromIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SignTxPage extends Component<Props, State> {
if (tokenInfo == null) return this.displayUnAvailableToken(request.entry);
const shiftedAmount = request.entry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals);

if (this.props.unitOfAccountSetting.enabled === true) {
if (false && this.props.unitOfAccountSetting.enabled === true) {
const { currency } = this.props.unitOfAccountSetting;
const price = this.props.getCurrentPrice(request.entry.identifier, currency);
if (price != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class UtxoDetails extends Component<Props> {
if (tokenInfo == null) return this.displayUnAvailableToken(request.entry);
const shiftedAmount = request.entry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals);

if (this.props.unitOfAccountSetting.enabled === true) {
if (false && this.props.unitOfAccountSetting.enabled === true) {
const { currency } = this.props.unitOfAccountSetting;
const price = this.props.getCurrentPrice(request.entry.identifier, currency);
if (price != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/yoroi-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yoroi",
"version": "4.14.300",
"version": "4.14.400",
"description": "Cardano ADA wallet",
"scripts": {
"dev:build": "rimraf dev/ && babel-node scripts/build --type=debug",
Expand Down