@atomiqlabs/chain-evm 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,8 @@ function initializeBotanix(options, bitcoinRpc, network) {
89
89
  maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
90
90
  maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
91
91
  maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
92
- useAccessLists: options?.evmConfig?.useAccessLists
92
+ useAccessLists: options?.evmConfig?.useAccessLists,
93
+ defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
93
94
  }, options.retryPolicy, Fees);
94
95
  const btcRelay = new EVMBtcRelay_1.EVMBtcRelay(chainInterface, bitcoinRpc, network, options.btcRelayContract ?? defaultContractAddresses.btcRelayContract, options.btcRelayDeploymentHeight ?? defaultContractAddresses.btcRelayDeploymentHeight);
95
96
  const swapContract = new EVMSwapContract_1.EVMSwapContract(chainInterface, btcRelay, options.swapContract ?? defaultContractAddresses.swapContract, {
@@ -95,7 +95,8 @@ function initializeCitrea(options, bitcoinRpc, network) {
95
95
  maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
96
96
  maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
97
97
  maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
98
- useAccessLists: options?.evmConfig?.useAccessLists
98
+ useAccessLists: options?.evmConfig?.useAccessLists,
99
+ defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
99
100
  }, options.retryPolicy, Fees);
100
101
  chainInterface.Tokens = new CitreaTokens_1.CitreaTokens(chainInterface); //Override with custom token module allowing l1 state diff based fee calculation
101
102
  const btcRelay = new CitreaBtcRelay_1.CitreaBtcRelay(chainInterface, bitcoinRpc, network, options.btcRelayContract ?? defaultContractAddresses.btcRelayContract, options.btcRelayDeploymentHeight ?? defaultContractAddresses.btcRelayDeploymentHeight);
@@ -21,6 +21,7 @@ export type EVMConfiguration = {
21
21
  maxParallelCalls: number;
22
22
  maxLogTopics: number;
23
23
  useAccessLists?: boolean;
24
+ defaultAccessListAddresses?: string[];
24
25
  };
25
26
  export declare class EVMChainInterface<ChainId extends string = string> implements ChainInterface<EVMTx, EVMSigner, ChainId, Signer> {
26
27
  readonly chainId: ChainId;
@@ -73,9 +73,30 @@ class EVMTransactions extends EVMModule_1.EVMModule {
73
73
  return confirmedTxId;
74
74
  }
75
75
  async applyAccessList(tx) {
76
- const accessListResponse = await this.provider.send("eth_createAccessList", [tx, "pending"]);
77
- const result = accessListResponse.result;
78
- tx.accessList = result.accessList;
76
+ let accessListResponse;
77
+ try {
78
+ accessListResponse = await this.provider.send("eth_createAccessList", [{
79
+ from: tx.from,
80
+ to: tx.to,
81
+ value: (0, ethers_1.toBeHex)(tx.value ?? 0n),
82
+ input: tx.data,
83
+ data: tx.data
84
+ }, "pending"]);
85
+ }
86
+ catch (e) {
87
+ if (e.code !== "UNKNOWN_ERROR" || e.error?.code !== 3)
88
+ throw e;
89
+ //Re-attempt with default pre-populated access list
90
+ accessListResponse = await this.provider.send("eth_createAccessList", [{
91
+ from: tx.from,
92
+ to: tx.to,
93
+ value: (0, ethers_1.toBeHex)(tx.value ?? 0n),
94
+ input: tx.data,
95
+ data: tx.data,
96
+ accessList: this.root.config.defaultAccessListAddresses.map(val => ({ address: val, storageKeys: [] }))
97
+ }, "pending"]);
98
+ }
99
+ tx.accessList = accessListResponse.accessList;
79
100
  }
80
101
  /**
81
102
  * Prepares starknet transactions, checks if the account is deployed, assigns nonces if needed & calls beforeTxSigned callback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "EVM specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -126,7 +126,8 @@ export function initializeBotanix(
126
126
  maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
127
127
  maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
128
128
  maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
129
- useAccessLists: options?.evmConfig?.useAccessLists
129
+ useAccessLists: options?.evmConfig?.useAccessLists,
130
+ defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
130
131
  }, options.retryPolicy, Fees);
131
132
 
132
133
  const btcRelay = new EVMBtcRelay(
@@ -132,7 +132,8 @@ export function initializeCitrea(
132
132
  maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
133
133
  maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
134
134
  maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
135
- useAccessLists: options?.evmConfig?.useAccessLists
135
+ useAccessLists: options?.evmConfig?.useAccessLists,
136
+ defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
136
137
  }, options.retryPolicy, Fees);
137
138
  chainInterface.Tokens = new CitreaTokens(chainInterface); //Override with custom token module allowing l1 state diff based fee calculation
138
139
 
@@ -34,7 +34,8 @@ export type EVMConfiguration = {
34
34
  maxParallelCalls: number,
35
35
  maxLogTopics: number,
36
36
 
37
- useAccessLists?: boolean
37
+ useAccessLists?: boolean,
38
+ defaultAccessListAddresses?: string[]
38
39
  };
39
40
 
40
41
  export class EVMChainInterface<ChainId extends string = string> implements ChainInterface<EVMTx, EVMSigner, ChainId, Signer> {
@@ -1,5 +1,5 @@
1
1
  import {EVMModule} from "../EVMModule";
2
- import {JsonRpcResult, makeError, Transaction, TransactionRequest, TransactionResponse} from "ethers";
2
+ import {JsonRpcResult, makeError, Transaction, TransactionRequest, TransactionResponse, toBeHex} from "ethers";
3
3
  import {timeoutPromise} from "../../../utils/Utils";
4
4
  import {EVMSigner} from "../../wallet/EVMSigner";
5
5
  import {TransactionRevertedError} from "@atomiqlabs/base";
@@ -94,11 +94,32 @@ export class EVMTransactions extends EVMModule<any> {
94
94
  }
95
95
 
96
96
  private async applyAccessList(tx: TransactionRequest) {
97
- const accessListResponse: JsonRpcResult = await this.provider.send("eth_createAccessList", [tx, "pending"]);
98
- const result: {
97
+ let accessListResponse: {
99
98
  accessList: {address: string, storageKeys: string[]}[]
100
- } = accessListResponse.result;
101
- tx.accessList = result.accessList;
99
+ };
100
+ try {
101
+ accessListResponse = await this.provider.send("eth_createAccessList", [{
102
+ from: tx.from,
103
+ to: tx.to,
104
+ value: toBeHex(tx.value ?? 0n),
105
+ input: tx.data,
106
+ data: tx.data
107
+ }, "pending"]);
108
+ } catch (e) {
109
+ if(e.code!=="UNKNOWN_ERROR" || e.error?.code!==3) throw e;
110
+
111
+ //Re-attempt with default pre-populated access list
112
+ accessListResponse = await this.provider.send("eth_createAccessList", [{
113
+ from: tx.from,
114
+ to: tx.to,
115
+ value: toBeHex(tx.value ?? 0n),
116
+ input: tx.data,
117
+ data: tx.data,
118
+ accessList: this.root.config.defaultAccessListAddresses.map(val => ({address: val, storageKeys: []}))
119
+ }, "pending"]);
120
+ }
121
+
122
+ tx.accessList = accessListResponse.accessList;
102
123
  }
103
124
 
104
125
  /**