@aastar/core 0.16.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.
Files changed (136) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abis/BLSAggregator.json +686 -0
  3. package/dist/abis/BLSValidator.json +42 -0
  4. package/dist/abis/DVTValidator.json +368 -0
  5. package/dist/abis/Eip7702Support.json +24 -0
  6. package/dist/abis/EntryPoint.json +1382 -0
  7. package/dist/abis/GToken.json +513 -0
  8. package/dist/abis/GTokenStaking.json +949 -0
  9. package/dist/abis/LegacyAccount.json +625 -0
  10. package/dist/abis/MySBT.json +1518 -0
  11. package/dist/abis/Paymaster.json +1143 -0
  12. package/dist/abis/PaymasterFactory.json +640 -0
  13. package/dist/abis/Registry.json +1942 -0
  14. package/dist/abis/ReputationSystem.json +699 -0
  15. package/dist/abis/SenderCreator.json +99 -0
  16. package/dist/abis/Simple7702Account.json +395 -0
  17. package/dist/abis/SimpleAccount.json +560 -0
  18. package/dist/abis/SimpleAccountFactory.json +111 -0
  19. package/dist/abis/SimpleAccountFactoryV08.json +87 -0
  20. package/dist/abis/SimpleAccountV08.json +557 -0
  21. package/dist/abis/SuperPaymaster.json +1781 -0
  22. package/dist/abis/UserOperationLib.json +57 -0
  23. package/dist/abis/abi.config.json +24 -0
  24. package/dist/abis/index.d.ts +1126 -0
  25. package/dist/abis/index.js +91 -0
  26. package/dist/abis/xPNTsFactory.json +718 -0
  27. package/dist/abis/xPNTsToken.json +1280 -0
  28. package/dist/actions/StateValidator.d.ts +68 -0
  29. package/dist/actions/StateValidator.js +187 -0
  30. package/dist/actions/StateValidator.test.d.ts +1 -0
  31. package/dist/actions/StateValidator.test.js +144 -0
  32. package/dist/actions/account.d.ts +55 -0
  33. package/dist/actions/account.js +133 -0
  34. package/dist/actions/account.test.d.ts +1 -0
  35. package/dist/actions/account.test.js +118 -0
  36. package/dist/actions/aggregator.d.ts +17 -0
  37. package/dist/actions/aggregator.js +31 -0
  38. package/dist/actions/aggregator.test.d.ts +1 -0
  39. package/dist/actions/aggregator.test.js +67 -0
  40. package/dist/actions/dvt.d.ts +30 -0
  41. package/dist/actions/dvt.js +41 -0
  42. package/dist/actions/dvt.test.d.ts +1 -0
  43. package/dist/actions/dvt.test.js +98 -0
  44. package/dist/actions/entryPoint.d.ts +90 -0
  45. package/dist/actions/entryPoint.js +211 -0
  46. package/dist/actions/entryPoint.test.d.ts +1 -0
  47. package/dist/actions/entryPoint.test.js +139 -0
  48. package/dist/actions/factory.d.ts +215 -0
  49. package/dist/actions/factory.js +442 -0
  50. package/dist/actions/factory.test.d.ts +1 -0
  51. package/dist/actions/factory.test.js +197 -0
  52. package/dist/actions/faucet.d.ts +48 -0
  53. package/dist/actions/faucet.js +337 -0
  54. package/dist/actions/faucet.test.d.ts +1 -0
  55. package/dist/actions/faucet.test.js +120 -0
  56. package/dist/actions/gtokenExtended.d.ts +39 -0
  57. package/dist/actions/gtokenExtended.js +115 -0
  58. package/dist/actions/gtokenExtended.test.d.ts +1 -0
  59. package/dist/actions/gtokenExtended.test.js +118 -0
  60. package/dist/actions/index.d.ts +15 -0
  61. package/dist/actions/index.js +17 -0
  62. package/dist/actions/paymasterV4.d.ts +170 -0
  63. package/dist/actions/paymasterV4.js +334 -0
  64. package/dist/actions/paymasterV4.test.d.ts +1 -0
  65. package/dist/actions/paymasterV4.test.js +159 -0
  66. package/dist/actions/registry.d.ts +246 -0
  67. package/dist/actions/registry.js +667 -0
  68. package/dist/actions/registry.test.d.ts +1 -0
  69. package/dist/actions/registry.test.js +360 -0
  70. package/dist/actions/reputation.d.ts +129 -0
  71. package/dist/actions/reputation.js +281 -0
  72. package/dist/actions/reputation.test.d.ts +1 -0
  73. package/dist/actions/reputation.test.js +169 -0
  74. package/dist/actions/sbt.d.ts +191 -0
  75. package/dist/actions/sbt.js +533 -0
  76. package/dist/actions/sbt.test.d.ts +1 -0
  77. package/dist/actions/sbt.test.js +256 -0
  78. package/dist/actions/staking.d.ts +132 -0
  79. package/dist/actions/staking.js +330 -0
  80. package/dist/actions/staking.test.d.ts +1 -0
  81. package/dist/actions/staking.test.js +223 -0
  82. package/dist/actions/superPaymaster.d.ts +237 -0
  83. package/dist/actions/superPaymaster.js +644 -0
  84. package/dist/actions/superPaymaster.test.d.ts +1 -0
  85. package/dist/actions/superPaymaster.test.js +287 -0
  86. package/dist/actions/tokens.d.ts +229 -0
  87. package/dist/actions/tokens.js +415 -0
  88. package/dist/actions/tokens.test.d.ts +1 -0
  89. package/dist/actions/tokens.test.js +53 -0
  90. package/dist/actions/validators.d.ts +194 -0
  91. package/dist/actions/validators.js +433 -0
  92. package/dist/actions/validators.test.d.ts +1 -0
  93. package/dist/actions/validators.test.js +215 -0
  94. package/dist/branding.d.ts +30 -0
  95. package/dist/branding.js +30 -0
  96. package/dist/clients/BaseClient.d.ts +25 -0
  97. package/dist/clients/BaseClient.js +66 -0
  98. package/dist/clients/types.d.ts +60 -0
  99. package/dist/clients/types.js +1 -0
  100. package/dist/clients.d.ts +5 -0
  101. package/dist/clients.js +11 -0
  102. package/dist/communities.d.ts +52 -0
  103. package/dist/communities.js +73 -0
  104. package/dist/config/ContractConfigManager.d.ts +20 -0
  105. package/dist/config/ContractConfigManager.js +48 -0
  106. package/dist/constants.d.ts +88 -0
  107. package/dist/constants.js +125 -0
  108. package/dist/contract-addresses.d.ts +110 -0
  109. package/dist/contract-addresses.js +99 -0
  110. package/dist/contracts.d.ts +424 -0
  111. package/dist/contracts.js +343 -0
  112. package/dist/contracts.test.d.ts +1 -0
  113. package/dist/contracts.test.js +40 -0
  114. package/dist/crypto/blsSigner.d.ts +64 -0
  115. package/dist/crypto/blsSigner.js +98 -0
  116. package/dist/crypto/index.d.ts +1 -0
  117. package/dist/crypto/index.js +1 -0
  118. package/dist/index.d.ts +21 -0
  119. package/dist/index.js +21 -0
  120. package/dist/networks.d.ts +127 -0
  121. package/dist/networks.js +118 -0
  122. package/dist/requirementChecker.d.ts +38 -0
  123. package/dist/requirementChecker.js +139 -0
  124. package/dist/requirementChecker.test.d.ts +1 -0
  125. package/dist/requirementChecker.test.js +60 -0
  126. package/dist/roles.d.ts +204 -0
  127. package/dist/roles.js +211 -0
  128. package/dist/roles.test.d.ts +1 -0
  129. package/dist/roles.test.js +23 -0
  130. package/dist/utils/validation.d.ts +24 -0
  131. package/dist/utils/validation.js +56 -0
  132. package/dist/utils/validation.test.d.ts +1 -0
  133. package/dist/utils/validation.test.js +40 -0
  134. package/dist/utils.d.ts +12 -0
  135. package/dist/utils.js +14 -0
  136. package/package.json +33 -0
@@ -0,0 +1,118 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { gTokenExtendedActions } from './gtokenExtended.js';
3
+ describe('GTokenExtended Actions', () => {
4
+ const mockGTokenAddress = '0x1234567890123456789012345678901234567890';
5
+ let mockPublicClient;
6
+ let mockWalletClient;
7
+ let mockAccount;
8
+ const MOCK_USER = '0x2222222222222222222222222222222222222222';
9
+ beforeEach(() => {
10
+ mockAccount = {
11
+ address: '0x1111111111111111111111111111111111111111',
12
+ type: 'json-rpc'
13
+ };
14
+ mockPublicClient = {
15
+ readContract: vi.fn(),
16
+ };
17
+ mockWalletClient = {
18
+ writeContract: vi.fn(),
19
+ account: mockAccount,
20
+ };
21
+ });
22
+ describe('Minting & Burning', () => {
23
+ it('should mint tokens', async () => {
24
+ const txHash = '0xabc...';
25
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
26
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
27
+ const result = await actions.mint({ to: MOCK_USER, amount: 1000n, account: mockAccount });
28
+ expect(result).toBe(txHash);
29
+ expect(mockWalletClient.writeContract).toHaveBeenCalledWith(expect.objectContaining({
30
+ functionName: 'mint',
31
+ args: [MOCK_USER, 1000n],
32
+ }));
33
+ });
34
+ it('should burn tokens', async () => {
35
+ const txHash = '0xdef...';
36
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
37
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
38
+ const result = await actions.burn({ amount: 500n, account: mockAccount });
39
+ expect(result).toBe(txHash);
40
+ });
41
+ it('should burn tokens from address', async () => {
42
+ const txHash = '0xghi...';
43
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
44
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
45
+ const result = await actions.burnFrom({ from: MOCK_USER, amount: 500n, account: mockAccount });
46
+ expect(result).toBe(txHash);
47
+ });
48
+ });
49
+ describe('Cap & Minter', () => {
50
+ it('should get cap', async () => {
51
+ mockPublicClient.readContract.mockResolvedValue(1000000n);
52
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockPublicClient);
53
+ const cap = await actions.cap();
54
+ expect(cap).toBe(1000000n);
55
+ });
56
+ it('should get minter', async () => {
57
+ const mockMinter = '0x3333333333333333333333333333333333333333';
58
+ mockPublicClient.readContract.mockResolvedValue(mockMinter);
59
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockPublicClient);
60
+ const minter = await actions.minter();
61
+ expect(minter).toBe(mockMinter);
62
+ });
63
+ it('should set minter', async () => {
64
+ const txHash = '0xjkl...';
65
+ const newMinter = '0x4444444444444444444444444444444444444444';
66
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
67
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
68
+ const result = await actions.setMinter({ minter: newMinter, account: mockAccount });
69
+ expect(result).toBe(txHash);
70
+ });
71
+ });
72
+ describe('Pause', () => {
73
+ it('should pause', async () => {
74
+ const txHash = '0xmno...';
75
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
76
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
77
+ const result = await actions.pause({ account: mockAccount });
78
+ expect(result).toBe(txHash);
79
+ });
80
+ it('should unpause', async () => {
81
+ const txHash = '0xpqr...';
82
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
83
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
84
+ const result = await actions.unpause({ account: mockAccount });
85
+ expect(result).toBe(txHash);
86
+ });
87
+ it('should check if paused', async () => {
88
+ mockPublicClient.readContract.mockResolvedValue(true);
89
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockPublicClient);
90
+ const isPaused = await actions.paused();
91
+ expect(isPaused).toBe(true);
92
+ });
93
+ });
94
+ describe('Ownership', () => {
95
+ it('should get owner', async () => {
96
+ const mockOwner = '0x5555555555555555555555555555555555555555';
97
+ mockPublicClient.readContract.mockResolvedValue(mockOwner);
98
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockPublicClient);
99
+ const owner = await actions.owner();
100
+ expect(owner).toBe(mockOwner);
101
+ });
102
+ it('should transfer ownership', async () => {
103
+ const txHash = '0xstu...';
104
+ const newOwner = '0x6666666666666666666666666666666666666666';
105
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
106
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
107
+ const result = await actions.transferOwnership({ newOwner, account: mockAccount });
108
+ expect(result).toBe(txHash);
109
+ });
110
+ it('should renounce ownership', async () => {
111
+ const txHash = '0xvwx...';
112
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
113
+ const actions = gTokenExtendedActions(mockGTokenAddress)(mockWalletClient);
114
+ const result = await actions.renounceOwnership({ account: mockAccount });
115
+ expect(result).toBe(txHash);
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,15 @@
1
+ export * from './registry.js';
2
+ export * from './staking.js';
3
+ export * from './sbt.js';
4
+ export * from './superPaymaster.js';
5
+ export * from './paymasterV4.js';
6
+ export * from './reputation.js';
7
+ export * from './tokens.js';
8
+ export * from './entryPoint.js';
9
+ export * from './gtokenExtended.js';
10
+ export * from './StateValidator.js';
11
+ export * from './dvt.js';
12
+ export * from './factory.js';
13
+ export * from './aggregator.js';
14
+ export * from './account.js';
15
+ export * from './faucet.js';
@@ -0,0 +1,17 @@
1
+ export * from './registry.js';
2
+ export * from './staking.js';
3
+ export * from './sbt.js';
4
+ export * from './superPaymaster.js';
5
+ export * from './paymasterV4.js';
6
+ export * from './reputation.js';
7
+ export * from './tokens.js';
8
+ export * from './entryPoint.js';
9
+ export * from './gtokenExtended.js';
10
+ export * from './StateValidator.js';
11
+ export * from './dvt.js';
12
+ export * from './factory.js';
13
+ export * from './aggregator.js';
14
+ export * from './account.js';
15
+ export * from './faucet.js';
16
+ // validators.ts merged into dvt.js and aggregator.js
17
+ // validators.ts merged into dvt.js and aggregator.js
@@ -0,0 +1,170 @@
1
+ import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
2
+ export type PaymasterV4Actions = {
3
+ paymasterV4DepositFor: (args: {
4
+ user: Address;
5
+ token: Address;
6
+ amount: bigint;
7
+ account?: Account | Address;
8
+ }) => Promise<Hash>;
9
+ paymasterV4Withdraw: (args: {
10
+ token: Address;
11
+ amount: bigint;
12
+ account?: Account | Address;
13
+ }) => Promise<Hash>;
14
+ paymasterV4Balances: (args: {
15
+ user: Address;
16
+ token: Address;
17
+ }) => Promise<bigint>;
18
+ paymasterV4SetTokenPrice: (args: {
19
+ token: Address;
20
+ price: bigint;
21
+ account?: Account | Address;
22
+ }) => Promise<Hash>;
23
+ paymasterV4TokenPrices: (args: {
24
+ token: Address;
25
+ }) => Promise<bigint>;
26
+ /** @deprecated V4 uses depositFor + tokenPrices instead */
27
+ paymasterV4AddGasToken: (args: {
28
+ token: Address;
29
+ priceFeed: Address;
30
+ account?: Account | Address;
31
+ }) => Promise<Hash>;
32
+ /** @deprecated V4 uses depositFor + tokenPrices instead */
33
+ paymasterV4RemoveGasToken: (args: {
34
+ token: Address;
35
+ account?: Account | Address;
36
+ }) => Promise<Hash>;
37
+ /** @deprecated V4 uses depositFor + tokenPrices instead */
38
+ paymasterV4GetSupportedGasTokens: () => Promise<Address[]>;
39
+ /** @deprecated V4 uses depositFor + tokenPrices instead */
40
+ paymasterV4IsGasTokenSupported: (args: {
41
+ token: Address;
42
+ }) => Promise<boolean>;
43
+ /** @deprecated V4 does not use SBT whitelist */
44
+ paymasterV4AddSBT: (args: {
45
+ sbt: Address;
46
+ account?: Account | Address;
47
+ }) => Promise<Hash>;
48
+ /** @deprecated V4 does not use SBT whitelist */
49
+ paymasterV4RemoveSBT: (args: {
50
+ sbt: Address;
51
+ account?: Account | Address;
52
+ }) => Promise<Hash>;
53
+ /** @deprecated V4 does not use SBT whitelist */
54
+ paymasterV4GetSupportedSBTs: () => Promise<Address[]>;
55
+ /** @deprecated V4 does not use SBT whitelist */
56
+ paymasterV4IsSBTSupported: (args: {
57
+ sbt: Address;
58
+ }) => Promise<boolean>;
59
+ paymasterV4ValidatePaymasterUserOp: (args: {
60
+ userOp: any;
61
+ userOpHash: Hex;
62
+ maxCost: bigint;
63
+ }) => Promise<any>;
64
+ paymasterV4PostOp: (args: {
65
+ mode: number;
66
+ context: Hex;
67
+ actualGasCost: bigint;
68
+ actualUserOpFeePerGas: bigint;
69
+ }) => Promise<void>;
70
+ paymasterV4Deposit: (args: {
71
+ account?: Account | Address;
72
+ }) => Promise<Hash>;
73
+ paymasterV4WithdrawTo: (args: {
74
+ to: Address;
75
+ amount: bigint;
76
+ account?: Account | Address;
77
+ }) => Promise<Hash>;
78
+ paymasterV4AddStake: (args: {
79
+ unstakeDelaySec: bigint;
80
+ amount: bigint;
81
+ account?: Account | Address;
82
+ }) => Promise<Hash>;
83
+ paymasterV4UnlockPaymasterStake: (args: {
84
+ account?: Account | Address;
85
+ }) => Promise<Hash>;
86
+ paymasterV4WithdrawStake: (args: {
87
+ to: Address;
88
+ account?: Account | Address;
89
+ }) => Promise<Hash>;
90
+ paymasterV4GetDeposit: () => Promise<bigint>;
91
+ paymasterV4EntryPoint: () => Promise<Address>;
92
+ paymasterV4Owner: () => Promise<Address>;
93
+ paymasterV4TransferOwnership: (args: {
94
+ newOwner: Address;
95
+ account?: Account | Address;
96
+ }) => Promise<Hash>;
97
+ paymasterV4RenounceOwnership: (args: {
98
+ account?: Account | Address;
99
+ }) => Promise<Hash>;
100
+ paymasterV4Registry: () => Promise<Address>;
101
+ paymasterV4Treasury: () => Promise<Address>;
102
+ paymasterV4Paused: () => Promise<boolean>;
103
+ paymasterV4MaxGasCostCap: () => Promise<bigint>;
104
+ paymasterV4MaxEthUsdPrice: () => Promise<bigint>;
105
+ paymasterV4MaxGasTokens: () => Promise<bigint>;
106
+ paymasterV4MaxSbts: () => Promise<bigint>;
107
+ paymasterV4MaxServiceFee: () => Promise<bigint>;
108
+ paymasterV4MinEthUsdPrice: () => Promise<bigint>;
109
+ paymasterV4PriceStalenessThreshold: () => Promise<bigint>;
110
+ paymasterV4AddDeposit: (args: {
111
+ account?: Account | Address;
112
+ }) => Promise<Hash>;
113
+ paymasterV4UnlockStake: (args: {
114
+ account?: Account | Address;
115
+ }) => Promise<Hash>;
116
+ paymasterV4EthUsdPriceFeed: () => Promise<Address>;
117
+ paymasterV4OracleDecimals: () => Promise<number>;
118
+ paymasterV4TokenDecimals: (args: {
119
+ token: Address;
120
+ }) => Promise<number>;
121
+ paymasterV4ServiceFeeRate: () => Promise<bigint>;
122
+ paymasterV4CalculateCost: (args: {
123
+ token: Address;
124
+ gasCost: bigint;
125
+ param: any;
126
+ }) => Promise<bigint>;
127
+ paymasterV4GetRealtimeTokenCost: (args: {
128
+ token: Address;
129
+ gasCost: bigint;
130
+ }) => Promise<bigint>;
131
+ paymasterV4IsActiveInRegistry: () => Promise<boolean>;
132
+ paymasterV4IsRegistrySet: () => Promise<boolean>;
133
+ paymasterV4CachedPriceView: (args: {
134
+ token: Address;
135
+ }) => Promise<bigint>;
136
+ paymasterV4SetCachedPrice: (args: {
137
+ token: Address;
138
+ price: bigint;
139
+ account?: Account | Address;
140
+ }) => Promise<Hash>;
141
+ paymasterV4SetServiceFeeRate: (args: {
142
+ rate: bigint;
143
+ account?: Account | Address;
144
+ }) => Promise<Hash>;
145
+ paymasterV4SetMaxGasCostCap: (args: {
146
+ cap: bigint;
147
+ account?: Account | Address;
148
+ }) => Promise<Hash>;
149
+ paymasterV4SetPriceStalenessThreshold: (args: {
150
+ threshold: bigint;
151
+ account?: Account | Address;
152
+ }) => Promise<Hash>;
153
+ paymasterV4SetTreasury: (args: {
154
+ treasury: Address;
155
+ account?: Account | Address;
156
+ }) => Promise<Hash>;
157
+ paymasterV4UpdatePrice: (args: {
158
+ token: Address;
159
+ account?: Account | Address;
160
+ }) => Promise<Hash>;
161
+ paymasterV4DeactivateFromRegistry: (args: {
162
+ account?: Account | Address;
163
+ }) => Promise<Hash>;
164
+ paymasterV4Initialize: (args: {
165
+ owner: Address;
166
+ account?: Account | Address;
167
+ }) => Promise<Hash>;
168
+ paymasterV4Version: () => Promise<string>;
169
+ };
170
+ export declare const paymasterV4Actions: (address: Address) => (client: PublicClient | WalletClient) => PaymasterV4Actions;
@@ -0,0 +1,334 @@
1
+ import { PaymasterV4ABI } from '../abis/index.js';
2
+ export const paymasterV4Actions = (address) => (client) => ({
3
+ // === NEW: Deposit-Only Model ===
4
+ async paymasterV4DepositFor({ user, token, amount, account }) {
5
+ return client.writeContract({
6
+ address,
7
+ abi: PaymasterV4ABI,
8
+ functionName: 'depositFor',
9
+ args: [user, token, amount],
10
+ account: account,
11
+ chain: client.chain
12
+ });
13
+ },
14
+ async paymasterV4Withdraw({ token, amount, account }) {
15
+ return client.writeContract({
16
+ address,
17
+ abi: PaymasterV4ABI,
18
+ functionName: 'withdraw',
19
+ args: [token, amount],
20
+ account: account,
21
+ chain: client.chain
22
+ });
23
+ },
24
+ async paymasterV4Balances({ user, token }) {
25
+ return client.readContract({
26
+ address,
27
+ abi: PaymasterV4ABI,
28
+ functionName: 'balances',
29
+ args: [user, token]
30
+ });
31
+ },
32
+ async paymasterV4SetTokenPrice({ token, price, account }) {
33
+ return client.writeContract({
34
+ address,
35
+ abi: PaymasterV4ABI,
36
+ functionName: 'setTokenPrice',
37
+ args: [token, price],
38
+ account: account,
39
+ chain: client.chain
40
+ });
41
+ },
42
+ async paymasterV4TokenPrices({ token }) {
43
+ return client.readContract({
44
+ address,
45
+ abi: PaymasterV4ABI,
46
+ functionName: 'tokenPrices',
47
+ args: [token]
48
+ });
49
+ },
50
+ // === DEPRECATED: Legacy Gas Token Management ===
51
+ async paymasterV4AddGasToken({ token, priceFeed, account }) {
52
+ return client.writeContract({
53
+ address,
54
+ abi: PaymasterV4ABI,
55
+ functionName: 'addGasToken',
56
+ args: [token, priceFeed],
57
+ account: account,
58
+ chain: client.chain
59
+ });
60
+ },
61
+ async paymasterV4RemoveGasToken({ token, account }) {
62
+ return client.writeContract({
63
+ address,
64
+ abi: PaymasterV4ABI,
65
+ functionName: 'removeGasToken',
66
+ args: [token],
67
+ account: account,
68
+ chain: client.chain
69
+ });
70
+ },
71
+ async paymasterV4GetSupportedGasTokens() {
72
+ return client.readContract({
73
+ address,
74
+ abi: PaymasterV4ABI,
75
+ functionName: 'getSupportedGasTokens',
76
+ args: []
77
+ });
78
+ },
79
+ async paymasterV4IsGasTokenSupported({ token }) {
80
+ return client.readContract({
81
+ address,
82
+ abi: PaymasterV4ABI,
83
+ functionName: 'isGasTokenSupported',
84
+ args: [token]
85
+ });
86
+ },
87
+ // SBT Management
88
+ async paymasterV4AddSBT({ sbt, account }) {
89
+ return client.writeContract({
90
+ address,
91
+ abi: PaymasterV4ABI,
92
+ functionName: 'addSBT',
93
+ args: [sbt],
94
+ account: account,
95
+ chain: client.chain
96
+ });
97
+ },
98
+ async paymasterV4RemoveSBT({ sbt, account }) {
99
+ return client.writeContract({
100
+ address,
101
+ abi: PaymasterV4ABI,
102
+ functionName: 'removeSBT',
103
+ args: [sbt],
104
+ account: account,
105
+ chain: client.chain
106
+ });
107
+ },
108
+ async paymasterV4GetSupportedSBTs() {
109
+ return client.readContract({
110
+ address,
111
+ abi: PaymasterV4ABI,
112
+ functionName: 'getSupportedSBTs',
113
+ args: []
114
+ });
115
+ },
116
+ async paymasterV4IsSBTSupported({ sbt }) {
117
+ return client.readContract({
118
+ address,
119
+ abi: PaymasterV4ABI,
120
+ functionName: 'isSBTSupported',
121
+ args: [sbt]
122
+ });
123
+ },
124
+ // Validation
125
+ async paymasterV4ValidatePaymasterUserOp({ userOp, userOpHash, maxCost }) {
126
+ return client.readContract({
127
+ address,
128
+ abi: PaymasterV4ABI,
129
+ functionName: 'validatePaymasterUserOp',
130
+ args: [userOp, userOpHash, maxCost]
131
+ });
132
+ },
133
+ async paymasterV4PostOp({ mode, context, actualGasCost, actualUserOpFeePerGas }) {
134
+ throw new Error('postOp is called by EntryPoint, not directly invoked');
135
+ },
136
+ // Deposit & Withdrawal (EntryPoint accounting)
137
+ async paymasterV4Deposit({ account }) {
138
+ return client.writeContract({
139
+ address,
140
+ abi: PaymasterV4ABI,
141
+ functionName: 'deposit',
142
+ args: [],
143
+ account: account,
144
+ chain: client.chain,
145
+ value: 0n // Assuming non-payable or handled elsewhere if payable
146
+ });
147
+ },
148
+ async paymasterV4WithdrawTo({ to, amount, account }) {
149
+ return client.writeContract({
150
+ address,
151
+ abi: PaymasterV4ABI,
152
+ functionName: 'withdrawTo',
153
+ args: [to, amount],
154
+ account: account,
155
+ chain: client.chain
156
+ });
157
+ },
158
+ async paymasterV4AddStake({ unstakeDelaySec, amount, account }) {
159
+ return client.writeContract({
160
+ address,
161
+ abi: PaymasterV4ABI,
162
+ functionName: 'addStake',
163
+ args: [unstakeDelaySec],
164
+ value: amount,
165
+ account: account,
166
+ chain: client.chain
167
+ });
168
+ },
169
+ async paymasterV4UnlockPaymasterStake({ account }) {
170
+ return client.writeContract({
171
+ address,
172
+ abi: PaymasterV4ABI,
173
+ functionName: 'unlockStake',
174
+ args: [],
175
+ account: account,
176
+ chain: client.chain
177
+ });
178
+ },
179
+ async paymasterV4WithdrawStake({ to, account }) {
180
+ return client.writeContract({
181
+ address,
182
+ abi: PaymasterV4ABI,
183
+ functionName: 'withdrawStake',
184
+ args: [to],
185
+ account: account,
186
+ chain: client.chain
187
+ });
188
+ },
189
+ async paymasterV4GetDeposit() {
190
+ return client.readContract({
191
+ address,
192
+ abi: PaymasterV4ABI,
193
+ functionName: 'getDeposit',
194
+ args: []
195
+ });
196
+ },
197
+ // EntryPoint
198
+ async paymasterV4EntryPoint() {
199
+ return client.readContract({
200
+ address,
201
+ abi: PaymasterV4ABI,
202
+ functionName: 'entryPoint',
203
+ args: []
204
+ });
205
+ },
206
+ // Ownership
207
+ async paymasterV4Owner() {
208
+ return client.readContract({
209
+ address,
210
+ abi: PaymasterV4ABI,
211
+ functionName: 'owner',
212
+ args: []
213
+ });
214
+ },
215
+ async paymasterV4TransferOwnership({ newOwner, account }) {
216
+ return client.writeContract({
217
+ address,
218
+ abi: PaymasterV4ABI,
219
+ functionName: 'transferOwnership',
220
+ args: [newOwner],
221
+ account: account,
222
+ chain: client.chain
223
+ });
224
+ },
225
+ async paymasterV4RenounceOwnership({ account }) {
226
+ return client.writeContract({
227
+ address,
228
+ abi: PaymasterV4ABI,
229
+ functionName: 'renounceOwnership',
230
+ args: [],
231
+ account: account,
232
+ chain: client.chain
233
+ });
234
+ },
235
+ // View Functions & Constants
236
+ async paymasterV4Registry() {
237
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'registry', args: [] });
238
+ },
239
+ async paymasterV4Treasury() {
240
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'treasury', args: [] });
241
+ },
242
+ async paymasterV4Paused() {
243
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'paused', args: [] });
244
+ },
245
+ async paymasterV4MaxGasCostCap() {
246
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'maxGasCostCap', args: [] });
247
+ },
248
+ async paymasterV4MaxEthUsdPrice() {
249
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'MAX_ETH_USD_PRICE', args: [] });
250
+ },
251
+ async paymasterV4MaxGasTokens() {
252
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'MAX_GAS_TOKENS', args: [] });
253
+ },
254
+ async paymasterV4MaxSbts() {
255
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'MAX_SBTS', args: [] });
256
+ },
257
+ async paymasterV4MaxServiceFee() {
258
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'MAX_SERVICE_FEE', args: [] });
259
+ },
260
+ async paymasterV4MinEthUsdPrice() {
261
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'MIN_ETH_USD_PRICE', args: [] });
262
+ },
263
+ async paymasterV4PriceStalenessThreshold() {
264
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'priceStalenessThreshold', args: [] });
265
+ },
266
+ // Aliases
267
+ async paymasterV4AddDeposit(args) {
268
+ return this.paymasterV4Deposit(args);
269
+ },
270
+ async paymasterV4UnlockStake(args) {
271
+ return this.paymasterV4UnlockPaymasterStake(args);
272
+ },
273
+ // View Functions & Constants (Missing)
274
+ async paymasterV4EthUsdPriceFeed() {
275
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'ethUsdPriceFeed', args: [] });
276
+ },
277
+ async paymasterV4OracleDecimals() {
278
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'oracleDecimals', args: [] });
279
+ },
280
+ async paymasterV4TokenDecimals({ token }) {
281
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'tokenDecimals', args: [token] });
282
+ },
283
+ async paymasterV4ServiceFeeRate() {
284
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'serviceFeeRate', args: [] });
285
+ },
286
+ async paymasterV4CalculateCost({ token, gasCost, param }) {
287
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'calculateCost', args: [token, gasCost, param] });
288
+ },
289
+ async paymasterV4GetRealtimeTokenCost({ token, gasCost }) {
290
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'getRealtimeTokenCost', args: [token, gasCost] });
291
+ },
292
+ async paymasterV4IsActiveInRegistry() {
293
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'isActiveInRegistry', args: [] });
294
+ },
295
+ async paymasterV4IsRegistrySet() {
296
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'isRegistrySet', args: [] });
297
+ },
298
+ async paymasterV4CachedPriceView({ token }) {
299
+ return client.readContract({ address, abi: PaymasterV4ABI, functionName: 'cachedPrice', args: [token] });
300
+ },
301
+ // Admin (Missing)
302
+ async paymasterV4SetCachedPrice({ token, price, account }) {
303
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'setCachedPrice', args: [token, price], account: account, chain: client.chain });
304
+ },
305
+ async paymasterV4SetServiceFeeRate({ rate, account }) {
306
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'setServiceFeeRate', args: [rate], account: account, chain: client.chain });
307
+ },
308
+ async paymasterV4SetMaxGasCostCap({ cap, account }) {
309
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'setMaxGasCostCap', args: [cap], account: account, chain: client.chain });
310
+ },
311
+ async paymasterV4SetPriceStalenessThreshold({ threshold, account }) {
312
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'setPriceStalenessThreshold', args: [threshold], account: account, chain: client.chain });
313
+ },
314
+ async paymasterV4SetTreasury({ treasury, account }) {
315
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'setTreasury', args: [treasury], account: account, chain: client.chain });
316
+ },
317
+ async paymasterV4UpdatePrice({ token, account }) {
318
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'updatePrice', args: [token], account: account, chain: client.chain });
319
+ },
320
+ async paymasterV4DeactivateFromRegistry({ account }) {
321
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'deactivateFromRegistry', args: [], account: account, chain: client.chain });
322
+ },
323
+ async paymasterV4Initialize({ owner, account }) {
324
+ return client.writeContract({ address, abi: PaymasterV4ABI, functionName: 'initialize', args: [owner], account: account, chain: client.chain });
325
+ },
326
+ async paymasterV4Version() {
327
+ return client.readContract({
328
+ address,
329
+ abi: PaymasterV4ABI,
330
+ functionName: 'version',
331
+ args: []
332
+ });
333
+ }
334
+ });
@@ -0,0 +1 @@
1
+ export {};