@aastar/sdk 0.20.8 → 0.21.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.
Files changed (144) hide show
  1. package/dist/BaseClient-CkBhQ1ou.d.cts +88 -0
  2. package/dist/UserClient-BDGP37PK.js +6 -0
  3. package/dist/{UserClient-AIIHB54I.js.map → UserClient-BDGP37PK.js.map} +1 -1
  4. package/dist/UserClient-FOAOBLGK.cjs +15 -0
  5. package/dist/UserClient-FOAOBLGK.cjs.map +1 -0
  6. package/dist/account.cjs +31 -0
  7. package/dist/account.cjs.map +1 -0
  8. package/dist/account.d.cts +48 -0
  9. package/dist/account.js +3 -3
  10. package/dist/admin.cjs +15 -0
  11. package/dist/admin.cjs.map +1 -0
  12. package/dist/admin.d.cts +62 -0
  13. package/dist/admin.js +3 -3
  14. package/dist/airaccount.cjs +452 -0
  15. package/dist/airaccount.cjs.map +1 -0
  16. package/dist/airaccount.d.cts +4 -0
  17. package/dist/airaccount.js +3 -3
  18. package/dist/channel-CkRRbzT8.d.cts +77 -0
  19. package/dist/channel.cjs +27 -0
  20. package/dist/channel.cjs.map +1 -0
  21. package/dist/channel.d.cts +64 -0
  22. package/dist/channel.js +3 -3
  23. package/dist/chunk-3HZEIFBW.cjs +118 -0
  24. package/dist/chunk-3HZEIFBW.cjs.map +1 -0
  25. package/dist/{chunk-7ARJ3OSU.js → chunk-57XLR2NT.js} +3 -3
  26. package/dist/{chunk-7ARJ3OSU.js.map → chunk-57XLR2NT.js.map} +1 -1
  27. package/dist/chunk-5JFYTJOE.cjs +448 -0
  28. package/dist/chunk-5JFYTJOE.cjs.map +1 -0
  29. package/dist/{chunk-KDH3UPKD.js → chunk-5NKU5NT5.js} +8 -8
  30. package/dist/{chunk-KDH3UPKD.js.map → chunk-5NKU5NT5.js.map} +1 -1
  31. package/dist/chunk-63JM67L7.cjs +435 -0
  32. package/dist/chunk-63JM67L7.cjs.map +1 -0
  33. package/dist/{chunk-IC3G6YM2.js → chunk-6OWZOTE7.js} +113 -9
  34. package/dist/chunk-6OWZOTE7.js.map +1 -0
  35. package/dist/chunk-CIEYY3A6.cjs +43259 -0
  36. package/dist/chunk-CIEYY3A6.cjs.map +1 -0
  37. package/dist/chunk-DEUBKZH5.cjs +421 -0
  38. package/dist/chunk-DEUBKZH5.cjs.map +1 -0
  39. package/dist/{chunk-TENYCMJ3.js → chunk-DF4WVR2H.js} +9 -9
  40. package/dist/{chunk-TENYCMJ3.js.map → chunk-DF4WVR2H.js.map} +1 -1
  41. package/dist/{chunk-BN5WY5GM.js → chunk-DQBKE4ND.js} +4 -4
  42. package/dist/{chunk-BN5WY5GM.js.map → chunk-DQBKE4ND.js.map} +1 -1
  43. package/dist/{chunk-4EZD7LPE.js → chunk-E4CQFW75.js} +3 -3
  44. package/dist/{chunk-4EZD7LPE.js.map → chunk-E4CQFW75.js.map} +1 -1
  45. package/dist/{chunk-LXWIPTPX.js → chunk-ENSMYCU6.js} +3 -3
  46. package/dist/{chunk-LXWIPTPX.js.map → chunk-ENSMYCU6.js.map} +1 -1
  47. package/dist/{chunk-FJ7XECC5.js → chunk-EY2AJTGV.js} +3 -3
  48. package/dist/{chunk-FJ7XECC5.js.map → chunk-EY2AJTGV.js.map} +1 -1
  49. package/dist/chunk-GAMSWXWI.cjs +1168 -0
  50. package/dist/chunk-GAMSWXWI.cjs.map +1 -0
  51. package/dist/chunk-IJN776TA.cjs +585 -0
  52. package/dist/chunk-IJN776TA.cjs.map +1 -0
  53. package/dist/{chunk-PKCHRXFR.js → chunk-KZERVPUR.js} +3 -3
  54. package/dist/{chunk-PKCHRXFR.js.map → chunk-KZERVPUR.js.map} +1 -1
  55. package/dist/{chunk-6QYXGMCR.js → chunk-M5WFKETT.js} +833 -47
  56. package/dist/chunk-M5WFKETT.js.map +1 -0
  57. package/dist/chunk-M7HXR7G5.cjs +128 -0
  58. package/dist/chunk-M7HXR7G5.cjs.map +1 -0
  59. package/dist/{chunk-PAABYXS6.js → chunk-MCALA6WM.js} +6 -6
  60. package/dist/{chunk-PAABYXS6.js.map → chunk-MCALA6WM.js.map} +1 -1
  61. package/dist/chunk-MXJEULSE.cjs +396 -0
  62. package/dist/chunk-MXJEULSE.cjs.map +1 -0
  63. package/dist/chunk-OVNOSAL3.cjs +4797 -0
  64. package/dist/chunk-OVNOSAL3.cjs.map +1 -0
  65. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  66. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  67. package/dist/{chunk-MVEWJIPY.js → chunk-RXPSL33E.js} +3 -3
  68. package/dist/{chunk-MVEWJIPY.js.map → chunk-RXPSL33E.js.map} +1 -1
  69. package/dist/{chunk-G3UJC4EL.js → chunk-UCLK6LTB.js} +39 -36
  70. package/dist/chunk-UCLK6LTB.js.map +1 -0
  71. package/dist/chunk-WR4OZUXR.cjs +115 -0
  72. package/dist/chunk-WR4OZUXR.cjs.map +1 -0
  73. package/dist/chunk-XQROKLZI.cjs +4521 -0
  74. package/dist/chunk-XQROKLZI.cjs.map +1 -0
  75. package/dist/chunk-Y4EJX7UA.cjs +228 -0
  76. package/dist/chunk-Y4EJX7UA.cjs.map +1 -0
  77. package/dist/chunk-Z4GZ6DQA.cjs +108 -0
  78. package/dist/chunk-Z4GZ6DQA.cjs.map +1 -0
  79. package/dist/contract-addresses-RABD77VP.cjs +49 -0
  80. package/dist/contract-addresses-RABD77VP.cjs.map +1 -0
  81. package/dist/{contract-addresses-N3TOL2WL.js → contract-addresses-TVXSRQ7I.js} +3 -3
  82. package/dist/{contract-addresses-N3TOL2WL.js.map → contract-addresses-TVXSRQ7I.js.map} +1 -1
  83. package/dist/core.cjs +898 -0
  84. package/dist/core.cjs.map +1 -0
  85. package/dist/core.d.cts +7048 -0
  86. package/dist/core.d.ts +130 -12
  87. package/dist/core.js +2 -2
  88. package/dist/dapp.cjs +289 -0
  89. package/dist/dapp.cjs.map +1 -0
  90. package/dist/dapp.d.cts +127 -0
  91. package/dist/dapp.js +3 -3
  92. package/dist/doc-types-471vSmPO.d.cts +16 -0
  93. package/dist/enduser.cjs +24 -0
  94. package/dist/enduser.cjs.map +1 -0
  95. package/dist/enduser.d.cts +261 -0
  96. package/dist/enduser.js +4 -4
  97. package/dist/identity.cjs +23 -0
  98. package/dist/identity.cjs.map +1 -0
  99. package/dist/identity.d.cts +81 -0
  100. package/dist/identity.js +3 -3
  101. package/dist/index-B6SfEQxo.d.cts +47 -0
  102. package/dist/index.cjs +2818 -0
  103. package/dist/index.cjs.map +1 -0
  104. package/dist/index.d.cts +656 -0
  105. package/dist/index.d.ts +1 -1
  106. package/dist/index.js +17 -17
  107. package/dist/kms.cjs +452 -0
  108. package/dist/kms.cjs.map +1 -0
  109. package/dist/kms.d.cts +3104 -0
  110. package/dist/kms.d.ts +62 -12
  111. package/dist/kms.js +3 -3
  112. package/dist/lib-FE4GR7TO.cjs +1865 -0
  113. package/dist/lib-FE4GR7TO.cjs.map +1 -0
  114. package/dist/operator.cjs +27 -0
  115. package/dist/operator.cjs.map +1 -0
  116. package/dist/operator.d.cts +164 -0
  117. package/dist/operator.js +3 -3
  118. package/dist/paymaster.cjs +63 -0
  119. package/dist/paymaster.cjs.map +1 -0
  120. package/dist/paymaster.d.cts +312 -0
  121. package/dist/paymaster.js +3 -3
  122. package/dist/src-CUHI6G6W.cjs +898 -0
  123. package/dist/src-CUHI6G6W.cjs.map +1 -0
  124. package/dist/src-KHCWIS4Q.cjs +63 -0
  125. package/dist/src-KHCWIS4Q.cjs.map +1 -0
  126. package/dist/{src-X5MIV3EB.js → src-RSN4U2T2.js} +5 -5
  127. package/dist/src-RSN4U2T2.js.map +1 -0
  128. package/dist/{src-L5SI5WNB.js → src-XCV6BTSV.js} +4 -4
  129. package/dist/{src-X5MIV3EB.js.map → src-XCV6BTSV.js.map} +1 -1
  130. package/dist/tier-router-DeeVg69O.d.cts +370 -0
  131. package/dist/tokens.cjs +15 -0
  132. package/dist/tokens.cjs.map +1 -0
  133. package/dist/tokens.d.cts +64 -0
  134. package/dist/tokens.js +3 -3
  135. package/dist/x402.cjs +103 -0
  136. package/dist/x402.cjs.map +1 -0
  137. package/dist/x402.d.cts +373 -0
  138. package/dist/x402.js +3 -3
  139. package/package.json +116 -32
  140. package/dist/UserClient-AIIHB54I.js +0 -6
  141. package/dist/chunk-6QYXGMCR.js.map +0 -1
  142. package/dist/chunk-G3UJC4EL.js.map +0 -1
  143. package/dist/chunk-IC3G6YM2.js.map +0 -1
  144. package/dist/src-L5SI5WNB.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var chunkIJN776TA_cjs = require('./chunk-IJN776TA.cjs');
4
+ require('./chunk-CIEYY3A6.cjs');
5
+ require('./chunk-MXJEULSE.cjs');
6
+ require('./chunk-Q7SFCCGT.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "OperatorLifecycle", {
11
+ enumerable: true,
12
+ get: function () { return chunkIJN776TA_cjs.OperatorLifecycle; }
13
+ });
14
+ Object.defineProperty(exports, "PaymasterOperatorClient", {
15
+ enumerable: true,
16
+ get: function () { return chunkIJN776TA_cjs.PaymasterOperatorClient; }
17
+ });
18
+ Object.defineProperty(exports, "ProposalState", {
19
+ enumerable: true,
20
+ get: function () { return chunkIJN776TA_cjs.ProposalState; }
21
+ });
22
+ Object.defineProperty(exports, "ProtocolClient", {
23
+ enumerable: true,
24
+ get: function () { return chunkIJN776TA_cjs.ProtocolClient; }
25
+ });
26
+ //# sourceMappingURL=operator.cjs.map
27
+ //# sourceMappingURL=operator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"operator.cjs"}
@@ -0,0 +1,164 @@
1
+ import { Address, Hash, Hex } from 'viem';
2
+ import { C as ClientConfig, a as BaseClient, T as TransactionOptions } from './BaseClient-CkBhQ1ou.cjs';
3
+ import './doc-types-471vSmPO.cjs';
4
+
5
+ interface OperatorClientConfig extends ClientConfig {
6
+ superPaymasterAddress: Address;
7
+ tokenAddress?: Address;
8
+ }
9
+ interface SponsorshipPolicy {
10
+ globalLimit: bigint;
11
+ userLimit: bigint;
12
+ itemPrice: bigint;
13
+ }
14
+ /**
15
+ * Client for Paymaster Operators (ROLE_PAYMASTER_SUPER)
16
+ */
17
+ declare class PaymasterOperatorClient extends BaseClient {
18
+ superPaymasterAddress: Address;
19
+ tokenAddress?: Address;
20
+ ethUsdPriceFeed: Address;
21
+ xpntsFactory: Address;
22
+ constructor(config: OperatorClientConfig);
23
+ /**
24
+ * Register as SuperPaymaster Operator (one-stop API).
25
+ * This method handles all necessary steps:
26
+ * 1. Checks prerequisites (must have ROLE_COMMUNITY)
27
+ * 2. Checks and approves GToken to GTokenStaking
28
+ * 3. Registers ROLE_PAYMASTER_SUPER
29
+ * 4. Optionally deposits collateral to SuperPaymaster
30
+ *
31
+ * @param params Registration parameters
32
+ * @param options Transaction options
33
+ * @returns Transaction hash of role registration
34
+ */
35
+ registerAsSuperPaymasterOperator(params?: {
36
+ stakeAmount?: bigint;
37
+ depositAmount?: bigint;
38
+ }, options?: TransactionOptions): Promise<Hash>;
39
+ /**
40
+ * Deploy a new Paymaster V4 and Register as AOA Operator (one-stop API).
41
+ * This method handles:
42
+ * 1. Checks prerequisites (ROLE_COMMUNITY)
43
+ * 2. Predicts new Paymaster address
44
+ * 3. Deploys Paymaster V4 via Factory
45
+ * 4. Registers ROLE_PAYMASTER_AOA with staking
46
+ *
47
+ * @param params Deployment parameters
48
+ * @param options Transaction options
49
+ * @returns Object containing new paymaster address and transaction hashes
50
+ */
51
+ deployAndRegisterPaymasterV4(params?: {
52
+ stakeAmount?: bigint;
53
+ version?: string;
54
+ salt?: bigint;
55
+ priceFeed?: Address;
56
+ }, options?: TransactionOptions): Promise<{
57
+ paymasterAddress: Address;
58
+ deployHash: Hash;
59
+ registerHash: Hash;
60
+ }>;
61
+ /**
62
+ * Deposit collateral (aPNTs/GToken) to SuperPaymaster.
63
+ * This is a helper method used by registerAsSuperPaymasterOperator.
64
+ */
65
+ depositCollateral(amount: bigint, options?: TransactionOptions): Promise<Hash>;
66
+ /**
67
+ * Configure operator parameters (Token, Treasury).
68
+ * Exchange rate is now read live from xPNTsToken.exchangeRate() at runtime.
69
+ * If parameters are undefined, existing values are preserved.
70
+ */
71
+ configureOperator(xPNTsToken?: Address, treasury?: Address, options?: TransactionOptions): Promise<Hash>;
72
+ withdrawCollateral(to: Address, amount: bigint, options?: TransactionOptions): Promise<Hash>;
73
+ isOperator(operator: Address): Promise<boolean>;
74
+ getOperatorDetails(operator?: Address): Promise<any>;
75
+ initiateExit(options?: TransactionOptions): Promise<Hash>;
76
+ withdrawStake(to: Address, options?: TransactionOptions): Promise<Hash>;
77
+ addGasToken(token: Address, price: bigint, options?: TransactionOptions): Promise<Hash>;
78
+ getTokenPrice(token: Address): Promise<bigint>;
79
+ setupPaymasterDeposit(params: {
80
+ paymaster: Address;
81
+ user: Address;
82
+ token: Address;
83
+ amount: bigint;
84
+ }, options?: TransactionOptions): Promise<Hash>;
85
+ }
86
+
87
+ interface ProtocolClientConfig extends ClientConfig {
88
+ dvtValidatorAddress: Address;
89
+ blsAggregatorAddress?: Address;
90
+ superPaymasterAddress?: Address;
91
+ }
92
+ declare enum ProposalState {
93
+ Pending = 0,
94
+ Active = 1,
95
+ Canceled = 2,
96
+ Defeated = 3,
97
+ Succeeded = 4,
98
+ Queued = 5,
99
+ Expired = 6,
100
+ Executed = 7
101
+ }
102
+ /**
103
+ * Client for Protocol Governors and Validators (Infrastructure)
104
+ */
105
+ declare class ProtocolClient extends BaseClient {
106
+ dvtValidatorAddress: Address;
107
+ blsAggregatorAddress?: Address;
108
+ superPaymasterAddress?: Address;
109
+ constructor(config: ProtocolClientConfig);
110
+ /**
111
+ * Create a new proposal
112
+ */
113
+ createProposal(target: Address, calldata: Hex, description: string, options?: TransactionOptions): Promise<Hash>;
114
+ signProposal(proposalId: bigint, signature?: Hex, options?: TransactionOptions): Promise<Hash>;
115
+ /**
116
+ * Execute a proposal with collected signatures
117
+ */
118
+ executeWithProof(proposalId: bigint, signatures: Hex[], options?: TransactionOptions): Promise<Hash>;
119
+ registerBLSKey(publicKey: Hex, options?: TransactionOptions): Promise<Hash>;
120
+ setProtocolFee(bps: bigint, options?: TransactionOptions): Promise<Hash>;
121
+ setTreasury(treasury: Address, options?: TransactionOptions): Promise<Hash>;
122
+ }
123
+
124
+ interface OperatorStatus {
125
+ isConfigured: boolean;
126
+ isActive: boolean;
127
+ balance: bigint;
128
+ }
129
+ /**
130
+ * OperatorLifecycle - L3 Pattern
131
+ *
132
+ * Responsibilities:
133
+ * 1. Managing the complete lifecycle of a Paymaster Operator
134
+ * 2. Unifying setup (onboard), operation (config), and exit (withdraw)
135
+ */
136
+ declare class OperatorLifecycle extends PaymasterOperatorClient {
137
+ constructor(config: OperatorClientConfig);
138
+ /**
139
+ * Check if the account is ready to become an operator
140
+ * (e.g., has GToken, has ROLE_COMMUNITY, etc.)
141
+ */
142
+ checkReadiness(): Promise<OperatorStatus>;
143
+ /**
144
+ * One-click Setup: Register + Deposit + Deploy Node
145
+ * Wraps existing registerAsSuperPaymasterOperator or deployAndRegisterPaymasterV4
146
+ */
147
+ setupNode(params: {
148
+ type: 'V4' | 'SUPER';
149
+ stakeAmount?: bigint;
150
+ depositAmount?: bigint;
151
+ }, options?: TransactionOptions): Promise<Hash[]>;
152
+ getOperatorStats(): Promise<any>;
153
+ /**
154
+ * Start the exit process: Unstake from Registry/SuperPaymaster and Unlock funds
155
+ */
156
+ initiateExit(options?: TransactionOptions): Promise<Hash>;
157
+ /**
158
+ * Finalize exit: Withdraw all funds (Collateral + Rewards)
159
+ */
160
+ withdrawAllFunds(to?: Address, options?: TransactionOptions): Promise<Hash[]>;
161
+ private getTokenBalance;
162
+ }
163
+
164
+ export { type OperatorClientConfig, OperatorLifecycle, type OperatorStatus, PaymasterOperatorClient, ProposalState, ProtocolClient, type ProtocolClientConfig, type SponsorshipPolicy };
package/dist/operator.js CHANGED
@@ -1,6 +1,6 @@
1
- export { OperatorLifecycle, PaymasterOperatorClient, ProposalState, ProtocolClient } from './chunk-BN5WY5GM.js';
2
- import './chunk-6QYXGMCR.js';
3
- import './chunk-G3UJC4EL.js';
1
+ export { OperatorLifecycle, PaymasterOperatorClient, ProposalState, ProtocolClient } from './chunk-DQBKE4ND.js';
2
+ import './chunk-M5WFKETT.js';
3
+ import './chunk-UCLK6LTB.js';
4
4
  import './chunk-PZ5AY32C.js';
5
5
  //# sourceMappingURL=operator.js.map
6
6
  //# sourceMappingURL=operator.js.map
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var chunkGAMSWXWI_cjs = require('./chunk-GAMSWXWI.cjs');
4
+ require('./chunk-CIEYY3A6.cjs');
5
+ require('./chunk-MXJEULSE.cjs');
6
+ require('./chunk-Q7SFCCGT.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "PaymasterClient", {
11
+ enumerable: true,
12
+ get: function () { return chunkGAMSWXWI_cjs.PaymasterClient; }
13
+ });
14
+ Object.defineProperty(exports, "PaymasterManager", {
15
+ enumerable: true,
16
+ get: function () { return chunkGAMSWXWI_cjs.PaymasterManager; }
17
+ });
18
+ Object.defineProperty(exports, "PaymasterOperator", {
19
+ enumerable: true,
20
+ get: function () { return chunkGAMSWXWI_cjs.PaymasterOperator; }
21
+ });
22
+ Object.defineProperty(exports, "SuperPaymasterAdminClient", {
23
+ enumerable: true,
24
+ get: function () { return chunkGAMSWXWI_cjs.SuperPaymasterAdminClient; }
25
+ });
26
+ Object.defineProperty(exports, "SuperPaymasterClient", {
27
+ enumerable: true,
28
+ get: function () { return chunkGAMSWXWI_cjs.SuperPaymasterClient; }
29
+ });
30
+ Object.defineProperty(exports, "buildPaymasterData", {
31
+ enumerable: true,
32
+ get: function () { return chunkGAMSWXWI_cjs.buildPaymasterData; }
33
+ });
34
+ Object.defineProperty(exports, "buildSuperPaymasterData", {
35
+ enumerable: true,
36
+ get: function () { return chunkGAMSWXWI_cjs.buildSuperPaymasterData; }
37
+ });
38
+ Object.defineProperty(exports, "checkEligibility", {
39
+ enumerable: true,
40
+ get: function () { return chunkGAMSWXWI_cjs.checkEligibility; }
41
+ });
42
+ Object.defineProperty(exports, "formatUserOpV07", {
43
+ enumerable: true,
44
+ get: function () { return chunkGAMSWXWI_cjs.formatUserOpV07; }
45
+ });
46
+ Object.defineProperty(exports, "getPaymasterV4Middleware", {
47
+ enumerable: true,
48
+ get: function () { return chunkGAMSWXWI_cjs.getPaymasterV4Middleware; }
49
+ });
50
+ Object.defineProperty(exports, "getSuperPaymasterMiddleware", {
51
+ enumerable: true,
52
+ get: function () { return chunkGAMSWXWI_cjs.getSuperPaymasterMiddleware; }
53
+ });
54
+ Object.defineProperty(exports, "getUserOpHashV07", {
55
+ enumerable: true,
56
+ get: function () { return chunkGAMSWXWI_cjs.getUserOpHashV07; }
57
+ });
58
+ Object.defineProperty(exports, "tuneGasLimit", {
59
+ enumerable: true,
60
+ get: function () { return chunkGAMSWXWI_cjs.tuneGasLimit; }
61
+ });
62
+ //# sourceMappingURL=paymaster.cjs.map
63
+ //# sourceMappingURL=paymaster.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"paymaster.cjs"}
@@ -0,0 +1,312 @@
1
+ export { P as PaymasterConfig, S as SuperPaymasterAdminClient, c as checkEligibility, g as getSuperPaymasterMiddleware } from './index-B6SfEQxo.cjs';
2
+ import { Address, Hex } from 'viem';
3
+
4
+ type PaymasterV4MiddlewareConfig = {
5
+ paymasterAddress: Address;
6
+ gasToken: Address;
7
+ verificationGasLimit?: bigint;
8
+ postOpGasLimit?: bigint;
9
+ };
10
+ type GaslessReadinessReport = {
11
+ isReady: boolean;
12
+ issues: string[];
13
+ details: {
14
+ paymasterStake: bigint;
15
+ paymasterDeposit: bigint;
16
+ ethUsdPrice: bigint;
17
+ tokenSupported: boolean;
18
+ tokenPrice: bigint;
19
+ userTokenBalance: bigint;
20
+ userPaymasterDeposit: bigint;
21
+ };
22
+ };
23
+ /**
24
+ * Constructs the middleware for Paymaster V4.
25
+ * Returns the `paymasterAndData` hex string.
26
+ */
27
+ declare function getPaymasterV4Middleware(config: PaymasterV4MiddlewareConfig): {
28
+ sponsorUserOperation: (args: {
29
+ userOperation: any;
30
+ }) => Promise<{
31
+ paymasterAndData: `0x${string}`;
32
+ verificationGasLimit: bigint;
33
+ preVerificationGas: any;
34
+ }>;
35
+ };
36
+ /**
37
+ * Build paymasterAndData for gasless UserOperation.
38
+ * Layout: [Paymaster(20)] [VerificationGasLimit(16)] [PostOpGasLimit(16)] [Token(20)] [ValidUntil(6)] [ValidAfter(6)]
39
+ */
40
+ declare function buildPaymasterData(paymasterAddress: Address, token: Address, options?: {
41
+ validityWindow?: number;
42
+ verificationGasLimit?: bigint;
43
+ postOpGasLimit?: bigint;
44
+ }): `0x${string}`;
45
+ /**
46
+ * Build paymasterAndData for SuperPaymaster V3.
47
+ * Layout: [Paymaster(20)] [verGas(16)] [postGas(16)] [operator(20)] [maxRate(32)]
48
+ * Total: 104 bytes
49
+ *
50
+ * IMPORTANT: SuperPaymaster contract generates validUntil internally using:
51
+ * validUntil = cachedPrice.updatedAt + priceStalenessThreshold
52
+ * Do NOT include validUntil/validAfter in paymasterAndData!
53
+ */
54
+ declare function buildSuperPaymasterData(paymasterAddress: Address, operator: Address, options?: {
55
+ verificationGasLimit?: bigint;
56
+ postOpGasLimit?: bigint;
57
+ maxRate?: bigint;
58
+ }): `0x${string}`;
59
+ /**
60
+ * Helper to format UserOp for Alchemy/Standard Bundlers (v0.7 Decomposed)
61
+ */
62
+ declare function formatUserOpV07(userOp: any): any;
63
+ declare function getUserOpHashV07(userOp: any, entryPoint: Address, chainId: bigint): Hex;
64
+ /**
65
+ * Tune gas limit using a dynamic nominal ceiling to satisfy Bundler efficiency (0.4)
66
+ * Target: Actual / Limit >= targetEfficiency
67
+ */
68
+ declare function tuneGasLimit(estimate: bigint, nominalActual: bigint, targetEfficiency?: number): bigint;
69
+
70
+ /**
71
+ * PaymasterClient
72
+ * Focus: Integration, Funding, Interaction.
73
+ */
74
+ declare class PaymasterClient {
75
+ /**
76
+ * @private
77
+ * Static utility class, should not be instantiated.
78
+ */
79
+ private constructor();
80
+ private static makePlaceholderSignature;
81
+ private static estimatePreVerificationGasV07;
82
+ /**
83
+ * Get user's deposited balance on the Paymaster.
84
+ */
85
+ static getDepositedBalance(publicClient: any, address: Address, user: Address, token: Address): Promise<bigint>;
86
+ /**
87
+ * Deposit tokens to Paymaster for a user (enables gasless transactions).
88
+ */
89
+ static depositFor(wallet: any, address: Address, user: Address, token: Address, amount: bigint): Promise<any>;
90
+ /**
91
+ * Approve the Paymaster (or any spender) to spend gas tokens.
92
+ */
93
+ static approveGasToken(wallet: any, token: Address, spender: Address, amount: bigint): Promise<any>;
94
+ /**
95
+ * Estimate Gas for a UserOperation.
96
+ */
97
+ static estimateUserOperationGas(client: any, wallet: any, aaAddress: Address, entryPoint: Address, paymasterAddress: Address, token: Address, bundlerUrl: string, callData: `0x${string}`, options?: {
98
+ validityWindow?: number;
99
+ operator?: Address;
100
+ factory?: Address;
101
+ factoryData?: Hex;
102
+ }): Promise<{
103
+ preVerificationGas: bigint;
104
+ verificationGasLimit: bigint;
105
+ callGasLimit: bigint;
106
+ paymasterVerificationGasLimit: bigint;
107
+ paymasterPostOpGasLimit: bigint;
108
+ }>;
109
+ /**
110
+ * High-level API to submit a gasless UserOperation.
111
+ * Automatically handles nonce fetching, gas estimation (if not provided), signing, and submission.
112
+ */
113
+ static submitGaslessUserOperation(client: any, wallet: any, aaAddress: Address, entryPoint: Address, paymasterAddress: Address, token: Address, bundlerUrl: string, callData: `0x${string}`, options?: {
114
+ validityWindow?: number;
115
+ verificationGasLimit?: bigint;
116
+ callGasLimit?: bigint;
117
+ preVerificationGas?: bigint;
118
+ maxFeePerGas?: bigint;
119
+ maxPriorityFeePerGas?: bigint;
120
+ autoEstimate?: boolean;
121
+ operator?: Address;
122
+ paymasterVerificationGasLimit?: bigint;
123
+ paymasterPostOpGasLimit?: bigint;
124
+ factory?: Address;
125
+ factoryData?: Hex;
126
+ }): Promise<`0x${string}`>;
127
+ /**
128
+ * Helper to extract the actual Gas Token fee from a UserOperation receipt.
129
+ * Looks for the 'PostOpProcessed' event emitted by the Paymaster.
130
+ */
131
+ static getFeeFromReceipt(receipt: any, paymasterAddress: Address): {
132
+ tokenCost: bigint;
133
+ actualGasCostWei: bigint;
134
+ } | null;
135
+ /**
136
+ * Get the fee for a specific transaction hash.
137
+ * Fetches the receipt (no scanning required) and decodes the log.
138
+ */
139
+ static getTransactionFee(publicClient: any, txHash: `0x${string}`, paymasterAddress: Address): Promise<{
140
+ tokenCost: bigint;
141
+ actualGasCostWei: bigint;
142
+ } | null>;
143
+ /**
144
+ * Helper: Encode a standardized ERC-20 Transfer.
145
+ * Returns the raw function data: `transfer(to, amount)`
146
+ */
147
+ static encodeTokenTransfer(recipient: Address, amount: bigint): `0x${string}`;
148
+ /**
149
+ * Helper: Encode a SimpleAccount execution.
150
+ * Wraps the inner call into: `execute(target, value, data)`
151
+ * This is the payload signed by the user.
152
+ */
153
+ static encodeExecution(target: Address, value: bigint, data: `0x${string}`): `0x${string}`;
154
+ /**
155
+ * More robust version of waitForUserOperationReceipt.
156
+ * Catches timeouts and returns a cleaner result.
157
+ */
158
+ static waitForUserOperation(bundlerClient: any, hash: `0x${string}`, timeout?: number): Promise<any>;
159
+ }
160
+
161
+ /**
162
+ * PaymasterOperator
163
+ * Focus: Deployment, Configuration, Maintenance, Keeper Bots.
164
+ */
165
+ declare class PaymasterOperator {
166
+ /**
167
+ * Update the cached ETH/USD price from Chainlink Oracle.
168
+ * Must be called if cachedPrice is 0 (uninitialized).
169
+ */
170
+ static updatePrice(wallet: any, address: Address): Promise<any>;
171
+ /**
172
+ * Set the token price (in 8 decimals, e.g., 1e8 = $1 USD).
173
+ */
174
+ static setTokenPrice(wallet: any, address: Address, token: Address, priceUSD: bigint): Promise<any>;
175
+ static getCachedPrice(publicClient: any, address: Address): Promise<{
176
+ price: bigint;
177
+ updatedAt: bigint;
178
+ }>;
179
+ static getTokenPrice(publicClient: any, address: Address, token: Address): Promise<bigint>;
180
+ static getDepositedBalance(publicClient: any, address: Address, user: Address, token: Address): Promise<bigint>;
181
+ static ensurePriceInitialized(wallet: any, publicClient: any, address: Address): Promise<boolean>;
182
+ static addStake(wallet: any, address: Address, amount: bigint, unstakeDelaySec: number): Promise<any>;
183
+ static addDeposit(wallet: any, address: Address, amount: bigint): Promise<any>;
184
+ static addGasToken(wallet: any, address: Address, token: Address): Promise<any>;
185
+ static removeGasToken(wallet: any, address: Address, token: Address): Promise<any>;
186
+ static setServiceFeeRate(wallet: any, address: Address, rate: bigint): Promise<any>;
187
+ static setMaxGasCostCap(wallet: any, address: Address, cap: bigint): Promise<any>;
188
+ static withdrawPNT(wallet: any, address: Address, to: Address, token: Address, amount: bigint): Promise<any>;
189
+ static checkGaslessReadiness(publicClient: any, entryPoint: Address, paymasterAddress: Address, user: Address, token: Address): Promise<GaslessReadinessReport>;
190
+ static prepareGaslessEnvironment(operatorWallet: any, publicClient: any, entryPoint: Address, paymasterAddress: Address, token: Address, options?: {
191
+ minStake?: bigint;
192
+ minDeposit?: bigint;
193
+ tokenPriceUSD?: bigint;
194
+ }): Promise<{
195
+ step: string;
196
+ hash?: string;
197
+ status: string;
198
+ }[]>;
199
+ }
200
+
201
+ type GaslessTransactionConfig = {
202
+ token: Address;
203
+ recipient: Address;
204
+ amount: bigint;
205
+ operator: Address;
206
+ paymasterAddress: Address;
207
+ factory?: Address;
208
+ factoryData?: Hex;
209
+ };
210
+ /**
211
+ * SuperPaymasterClient
212
+ * High-level API for SuperPaymaster operations, including dynamic gas estimation.
213
+ */
214
+ declare class SuperPaymasterClient {
215
+ /**
216
+ * @private
217
+ * Static utility class, should not be instantiated.
218
+ */
219
+ private constructor();
220
+ /**
221
+ * Submit a gasless transaction using SuperPaymaster.
222
+ * Automatically handles gas estimation with a smart efficiency buffer.
223
+ */
224
+ static submitGaslessTransaction(client: any, wallet: any, aaAddress: Address, entryPoint: Address, bundlerUrl: string, config: GaslessTransactionConfig): Promise<Hex>;
225
+ }
226
+
227
+ /**
228
+ * Supported paymaster types.
229
+ * - 'v4' → PaymasterV4 layout (84 bytes): [paymaster(20)][verGas(16)][postGas(16)][token(20)][validUntil(6)][validAfter(6)]
230
+ * - 'super' → SuperPaymaster layout (104 bytes): [paymaster(20)][verGas(16)][postGas(16)][operator(20)][maxRate(32)]
231
+ */
232
+ type PaymasterType = 'v4' | 'super';
233
+ /**
234
+ * Unified parameters for building `paymasterAndData`.
235
+ *
236
+ * The byte layout differs by paymaster type; this shape carries the union of
237
+ * both packers' inputs. `buildPaymasterData` validates that the fields required
238
+ * for the resolved type are present, and dispatches to the correct existing
239
+ * packer. Callers no longer need to know which format a given paymaster uses.
240
+ */
241
+ interface BuildPaymasterDataParams {
242
+ /**
243
+ * Explicit paymaster type. Preferred over address-based heuristics.
244
+ * If omitted, the type is resolved from `paymasterAddress` against the
245
+ * manager's registered known-paymaster map (throws if unresolved).
246
+ */
247
+ type?: PaymasterType;
248
+ /** Paymaster contract address (first 20 bytes of the layout). */
249
+ paymasterAddress: Address;
250
+ /** Paymaster verification gas limit (16-byte field, both layouts). */
251
+ verificationGasLimit?: bigint;
252
+ /** Paymaster postOp gas limit (16-byte field, both layouts). */
253
+ postOpGasLimit?: bigint;
254
+ /** Gas token address. Required for type 'v4'. */
255
+ token?: Address;
256
+ /** Validity window in seconds (used to compute validUntil/validAfter). 'v4' only. */
257
+ validityWindow?: number;
258
+ /** Operator address. Required for type 'super'. */
259
+ operator?: Address;
260
+ /** Optional max rate commitment (rug-pull protection). 'super' only. */
261
+ maxRate?: bigint;
262
+ }
263
+ /**
264
+ * PaymasterManager — unifies the per-type `paymasterAndData` packers behind a
265
+ * single `buildPaymasterData` entry point that AUTO-SELECTS the correct byte
266
+ * format by paymaster type.
267
+ *
268
+ * Type resolution order:
269
+ * 1. Explicit `params.type` (preferred — no guessing).
270
+ * 2. Address-based lookup against the registered known-paymaster map.
271
+ *
272
+ * The underlying packers (`buildPaymasterData` / `buildSuperPaymasterData` in
273
+ * PaymasterUtils) remain exported and are reused verbatim here — this class
274
+ * does NOT reimplement byte-packing.
275
+ */
276
+ declare class PaymasterManager {
277
+ private readonly knownPaymasters;
278
+ constructor(opts?: {
279
+ knownPaymasters?: Record<string, PaymasterType>;
280
+ });
281
+ /**
282
+ * Register a known paymaster address → type mapping so that callers can
283
+ * omit the explicit `type` and have it resolved from the address.
284
+ */
285
+ registerPaymaster(address: Address, type: PaymasterType): void;
286
+ /**
287
+ * Record an address → type mapping, throwing on a CONFLICTING re-registration.
288
+ * Silently overwriting a v4 address with `super` (or vice-versa) would later
289
+ * pack the wrong-length paymasterData for a `type`-less call, so a conflicting
290
+ * re-registration is treated as a programmer error. Re-registering the SAME
291
+ * type (including a case-variant of the address) is an idempotent no-op.
292
+ */
293
+ private setKnownPaymaster;
294
+ /**
295
+ * Resolve a paymaster's type from a registered address. Returns undefined
296
+ * if the address is not registered.
297
+ */
298
+ resolveType(address: Address): PaymasterType | undefined;
299
+ /**
300
+ * Build `paymasterAndData`, auto-selecting the correct byte layout for the
301
+ * paymaster type. Dispatches to the existing per-type packers.
302
+ */
303
+ buildPaymasterData(params: BuildPaymasterDataParams): Hex;
304
+ /**
305
+ * Static helper: build `paymasterAndData` for an explicit type without an
306
+ * instance. Useful when the caller already knows the type.
307
+ */
308
+ static buildPaymasterData(type: PaymasterType, params: Omit<BuildPaymasterDataParams, 'type'>): Hex;
309
+ private static dispatch;
310
+ }
311
+
312
+ export { type BuildPaymasterDataParams, type GaslessReadinessReport, type GaslessTransactionConfig, PaymasterClient, PaymasterManager, PaymasterOperator, type PaymasterType, type PaymasterV4MiddlewareConfig, SuperPaymasterClient, buildPaymasterData, buildSuperPaymasterData, formatUserOpV07, getPaymasterV4Middleware, getUserOpHashV07, tuneGasLimit };
package/dist/paymaster.js CHANGED
@@ -1,6 +1,6 @@
1
- export { PaymasterClient, PaymasterManager, PaymasterOperator, SuperPaymasterAdminClient, SuperPaymasterClient, buildPaymasterData, buildSuperPaymasterData, checkEligibility, formatUserOpV07, getPaymasterV4Middleware, getSuperPaymasterMiddleware, getUserOpHashV07, tuneGasLimit } from './chunk-MVEWJIPY.js';
2
- import './chunk-6QYXGMCR.js';
3
- import './chunk-G3UJC4EL.js';
1
+ export { PaymasterClient, PaymasterManager, PaymasterOperator, SuperPaymasterAdminClient, SuperPaymasterClient, buildPaymasterData, buildSuperPaymasterData, checkEligibility, formatUserOpV07, getPaymasterV4Middleware, getSuperPaymasterMiddleware, getUserOpHashV07, tuneGasLimit } from './chunk-RXPSL33E.js';
2
+ import './chunk-M5WFKETT.js';
3
+ import './chunk-UCLK6LTB.js';
4
4
  import './chunk-PZ5AY32C.js';
5
5
  //# sourceMappingURL=paymaster.js.map
6
6
  //# sourceMappingURL=paymaster.js.map