Skip to content

Commit

Permalink
fix wc nonces (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 committed Jan 10, 2021
1 parent d40d0c9 commit 20636b3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/parsers/requests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { convertHexToUtf8 } from '@walletconnect/utils';
import BigNumber from 'bignumber.js';
import { get } from 'lodash';
import { get, isNil } from 'lodash';
import { isHexString } from '../handlers/web3';
import {
convertAmountAndPriceToNativeDisplay,
Expand All @@ -17,6 +17,7 @@ import {
SIGN_TRANSACTION,
SIGN_TYPED_DATA,
} from '../utils/signingMethods';
import { ethUnits } from '@rainbow-me/references';

export const getRequestDisplayDetails = (payload, assets, nativeCurrency) => {
let timestampInMs = Date.now();
Expand All @@ -36,12 +37,7 @@ export const getRequestDisplayDetails = (payload, assets, nativeCurrency) => {

// We must pass a number through the bridge
if (!transaction.gasLimit) {
transaction.gasLimit = 0;
}

// Dapps usually won't send this
if (!transaction.nonce) {
transaction.nonce = 0;
transaction.gasLimit = ethUnits.gasLimit;
}

// Fallback for dapps sending no data
Expand Down Expand Up @@ -120,9 +116,11 @@ const getTransactionDisplayDetails = (
gasPrice: BigNumber(convertHexToString(transaction.gasPrice)),
nativeAmount: amount,
nativeAmountDisplay: display,
nonce: Number(convertHexToString(transaction.nonce)),
to: transaction.to,
value,
...(!isNil(transaction.nonce)
? { nonce: Number(convertHexToString(transaction.nonce)) }
: {}),
},
timestampInMs,
};
Expand Down Expand Up @@ -151,7 +149,9 @@ const getTransactionDisplayDetails = (
gasPrice: BigNumber(convertHexToString(transaction.gasPrice)),
nativeAmount: native.amount,
nativeAmountDisplay: native.display,
nonce: Number(convertHexToString(transaction.nonce)),
...(!isNil(transaction.nonce)
? { nonce: Number(convertHexToString(transaction.nonce)) }
: {}),
to: toAddress,
value,
},
Expand All @@ -172,7 +172,9 @@ const getTransactionDisplayDetails = (
from: transaction.from,
gasLimit: BigNumber(convertHexToString(transaction.gasLimit)),
gasPrice: BigNumber(convertHexToString(transaction.gasPrice)),
nonce: Number(convertHexToString(transaction.nonce)),
...(!isNil(transaction.nonce)
? { nonce: Number(convertHexToString(transaction.nonce)) }
: {}),
to: transaction.to,
value,
},
Expand Down

0 comments on commit 20636b3

Please sign in to comment.