Skip to content

Commit 2964536

Browse files
committed
Added support for eth_createAccessList and sendTransaction support for it
1 parent 343cde9 commit 2964536

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

app/scripts/controllers/permissions/specifications.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export const unrestrictedMethods = Object.freeze([
221221
'eth_coinbase',
222222
'eth_decrypt',
223223
'eth_estimateGas',
224+
'eth_createAccessList',
224225
'eth_feeHistory',
225226
'eth_gasPrice',
226227
'eth_getBalance',

app/scripts/controllers/transactions/lib/util.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { isEIP1559Transaction } from '../../../../../shared/modules/transaction.utils';
1010
import { isValidHexAddress } from '../../../../../shared/modules/hexstring-utils';
1111

12+
const identity = (x) => x;
1213
const normalizers = {
1314
from: addHexPrefix,
1415
to: (to, lowerCase) =>
@@ -21,8 +22,9 @@ const normalizers = {
2122
maxFeePerGas: addHexPrefix,
2223
maxPriorityFeePerGas: addHexPrefix,
2324
type: addHexPrefix,
24-
estimateSuggested: (estimate) => estimate,
25-
estimateUsed: (estimate) => estimate,
25+
estimateSuggested: identity,
26+
estimateUsed: identity,
27+
accessList: identity,
2628
};
2729

2830
export function normalizeAndValidateTxParams(txParams, lowerCase = true) {
@@ -224,12 +226,27 @@ export function validateTxParams(txParams, eip1559Compatibility = true) {
224226
validateInputData(value);
225227
ensureFieldIsString(txParams, 'data');
226228
break;
229+
case 'accessList':
230+
validateAccessList(value);
231+
break;
227232
default:
228233
ensureFieldIsString(txParams, key);
229234
}
230235
});
231236
}
232237

238+
/**
239+
*
240+
* @param {*} value
241+
*/
242+
export function validateAccessList(value) {
243+
if (value instanceof Array === false) {
244+
throw ethErrors.rpc.invalidParams(
245+
`Invalid transaction params: accessList must be an array of access entries`,
246+
);
247+
}
248+
}
249+
233250
/**
234251
*
235252
* @param {*} value

app/scripts/controllers/transactions/tx-gas-utils.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,27 @@ export default class TxGasUtil {
7676
delete txParams.maxFeePerGas;
7777
delete txParams.maxPriorityFeePerGas;
7878

79-
// estimate tx gas requirements
80-
return await this.query.estimateGas(txParams);
79+
// dont use ethjs-query here because it will blow up about accessList
80+
if (txParams.accessList) {
81+
return await new Promise((resolve, reject) => {
82+
this.query.rpc.currentProvider.sendAsync(
83+
{
84+
id: '1',
85+
jsonrpc: '2.0',
86+
method: 'eth_estimateGas',
87+
params: [txParams, 'latest'],
88+
},
89+
(err, { result, error }) => {
90+
if (error || err) {
91+
reject(error);
92+
} else {
93+
resolve(result);
94+
}
95+
},
96+
);
97+
});
98+
}
99+
return this.query.estimateGas(txParams);
81100
}
82101

83102
/**

app/scripts/controllers/transactions/tx-state-manager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export default class TransactionStateManager extends EventEmitter {
242242
if (txMeta.txParams) {
243243
txMeta.txParams = normalizeAndValidateTxParams(txMeta.txParams, false);
244244
}
245+
console.log('add transaction, post normalization', txMeta.txParams);
245246

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

0 commit comments

Comments
 (0)