@lumiapassport/core 1.16.2 → 1.17.0
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.
- package/dist/bundler/index.cjs +382 -154
- package/dist/bundler/index.cjs.map +1 -1
- package/dist/bundler/index.d.cts +42 -113
- package/dist/bundler/index.d.ts +42 -113
- package/dist/bundler/index.js +382 -149
- package/dist/bundler/index.js.map +1 -1
- package/dist/clients/index.cjs +502 -211
- package/dist/clients/index.cjs.map +1 -1
- package/dist/clients/index.d.cts +2 -2
- package/dist/clients/index.d.ts +2 -2
- package/dist/clients/index.js +501 -206
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/node.d.cts +1 -1
- package/dist/clients/node.d.ts +1 -1
- package/dist/errors-zNASNfHJ.d.cts +17 -0
- package/dist/errors-zNASNfHJ.d.ts +17 -0
- package/dist/index.cjs +505 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +505 -207
- package/dist/index.js.map +1 -1
- package/dist/internal/error-tracking.cjs +1 -1
- package/dist/internal/error-tracking.js +1 -1
- package/dist/read/index.cjs +286 -20
- package/dist/read/index.cjs.map +1 -1
- package/dist/read/index.d.cts +223 -358
- package/dist/read/index.d.ts +223 -358
- package/dist/read/index.js +268 -21
- package/dist/read/index.js.map +1 -1
- package/dist/{server-wallet-manager-Ckw2qlPe.d.cts → server-wallet-manager-DhJaAfXW.d.cts} +6 -11
- package/dist/{server-wallet-manager-Ckw2qlPe.d.ts → server-wallet-manager-DhJaAfXW.d.ts} +6 -11
- package/dist/types-Cl4_gFZq.d.cts +363 -0
- package/dist/types-Cl4_gFZq.d.ts +363 -0
- package/dist/types-D86_Vj_F.d.ts +104 -0
- package/dist/types-mOTpHveq.d.cts +104 -0
- package/dist/utils/index.cjs +2 -15
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +9 -3
- package/dist/utils/index.d.ts +9 -3
- package/dist/utils/index.js +2 -15
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -3
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,34 +1,279 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var viem = require('viem');
|
|
4
|
+
require('viem/account-abstraction');
|
|
5
|
+
|
|
3
6
|
// src/bundler/constants.ts
|
|
4
7
|
var ENTRYPOINT_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
5
|
-
var ENTRYPOINT_V06 = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
|
|
6
8
|
var ENTRYPOINT = ENTRYPOINT_V07;
|
|
9
|
+
var ARBITRUM_SEPOLIA_CHAIN_ID = 421614;
|
|
10
|
+
var ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
11
|
+
var ARBITRUM_SEPOLIA = {
|
|
12
|
+
id: ARBITRUM_SEPOLIA_CHAIN_ID,
|
|
13
|
+
name: "Arbitrum Sepolia",
|
|
14
|
+
logo: "arbitrum",
|
|
15
|
+
logoDataUri: "",
|
|
16
|
+
rpcUrls: ["https://arbitrum-sepolia-rpc.publicnode.com"],
|
|
17
|
+
blockExplorerUrl: "https://sepolia.arbiscan.io",
|
|
18
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
19
|
+
multicall3: ARBITRUM_SEPOLIA_MULTICALL3_ADDRESS,
|
|
20
|
+
blockTime: 1,
|
|
21
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler-arbitrum-sepolia",
|
|
22
|
+
// EVM version: shanghai
|
|
23
|
+
factoryAddress: "0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f",
|
|
24
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
25
|
+
paymasterAddress: "0x536b6F1Db43AA3D537376E40f73cFdcFf8930244"
|
|
26
|
+
};
|
|
27
|
+
var arbitrumSepoliaChain = viem.defineChain({
|
|
28
|
+
id: ARBITRUM_SEPOLIA_CHAIN_ID,
|
|
29
|
+
name: "Arbitrum Sepolia",
|
|
30
|
+
nativeCurrency: ARBITRUM_SEPOLIA.nativeCurrency,
|
|
31
|
+
rpcUrls: {
|
|
32
|
+
default: { http: ARBITRUM_SEPOLIA.rpcUrls },
|
|
33
|
+
public: { http: ARBITRUM_SEPOLIA.rpcUrls }
|
|
34
|
+
},
|
|
35
|
+
blockExplorers: {
|
|
36
|
+
default: { name: "Arbiscan", url: ARBITRUM_SEPOLIA.blockExplorerUrl }
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
40
|
+
var BASE_SEPOLIA_MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
41
|
+
var BASE_SEPOLIA = {
|
|
42
|
+
id: BASE_SEPOLIA_CHAIN_ID,
|
|
43
|
+
name: "Base Sepolia",
|
|
44
|
+
logo: "base",
|
|
45
|
+
logoDataUri: "",
|
|
46
|
+
rpcUrls: ["https://base-sepolia-rpc.publicnode.com"],
|
|
47
|
+
blockExplorerUrl: "https://sepolia.basescan.org",
|
|
48
|
+
nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
|
|
49
|
+
multicall3: BASE_SEPOLIA_MULTICALL3_ADDRESS,
|
|
50
|
+
blockTime: 2,
|
|
51
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler-base-sepolia",
|
|
52
|
+
// EVM version: shanghai
|
|
53
|
+
factoryAddress: "0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f",
|
|
54
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
55
|
+
paymasterAddress: "0x536b6F1Db43AA3D537376E40f73cFdcFf8930244"
|
|
56
|
+
};
|
|
57
|
+
var baseSepoliaChain = viem.defineChain({
|
|
58
|
+
id: BASE_SEPOLIA_CHAIN_ID,
|
|
59
|
+
name: "Base Sepolia",
|
|
60
|
+
nativeCurrency: BASE_SEPOLIA.nativeCurrency,
|
|
61
|
+
rpcUrls: {
|
|
62
|
+
default: { http: BASE_SEPOLIA.rpcUrls },
|
|
63
|
+
public: { http: BASE_SEPOLIA.rpcUrls }
|
|
64
|
+
},
|
|
65
|
+
blockExplorers: {
|
|
66
|
+
default: { name: "BaseScan", url: BASE_SEPOLIA.blockExplorerUrl }
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var BSC_TESTNET_CHAIN_ID = 97;
|
|
70
|
+
var BSC_TESTNET_MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
71
|
+
var BSC_TESTNET = {
|
|
72
|
+
id: BSC_TESTNET_CHAIN_ID,
|
|
73
|
+
name: "BSC Testnet",
|
|
74
|
+
logo: "bnb",
|
|
75
|
+
logoDataUri: "",
|
|
76
|
+
rpcUrls: ["https://bsc-testnet-rpc.publicnode.com"],
|
|
77
|
+
blockExplorerUrl: "https://testnet.bscscan.com",
|
|
78
|
+
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
|
79
|
+
multicall3: BSC_TESTNET_MULTICALL3_ADDRESS,
|
|
80
|
+
blockTime: 3,
|
|
81
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler-bnb-testnet",
|
|
82
|
+
// EVM version: shanghai
|
|
83
|
+
factoryAddress: "0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f",
|
|
84
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
85
|
+
paymasterAddress: "0x536b6F1Db43AA3D537376E40f73cFdcFf8930244"
|
|
86
|
+
};
|
|
87
|
+
var bscTestnetChain = viem.defineChain({
|
|
88
|
+
id: BSC_TESTNET_CHAIN_ID,
|
|
89
|
+
name: "BSC Testnet",
|
|
90
|
+
nativeCurrency: BSC_TESTNET.nativeCurrency,
|
|
91
|
+
rpcUrls: {
|
|
92
|
+
default: { http: BSC_TESTNET.rpcUrls },
|
|
93
|
+
public: { http: BSC_TESTNET.rpcUrls }
|
|
94
|
+
},
|
|
95
|
+
blockExplorers: {
|
|
96
|
+
default: { name: "BscScan Testnet", url: BSC_TESTNET.blockExplorerUrl }
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
var LUMIA_MAINNET_CHAIN_ID = 994873017;
|
|
100
|
+
var MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
101
|
+
var LUMIA_MAINNET = {
|
|
102
|
+
id: LUMIA_MAINNET_CHAIN_ID,
|
|
103
|
+
name: "Lumia Prism Mainnet",
|
|
104
|
+
logo: "lumia",
|
|
105
|
+
logoDataUri: "",
|
|
106
|
+
rpcUrls: ["https://mainnet-rpc.lumia.org"],
|
|
107
|
+
blockExplorerUrl: "https://explorer.lumia.org",
|
|
108
|
+
multicall3: MULTICALL3_ADDRESS,
|
|
109
|
+
blockTime: 2,
|
|
110
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler-prism",
|
|
111
|
+
nativeCurrency: { name: "LUMIA", symbol: "LUMIA", decimals: 18 },
|
|
112
|
+
// EVM version: shanghai (no MCOPY opcode)
|
|
113
|
+
factoryAddress: "0x9Db2Ed382E6E627d548204483fB588FDc0d664B0",
|
|
114
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
115
|
+
paymasterAddress: "0x1A8692fC7135CA59AF157C33C015F601FE4B3B7b"
|
|
116
|
+
};
|
|
117
|
+
var lumiaMainnetChain = viem.defineChain({
|
|
118
|
+
id: LUMIA_MAINNET_CHAIN_ID,
|
|
119
|
+
name: "Lumia Prism Mainnet",
|
|
120
|
+
nativeCurrency: LUMIA_MAINNET.nativeCurrency,
|
|
121
|
+
rpcUrls: {
|
|
122
|
+
default: { http: LUMIA_MAINNET.rpcUrls },
|
|
123
|
+
public: { http: LUMIA_MAINNET.rpcUrls }
|
|
124
|
+
},
|
|
125
|
+
blockExplorers: {
|
|
126
|
+
default: { name: "Lumia Explorer", url: LUMIA_MAINNET.blockExplorerUrl }
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
var LUMIA_TESTNET_CHAIN_ID = 2030232745;
|
|
130
|
+
var MULTICALL3_ADDRESS2 = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
131
|
+
var LUMIA_TESTNET = {
|
|
132
|
+
id: LUMIA_TESTNET_CHAIN_ID,
|
|
133
|
+
name: "Lumia Beam",
|
|
134
|
+
logo: "lumia",
|
|
135
|
+
logoDataUri: "",
|
|
136
|
+
rpcUrls: ["https://beam-rpc.lumia.org"],
|
|
137
|
+
blockExplorerUrl: "https://beam-explorer.lumia.org",
|
|
138
|
+
nativeCurrency: { name: "LUMIA", symbol: "LUMIA", decimals: 18 },
|
|
139
|
+
multicall3: MULTICALL3_ADDRESS2,
|
|
140
|
+
blockTime: 2,
|
|
141
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler",
|
|
142
|
+
factoryAddress: "0x37053B3C6fb47B92355B95E7bEfa6dDf04Cc9981",
|
|
143
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
144
|
+
paymasterAddress: "0x9Dca693bdDc09d6B10c7ad3C86BBC0C704571Ec5"
|
|
145
|
+
};
|
|
146
|
+
var lumiaTestnetChain = viem.defineChain({
|
|
147
|
+
id: LUMIA_TESTNET_CHAIN_ID,
|
|
148
|
+
name: "Lumia Beam Testnet",
|
|
149
|
+
nativeCurrency: LUMIA_TESTNET.nativeCurrency,
|
|
150
|
+
rpcUrls: {
|
|
151
|
+
default: { http: LUMIA_TESTNET.rpcUrls },
|
|
152
|
+
public: { http: LUMIA_TESTNET.rpcUrls }
|
|
153
|
+
},
|
|
154
|
+
blockExplorers: {
|
|
155
|
+
default: { name: "Lumia Beam Explorer", url: LUMIA_TESTNET.blockExplorerUrl }
|
|
156
|
+
},
|
|
157
|
+
logo: "lumia"
|
|
158
|
+
});
|
|
159
|
+
var SEPOLIA_CHAIN_ID = 11155111;
|
|
160
|
+
var MULTICALL3_ADDRESS3 = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
161
|
+
var SEPOLIA = {
|
|
162
|
+
id: SEPOLIA_CHAIN_ID,
|
|
163
|
+
name: "Sepolia",
|
|
164
|
+
logo: "ethereum",
|
|
165
|
+
logoDataUri: "",
|
|
166
|
+
rpcUrls: ["https://ethereum-sepolia-rpc.publicnode.com"],
|
|
167
|
+
blockExplorerUrl: "https://sepolia.etherscan.io",
|
|
168
|
+
multicall3: MULTICALL3_ADDRESS3,
|
|
169
|
+
blockTime: 12,
|
|
170
|
+
bundlerUrl: "https://api.lumiapassport.com/rundler-sepolia",
|
|
171
|
+
nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
|
|
172
|
+
factoryAddress: "0x4be18A5ff553A881b2a272d0Ce4b3E82d763574f",
|
|
173
|
+
entryPointV07Address: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
174
|
+
paymasterAddress: "0x536b6F1Db43AA3D537376E40f73cFdcFf8930244"
|
|
175
|
+
};
|
|
176
|
+
var sepoliaChain = viem.defineChain({
|
|
177
|
+
id: SEPOLIA_CHAIN_ID,
|
|
178
|
+
name: "Sepolia",
|
|
179
|
+
nativeCurrency: SEPOLIA.nativeCurrency,
|
|
180
|
+
rpcUrls: {
|
|
181
|
+
default: { http: SEPOLIA.rpcUrls },
|
|
182
|
+
public: { http: SEPOLIA.rpcUrls }
|
|
183
|
+
},
|
|
184
|
+
blockExplorers: {
|
|
185
|
+
default: { name: "Etherscan", url: SEPOLIA.blockExplorerUrl }
|
|
186
|
+
},
|
|
187
|
+
testnet: true
|
|
188
|
+
});
|
|
7
189
|
|
|
8
|
-
// src/
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
190
|
+
// src/config/networks/index.ts
|
|
191
|
+
var SUPPORTED_CHAINS = /* @__PURE__ */ new Map([
|
|
192
|
+
[LUMIA_MAINNET_CHAIN_ID, LUMIA_MAINNET],
|
|
193
|
+
[LUMIA_TESTNET_CHAIN_ID, LUMIA_TESTNET],
|
|
194
|
+
[SEPOLIA_CHAIN_ID, SEPOLIA],
|
|
195
|
+
[BSC_TESTNET_CHAIN_ID, BSC_TESTNET],
|
|
196
|
+
[ARBITRUM_SEPOLIA_CHAIN_ID, ARBITRUM_SEPOLIA],
|
|
197
|
+
[BASE_SEPOLIA_CHAIN_ID, BASE_SEPOLIA]
|
|
198
|
+
]);
|
|
199
|
+
var VIEM_CHAINS = /* @__PURE__ */ new Map([
|
|
200
|
+
[LUMIA_MAINNET_CHAIN_ID, lumiaMainnetChain],
|
|
201
|
+
[LUMIA_TESTNET_CHAIN_ID, lumiaTestnetChain],
|
|
202
|
+
[SEPOLIA_CHAIN_ID, sepoliaChain],
|
|
203
|
+
[BSC_TESTNET_CHAIN_ID, bscTestnetChain],
|
|
204
|
+
[ARBITRUM_SEPOLIA_CHAIN_ID, arbitrumSepoliaChain],
|
|
205
|
+
[BASE_SEPOLIA_CHAIN_ID, baseSepoliaChain]
|
|
206
|
+
]);
|
|
207
|
+
function getChainConfig(chainId) {
|
|
208
|
+
return SUPPORTED_CHAINS.get(chainId);
|
|
209
|
+
}
|
|
210
|
+
function getViemChain(chainId) {
|
|
211
|
+
return VIEM_CHAINS.get(chainId);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/lib/errors.ts
|
|
215
|
+
var LumiaPassportError = class extends Error {
|
|
216
|
+
/** Machine-readable error code for programmatic handling */
|
|
217
|
+
code;
|
|
218
|
+
constructor(message, code) {
|
|
219
|
+
super(message);
|
|
220
|
+
this.code = code;
|
|
221
|
+
this.name = "LumiaPassportError";
|
|
222
|
+
if (Error.captureStackTrace) {
|
|
223
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
224
|
}
|
|
16
225
|
}
|
|
17
|
-
|
|
18
|
-
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/read/errors.ts
|
|
229
|
+
var ReadLayerError = class extends LumiaPassportError {
|
|
230
|
+
constructor(message, code) {
|
|
231
|
+
super(message, code);
|
|
232
|
+
this.name = "ReadLayerError";
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var ChainNotSupportedError = class extends ReadLayerError {
|
|
236
|
+
/** List of supported chain IDs */
|
|
237
|
+
supportedChains;
|
|
238
|
+
constructor(chainId, supportedChains = []) {
|
|
239
|
+
const chainList = supportedChains.length > 0 ? `Supported chains: ${supportedChains.join(", ")}` : "Please provide an RPC URL.";
|
|
240
|
+
super(
|
|
241
|
+
`Chain ${chainId} is not supported. ${chainList}`,
|
|
242
|
+
"CHAIN_NOT_SUPPORTED"
|
|
243
|
+
);
|
|
244
|
+
this.name = "ChainNotSupportedError";
|
|
245
|
+
this.supportedChains = supportedChains;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function createPublicClientForChain(chainId) {
|
|
249
|
+
const chainConfig = getChainConfig(chainId);
|
|
250
|
+
if (!chainConfig) {
|
|
251
|
+
const supportedChainIds = Array.from(SUPPORTED_CHAINS.keys());
|
|
252
|
+
throw new ChainNotSupportedError(chainId, supportedChainIds);
|
|
19
253
|
}
|
|
254
|
+
const viemChain = getViemChain(chainId);
|
|
255
|
+
return viem.createPublicClient({
|
|
256
|
+
chain: viemChain,
|
|
257
|
+
transport: viem.http(chainConfig.rpcUrls[0], {
|
|
258
|
+
timeout: 1e4,
|
|
259
|
+
retryCount: 2,
|
|
260
|
+
fetchOptions: { mode: "cors" }
|
|
261
|
+
})
|
|
262
|
+
});
|
|
20
263
|
}
|
|
21
|
-
|
|
264
|
+
|
|
265
|
+
// src/utils/helpers.ts
|
|
266
|
+
var safeToBigInt = (val, fallback2 = "0x0") => {
|
|
22
267
|
try {
|
|
23
|
-
return BigInt(val ||
|
|
268
|
+
return BigInt(val || fallback2);
|
|
24
269
|
} catch {
|
|
25
|
-
return BigInt(
|
|
270
|
+
return BigInt(fallback2);
|
|
26
271
|
}
|
|
27
272
|
};
|
|
28
273
|
var pack2x128 = (hi, lo) => {
|
|
29
274
|
return hi << 128n | lo & (1n << 128n) - 1n;
|
|
30
275
|
};
|
|
31
|
-
async function fetchEntryPointNonce(account, _entryPoint) {
|
|
276
|
+
async function fetchEntryPointNonce(account, _entryPoint, _context) {
|
|
32
277
|
console.log("[AA] fetchEntryPointNonce called for:", account);
|
|
33
278
|
return "0x0";
|
|
34
279
|
}
|
|
@@ -98,8 +343,7 @@ async function bundlerRpc(method, params, bundlerUrl) {
|
|
|
98
343
|
const body = { jsonrpc: "2.0", id: 1, method, params: cleanParams };
|
|
99
344
|
const bodyStr = JSON.stringify(body, (_k, v) => typeof v === "bigint" ? `0x${v.toString(16)}` : v);
|
|
100
345
|
console.log("[Bundler][RPC] ->", method, bodyStr);
|
|
101
|
-
const
|
|
102
|
-
const res = await fetch(url, {
|
|
346
|
+
const res = await fetch(bundlerUrl, {
|
|
103
347
|
method: "POST",
|
|
104
348
|
headers: { "content-type": "application/json" },
|
|
105
349
|
body: bodyStr
|
|
@@ -115,53 +359,36 @@ async function bundlerRpc(method, params, bundlerUrl) {
|
|
|
115
359
|
}
|
|
116
360
|
|
|
117
361
|
// src/bundler/submission.ts
|
|
118
|
-
async function sendUserOperationRaw(userOp) {
|
|
119
|
-
const
|
|
362
|
+
async function sendUserOperationRaw(userOp, options) {
|
|
363
|
+
const chainConfig = getChainConfig(options.chainId);
|
|
364
|
+
if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`);
|
|
365
|
+
const hash = await bundlerRpc(
|
|
366
|
+
"eth_sendUserOperation",
|
|
367
|
+
[userOp, chainConfig?.entryPointV07Address],
|
|
368
|
+
chainConfig?.bundlerUrl
|
|
369
|
+
);
|
|
120
370
|
return hash;
|
|
121
371
|
}
|
|
122
|
-
async function
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
let attempts = 0;
|
|
128
|
-
let currentUserOp = userOp;
|
|
129
|
-
while (attempts < maxRetries) {
|
|
130
|
-
try {
|
|
131
|
-
return await sendUserOperationRaw(currentUserOp);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
attempts++;
|
|
134
|
-
const errorMsg = String(error?.message || error);
|
|
135
|
-
if (attempts >= maxRetries) throw error;
|
|
136
|
-
if (/nonce too low|nonce.*invalid/i.test(errorMsg)) {
|
|
137
|
-
const newNonce = await fetchEntryPointNonce(userOp.sender);
|
|
138
|
-
currentUserOp = await resigner(newNonce);
|
|
139
|
-
} else if (/replacement.*underpriced/i.test(errorMsg)) {
|
|
140
|
-
const increasedMaxFeePerGas = `0x${(BigInt(currentUserOp.maxFeePerGas) * 110n / 100n).toString(16)}`;
|
|
141
|
-
const increasedMaxPriorityFeePerGas = `0x${(BigInt(currentUserOp.maxPriorityFeePerGas) * 110n / 100n).toString(16)}`;
|
|
142
|
-
currentUserOp = { ...currentUserOp, maxFeePerGas: increasedMaxFeePerGas, maxPriorityFeePerGas: increasedMaxPriorityFeePerGas };
|
|
143
|
-
currentUserOp = await resigner(currentUserOp.nonce);
|
|
144
|
-
} else {
|
|
145
|
-
const newNonce = await fetchEntryPointNonce(userOp.sender);
|
|
146
|
-
currentUserOp = await resigner(newNonce);
|
|
147
|
-
}
|
|
148
|
-
await new Promise((r) => setTimeout(r, 1e3 * attempts));
|
|
149
|
-
}
|
|
372
|
+
async function sendUserOperationWithRetry(userOp, resigner, options) {
|
|
373
|
+
const { chainId, maxRetries = 1 } = options;
|
|
374
|
+
const chainConfig = getChainConfig(chainId);
|
|
375
|
+
if (!chainConfig) {
|
|
376
|
+
throw new Error(`[sendUserOperationWithRetry] ChainConfig is not found (chainId:${chainId}`);
|
|
150
377
|
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
async function sendUserOperationV06WithRetry(userOp, resigner, maxRetries = 1) {
|
|
378
|
+
createPublicClientForChain(chainId);
|
|
154
379
|
let attempts = 0;
|
|
155
380
|
let currentUserOp = userOp;
|
|
156
381
|
while (attempts < maxRetries) {
|
|
157
382
|
try {
|
|
158
|
-
return await
|
|
383
|
+
return await sendUserOperationRaw(currentUserOp, { chainId });
|
|
159
384
|
} catch (error) {
|
|
160
385
|
attempts++;
|
|
161
386
|
const errorMsg = String(error?.message || error);
|
|
162
387
|
if (attempts >= maxRetries) throw error;
|
|
163
388
|
if (/nonce too low|nonce.*invalid/i.test(errorMsg)) {
|
|
164
|
-
const newNonce = await fetchEntryPointNonce(
|
|
389
|
+
const newNonce = await fetchEntryPointNonce(
|
|
390
|
+
userOp.sender,
|
|
391
|
+
chainConfig.entryPointV07Address);
|
|
165
392
|
currentUserOp = await resigner(newNonce);
|
|
166
393
|
} else if (/replacement.*underpriced/i.test(errorMsg)) {
|
|
167
394
|
const increasedMaxFeePerGas = `0x${(BigInt(currentUserOp.maxFeePerGas) * 110n / 100n).toString(16)}`;
|
|
@@ -169,36 +396,21 @@ async function sendUserOperationV06WithRetry(userOp, resigner, maxRetries = 1) {
|
|
|
169
396
|
currentUserOp = { ...currentUserOp, maxFeePerGas: increasedMaxFeePerGas, maxPriorityFeePerGas: increasedMaxPriorityFeePerGas };
|
|
170
397
|
currentUserOp = await resigner(currentUserOp.nonce);
|
|
171
398
|
} else {
|
|
172
|
-
const newNonce = await fetchEntryPointNonce(
|
|
399
|
+
const newNonce = await fetchEntryPointNonce(
|
|
400
|
+
userOp.sender,
|
|
401
|
+
chainConfig.entryPointV07Address);
|
|
173
402
|
currentUserOp = await resigner(newNonce);
|
|
174
403
|
}
|
|
175
404
|
await new Promise((r) => setTimeout(r, 1e3 * attempts));
|
|
176
405
|
}
|
|
177
406
|
}
|
|
178
|
-
throw new Error(`Failed to send UserOperation
|
|
407
|
+
throw new Error(`Failed to send UserOperation after ${maxRetries} attempts`);
|
|
179
408
|
}
|
|
180
|
-
async function getUserOperationReceipt(userOpHash) {
|
|
181
|
-
const receipt = await bundlerRpc("eth_getUserOperationReceipt", [userOpHash]);
|
|
409
|
+
async function getUserOperationReceipt(userOpHash, bundlerUrl) {
|
|
410
|
+
const receipt = await bundlerRpc("eth_getUserOperationReceipt", [userOpHash], bundlerUrl);
|
|
182
411
|
return receipt;
|
|
183
412
|
}
|
|
184
413
|
|
|
185
|
-
// src/bundler/client-provider.ts
|
|
186
|
-
var globalPublicClient = null;
|
|
187
|
-
function setPublicClient(client) {
|
|
188
|
-
globalPublicClient = client;
|
|
189
|
-
}
|
|
190
|
-
function getPublicClient() {
|
|
191
|
-
if (!globalPublicClient) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
"[LumiaPassport] PublicClient not configured. Please provide a publicClient in config or call setPublicClient() before using fee calculation functions."
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
return globalPublicClient;
|
|
197
|
-
}
|
|
198
|
-
function hasPublicClient() {
|
|
199
|
-
return globalPublicClient !== null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
414
|
// src/utils/env.ts
|
|
203
415
|
function getEnvironmentVars() {
|
|
204
416
|
const win = typeof globalThis !== "undefined" && globalThis.window;
|
|
@@ -258,8 +470,9 @@ function getDefaultPriorityFeePerGasHex() {
|
|
|
258
470
|
}
|
|
259
471
|
var DEFAULT_FEE_CONFIG = { baseFeeBuffer: 0.5, priorityFeeBuffer: 0.05, fallbackMaxFeePerGas: HARDCODED_FALLBACK_MAX_FEE, fallbackMaxPriorityFeePerGas: HARDCODED_FALLBACK_PRIORITY_FEE };
|
|
260
472
|
var CONSERVATIVE_FEE_CONFIG = { baseFeeBuffer: 1, priorityFeeBuffer: 0.25, fallbackMaxFeePerGas: 5000000000n, fallbackMaxPriorityFeePerGas: 3000000000n };
|
|
261
|
-
function shouldUseLegacyGasForChain() {
|
|
473
|
+
function shouldUseLegacyGasForChain(options) {
|
|
262
474
|
try {
|
|
475
|
+
const { publicClient } = options;
|
|
263
476
|
const legacyChainIds = getEnvVar("VITE_LEGACY_GAS_CHAIN_IDS") || getEnvVar("LEGACY_GAS_CHAIN_IDS") || "";
|
|
264
477
|
console.log("[Fees] Environment check:", {
|
|
265
478
|
LEGACY_GAS_CHAIN_IDS: legacyChainIds
|
|
@@ -267,7 +480,6 @@ function shouldUseLegacyGasForChain() {
|
|
|
267
480
|
const defaultLegacyChains = "2030232745";
|
|
268
481
|
const chainIdsString = legacyChainIds || defaultLegacyChains;
|
|
269
482
|
const legacyChains = chainIdsString.split(",").map((id) => parseInt(id.trim())).filter((id) => !isNaN(id));
|
|
270
|
-
const publicClient = getPublicClient();
|
|
271
483
|
const currentChainId = publicClient?.chain?.id;
|
|
272
484
|
if (!currentChainId) return false;
|
|
273
485
|
const shouldUseLegacy = legacyChains.includes(currentChainId);
|
|
@@ -284,41 +496,40 @@ function shouldUseLegacyGasForChain() {
|
|
|
284
496
|
return false;
|
|
285
497
|
}
|
|
286
498
|
}
|
|
287
|
-
async function getCurrentBaseFee() {
|
|
288
|
-
const
|
|
289
|
-
const block = await publicClient.getBlock({ blockTag: "latest" });
|
|
499
|
+
async function getCurrentBaseFee(context) {
|
|
500
|
+
const block = await context.client.getBlock({ blockTag: "latest" });
|
|
290
501
|
if (block.baseFeePerGas) return block.baseFeePerGas;
|
|
291
|
-
const gasPriceHex = await
|
|
502
|
+
const gasPriceHex = await context.client.getGasPrice();
|
|
292
503
|
const gasPrice = BigInt(gasPriceHex);
|
|
293
504
|
const estimatedBaseFee = gasPrice * 9n / 10n;
|
|
294
505
|
return estimatedBaseFee;
|
|
295
506
|
}
|
|
296
|
-
async function getCurrentPriorityFee() {
|
|
507
|
+
async function getCurrentPriorityFee(bundlerUrl, context) {
|
|
297
508
|
try {
|
|
298
|
-
const priorityFeeHex = await bundlerRpc("rundler_maxPriorityFeePerGas", []);
|
|
509
|
+
const priorityFeeHex = await bundlerRpc("rundler_maxPriorityFeePerGas", [], bundlerUrl);
|
|
299
510
|
const priorityFee = BigInt(priorityFeeHex);
|
|
300
|
-
if (priorityFee === 0n)
|
|
511
|
+
if (priorityFee === 0n) {
|
|
512
|
+
return await getFallbackPriorityFee(context);
|
|
513
|
+
}
|
|
301
514
|
return priorityFee;
|
|
302
515
|
} catch {
|
|
303
|
-
return await getFallbackPriorityFee();
|
|
516
|
+
return await getFallbackPriorityFee(context);
|
|
304
517
|
}
|
|
305
518
|
}
|
|
306
|
-
async function getFallbackPriorityFee() {
|
|
519
|
+
async function getFallbackPriorityFee(context) {
|
|
307
520
|
try {
|
|
308
|
-
const
|
|
309
|
-
const gasPriceHex = await publicClient.getGasPrice();
|
|
521
|
+
const gasPriceHex = await context.client.getGasPrice();
|
|
310
522
|
const gasPrice = BigInt(gasPriceHex);
|
|
311
523
|
return gasPrice / 10n;
|
|
312
524
|
} catch {
|
|
313
525
|
return 100000000n;
|
|
314
526
|
}
|
|
315
527
|
}
|
|
316
|
-
async function calculateLegacyFees(bufferPercent
|
|
528
|
+
async function calculateLegacyFees(bufferPercent, context) {
|
|
317
529
|
const minMaxFee = getMinMaxFeePerGas();
|
|
318
530
|
const minPriorityFee = getMinPriorityFeePerGas();
|
|
319
531
|
try {
|
|
320
|
-
const
|
|
321
|
-
const gasPriceHex = await publicClient.getGasPrice();
|
|
532
|
+
const gasPriceHex = await context.client.getGasPrice();
|
|
322
533
|
const networkGasPrice = BigInt(gasPriceHex);
|
|
323
534
|
const bufferedGasPrice = networkGasPrice + networkGasPrice * BigInt(bufferPercent) / 100n;
|
|
324
535
|
const effectiveGasPrice = bufferedGasPrice < minMaxFee ? minMaxFee : bufferedGasPrice;
|
|
@@ -344,19 +555,20 @@ async function calculateLegacyFees(bufferPercent = 30) {
|
|
|
344
555
|
};
|
|
345
556
|
}
|
|
346
557
|
}
|
|
347
|
-
async function calculateDynamicFees(config = DEFAULT_FEE_CONFIG) {
|
|
558
|
+
async function calculateDynamicFees(config = DEFAULT_FEE_CONFIG, context) {
|
|
559
|
+
const { client, bundlerUrl } = context;
|
|
348
560
|
const minMaxFee = getMinMaxFeePerGas();
|
|
349
561
|
const minPriorityFee = getMinPriorityFeePerGas();
|
|
350
562
|
try {
|
|
351
563
|
const forceLegacy = getEnvVarBool("VITE_FORCE_LEGACY_GAS") || getEnvVarBool("FORCE_LEGACY_GAS");
|
|
352
|
-
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain();
|
|
564
|
+
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client });
|
|
353
565
|
if (shouldUseLegacy) {
|
|
354
566
|
console.log("[Fees] Using legacy gas pricing", forceLegacy ? "(forced by FORCE_LEGACY_GAS env var)" : "(chain requires legacy gas)");
|
|
355
|
-
return await calculateLegacyFees();
|
|
567
|
+
return await calculateLegacyFees(30, { client });
|
|
356
568
|
}
|
|
357
|
-
const baseFee = await getCurrentBaseFee();
|
|
569
|
+
const baseFee = await getCurrentBaseFee({ client });
|
|
358
570
|
const bufferedBaseFee = baseFee + baseFee * BigInt(Math.floor(config.baseFeeBuffer * 1e3)) / 1000n;
|
|
359
|
-
const priorityFee = await getCurrentPriorityFee();
|
|
571
|
+
const priorityFee = await getCurrentPriorityFee(bundlerUrl, { client });
|
|
360
572
|
const bufferedPriorityFee = priorityFee + priorityFee * BigInt(Math.floor(config.priorityFeeBuffer * 1e3)) / 1000n;
|
|
361
573
|
let maxFeePerGas = bufferedBaseFee + bufferedPriorityFee;
|
|
362
574
|
let maxPriorityFeePerGas = bufferedPriorityFee;
|
|
@@ -370,23 +582,29 @@ async function calculateDynamicFees(config = DEFAULT_FEE_CONFIG) {
|
|
|
370
582
|
}
|
|
371
583
|
return { maxFeePerGas: `0x${maxFeePerGas.toString(16)}`, maxPriorityFeePerGas: `0x${maxPriorityFeePerGas.toString(16)}`, baseFee, priorityFee, bufferedBaseFee, bufferedPriorityFee };
|
|
372
584
|
} catch {
|
|
373
|
-
return await calculateLegacyFees();
|
|
585
|
+
return await calculateLegacyFees(30, { client });
|
|
374
586
|
}
|
|
375
587
|
}
|
|
376
|
-
async function calculateFastFees() {
|
|
588
|
+
async function calculateFastFees(context) {
|
|
589
|
+
const { client } = context;
|
|
377
590
|
const forceLegacy = getEnvVarBool("VITE_FORCE_LEGACY_GAS") || getEnvVarBool("FORCE_LEGACY_GAS");
|
|
378
|
-
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain();
|
|
379
|
-
if (shouldUseLegacy) return await calculateLegacyFees(50);
|
|
380
|
-
return calculateDynamicFees({ baseFeeBuffer: 0.75, priorityFeeBuffer: 0.5, fallbackMaxFeePerGas: 3000000000n, fallbackMaxPriorityFeePerGas: 2000000000n });
|
|
591
|
+
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client });
|
|
592
|
+
if (shouldUseLegacy) return await calculateLegacyFees(50, { client });
|
|
593
|
+
return calculateDynamicFees({ baseFeeBuffer: 0.75, priorityFeeBuffer: 0.5, fallbackMaxFeePerGas: 3000000000n, fallbackMaxPriorityFeePerGas: 2000000000n }, context);
|
|
381
594
|
}
|
|
382
|
-
async function calculateEconomyFees() {
|
|
595
|
+
async function calculateEconomyFees(context) {
|
|
596
|
+
const { client } = context;
|
|
383
597
|
const forceLegacy = getEnvVarBool("VITE_FORCE_LEGACY_GAS") || getEnvVarBool("FORCE_LEGACY_GAS");
|
|
384
|
-
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain();
|
|
385
|
-
if (shouldUseLegacy) return await calculateLegacyFees(30);
|
|
386
|
-
return calculateDynamicFees({ baseFeeBuffer: 0.27, priorityFeeBuffer: 0.01, fallbackMaxFeePerGas: 1000000000n, fallbackMaxPriorityFeePerGas: 500000000n });
|
|
387
|
-
}
|
|
388
|
-
async function getFeeEstimates() {
|
|
389
|
-
const [economy, standard, fast] = await Promise.all([
|
|
598
|
+
const shouldUseLegacy = forceLegacy || shouldUseLegacyGasForChain({ publicClient: client });
|
|
599
|
+
if (shouldUseLegacy) return await calculateLegacyFees(30, { client });
|
|
600
|
+
return calculateDynamicFees({ baseFeeBuffer: 0.27, priorityFeeBuffer: 0.01, fallbackMaxFeePerGas: 1000000000n, fallbackMaxPriorityFeePerGas: 500000000n }, context);
|
|
601
|
+
}
|
|
602
|
+
async function getFeeEstimates(context) {
|
|
603
|
+
const [economy, standard, fast] = await Promise.all([
|
|
604
|
+
calculateEconomyFees(context),
|
|
605
|
+
calculateDynamicFees(void 0, context),
|
|
606
|
+
calculateFastFees(context)
|
|
607
|
+
]);
|
|
390
608
|
return { economy, standard, fast };
|
|
391
609
|
}
|
|
392
610
|
|
|
@@ -430,43 +648,21 @@ function createDummyUserOperation(sender, nonce, callData, includeFactory = fals
|
|
|
430
648
|
}
|
|
431
649
|
return userOp;
|
|
432
650
|
}
|
|
433
|
-
function
|
|
434
|
-
|
|
435
|
-
if (includeFactory && factoryAddress && factoryData) {
|
|
436
|
-
const factoryAddrClean = factoryAddress.startsWith("0x") ? factoryAddress.slice(2) : factoryAddress;
|
|
437
|
-
const factoryDataClean = factoryData.startsWith("0x") ? factoryData.slice(2) : factoryData;
|
|
438
|
-
initCode = `0x${factoryAddrClean}${factoryDataClean}`;
|
|
439
|
-
}
|
|
440
|
-
return { sender, nonce, initCode, callData, callGasLimit: "0x0", verificationGasLimit: "0x0", preVerificationGas: "0x0", maxFeePerGas: customMaxFeePerGas || getDefaultMaxFeePerGasHex(), maxPriorityFeePerGas: customMaxPriorityFeePerGas || getDefaultPriorityFeePerGasHex(), paymasterAndData: "0x", signature: DUMMY_SIGNATURE };
|
|
441
|
-
}
|
|
442
|
-
async function createUserOperationWithDynamicFees(sender, nonce, callData, includeFactory = false, factoryAddress, factoryData, feeType = "standard") {
|
|
651
|
+
async function createUserOperationWithDynamicFees(params, context) {
|
|
652
|
+
const { sender, nonce, callData, includeFactory = false, factoryAddress, factoryData, feeType = "standard" } = params;
|
|
443
653
|
let fees;
|
|
444
654
|
switch (feeType) {
|
|
445
655
|
case "economy":
|
|
446
|
-
fees = await calculateEconomyFees();
|
|
656
|
+
fees = await calculateEconomyFees(context);
|
|
447
657
|
break;
|
|
448
658
|
case "fast":
|
|
449
|
-
fees = await calculateFastFees();
|
|
659
|
+
fees = await calculateFastFees(context);
|
|
450
660
|
break;
|
|
451
661
|
default:
|
|
452
|
-
fees = await calculateDynamicFees();
|
|
662
|
+
fees = await calculateDynamicFees(void 0, context);
|
|
453
663
|
}
|
|
454
664
|
return createDummyUserOperation(sender, nonce, callData, includeFactory, factoryAddress, factoryData, fees.maxFeePerGas, fees.maxPriorityFeePerGas);
|
|
455
665
|
}
|
|
456
|
-
async function createUserOperationV06WithDynamicFees(sender, nonce, callData, includeFactory = false, factoryAddress, factoryData, feeType = "standard") {
|
|
457
|
-
let fees;
|
|
458
|
-
switch (feeType) {
|
|
459
|
-
case "economy":
|
|
460
|
-
fees = await calculateEconomyFees();
|
|
461
|
-
break;
|
|
462
|
-
case "fast":
|
|
463
|
-
fees = await calculateFastFees();
|
|
464
|
-
break;
|
|
465
|
-
default:
|
|
466
|
-
fees = await calculateDynamicFees();
|
|
467
|
-
}
|
|
468
|
-
return createDummyUserOperationV06(sender, nonce, callData, includeFactory, factoryAddress, factoryData, fees.maxFeePerGas, fees.maxPriorityFeePerGas);
|
|
469
|
-
}
|
|
470
666
|
|
|
471
667
|
// src/bundler/gas-estimation.ts
|
|
472
668
|
var VALIDATION_ERROR_PATTERNS = [
|
|
@@ -508,20 +704,29 @@ function isValidationError(errorMsg) {
|
|
|
508
704
|
function isExecutionRevert(errorMsg) {
|
|
509
705
|
return EXECUTION_REVERT_PATTERNS.some((pattern) => pattern.test(errorMsg));
|
|
510
706
|
}
|
|
511
|
-
async function estimateUserOperationGas(userOp,
|
|
512
|
-
const
|
|
707
|
+
async function estimateUserOperationGas(userOp, options) {
|
|
708
|
+
const chainConfig = getChainConfig(options.chainId);
|
|
709
|
+
if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`);
|
|
513
710
|
try {
|
|
514
|
-
const gas = await bundlerRpc(
|
|
711
|
+
const gas = await bundlerRpc(
|
|
712
|
+
"eth_estimateUserOperationGas",
|
|
713
|
+
[userOp, chainConfig.entryPointV07Address],
|
|
714
|
+
chainConfig.bundlerUrl
|
|
715
|
+
);
|
|
515
716
|
return gas;
|
|
516
717
|
} catch (error) {
|
|
517
718
|
const errorMsg = String(error);
|
|
518
|
-
if (retryWithoutFactory && (userOp.factory || userOp.factoryData)) {
|
|
719
|
+
if (options.retryWithoutFactory && (userOp.factory || userOp.factoryData)) {
|
|
519
720
|
if (/AA10 sender already constructed/i.test(errorMsg) || /sender.*is an existing contract.*but initCode is nonempty/i.test(errorMsg)) {
|
|
520
721
|
const userOpWithoutFactory = { ...userOp };
|
|
521
722
|
delete userOpWithoutFactory.factory;
|
|
522
723
|
delete userOpWithoutFactory.factoryData;
|
|
523
724
|
try {
|
|
524
|
-
const gas = await bundlerRpc(
|
|
725
|
+
const gas = await bundlerRpc(
|
|
726
|
+
"eth_estimateUserOperationGas",
|
|
727
|
+
[userOpWithoutFactory, chainConfig.entryPointV07Address],
|
|
728
|
+
chainConfig.bundlerUrl
|
|
729
|
+
);
|
|
525
730
|
return gas;
|
|
526
731
|
} catch {
|
|
527
732
|
}
|
|
@@ -545,23 +750,34 @@ async function estimateUserOperationGas(userOp, retryWithoutFactory = true) {
|
|
|
545
750
|
};
|
|
546
751
|
}
|
|
547
752
|
}
|
|
548
|
-
async function estimateUserOperationGasWithSignature(userOp, _getSignature, _getUserOpHash,
|
|
753
|
+
async function estimateUserOperationGasWithSignature(userOp, _getSignature, _getUserOpHash, options) {
|
|
549
754
|
const userOpForEstimation = { ...userOp, signature: DUMMY_SIGNATURE };
|
|
550
|
-
return estimateUserOperationGas(
|
|
755
|
+
return estimateUserOperationGas(
|
|
756
|
+
userOpForEstimation,
|
|
757
|
+
{
|
|
758
|
+
chainId: options.chainId,
|
|
759
|
+
retryWithoutFactory: options.retryWithoutFactory
|
|
760
|
+
}
|
|
761
|
+
);
|
|
551
762
|
}
|
|
552
|
-
async function estimateUserOperationGasWithDynamicFees(
|
|
553
|
-
const userOp = await createUserOperationWithDynamicFees(
|
|
554
|
-
const gasResult = await estimateUserOperationGas(
|
|
555
|
-
|
|
763
|
+
async function estimateUserOperationGasWithDynamicFees(params, context, retryWithoutFactory = true) {
|
|
764
|
+
const userOp = await createUserOperationWithDynamicFees(params, context);
|
|
765
|
+
const gasResult = await estimateUserOperationGas(
|
|
766
|
+
userOp,
|
|
767
|
+
{ retryWithoutFactory, chainId: context.chainConfig.id }
|
|
768
|
+
);
|
|
769
|
+
return { ...gasResult, calculatedFees: { maxFeePerGas: userOp.maxFeePerGas, maxPriorityFeePerGas: userOp.maxPriorityFeePerGas, feeType: params.feeType || "standard" } };
|
|
556
770
|
}
|
|
557
771
|
|
|
558
772
|
// src/bundler/simulation.ts
|
|
559
|
-
async function simulateUserOperation(userOp,
|
|
773
|
+
async function simulateUserOperation(userOp, options) {
|
|
774
|
+
const chainConfig = getChainConfig(options.chainId);
|
|
775
|
+
if (!chainConfig) throw new Error(`Chain ID ${options.chainId} is not supported.`);
|
|
560
776
|
try {
|
|
561
777
|
const result = await bundlerRpc("lumia_simulateUserOperation", [{
|
|
562
778
|
userOperation: userOp,
|
|
563
|
-
entryPoint
|
|
564
|
-
}]);
|
|
779
|
+
entryPoint: chainConfig.entryPointV07Address
|
|
780
|
+
}], chainConfig?.bundlerUrl);
|
|
565
781
|
return result;
|
|
566
782
|
} catch (error) {
|
|
567
783
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
@@ -574,9 +790,9 @@ async function simulateUserOperation(userOp, entryPoint = ENTRYPOINT_V07) {
|
|
|
574
790
|
};
|
|
575
791
|
}
|
|
576
792
|
}
|
|
577
|
-
async function validateUserOperation(userOp) {
|
|
793
|
+
async function validateUserOperation(userOp, options) {
|
|
578
794
|
try {
|
|
579
|
-
const result = await simulateUserOperation(userOp);
|
|
795
|
+
const result = await simulateUserOperation(userOp, { chainId: options.chainId });
|
|
580
796
|
if (result.error) {
|
|
581
797
|
return { valid: false, error: result.error.message };
|
|
582
798
|
}
|
|
@@ -587,19 +803,33 @@ async function validateUserOperation(userOp) {
|
|
|
587
803
|
}
|
|
588
804
|
}
|
|
589
805
|
|
|
806
|
+
// src/bundler/client-provider.ts
|
|
807
|
+
var globalPublicClient = null;
|
|
808
|
+
function setPublicClient(client) {
|
|
809
|
+
globalPublicClient = client;
|
|
810
|
+
}
|
|
811
|
+
function getPublicClient2() {
|
|
812
|
+
if (!globalPublicClient) {
|
|
813
|
+
throw new Error(
|
|
814
|
+
"[LumiaPassport] PublicClient not configured. Please provide a publicClient in config or call setPublicClient() before using fee calculation functions."
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
return globalPublicClient;
|
|
818
|
+
}
|
|
819
|
+
function hasPublicClient() {
|
|
820
|
+
return globalPublicClient !== null;
|
|
821
|
+
}
|
|
822
|
+
|
|
590
823
|
exports.CONSERVATIVE_FEE_CONFIG = CONSERVATIVE_FEE_CONFIG;
|
|
591
824
|
exports.DEFAULT_FEE_CONFIG = DEFAULT_FEE_CONFIG;
|
|
592
825
|
exports.DUMMY_SIGNATURE = DUMMY_SIGNATURE;
|
|
593
826
|
exports.ENTRYPOINT = ENTRYPOINT;
|
|
594
|
-
exports.ENTRYPOINT_V06 = ENTRYPOINT_V06;
|
|
595
827
|
exports.ENTRYPOINT_V07 = ENTRYPOINT_V07;
|
|
596
828
|
exports.calculateDynamicFees = calculateDynamicFees;
|
|
597
829
|
exports.calculateEconomyFees = calculateEconomyFees;
|
|
598
830
|
exports.calculateFastFees = calculateFastFees;
|
|
599
831
|
exports.calculateLegacyFees = calculateLegacyFees;
|
|
600
832
|
exports.createDummyUserOperation = createDummyUserOperation;
|
|
601
|
-
exports.createDummyUserOperationV06 = createDummyUserOperationV06;
|
|
602
|
-
exports.createUserOperationV06WithDynamicFees = createUserOperationV06WithDynamicFees;
|
|
603
833
|
exports.createUserOperationWithDynamicFees = createUserOperationWithDynamicFees;
|
|
604
834
|
exports.estimateUserOperationGas = estimateUserOperationGas;
|
|
605
835
|
exports.estimateUserOperationGasWithDynamicFees = estimateUserOperationGasWithDynamicFees;
|
|
@@ -607,13 +837,11 @@ exports.estimateUserOperationGasWithSignature = estimateUserOperationGasWithSign
|
|
|
607
837
|
exports.getCurrentBaseFee = getCurrentBaseFee;
|
|
608
838
|
exports.getCurrentPriorityFee = getCurrentPriorityFee;
|
|
609
839
|
exports.getFeeEstimates = getFeeEstimates;
|
|
610
|
-
exports.getPublicClient =
|
|
840
|
+
exports.getPublicClient = getPublicClient2;
|
|
611
841
|
exports.getUserOperationReceipt = getUserOperationReceipt;
|
|
612
842
|
exports.hasPublicClient = hasPublicClient;
|
|
613
843
|
exports.packUserOperationV07 = packUserOperationV07;
|
|
614
844
|
exports.sendUserOperationRaw = sendUserOperationRaw;
|
|
615
|
-
exports.sendUserOperationV06Raw = sendUserOperationV06Raw;
|
|
616
|
-
exports.sendUserOperationV06WithRetry = sendUserOperationV06WithRetry;
|
|
617
845
|
exports.sendUserOperationWithRetry = sendUserOperationWithRetry;
|
|
618
846
|
exports.setPublicClient = setPublicClient;
|
|
619
847
|
exports.simulateUserOperation = simulateUserOperation;
|