@aastar/sdk 0.20.4 → 0.20.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.
- package/README.md +32 -24
- package/dist/BaseClient-BjbYP0cf.d.ts +88 -0
- package/dist/UserClient-AIIHB54I.js +6 -0
- package/dist/{UserClient-JMNNZT4P.js.map → UserClient-AIIHB54I.js.map} +1 -1
- package/dist/account.d.ts +48 -1
- package/dist/account.js +3 -3
- package/dist/admin.d.ts +62 -1
- package/dist/admin.js +3 -3
- package/dist/airaccount.d.ts +4 -2
- package/dist/airaccount.js +2 -4498
- package/dist/airaccount.js.map +1 -1
- package/dist/channel-CkRRbzT8.d.ts +77 -0
- package/dist/channel.d.ts +64 -1
- package/dist/channel.js +3 -3
- package/dist/{chunk-YSDWB6DO.js → chunk-4EZD7LPE.js} +30 -24
- package/dist/chunk-4EZD7LPE.js.map +1 -0
- package/dist/{chunk-TBDMSJVL.js → chunk-6QYXGMCR.js} +513 -322
- package/dist/chunk-6QYXGMCR.js.map +1 -0
- package/dist/{chunk-QNYP7RPI.js → chunk-7ARJ3OSU.js} +29 -21
- package/dist/chunk-7ARJ3OSU.js.map +1 -0
- package/dist/{chunk-KL6SCEIU.js → chunk-BN5WY5GM.js} +16 -14
- package/dist/chunk-BN5WY5GM.js.map +1 -0
- package/dist/{chunk-5TDDS3T5.js → chunk-FJ7XECC5.js} +4 -4
- package/dist/chunk-FJ7XECC5.js.map +1 -0
- package/dist/{chunk-4KRQXOTI.js → chunk-FUU7RIIA.js} +113 -102
- package/dist/chunk-FUU7RIIA.js.map +1 -0
- package/dist/{chunk-ZJLIKMCA.js → chunk-G3UJC4EL.js} +17 -8
- package/dist/chunk-G3UJC4EL.js.map +1 -0
- package/dist/{chunk-M5ORP2PM.js → chunk-KDH3UPKD.js} +10 -13
- package/dist/chunk-KDH3UPKD.js.map +1 -0
- package/dist/chunk-KISL64KW.js +4245 -0
- package/dist/chunk-KISL64KW.js.map +1 -0
- package/dist/{chunk-Y3KP7R2Y.js → chunk-LXWIPTPX.js} +5 -5
- package/dist/chunk-LXWIPTPX.js.map +1 -0
- package/dist/{chunk-NAPMVAVJ.js → chunk-MVEWJIPY.js} +124 -110
- package/dist/chunk-MVEWJIPY.js.map +1 -0
- package/dist/{chunk-LNICTATJ.js → chunk-PAABYXS6.js} +33 -40
- package/dist/chunk-PAABYXS6.js.map +1 -0
- package/dist/{chunk-O454V5ML.js → chunk-PKCHRXFR.js} +8 -12
- package/dist/chunk-PKCHRXFR.js.map +1 -0
- package/dist/{chunk-R2RATIK2.js → chunk-TENYCMJ3.js} +31 -31
- package/dist/chunk-TENYCMJ3.js.map +1 -0
- package/dist/{contract-addresses-VLAHHXOO.js → contract-addresses-N3TOL2WL.js} +3 -3
- package/dist/{contract-addresses-VLAHHXOO.js.map → contract-addresses-N3TOL2WL.js.map} +1 -1
- package/dist/core.d.ts +6930 -13
- package/dist/core.js +2 -2
- package/dist/dapp.d.ts +127 -1
- package/dist/dapp.js +12 -13
- package/dist/dapp.js.map +1 -1
- package/dist/doc-types-471vSmPO.d.ts +16 -0
- package/dist/enduser.d.ts +261 -1
- package/dist/enduser.js +4 -4
- package/dist/identity.d.ts +81 -1
- package/dist/identity.js +3 -3
- package/dist/index-B6SfEQxo.d.ts +47 -0
- package/dist/index.d.ts +55 -14
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/kms.d.ts +2986 -0
- package/dist/kms.js +5 -0
- package/dist/kms.js.map +1 -0
- package/dist/operator.d.ts +164 -1
- package/dist/operator.js +3 -3
- package/dist/paymaster.d.ts +312 -1
- package/dist/paymaster.js +3 -3
- package/dist/{index.node-GNYPFVZQ.js → src-L5SI5WNB.js} +4 -4
- package/dist/src-L5SI5WNB.js.map +1 -0
- package/dist/{dist-WMYQOYRO.js → src-X5MIV3EB.js} +5 -5
- package/dist/src-X5MIV3EB.js.map +1 -0
- package/dist/tier-router-DLiMxs0h.d.ts +321 -0
- package/dist/tokens.d.ts +64 -1
- package/dist/tokens.js +3 -3
- package/dist/x402.d.ts +373 -1
- package/dist/x402.js +3 -3
- package/package.json +19 -15
- package/LICENSE +0 -180
- package/dist/UserClient-JMNNZT4P.js +0 -6
- package/dist/chunk-4KRQXOTI.js.map +0 -1
- package/dist/chunk-5TDDS3T5.js.map +0 -1
- package/dist/chunk-KL6SCEIU.js.map +0 -1
- package/dist/chunk-LNICTATJ.js.map +0 -1
- package/dist/chunk-M5ORP2PM.js.map +0 -1
- package/dist/chunk-NAPMVAVJ.js.map +0 -1
- package/dist/chunk-O454V5ML.js.map +0 -1
- package/dist/chunk-QNYP7RPI.js.map +0 -1
- package/dist/chunk-R2RATIK2.js.map +0 -1
- package/dist/chunk-TBDMSJVL.js.map +0 -1
- package/dist/chunk-Y3KP7R2Y.js.map +0 -1
- package/dist/chunk-YSDWB6DO.js.map +0 -1
- package/dist/chunk-ZJLIKMCA.js.map +0 -1
- package/dist/dist-WMYQOYRO.js.map +0 -1
- package/dist/index.node-GNYPFVZQ.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { channelActions } from './chunk-
|
|
1
|
+
import { channelActions } from './chunk-6QYXGMCR.js';
|
|
2
2
|
|
|
3
|
-
// ../channel/
|
|
3
|
+
// ../channel/src/voucher.ts
|
|
4
4
|
var VOUCHER_TYPES = {
|
|
5
5
|
Voucher: [
|
|
6
6
|
{ name: "channelId", type: "bytes32" },
|
|
@@ -33,7 +33,7 @@ async function signVoucher(walletClient, params) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// ../channel/
|
|
36
|
+
// ../channel/src/ChannelClient.ts
|
|
37
37
|
var ChannelClient = class {
|
|
38
38
|
readActions;
|
|
39
39
|
writeActions;
|
|
@@ -109,5 +109,5 @@ var ChannelClient = class {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
export { ChannelClient, VOUCHER_TYPES, getVoucherDomain, signVoucher };
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-LXWIPTPX.js.map
|
|
113
|
+
//# sourceMappingURL=chunk-LXWIPTPX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../channel/src/voucher.ts","../../channel/src/ChannelClient.ts"],"names":[],"mappings":";;;AAEO,IAAM,aAAA,GAAgB;AAAA,EACzB,OAAA,EAAS;AAAA,IACL,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,SAAA,EAAU;AAAA,IACrC,EAAE,IAAA,EAAM,kBAAA,EAAoB,IAAA,EAAM,SAAA;AAAU;AAEpD;AAEO,SAAS,gBAAA,CAAiB,SAAiB,iBAAA,EAA4B;AAC1E,EAAA,OAAO;AAAA,IACH,IAAA,EAAM,qBAAA;AAAA,IACN,OAAA,EAAS,OAAA;AAAA,IACT,OAAA;AAAA,IACA;AAAA,GACJ;AACJ;AAEA,eAAsB,WAAA,CAClB,cACA,MAAA,EAMY;AACZ,EAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,MAAA,CAAO,OAAA,EAAS,OAAO,iBAAiB,CAAA;AAExE,EAAA,MAAM,UAAU,YAAA,CAAa,OAAA;AAC7B,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,MAAM,IAAI,MAAM,mCAAmC,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,aAAa,aAAA,CAAc;AAAA,IAC9B,OAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa,SAAA;AAAA,IACb,OAAA,EAAS;AAAA,MACL,WAAW,MAAA,CAAO,SAAA;AAAA,MAClB,kBAAkB,MAAA,CAAO;AAAA;AAC7B,GACH,CAAA;AACL;;;AChCO,IAAM,gBAAN,MAAoB;AAAA,EACN,WAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EAEjB,YAAY,MAAA,EAA6B;AACrC,I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"chunk-LXWIPTPX.js","sourcesContent":["import { type Address, type Hex, type WalletClient } from 'viem';\n\nexport const VOUCHER_TYPES = {\n Voucher: [\n { name: 'channelId', type: 'bytes32' },\n { name: 'cumulativeAmount', type: 'uint128' },\n ],\n} as const;\n\nexport function getVoucherDomain(chainId: number, verifyingContract: Address) {\n return {\n name: 'MicroPaymentChannel',\n version: '1.0.0',\n chainId,\n verifyingContract,\n };\n}\n\nexport async function signVoucher(\n walletClient: WalletClient,\n params: {\n channelId: Hex;\n cumulativeAmount: bigint;\n chainId: number;\n verifyingContract: Address;\n }\n): Promise<Hex> {\n const domain = getVoucherDomain(params.chainId, params.verifyingContract);\n\n const account = walletClient.account;\n if (!account) {\n throw new Error('WalletClient must have an account');\n }\n\n return walletClient.signTypedData({\n account,\n domain,\n types: VOUCHER_TYPES,\n primaryType: 'Voucher',\n message: {\n channelId: params.channelId,\n cumulativeAmount: params.cumulativeAmount,\n },\n });\n}\n","import { type Address, type Hex, type Hash, type PublicClient, type WalletClient } from 'viem';\nimport { channelActions, type ChannelState } from '@aastar/core';\nimport type { SignedVoucher, ChannelConfig } from './types.js';\nimport { signVoucher } from './voucher.js';\n\nexport type ChannelClientConfig = {\n publicClient: PublicClient;\n walletClient: WalletClient;\n channelAddress: Address;\n chainId: number;\n};\n\nexport class ChannelClient {\n private readonly readActions;\n private readonly writeActions;\n private readonly config: ChannelClientConfig;\n\n constructor(config: ChannelClientConfig) {\n this.config = config;\n // Separate clients: publicClient for reads (no account required),\n // walletClient for writes. Unlike X402Client which is always write-first,\n // ChannelClient exposes read-heavy helpers (getChannel, verifyVoucher) that\n // callers may invoke without a wallet configured.\n this.readActions = channelActions(config.channelAddress)(config.publicClient);\n this.writeActions = channelActions(config.channelAddress)(config.walletClient);\n }\n\n async openChannel(channelConfig: ChannelConfig): Promise<Hash> {\n return this.writeActions.openChannel({\n payee: channelConfig.payee,\n token: channelConfig.token,\n deposit: channelConfig.deposit,\n salt: channelConfig.salt,\n authorizedSigner: channelConfig.authorizedSigner,\n account: this.config.walletClient.account!,\n });\n }\n\n async signVoucherOffline(channelId: Hex, cumulativeAmount: bigint): Promise<SignedVoucher> {\n const signature = await signVoucher(this.config.walletClient, {\n channelId,\n cumulativeAmount,\n chainId: this.config.chainId,\n verifyingContract: this.config.channelAddress,\n });\n\n return { channelId, cumulativeAmount, signature };\n }\n\n async settleChannel(voucher: SignedVoucher): Promise<Hash> {\n return this.writeActions.settleChannel({\n channelId: voucher.channelId,\n cumulativeAmount: voucher.cumulativeAmount,\n signature: voucher.signature,\n account: this.config.walletClient.account!,\n });\n }\n\n async closeChannel(voucher: SignedVoucher): Promise<Hash> {\n return this.writeActions.closeChannel({\n channelId: voucher.channelId,\n cumulativeAmount: voucher.cumulativeAmount,\n signature: voucher.signature,\n account: this.config.walletClient.account!,\n });\n }\n\n async topUpChannel(channelId: Hex, amount: bigint): Promise<Hash> {\n return this.writeActions.topUpChannel({\n channelId,\n amount,\n account: this.config.walletClient.account!,\n });\n }\n\n async requestClose(channelId: Hex): Promise<Hash> {\n return this.writeActions.requestCloseChannel({\n channelId,\n account: this.config.walletClient.account!,\n });\n }\n\n async withdraw(channelId: Hex): Promise<Hash> {\n return this.writeActions.withdrawChannel({\n channelId,\n account: this.config.walletClient.account!,\n });\n }\n\n async getChannelState(channelId: Hex): Promise<ChannelState> {\n return this.readActions.getChannel({ channelId });\n }\n\n async getCloseTimeout(): Promise<bigint> {\n return this.readActions.CLOSE_TIMEOUT();\n }\n\n async getVersion(): Promise<string> {\n return this.readActions.version();\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuperPaymasterABI } from './chunk-
|
|
1
|
+
import { SuperPaymasterABI } from './chunk-6QYXGMCR.js';
|
|
2
2
|
import { concat, pad, toHex, keccak256, encodeAbiParameters, toBytes, parseAbiParameters, parseAbi, encodeFunctionData } from 'viem';
|
|
3
3
|
|
|
4
4
|
var DEFAULT_VERIFICATION_GAS = 160000n;
|
|
@@ -205,48 +205,41 @@ function formatUserOpV07(userOp) {
|
|
|
205
205
|
return result;
|
|
206
206
|
}
|
|
207
207
|
function getUserOpHashV07(userOp, entryPoint, chainId) {
|
|
208
|
-
const hashedUserOp = keccak256(encodeAbiParameters(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
208
|
+
const hashedUserOp = keccak256(encodeAbiParameters(
|
|
209
|
+
["address", "uint256", "bytes32", "bytes32", "bytes32", "uint256", "bytes32", "bytes32"].map((t) => ({ type: t })),
|
|
210
|
+
[
|
|
211
|
+
userOp.sender,
|
|
212
|
+
userOp.nonce,
|
|
213
|
+
keccak256(toBytes(userOp.initCode)),
|
|
214
|
+
keccak256(toBytes(userOp.callData)),
|
|
215
|
+
userOp.accountGasLimits,
|
|
216
|
+
toHex(userOp.preVerificationGas),
|
|
217
|
+
userOp.gasFees,
|
|
218
|
+
keccak256(toBytes(userOp.paymasterAndData))
|
|
219
|
+
]
|
|
220
|
+
));
|
|
221
|
+
return keccak256(encodeAbiParameters(
|
|
222
|
+
["bytes32", "address", "uint256"].map((t) => ({ type: t })),
|
|
223
|
+
[hashedUserOp, entryPoint, chainId]
|
|
224
|
+
));
|
|
219
225
|
}
|
|
220
226
|
function tuneGasLimit(estimate, nominalActual, targetEfficiency = 0.45) {
|
|
221
|
-
if (estimate === 0n)
|
|
222
|
-
return 0n;
|
|
227
|
+
if (estimate === 0n) return 0n;
|
|
223
228
|
const ceiling = nominalActual * 100n / BigInt(Math.floor(targetEfficiency * 100));
|
|
224
229
|
return estimate < ceiling ? estimate : ceiling;
|
|
225
230
|
}
|
|
226
231
|
|
|
227
|
-
// ../paymaster/
|
|
228
|
-
var BundlerType;
|
|
229
|
-
(function(BundlerType2) {
|
|
230
|
-
BundlerType2["ALCHEMY"] = "alchemy";
|
|
231
|
-
BundlerType2["PIMLICO"] = "pimlico";
|
|
232
|
-
BundlerType2["STACKUP"] = "stackup";
|
|
233
|
-
BundlerType2["CANDIDE"] = "candide";
|
|
234
|
-
BundlerType2["UNKNOWN"] = "unknown";
|
|
235
|
-
})(BundlerType || (BundlerType = {}));
|
|
232
|
+
// ../paymaster/src/V4/BundlerCompat.ts
|
|
236
233
|
function detectBundlerType(bundlerUrl) {
|
|
237
234
|
const url = bundlerUrl.toLowerCase();
|
|
238
|
-
if (url.includes("alchemy.com"))
|
|
239
|
-
|
|
240
|
-
if (url.includes("
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return BundlerType.STACKUP;
|
|
244
|
-
if (url.includes("candide.dev"))
|
|
245
|
-
return BundlerType.CANDIDE;
|
|
246
|
-
return BundlerType.UNKNOWN;
|
|
235
|
+
if (url.includes("alchemy.com")) return "alchemy" /* ALCHEMY */;
|
|
236
|
+
if (url.includes("pimlico.io")) return "pimlico" /* PIMLICO */;
|
|
237
|
+
if (url.includes("stackup")) return "stackup" /* STACKUP */;
|
|
238
|
+
if (url.includes("candide.dev")) return "candide" /* CANDIDE */;
|
|
239
|
+
return "unknown" /* UNKNOWN */;
|
|
247
240
|
}
|
|
248
241
|
|
|
249
|
-
// ../paymaster/
|
|
242
|
+
// ../paymaster/src/V4/PaymasterClient.ts
|
|
250
243
|
var PaymasterClient = class _PaymasterClient {
|
|
251
244
|
/**
|
|
252
245
|
* @private
|
|
@@ -259,23 +252,25 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
259
252
|
return `0x${"11".repeat(clamped)}`;
|
|
260
253
|
}
|
|
261
254
|
static estimatePreVerificationGasV07(userOp) {
|
|
262
|
-
const encoded = encodeAbiParameters(
|
|
255
|
+
const encoded = encodeAbiParameters(
|
|
256
|
+
parseAbiParameters("(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)"),
|
|
263
257
|
[
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
258
|
+
[
|
|
259
|
+
userOp.sender,
|
|
260
|
+
userOp.nonce,
|
|
261
|
+
userOp.initCode,
|
|
262
|
+
userOp.callData,
|
|
263
|
+
userOp.accountGasLimits,
|
|
264
|
+
userOp.preVerificationGas,
|
|
265
|
+
userOp.gasFees,
|
|
266
|
+
userOp.paymasterAndData,
|
|
267
|
+
userOp.signature
|
|
268
|
+
]
|
|
273
269
|
]
|
|
274
|
-
|
|
270
|
+
);
|
|
275
271
|
const bytes = toBytes(encoded);
|
|
276
272
|
let calldataCost = 0n;
|
|
277
|
-
for (const b of bytes)
|
|
278
|
-
calldataCost += b === 0 ? 4n : 16n;
|
|
273
|
+
for (const b of bytes) calldataCost += b === 0 ? 4n : 16n;
|
|
279
274
|
return calldataCost + 26000n;
|
|
280
275
|
}
|
|
281
276
|
/**
|
|
@@ -358,12 +353,13 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
358
353
|
await client.waitForTransactionReceipt({ hash: updateHash });
|
|
359
354
|
console.log("[PaymasterClient] \u2705 cachedPrice refreshed via updatePrice()");
|
|
360
355
|
} else {
|
|
361
|
-
throw new Error(
|
|
356
|
+
throw new Error(
|
|
357
|
+
`Paymaster cachedPrice is stale on Mainnet (chainId: ${chainId2}). This requires Keeper to call updatePrice(). Please ensure Keeper is running.`
|
|
358
|
+
);
|
|
362
359
|
}
|
|
363
360
|
}
|
|
364
361
|
} catch (e) {
|
|
365
|
-
if (e.message?.includes("requires Keeper"))
|
|
366
|
-
throw e;
|
|
362
|
+
if (e.message?.includes("requires Keeper")) throw e;
|
|
367
363
|
console.log("[PaymasterClient] \u26A0\uFE0F Failed to check cachedPrice:", e.message?.slice(0, 50));
|
|
368
364
|
}
|
|
369
365
|
}
|
|
@@ -399,15 +395,11 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
399
395
|
}
|
|
400
396
|
}
|
|
401
397
|
if (isTestnet) {
|
|
402
|
-
if (maxPriorityFeePerGas < TESTNET_PRIORITY_FLOOR)
|
|
403
|
-
|
|
404
|
-
if (maxFeePerGas < TESTNET_PRIORITY_FLOOR * 2n)
|
|
405
|
-
maxFeePerGas = TESTNET_PRIORITY_FLOOR * 2n;
|
|
398
|
+
if (maxPriorityFeePerGas < TESTNET_PRIORITY_FLOOR) maxPriorityFeePerGas = TESTNET_PRIORITY_FLOOR;
|
|
399
|
+
if (maxFeePerGas < TESTNET_PRIORITY_FLOOR * 2n) maxFeePerGas = TESTNET_PRIORITY_FLOOR * 2n;
|
|
406
400
|
}
|
|
407
|
-
if (!maxFeePerGas)
|
|
408
|
-
|
|
409
|
-
if (maxFeePerGas < maxPriorityFeePerGas)
|
|
410
|
-
maxFeePerGas = maxPriorityFeePerGas + 1n;
|
|
401
|
+
if (!maxFeePerGas) maxFeePerGas = 1n;
|
|
402
|
+
if (maxFeePerGas < maxPriorityFeePerGas) maxFeePerGas = maxPriorityFeePerGas + 1n;
|
|
411
403
|
const partialUserOp = {
|
|
412
404
|
sender: aaAddress,
|
|
413
405
|
nonce: 0n,
|
|
@@ -459,8 +451,7 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
459
451
|
paymasterPostOpGasLimit: 100000n
|
|
460
452
|
};
|
|
461
453
|
}
|
|
462
|
-
if (result.error)
|
|
463
|
-
throw new Error(`Estimation Error: ${JSON.stringify(result.error)}`);
|
|
454
|
+
if (result.error) throw new Error(`Estimation Error: ${JSON.stringify(result.error)}`);
|
|
464
455
|
const estVGL = BigInt(data.verificationGasLimit);
|
|
465
456
|
const estPMVGL = data.paymasterVerificationGasLimit ? BigInt(data.paymasterVerificationGasLimit) : 100000n;
|
|
466
457
|
return {
|
|
@@ -485,12 +476,22 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
485
476
|
paymasterPostOpGasLimit: options?.paymasterPostOpGasLimit ?? 200000n
|
|
486
477
|
};
|
|
487
478
|
if (options?.autoEstimate !== false && (!gasLimits.verificationGasLimit || !gasLimits.callGasLimit)) {
|
|
488
|
-
const est = await this.estimateUserOperationGas(
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
479
|
+
const est = await this.estimateUserOperationGas(
|
|
480
|
+
client,
|
|
481
|
+
wallet,
|
|
482
|
+
aaAddress,
|
|
483
|
+
entryPoint,
|
|
484
|
+
paymasterAddress,
|
|
485
|
+
token,
|
|
486
|
+
bundlerUrl,
|
|
487
|
+
callData,
|
|
488
|
+
{
|
|
489
|
+
validityWindow: options?.validityWindow,
|
|
490
|
+
operator: options?.operator,
|
|
491
|
+
factory: options?.factory,
|
|
492
|
+
factoryData: options?.factoryData
|
|
493
|
+
}
|
|
494
|
+
);
|
|
494
495
|
gasLimits.preVerificationGas = options?.preVerificationGas ?? est.preVerificationGas;
|
|
495
496
|
gasLimits.verificationGasLimit = options?.verificationGasLimit ?? est.verificationGasLimit;
|
|
496
497
|
gasLimits.callGasLimit = options?.callGasLimit ?? est.callGasLimit;
|
|
@@ -528,15 +529,12 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
528
529
|
}
|
|
529
530
|
if (isTestnet) {
|
|
530
531
|
maxPriorityFeePerGas = maxPriorityFeePerGas ?? TESTNET_PRIORITY_FLOOR;
|
|
531
|
-
if (maxPriorityFeePerGas < TESTNET_PRIORITY_FLOOR)
|
|
532
|
-
|
|
533
|
-
if (!maxFeePerGas || maxFeePerGas < TESTNET_PRIORITY_FLOOR * 2n)
|
|
534
|
-
maxFeePerGas = TESTNET_PRIORITY_FLOOR * 2n;
|
|
532
|
+
if (maxPriorityFeePerGas < TESTNET_PRIORITY_FLOOR) maxPriorityFeePerGas = TESTNET_PRIORITY_FLOOR;
|
|
533
|
+
if (!maxFeePerGas || maxFeePerGas < TESTNET_PRIORITY_FLOOR * 2n) maxFeePerGas = TESTNET_PRIORITY_FLOOR * 2n;
|
|
535
534
|
}
|
|
536
535
|
maxFeePerGas = maxFeePerGas ?? 1n;
|
|
537
536
|
maxPriorityFeePerGas = maxPriorityFeePerGas ?? 0n;
|
|
538
|
-
if (maxFeePerGas < maxPriorityFeePerGas)
|
|
539
|
-
maxFeePerGas = maxPriorityFeePerGas + 1n;
|
|
537
|
+
if (maxFeePerGas < maxPriorityFeePerGas) maxFeePerGas = maxPriorityFeePerGas + 1n;
|
|
540
538
|
console.log(`[PaymasterClient] Gas Pricing: ${isTestnet ? "TESTNET (0.5 Gwei floor)" : "MAINNET (dynamic)"} | priority=${maxPriorityFeePerGas} maxFee=${maxFeePerGas}`);
|
|
541
539
|
let paymasterAndData;
|
|
542
540
|
if (options?.operator) {
|
|
@@ -647,8 +645,7 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
647
645
|
newMaxFee = required;
|
|
648
646
|
}
|
|
649
647
|
}
|
|
650
|
-
if (newMaxFee < newMaxPriority)
|
|
651
|
-
newMaxFee = newMaxPriority + 1n;
|
|
648
|
+
if (newMaxFee < newMaxPriority) newMaxFee = newMaxPriority + 1n;
|
|
652
649
|
userOp.gasFees = concat([
|
|
653
650
|
pad(toHex(newMaxPriority), { size: 16 }),
|
|
654
651
|
pad(toHex(newMaxFee), { size: 16 })
|
|
@@ -684,8 +681,7 @@ var PaymasterClient = class _PaymasterClient {
|
|
|
684
681
|
account: wallet.account
|
|
685
682
|
});
|
|
686
683
|
}
|
|
687
|
-
if (result.error)
|
|
688
|
-
throw new Error(`Bundler Error: ${JSON.stringify(result.error)}`);
|
|
684
|
+
if (result.error) throw new Error(`Bundler Error: ${JSON.stringify(result.error)}`);
|
|
689
685
|
console.log("[PaymasterClient] \u2705 Submitted via", bundlerType, "hash:", result.result);
|
|
690
686
|
return result.result;
|
|
691
687
|
}
|
|
@@ -914,19 +910,15 @@ var PaymasterOperator = class {
|
|
|
914
910
|
functionName: "getDepositInfo",
|
|
915
911
|
args: [paymasterAddress]
|
|
916
912
|
});
|
|
917
|
-
if (depositInfo[2] < 50000000000000000n)
|
|
918
|
-
|
|
919
|
-
if (depositInfo[
|
|
920
|
-
issues.push("Paymaster unstake delay is less than 1 day");
|
|
921
|
-
if (depositInfo[0] < 100000000000000000n)
|
|
922
|
-
issues.push("Paymaster deposit in EntryPoint is less than 0.1 ETH");
|
|
913
|
+
if (depositInfo[2] < 50000000000000000n) issues.push("Paymaster stake in EntryPoint is less than 0.05 ETH");
|
|
914
|
+
if (depositInfo[3] < 86400) issues.push("Paymaster unstake delay is less than 1 day");
|
|
915
|
+
if (depositInfo[0] < 100000000000000000n) issues.push("Paymaster deposit in EntryPoint is less than 0.1 ETH");
|
|
923
916
|
const ethPrice = await publicClient.readContract({
|
|
924
917
|
address: paymasterAddress,
|
|
925
918
|
abi: parseAbi(["function cachedPrice() external view returns (uint208 price, uint48 updatedAt)"]),
|
|
926
919
|
functionName: "cachedPrice"
|
|
927
920
|
}).catch(() => [0n, 0n]);
|
|
928
|
-
if (ethPrice[0] === 0n)
|
|
929
|
-
issues.push("Paymaster ETH/USD price not initialized");
|
|
921
|
+
if (ethPrice[0] === 0n) issues.push("Paymaster ETH/USD price not initialized");
|
|
930
922
|
const [tokenPrice, userTokenBal, userPMDeposit] = await Promise.all([
|
|
931
923
|
this.getTokenPrice(publicClient, paymasterAddress, token),
|
|
932
924
|
publicClient.readContract({
|
|
@@ -937,10 +929,8 @@ var PaymasterOperator = class {
|
|
|
937
929
|
}),
|
|
938
930
|
this.getDepositedBalance(publicClient, paymasterAddress, user, token)
|
|
939
931
|
]);
|
|
940
|
-
if (tokenPrice === 0n)
|
|
941
|
-
|
|
942
|
-
if (userPMDeposit === 0n)
|
|
943
|
-
issues.push("User has no deposit in Paymaster");
|
|
932
|
+
if (tokenPrice === 0n) issues.push("Token price not set in Paymaster");
|
|
933
|
+
if (userPMDeposit === 0n) issues.push("User has no deposit in Paymaster");
|
|
944
934
|
return {
|
|
945
935
|
isReady: issues.length === 0,
|
|
946
936
|
issues,
|
|
@@ -1019,11 +1009,21 @@ var SuperPaymasterClient = class {
|
|
|
1019
1009
|
console.log(` - Token: ${config.token}`);
|
|
1020
1010
|
console.log(` - Operator: ${config.operator}`);
|
|
1021
1011
|
console.log("[SuperPaymasterClient] \u2601\uFE0F Estimating Gas usage...");
|
|
1022
|
-
const est = await PaymasterClient.estimateUserOperationGas(
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1012
|
+
const est = await PaymasterClient.estimateUserOperationGas(
|
|
1013
|
+
client,
|
|
1014
|
+
wallet,
|
|
1015
|
+
aaAddress,
|
|
1016
|
+
entryPoint,
|
|
1017
|
+
config.paymasterAddress,
|
|
1018
|
+
config.token,
|
|
1019
|
+
bundlerUrl,
|
|
1020
|
+
callData,
|
|
1021
|
+
{
|
|
1022
|
+
operator: config.operator,
|
|
1023
|
+
factory: config.factory,
|
|
1024
|
+
factoryData: config.factoryData
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
1027
|
console.log("[SuperPaymasterClient] \u2601\uFE0F Bundler Estimates:", est);
|
|
1028
1028
|
const tunedVGL = tuneGasLimit(est.verificationGasLimit, 35000n, 0.45);
|
|
1029
1029
|
const bundlerEstimateVGL = est.paymasterVerificationGasLimit || 100000n;
|
|
@@ -1031,23 +1031,33 @@ var SuperPaymasterClient = class {
|
|
|
1031
1031
|
const _postOpBase = est.paymasterPostOpGasLimit + 100000n;
|
|
1032
1032
|
const tunedPostOp = _postOpBase > 200000n ? _postOpBase : 200000n;
|
|
1033
1033
|
console.log(`[SuperPaymasterClient] \u{1F527} Tuned Limits: VGL=${tunedVGL}, PMVGL=${tunedPMVerificationGas}, PostOp=${tunedPostOp}`);
|
|
1034
|
-
return PaymasterClient.submitGaslessUserOperation(
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1034
|
+
return PaymasterClient.submitGaslessUserOperation(
|
|
1035
|
+
client,
|
|
1036
|
+
wallet,
|
|
1037
|
+
aaAddress,
|
|
1038
|
+
entryPoint,
|
|
1039
|
+
config.paymasterAddress,
|
|
1040
|
+
config.token,
|
|
1041
|
+
bundlerUrl,
|
|
1042
|
+
callData,
|
|
1043
|
+
{
|
|
1044
|
+
operator: config.operator,
|
|
1045
|
+
verificationGasLimit: tunedVGL,
|
|
1046
|
+
callGasLimit: est.callGasLimit,
|
|
1047
|
+
preVerificationGas: est.preVerificationGas,
|
|
1048
|
+
paymasterVerificationGasLimit: tunedPMVerificationGas,
|
|
1049
|
+
// EXPLICIT PM LIMIT
|
|
1050
|
+
paymasterPostOpGasLimit: tunedPostOp,
|
|
1051
|
+
autoEstimate: false,
|
|
1052
|
+
// We did it ourselves
|
|
1053
|
+
factory: config.factory,
|
|
1054
|
+
factoryData: config.factoryData
|
|
1055
|
+
}
|
|
1056
|
+
);
|
|
1047
1057
|
}
|
|
1048
1058
|
};
|
|
1049
1059
|
|
|
1050
|
-
// ../paymaster/
|
|
1060
|
+
// ../paymaster/src/PaymasterManager.ts
|
|
1051
1061
|
var PaymasterManager = class _PaymasterManager {
|
|
1052
1062
|
knownPaymasters;
|
|
1053
1063
|
constructor(opts) {
|
|
@@ -1076,7 +1086,9 @@ var PaymasterManager = class _PaymasterManager {
|
|
|
1076
1086
|
const normalized = address.toLowerCase();
|
|
1077
1087
|
const existing = this.knownPaymasters.get(normalized);
|
|
1078
1088
|
if (existing && existing !== type) {
|
|
1079
|
-
throw new Error(
|
|
1089
|
+
throw new Error(
|
|
1090
|
+
`Paymaster ${address} is already registered as '${existing}'; refusing to re-register as '${type}'`
|
|
1091
|
+
);
|
|
1080
1092
|
}
|
|
1081
1093
|
this.knownPaymasters.set(normalized, type);
|
|
1082
1094
|
}
|
|
@@ -1094,7 +1106,9 @@ var PaymasterManager = class _PaymasterManager {
|
|
|
1094
1106
|
buildPaymasterData(params) {
|
|
1095
1107
|
const type = params.type ?? this.resolveType(params.paymasterAddress);
|
|
1096
1108
|
if (!type) {
|
|
1097
|
-
throw new Error(
|
|
1109
|
+
throw new Error(
|
|
1110
|
+
`PaymasterManager: cannot resolve paymaster type for ${params.paymasterAddress}. Pass an explicit \`type\` ('v4' | 'super') or register the address via registerPaymaster().`
|
|
1111
|
+
);
|
|
1098
1112
|
}
|
|
1099
1113
|
return _PaymasterManager.dispatch(type, params);
|
|
1100
1114
|
}
|
|
@@ -1136,5 +1150,5 @@ var PaymasterManager = class _PaymasterManager {
|
|
|
1136
1150
|
};
|
|
1137
1151
|
|
|
1138
1152
|
export { PaymasterClient, PaymasterManager, PaymasterOperator, SuperPaymasterAdminClient, SuperPaymasterClient, buildPaymasterData, buildSuperPaymasterData, checkEligibility, formatUserOpV07, getPaymasterV4Middleware, getSuperPaymasterMiddleware, getUserOpHashV07, tuneGasLimit };
|
|
1139
|
-
//# sourceMappingURL=chunk-
|
|
1140
|
-
//# sourceMappingURL=chunk-
|
|
1153
|
+
//# sourceMappingURL=chunk-MVEWJIPY.js.map
|
|
1154
|
+
//# sourceMappingURL=chunk-MVEWJIPY.js.map
|