@aastar/sdk 0.20.5 → 0.20.7
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/BaseClient-BjbYP0cf.d.ts +88 -0
- package/dist/UserClient-AIIHB54I.js +6 -0
- package/dist/{UserClient-UYIHF6UJ.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 -2
- package/dist/channel-CkRRbzT8.d.ts +77 -0
- package/dist/channel.d.ts +64 -1
- package/dist/channel.js +3 -3
- package/dist/{chunk-FBDMID2J.js → chunk-4EZD7LPE.js} +30 -24
- package/dist/chunk-4EZD7LPE.js.map +1 -0
- package/dist/{chunk-TIH7D4FQ.js → chunk-6QYXGMCR.js} +513 -322
- package/dist/chunk-6QYXGMCR.js.map +1 -0
- package/dist/{chunk-6UHVUGDT.js → chunk-7ARJ3OSU.js} +29 -21
- package/dist/chunk-7ARJ3OSU.js.map +1 -0
- package/dist/{chunk-VYU6P7HB.js → chunk-BN5WY5GM.js} +16 -14
- package/dist/chunk-BN5WY5GM.js.map +1 -0
- package/dist/{chunk-ZFIKBDBT.js → chunk-FJ7XECC5.js} +4 -4
- package/dist/chunk-FJ7XECC5.js.map +1 -0
- package/dist/{chunk-NRH56SAJ.js → chunk-G3UJC4EL.js} +6 -7
- package/dist/chunk-G3UJC4EL.js.map +1 -0
- package/dist/{chunk-QJT4IOIS.js → chunk-KDH3UPKD.js} +10 -13
- package/dist/chunk-KDH3UPKD.js.map +1 -0
- package/dist/{chunk-ZGOEADCO.js → chunk-LXWIPTPX.js} +5 -5
- package/dist/chunk-LXWIPTPX.js.map +1 -0
- package/dist/{chunk-I3VRFZA4.js → chunk-MVEWJIPY.js} +124 -110
- package/dist/chunk-MVEWJIPY.js.map +1 -0
- package/dist/{chunk-FIS3RUGL.js → chunk-PAABYXS6.js} +33 -40
- package/dist/chunk-PAABYXS6.js.map +1 -0
- package/dist/{chunk-HNTLDUL7.js → chunk-PKCHRXFR.js} +8 -12
- package/dist/chunk-PKCHRXFR.js.map +1 -0
- package/dist/{chunk-42KVVOOU.js → chunk-TENYCMJ3.js} +31 -31
- package/dist/chunk-TENYCMJ3.js.map +1 -0
- package/dist/{chunk-WPSWFZKF.js → chunk-UIFMIVDK.js} +1033 -937
- package/dist/chunk-UIFMIVDK.js.map +1 -0
- package/dist/{chunk-4KRQXOTI.js → chunk-X3AMH53O.js} +248 -195
- package/dist/chunk-X3AMH53O.js.map +1 -0
- package/dist/{contract-addresses-ADEWLDHE.js → contract-addresses-N3TOL2WL.js} +3 -3
- package/dist/{contract-addresses-ADEWLDHE.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 +59 -15
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/kms.d.ts +3054 -2
- package/dist/kms.js +2 -2
- 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-KIKM4EG6.js → src-L5SI5WNB.js} +4 -4
- package/dist/src-L5SI5WNB.js.map +1 -0
- package/dist/{dist-GVWCRI4F.js → src-X5MIV3EB.js} +5 -5
- package/dist/src-X5MIV3EB.js.map +1 -0
- package/dist/tier-router-DeeVg69O.d.ts +370 -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 +1 -2
- package/dist/UserClient-UYIHF6UJ.js +0 -6
- package/dist/chunk-42KVVOOU.js.map +0 -1
- package/dist/chunk-4KRQXOTI.js.map +0 -1
- package/dist/chunk-6UHVUGDT.js.map +0 -1
- package/dist/chunk-FBDMID2J.js.map +0 -1
- package/dist/chunk-FIS3RUGL.js.map +0 -1
- package/dist/chunk-HNTLDUL7.js.map +0 -1
- package/dist/chunk-I3VRFZA4.js.map +0 -1
- package/dist/chunk-NRH56SAJ.js.map +0 -1
- package/dist/chunk-QJT4IOIS.js.map +0 -1
- package/dist/chunk-TIH7D4FQ.js.map +0 -1
- package/dist/chunk-VYU6P7HB.js.map +0 -1
- package/dist/chunk-WPSWFZKF.js.map +0 -1
- package/dist/chunk-ZFIKBDBT.js.map +0 -1
- package/dist/chunk-ZGOEADCO.js.map +0 -1
- package/dist/dist-GVWCRI4F.js.map +0 -1
- package/dist/index.node-KIKM4EG6.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuperPaymasterABI } from './chunk-
|
|
1
|
+
import { SuperPaymasterABI } from './chunk-6QYXGMCR.js';
|
|
2
2
|
import { parseAbi, formatEther } from 'viem';
|
|
3
3
|
|
|
4
4
|
var STAKING_ABI = parseAbi([
|
|
@@ -12,8 +12,6 @@ var ERC20_ABI = parseAbi([
|
|
|
12
12
|
"function transfer(address,uint256) returns (bool)"
|
|
13
13
|
]);
|
|
14
14
|
var FinanceClient = class _FinanceClient {
|
|
15
|
-
publicClient;
|
|
16
|
-
walletClient;
|
|
17
15
|
/**
|
|
18
16
|
* Initialize FinanceClient
|
|
19
17
|
* @param publicClient The public client for queries
|
|
@@ -116,7 +114,7 @@ var FinanceClient = class _FinanceClient {
|
|
|
116
114
|
* Get GToken balance
|
|
117
115
|
*/
|
|
118
116
|
async getGTokenBalance(address) {
|
|
119
|
-
const { CORE_ADDRESSES } = await import('./
|
|
117
|
+
const { CORE_ADDRESSES } = await import('./src-L5SI5WNB.js');
|
|
120
118
|
return this.publicClient.readContract({
|
|
121
119
|
address: CORE_ADDRESSES.gToken,
|
|
122
120
|
abi: ERC20_ABI,
|
|
@@ -128,7 +126,7 @@ var FinanceClient = class _FinanceClient {
|
|
|
128
126
|
* Get aPNTs balance
|
|
129
127
|
*/
|
|
130
128
|
async getAPNTsBalance(address) {
|
|
131
|
-
const { CORE_ADDRESSES } = await import('./
|
|
129
|
+
const { CORE_ADDRESSES } = await import('./src-L5SI5WNB.js');
|
|
132
130
|
return this.publicClient.readContract({
|
|
133
131
|
address: CORE_ADDRESSES.aPNTs,
|
|
134
132
|
abi: ERC20_ABI,
|
|
@@ -138,15 +136,14 @@ var FinanceClient = class _FinanceClient {
|
|
|
138
136
|
}
|
|
139
137
|
/**
|
|
140
138
|
* One-step stake: Approve (if needed) + Stake
|
|
141
|
-
*
|
|
139
|
+
*
|
|
142
140
|
* @param amount Amount of GToken to stake
|
|
143
141
|
* @returns Transaction hash of the stake action
|
|
144
142
|
*/
|
|
145
143
|
async approveAndStake(amount) {
|
|
146
144
|
const account = this.walletClient.account;
|
|
147
|
-
if (!account)
|
|
148
|
-
|
|
149
|
-
const { CORE_ADDRESSES } = await import('./index.node-KIKM4EG6.js');
|
|
145
|
+
if (!account) throw new Error("Account required");
|
|
146
|
+
const { CORE_ADDRESSES } = await import('./src-L5SI5WNB.js');
|
|
150
147
|
const gTokenAddress = CORE_ADDRESSES.gToken;
|
|
151
148
|
const stakingAddress = CORE_ADDRESSES.gTokenStaking;
|
|
152
149
|
const allowance = await this.publicClient.readContract({
|
|
@@ -175,7 +172,7 @@ var FinanceClient = class _FinanceClient {
|
|
|
175
172
|
* Get circulating supply (total - locked)
|
|
176
173
|
*/
|
|
177
174
|
async getCirculatingSupply() {
|
|
178
|
-
const { CORE_ADDRESSES } = await import('./
|
|
175
|
+
const { CORE_ADDRESSES } = await import('./src-L5SI5WNB.js');
|
|
179
176
|
const gTokenAddress = CORE_ADDRESSES.gToken;
|
|
180
177
|
const total = await this.publicClient.readContract({
|
|
181
178
|
address: gTokenAddress,
|
|
@@ -193,7 +190,7 @@ var FinanceClient = class _FinanceClient {
|
|
|
193
190
|
* Get comprehensive tokenomics data
|
|
194
191
|
*/
|
|
195
192
|
async getTokenomicsOverview() {
|
|
196
|
-
const { CORE_ADDRESSES } = await import('./
|
|
193
|
+
const { CORE_ADDRESSES } = await import('./src-L5SI5WNB.js');
|
|
197
194
|
const [totalSupply, totalStaked, blackholeBalance] = await Promise.all([
|
|
198
195
|
this.publicClient.readContract({
|
|
199
196
|
address: CORE_ADDRESSES.gToken,
|
|
@@ -225,5 +222,5 @@ var FinanceClient = class _FinanceClient {
|
|
|
225
222
|
};
|
|
226
223
|
|
|
227
224
|
export { FinanceClient };
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
229
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-KDH3UPKD.js.map
|
|
226
|
+
//# sourceMappingURL=chunk-KDH3UPKD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../tokens/src/index.ts"],"names":[],"mappings":";;;AAGA,IAAM,cAAc,QAAA,CAAS;AAAA,EACzB,yBAAA;AAAA,EACA;AACJ,CAAC,CAAA;AAED,IAAM,YAAY,QAAA,CAAS;AAAA,EACvB,oDAAA;AAAA,EACA,+CAAA;AAAA,EACA,kDAAA;AAAA,EACA;AACJ,CAAC,CAAA;AAEM,IAAM,aAAA,GAAN,MAAM,cAAA,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,WAAA,CACY,cACA,YAAA,EACV;AAFU,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AACA,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAAA,EACT;AAAA;AAAA;AAAA,EAKH,aAAa,kBAAA,CAAmB,MAAA,EAAsB,SAAA,EAAoB,MAAA,EAAgB;AACtF,IAAA,OAAO,OAAO,aAAA,CAAc;AA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Ac,gBAAA;AAChD,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,WAAA,CAAY,WAAW,CAAC,IAAI,MAAA,CAAO,WAAA,CAAY,WAAW,CAAC,CAAA,GAAI,GAAA;AAEpF,IAAA,OAAO;AAAA,MACH,WAAA;AAAA,MACA,WAAA;AAAA,MACA,WAAA,EAAa,gBAAA;AAAA,MACb,iBAAA,EAAmB,WAAA;AAAA,MACnB,YAAA,EAAc;AAAA,KAClB;AAAA,EACJ;AACJ","file":"chunk-KDH3UPKD.js","sourcesContent":["import { type Address, parseAbi, type Hash, formatEther } from 'viem';\nimport { SuperPaymasterABI as SUPERPAYMASTER_ABI, CONTRACTS, type PublicClient, type WalletClient } from '@aastar/core';\n\nconst STAKING_ABI = parseAbi([\n 'function stake(uint256)',\n 'function withdraw(uint256)'\n]);\n\nconst ERC20_ABI = parseAbi([\n 'function balanceOf(address) view returns (uint256)',\n 'function totalSupply() view returns (uint256)',\n 'function approve(address,uint256) returns (bool)',\n 'function transfer(address,uint256) returns (bool)'\n]);\n\nexport class FinanceClient {\n /**\n * Initialize FinanceClient\n * @param publicClient The public client for queries\n * @param walletClient The wallet client for transactions\n */\n constructor(\n private publicClient: PublicClient,\n private walletClient: WalletClient\n ) {}\n\n // ========== Existing static methods (preserved for backward compatibility) ==========\n \n /** @deprecated Use instance methods instead */\n static async depositToPaymaster(wallet: WalletClient, paymaster: Address, amount: bigint) {\n return wallet.writeContract({\n address: paymaster,\n abi: SUPERPAYMASTER_ABI,\n functionName: 'deposit',\n args: [amount],\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async depositViaTransferAndCall(wallet: WalletClient, token: Address, paymaster: Address, amount: bigint) {\n const ERC1363_ABI = [{\n name: 'transferAndCall',\n type: 'function',\n stateMutability: 'nonpayable',\n inputs: [{ type: 'address', name: 'to' }, { type: 'uint256', name: 'value' }],\n outputs: [{ type: 'bool' }]\n }] as const;\n\n return wallet.writeContract({\n address: token,\n abi: ERC1363_ABI,\n functionName: 'transferAndCall',\n args: [paymaster, amount],\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async stakeGToken(wallet: WalletClient, stakingAddr: Address, amount: bigint) {\n return wallet.writeContract({\n address: stakingAddr,\n abi: STAKING_ABI,\n functionName: 'stake',\n args: [amount],\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async withdrawProtocolRevenue(wallet: WalletClient, paymaster: Address, to: Address, amount: bigint) {\n return wallet.writeContract({\n address: paymaster,\n abi: SUPERPAYMASTER_ABI,\n functionName: 'withdrawProtocolRevenue',\n args: [to, amount],\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async depositToEntryPoint(wallet: WalletClient, entryPoint: Address, paymaster: Address, amount: bigint) {\n return wallet.writeContract({\n address: entryPoint,\n abi: parseAbi(['function depositTo(address) payable']),\n functionName: 'depositTo',\n args: [paymaster],\n value: amount,\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async getEntryPointBalance(client: any, entryPoint: Address, account: Address): Promise<bigint> {\n return client.readContract({\n address: entryPoint,\n abi: parseAbi(['function balanceOf(address) view returns (uint256)']),\n functionName: 'balanceOf',\n args: [account]\n });\n }\n\n /** @deprecated Use instance methods instead */\n static async operatorDeposit(wallet: WalletClient, paymaster: Address, amount: bigint) {\n return wallet.writeContract({\n address: paymaster,\n abi: SUPERPAYMASTER_ABI,\n functionName: 'deposit',\n args: [amount],\n chain: wallet.chain\n } as any);\n }\n\n /** @deprecated Use instance methods instead */\n static async operatorNotifyDeposit(wallet: WalletClient, paymaster: Address, amount: bigint) {\n return wallet.writeContract({\n address: paymaster,\n abi: SUPERPAYMASTER_ABI,\n functionName: 'notifyDeposit',\n args: [amount],\n chain: wallet.chain\n } as any);\n }\n\n // ========== New instance methods (business primitives) ==========\n\n /**\n * Get GToken balance\n */\n async getGTokenBalance(address: Address): Promise<bigint> {\n const { CORE_ADDRESSES } = await import('@aastar/core');\n return this.publicClient.readContract({\n address: CORE_ADDRESSES.gToken,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [address]\n }) as Promise<bigint>;\n }\n\n /**\n * Get aPNTs balance\n */\n async getAPNTsBalance(address: Address): Promise<bigint> {\n const { CORE_ADDRESSES } = await import('@aastar/core');\n return this.publicClient.readContract({\n address: CORE_ADDRESSES.aPNTs,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [address]\n }) as Promise<bigint>;\n }\n\n /**\n * One-step stake: Approve (if needed) + Stake\n * \n * @param amount Amount of GToken to stake\n * @returns Transaction hash of the stake action\n */\n async approveAndStake(amount: bigint): Promise<Hash> {\n const account = this.walletClient.account;\n if (!account) throw new Error(\"Account required\");\n\n const { CORE_ADDRESSES } = await import('@aastar/core');\n const gTokenAddress = CORE_ADDRESSES.gToken;\n const stakingAddress = CORE_ADDRESSES.gTokenStaking;\n \n // 1. Check Allowance\n const allowance = await this.publicClient.readContract({\n address: gTokenAddress,\n abi: parseAbi(['function allowance(address owner, address spender) view returns (uint256)']),\n functionName: 'allowance',\n args: [account.address, stakingAddress]\n }); // as bigint\n\n if ((allowance as bigint) < amount) {\n console.log(`[FinanceClient] Approving ${formatEther(amount)} GToken...`);\n const approveTx = await this.walletClient.writeContract({\n address: gTokenAddress,\n abi: parseAbi(['function approve(address spender, uint256 amount) returns (bool)']),\n functionName: 'approve',\n args: [stakingAddress, amount],\n chain: this.walletClient.chain,\n account\n });\n await this.publicClient.waitForTransactionReceipt({ hash: approveTx });\n console.log(`[FinanceClient] Approved.`);\n }\n\n // 2. Stake\n console.log(`[FinanceClient] Staking...`);\n return FinanceClient.stakeGToken(this.walletClient, stakingAddress, amount);\n }\n\n /**\n * Get circulating supply (total - locked)\n */\n async getCirculatingSupply(): Promise<{\n total: bigint;\n locked: bigint;\n circulating: bigint;\n }> {\n const { CORE_ADDRESSES } = await import('@aastar/core');\n const gTokenAddress = CORE_ADDRESSES.gToken;\n\n const total = await this.publicClient.readContract({\n address: gTokenAddress,\n abi: ERC20_ABI,\n functionName: 'totalSupply'\n }) as bigint;\n\n // In a real scenario, we might query GTokenStaking's totalStaked\n const locked = 0n;\n\n return {\n total,\n locked,\n circulating: total - locked\n };\n }\n\n /**\n * Get comprehensive tokenomics data\n */\n async getTokenomicsOverview(): Promise<{\n totalSupply: bigint;\n totalStaked: bigint;\n totalBurned: bigint;\n circulatingSupply: bigint;\n stakingRatio: number;\n }> {\n const { CORE_ADDRESSES } = await import('@aastar/core');\n \n const [totalSupply, totalStaked, blackholeBalance] = await Promise.all([\n this.publicClient.readContract({\n address: CORE_ADDRESSES.gToken,\n abi: parseAbi(['function totalSupply() view returns (uint256)']),\n functionName: 'totalSupply'\n }) as Promise<bigint>,\n this.publicClient.readContract({\n address: CORE_ADDRESSES.gTokenStaking,\n abi: parseAbi(['function totalStaked() view returns (uint256)']),\n functionName: 'totalStaked'\n }) as Promise<bigint>,\n this.publicClient.readContract({\n address: CORE_ADDRESSES.gToken,\n abi: parseAbi(['function balanceOf(address) view returns (uint256)']),\n functionName: 'balanceOf',\n args: ['0x000000000000000000000000000000000000dEaD']\n }) as Promise<bigint>\n ]);\n\n const circulating = totalSupply - totalStaked - blackholeBalance;\n const ratio = Number(formatEther(totalStaked)) / Number(formatEther(totalSupply)) * 100;\n\n return {\n totalSupply,\n totalStaked,\n totalBurned: blackholeBalance,\n circulatingSupply: circulating,\n stakingRatio: ratio\n };\n }\n}\n"]}
|
|
@@ -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,aAA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AA,OAAO,IAAA,CAAK,WAAA,CAAY,UAAA,CAAW,EAAE,WAAW,CAAA;AAAA,EACpD;AAAA,EAEA,MAAM,eAAA,GAAmC;AACrC,IAAA,OAAO,IAAA,CAAK,YAAY,aAAA,EAAc;AAAA,EAC1C;AAAA,EAEA,MAAM,UAAA,GAA8B;AAChC,IAAA,OAAO,IAAA,CAAK,YAAY,OAAA,EAAQ;AAAA,EACpC;AACJ","file":"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
|