Skip to content
Closed
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
1 change: 1 addition & 0 deletions app/scripts/controllers/permissions/specifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const unrestrictedMethods = Object.freeze([
'eth_coinbase',
'eth_decrypt',
'eth_estimateGas',
'eth_createAccessList',
'eth_feeHistory',
'eth_gasPrice',
'eth_getBalance',
Expand Down
21 changes: 19 additions & 2 deletions app/scripts/controllers/transactions/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { isEIP1559Transaction } from '../../../../../shared/modules/transaction.utils';
import { isValidHexAddress } from '../../../../../shared/modules/hexstring-utils';

const identity = (x) => x;
const normalizers = {
from: addHexPrefix,
to: (to, lowerCase) =>
Expand All @@ -21,8 +22,9 @@ const normalizers = {
maxFeePerGas: addHexPrefix,
maxPriorityFeePerGas: addHexPrefix,
type: addHexPrefix,
estimateSuggested: (estimate) => estimate,
estimateUsed: (estimate) => estimate,
estimateSuggested: identity,
estimateUsed: identity,
accessList: identity,
};

export function normalizeAndValidateTxParams(txParams, lowerCase = true) {
Expand Down Expand Up @@ -224,12 +226,27 @@ export function validateTxParams(txParams, eip1559Compatibility = true) {
validateInputData(value);
ensureFieldIsString(txParams, 'data');
break;
case 'accessList':
validateAccessList(value);
break;
default:
ensureFieldIsString(txParams, key);
}
});
}

/**
*
* @param {*} value
*/
export function validateAccessList(value) {
if (value instanceof Array === false) {
throw ethErrors.rpc.invalidParams(
`Invalid transaction params: accessList must be an array of access entries`,
);
}
}

/**
*
* @param {*} value
Expand Down
23 changes: 21 additions & 2 deletions app/scripts/controllers/transactions/tx-gas-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,27 @@ export default class TxGasUtil {
delete txParams.maxFeePerGas;
delete txParams.maxPriorityFeePerGas;

// estimate tx gas requirements
return await this.query.estimateGas(txParams);
// dont use ethjs-query here because it will blow up about accessList
if (txParams.accessList) {
return await new Promise((resolve, reject) => {
this.query.rpc.currentProvider.sendAsync(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just update ethjs-query? What will be the difference by using the provider directly vs. using ethjs-query?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pr for updating it

ethjs/ethjs-schema#13

{
id: '1',
jsonrpc: '2.0',
method: 'eth_estimateGas',
params: [txParams, 'latest'],
},
(err, { result, error }) => {
if (error || err) {
reject(error);
} else {
resolve(result);
}
},
);
});
}
return this.query.estimateGas(txParams);
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/transactions/tx-state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export default class TransactionStateManager extends EventEmitter {
if (txMeta.txParams) {
txMeta.txParams = normalizeAndValidateTxParams(txMeta.txParams, false);
}
console.log('add transaction, post normalization', txMeta.txParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to keep this log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope!


this.once(`${txMeta.id}:signed`, () => {
this.removeAllListeners(`${txMeta.id}:rejected`);
Expand Down