@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.
- package/LICENSE +21 -0
- package/dist/abis/BLSAggregator.json +686 -0
- package/dist/abis/BLSValidator.json +42 -0
- package/dist/abis/DVTValidator.json +368 -0
- package/dist/abis/Eip7702Support.json +24 -0
- package/dist/abis/EntryPoint.json +1382 -0
- package/dist/abis/GToken.json +513 -0
- package/dist/abis/GTokenStaking.json +949 -0
- package/dist/abis/LegacyAccount.json +625 -0
- package/dist/abis/MySBT.json +1518 -0
- package/dist/abis/Paymaster.json +1143 -0
- package/dist/abis/PaymasterFactory.json +640 -0
- package/dist/abis/Registry.json +1942 -0
- package/dist/abis/ReputationSystem.json +699 -0
- package/dist/abis/SenderCreator.json +99 -0
- package/dist/abis/Simple7702Account.json +395 -0
- package/dist/abis/SimpleAccount.json +560 -0
- package/dist/abis/SimpleAccountFactory.json +111 -0
- package/dist/abis/SimpleAccountFactoryV08.json +87 -0
- package/dist/abis/SimpleAccountV08.json +557 -0
- package/dist/abis/SuperPaymaster.json +1781 -0
- package/dist/abis/UserOperationLib.json +57 -0
- package/dist/abis/abi.config.json +24 -0
- package/dist/abis/index.d.ts +1126 -0
- package/dist/abis/index.js +91 -0
- package/dist/abis/xPNTsFactory.json +718 -0
- package/dist/abis/xPNTsToken.json +1280 -0
- package/dist/actions/StateValidator.d.ts +68 -0
- package/dist/actions/StateValidator.js +187 -0
- package/dist/actions/StateValidator.test.d.ts +1 -0
- package/dist/actions/StateValidator.test.js +144 -0
- package/dist/actions/account.d.ts +55 -0
- package/dist/actions/account.js +133 -0
- package/dist/actions/account.test.d.ts +1 -0
- package/dist/actions/account.test.js +118 -0
- package/dist/actions/aggregator.d.ts +17 -0
- package/dist/actions/aggregator.js +31 -0
- package/dist/actions/aggregator.test.d.ts +1 -0
- package/dist/actions/aggregator.test.js +67 -0
- package/dist/actions/dvt.d.ts +30 -0
- package/dist/actions/dvt.js +41 -0
- package/dist/actions/dvt.test.d.ts +1 -0
- package/dist/actions/dvt.test.js +98 -0
- package/dist/actions/entryPoint.d.ts +90 -0
- package/dist/actions/entryPoint.js +211 -0
- package/dist/actions/entryPoint.test.d.ts +1 -0
- package/dist/actions/entryPoint.test.js +139 -0
- package/dist/actions/factory.d.ts +215 -0
- package/dist/actions/factory.js +442 -0
- package/dist/actions/factory.test.d.ts +1 -0
- package/dist/actions/factory.test.js +197 -0
- package/dist/actions/faucet.d.ts +48 -0
- package/dist/actions/faucet.js +337 -0
- package/dist/actions/faucet.test.d.ts +1 -0
- package/dist/actions/faucet.test.js +120 -0
- package/dist/actions/gtokenExtended.d.ts +39 -0
- package/dist/actions/gtokenExtended.js +115 -0
- package/dist/actions/gtokenExtended.test.d.ts +1 -0
- package/dist/actions/gtokenExtended.test.js +118 -0
- package/dist/actions/index.d.ts +15 -0
- package/dist/actions/index.js +17 -0
- package/dist/actions/paymasterV4.d.ts +170 -0
- package/dist/actions/paymasterV4.js +334 -0
- package/dist/actions/paymasterV4.test.d.ts +1 -0
- package/dist/actions/paymasterV4.test.js +159 -0
- package/dist/actions/registry.d.ts +246 -0
- package/dist/actions/registry.js +667 -0
- package/dist/actions/registry.test.d.ts +1 -0
- package/dist/actions/registry.test.js +360 -0
- package/dist/actions/reputation.d.ts +129 -0
- package/dist/actions/reputation.js +281 -0
- package/dist/actions/reputation.test.d.ts +1 -0
- package/dist/actions/reputation.test.js +169 -0
- package/dist/actions/sbt.d.ts +191 -0
- package/dist/actions/sbt.js +533 -0
- package/dist/actions/sbt.test.d.ts +1 -0
- package/dist/actions/sbt.test.js +256 -0
- package/dist/actions/staking.d.ts +132 -0
- package/dist/actions/staking.js +330 -0
- package/dist/actions/staking.test.d.ts +1 -0
- package/dist/actions/staking.test.js +223 -0
- package/dist/actions/superPaymaster.d.ts +237 -0
- package/dist/actions/superPaymaster.js +644 -0
- package/dist/actions/superPaymaster.test.d.ts +1 -0
- package/dist/actions/superPaymaster.test.js +287 -0
- package/dist/actions/tokens.d.ts +229 -0
- package/dist/actions/tokens.js +415 -0
- package/dist/actions/tokens.test.d.ts +1 -0
- package/dist/actions/tokens.test.js +53 -0
- package/dist/actions/validators.d.ts +194 -0
- package/dist/actions/validators.js +433 -0
- package/dist/actions/validators.test.d.ts +1 -0
- package/dist/actions/validators.test.js +215 -0
- package/dist/branding.d.ts +30 -0
- package/dist/branding.js +30 -0
- package/dist/clients/BaseClient.d.ts +25 -0
- package/dist/clients/BaseClient.js +66 -0
- package/dist/clients/types.d.ts +60 -0
- package/dist/clients/types.js +1 -0
- package/dist/clients.d.ts +5 -0
- package/dist/clients.js +11 -0
- package/dist/communities.d.ts +52 -0
- package/dist/communities.js +73 -0
- package/dist/config/ContractConfigManager.d.ts +20 -0
- package/dist/config/ContractConfigManager.js +48 -0
- package/dist/constants.d.ts +88 -0
- package/dist/constants.js +125 -0
- package/dist/contract-addresses.d.ts +110 -0
- package/dist/contract-addresses.js +99 -0
- package/dist/contracts.d.ts +424 -0
- package/dist/contracts.js +343 -0
- package/dist/contracts.test.d.ts +1 -0
- package/dist/contracts.test.js +40 -0
- package/dist/crypto/blsSigner.d.ts +64 -0
- package/dist/crypto/blsSigner.js +98 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/networks.d.ts +127 -0
- package/dist/networks.js +118 -0
- package/dist/requirementChecker.d.ts +38 -0
- package/dist/requirementChecker.js +139 -0
- package/dist/requirementChecker.test.d.ts +1 -0
- package/dist/requirementChecker.test.js +60 -0
- package/dist/roles.d.ts +204 -0
- package/dist/roles.js +211 -0
- package/dist/roles.test.d.ts +1 -0
- package/dist/roles.test.js +23 -0
- package/dist/utils/validation.d.ts +24 -0
- package/dist/utils/validation.js +56 -0
- package/dist/utils/validation.test.d.ts +1 -0
- package/dist/utils/validation.test.js +40 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +14 -0
- package/package.json +33 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { parseEther } from 'viem';
|
|
3
|
+
import { superPaymasterActions } from './superPaymaster.js';
|
|
4
|
+
describe('SuperPaymaster Actions', () => {
|
|
5
|
+
const mockPaymasterAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
6
|
+
const MOCK_OPERATOR = '0x1234567890123456789012345678901234567890';
|
|
7
|
+
const MOCK_USER = '0x2222222222222222222222222222222222222222';
|
|
8
|
+
let mockPublicClient;
|
|
9
|
+
let mockWalletClient;
|
|
10
|
+
let mockAccount;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
mockAccount = {
|
|
13
|
+
address: MOCK_OPERATOR,
|
|
14
|
+
type: 'json-rpc'
|
|
15
|
+
};
|
|
16
|
+
mockPublicClient = {
|
|
17
|
+
readContract: vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
mockWalletClient = {
|
|
20
|
+
writeContract: vi.fn(),
|
|
21
|
+
readContract: vi.fn(),
|
|
22
|
+
account: mockAccount,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
describe('Deposit operations', () => {
|
|
26
|
+
it('should deposit aPNTs', async () => {
|
|
27
|
+
const txHash = '0xabc...';
|
|
28
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
29
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
30
|
+
const result = await actions.superPaymasterDeposit({ amount: 1000n, account: mockAccount });
|
|
31
|
+
expect(result).toBe(txHash);
|
|
32
|
+
});
|
|
33
|
+
it('should deposit ETH', async () => {
|
|
34
|
+
const txHash = '0xdef...';
|
|
35
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
36
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
37
|
+
const result = await actions.superPaymasterDepositETH({ value: 1000000000000000000n, account: mockAccount });
|
|
38
|
+
expect(result).toBe(txHash);
|
|
39
|
+
});
|
|
40
|
+
it('should deposit for operator', async () => {
|
|
41
|
+
const txHash = '0xghi...';
|
|
42
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
43
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
44
|
+
const result = await actions.superPaymasterDepositFor({
|
|
45
|
+
operator: MOCK_OPERATOR,
|
|
46
|
+
amount: 5000n,
|
|
47
|
+
account: mockAccount
|
|
48
|
+
});
|
|
49
|
+
expect(result).toBe(txHash);
|
|
50
|
+
});
|
|
51
|
+
it('should withdraw to address', async () => {
|
|
52
|
+
const txHash = '0xjkl...';
|
|
53
|
+
const to = '0x9999999999999999999999999999999999999999';
|
|
54
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
55
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
56
|
+
const result = await actions.superPaymasterWithdrawTo({ to, amount: 2000n, account: mockAccount });
|
|
57
|
+
expect(result).toBe(txHash);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('Stake operations', () => {
|
|
61
|
+
it('should add super stake', async () => {
|
|
62
|
+
const txHash = '0xmno...';
|
|
63
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
64
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
65
|
+
const result = await actions.superPaymasterAddSuperStake({ amount: 10000n, account: mockAccount });
|
|
66
|
+
expect(result).toBe(txHash);
|
|
67
|
+
});
|
|
68
|
+
it('should unlock super stake', async () => {
|
|
69
|
+
const txHash = '0xpqr...';
|
|
70
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
71
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
72
|
+
const result = await actions.superPaymasterUnlockSuperStake({ account: mockAccount });
|
|
73
|
+
expect(result).toBe(txHash);
|
|
74
|
+
});
|
|
75
|
+
it('should withdraw stake', async () => {
|
|
76
|
+
const txHash = '0xstu...';
|
|
77
|
+
const to = '0x8888888888888888888888888888888888888888';
|
|
78
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
79
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
80
|
+
const result = await actions.superPaymasterWithdrawStake({ to, account: mockAccount });
|
|
81
|
+
expect(result).toBe(txHash);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
describe('Operator management', () => {
|
|
85
|
+
it('should configure operator', async () => {
|
|
86
|
+
const txHash = '0xvwx...';
|
|
87
|
+
const xPNTsToken = '0x7777777777777777777777777777777777777777';
|
|
88
|
+
const treasury = '0x6666666666666666666666666666666666666666';
|
|
89
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
90
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
91
|
+
const result = await actions.superPaymasterConfigureOperator({
|
|
92
|
+
xPNTsToken,
|
|
93
|
+
treasury,
|
|
94
|
+
exchangeRate: 1000000n,
|
|
95
|
+
account: mockAccount
|
|
96
|
+
});
|
|
97
|
+
expect(result).toBe(txHash);
|
|
98
|
+
});
|
|
99
|
+
it('should pause operator', async () => {
|
|
100
|
+
const txHash = '0xdef...';
|
|
101
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
102
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
103
|
+
const result = await actions.superPaymasterSetOperatorPaused({
|
|
104
|
+
operator: MOCK_OPERATOR,
|
|
105
|
+
paused: true,
|
|
106
|
+
account: mockAccount
|
|
107
|
+
});
|
|
108
|
+
expect(result).toBe(txHash);
|
|
109
|
+
});
|
|
110
|
+
it('should update reputation', async () => {
|
|
111
|
+
const txHash = '0x123...';
|
|
112
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
113
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
114
|
+
const result = await actions.superPaymasterUpdateReputation({
|
|
115
|
+
operator: MOCK_OPERATOR,
|
|
116
|
+
newReputation: 850n,
|
|
117
|
+
account: mockAccount
|
|
118
|
+
});
|
|
119
|
+
expect(result).toBe(txHash);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('Price and configuration', () => {
|
|
123
|
+
it('should set aPNTs price', async () => {
|
|
124
|
+
const txHash = '0x456...';
|
|
125
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
126
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
127
|
+
const result = await actions.superPaymasterSetAPNTsPrice({
|
|
128
|
+
priceUSD: 1000000n, // $1.00
|
|
129
|
+
account: mockAccount
|
|
130
|
+
});
|
|
131
|
+
expect(result).toBe(txHash);
|
|
132
|
+
});
|
|
133
|
+
it('should set cached price', async () => {
|
|
134
|
+
const txHash = '0x789...';
|
|
135
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
136
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
137
|
+
const result = await actions.superPaymasterSetCachedPrice({
|
|
138
|
+
price: 2000000000n,
|
|
139
|
+
account: mockAccount
|
|
140
|
+
});
|
|
141
|
+
expect(result).toBe(txHash);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe('Advanced Operator & User Management', () => {
|
|
145
|
+
it('should perform slashing operations', async () => {
|
|
146
|
+
const txHash = '0xhash';
|
|
147
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
148
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
149
|
+
const res1 = await actions.superPaymasterSlashOperator({ operator: MOCK_OPERATOR, amount: 100n, reason: 'Test', account: mockAccount });
|
|
150
|
+
const res2 = await actions.superPaymasterExecuteSlashWithBLS({
|
|
151
|
+
operator: MOCK_OPERATOR,
|
|
152
|
+
roleId: '0xROLE',
|
|
153
|
+
amount: 100n,
|
|
154
|
+
reason: 'Test',
|
|
155
|
+
blsSignature: '0xSIG',
|
|
156
|
+
account: mockAccount
|
|
157
|
+
});
|
|
158
|
+
expect(res1).toBe(txHash);
|
|
159
|
+
expect(res2).toBe(txHash);
|
|
160
|
+
});
|
|
161
|
+
it('should manage blocked users', async () => {
|
|
162
|
+
const txHash = '0xhash';
|
|
163
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
164
|
+
mockWalletClient.readContract.mockResolvedValue(true);
|
|
165
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
166
|
+
const tx1 = await actions.superPaymasterBlockUser({ user: MOCK_USER, blocked: true, account: mockAccount });
|
|
167
|
+
const tx2 = await actions.superPaymasterUpdateBlockedStatus({ user: MOCK_USER, blocked: true, account: mockAccount });
|
|
168
|
+
const isBlocked = await actions.superPaymasterBlockedUsers({ user: MOCK_USER });
|
|
169
|
+
expect(tx1).toBe(txHash);
|
|
170
|
+
expect(tx2).toBe(txHash);
|
|
171
|
+
expect(isBlocked).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('System Config & Price Management', () => {
|
|
175
|
+
it('should manage protocol fees', async () => {
|
|
176
|
+
const txHash = '0xhash';
|
|
177
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
178
|
+
mockWalletClient.readContract.mockResolvedValueOnce(100n).mockResolvedValueOnce(500n);
|
|
179
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
180
|
+
const tx = await actions.superPaymasterSetProtocolFee({ feeRecipient: MOCK_USER, feeBps: 100n, account: mockAccount });
|
|
181
|
+
const bps = await actions.superPaymasterProtocolFeeBPS();
|
|
182
|
+
const revenue = await actions.superPaymasterProtocolRevenue();
|
|
183
|
+
expect(tx).toBe(txHash);
|
|
184
|
+
expect(bps).toBe(100n);
|
|
185
|
+
expect(revenue).toBe(500n);
|
|
186
|
+
});
|
|
187
|
+
it('should manage price updates', async () => {
|
|
188
|
+
const txHash = '0xhash';
|
|
189
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
190
|
+
mockWalletClient.readContract.mockResolvedValue(2000n);
|
|
191
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
192
|
+
const tx1 = await actions.superPaymasterUpdatePrice({ account: mockAccount });
|
|
193
|
+
const tx2 = await actions.superPaymasterUpdatePriceDVT({ price: 2000n, proof: '0x', account: mockAccount });
|
|
194
|
+
const price = await actions.superPaymasterAPNTsPriceUSD();
|
|
195
|
+
expect(tx1).toBe(txHash);
|
|
196
|
+
expect(tx2).toBe(txHash);
|
|
197
|
+
expect(price).toBe(2000n);
|
|
198
|
+
});
|
|
199
|
+
it('should manage treasury and factory settings', async () => {
|
|
200
|
+
const txHash = '0xhash';
|
|
201
|
+
mockWalletClient.writeContract.mockResolvedValue(txHash);
|
|
202
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockWalletClient);
|
|
203
|
+
const tx1 = await actions.superPaymasterSetTreasury({ treasury: MOCK_USER, account: mockAccount });
|
|
204
|
+
const tx2 = await actions.superPaymasterSetXPNTsFactory({ factory: MOCK_USER, account: mockAccount });
|
|
205
|
+
const tx3 = await actions.superPaymasterSetAPNTsToken({ token: MOCK_USER, account: mockAccount });
|
|
206
|
+
const tx4 = await actions.superPaymasterSetBLSAggregator({ aggregator: MOCK_USER, account: mockAccount });
|
|
207
|
+
expect(tx1).toBe(txHash);
|
|
208
|
+
expect(tx2).toBe(txHash);
|
|
209
|
+
expect(tx3).toBe(txHash);
|
|
210
|
+
expect(tx4).toBe(txHash);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe('Slash History & Views', () => {
|
|
214
|
+
it('should query slash history', async () => {
|
|
215
|
+
mockPublicClient.readContract
|
|
216
|
+
.mockResolvedValueOnce(5n) // count
|
|
217
|
+
.mockResolvedValueOnce([]) // history
|
|
218
|
+
.mockResolvedValueOnce({ amount: 100n }); // latest
|
|
219
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
220
|
+
const count = await actions.superPaymasterGetSlashCount({ operator: MOCK_OPERATOR });
|
|
221
|
+
const history = await actions.superPaymasterGetSlashHistory({ operator: MOCK_OPERATOR });
|
|
222
|
+
const latest = await actions.superPaymasterGetLatestSlash({ operator: MOCK_OPERATOR });
|
|
223
|
+
expect(count).toBe(5n);
|
|
224
|
+
expect(Array.isArray(history)).toBe(true);
|
|
225
|
+
expect(latest.amount).toBe(100n);
|
|
226
|
+
});
|
|
227
|
+
it('should query various balance and status views', async () => {
|
|
228
|
+
mockPublicClient.readContract
|
|
229
|
+
.mockResolvedValueOnce(parseEther('10')) // getDeposit
|
|
230
|
+
.mockResolvedValueOnce(parseEther('1')) // getAvailableCredit
|
|
231
|
+
.mockResolvedValueOnce(123456n) // totalTrackedBalance
|
|
232
|
+
.mockResolvedValueOnce(999999n); // lastUserOpTimestamp
|
|
233
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
234
|
+
const deposit = await actions.superPaymasterGetDeposit();
|
|
235
|
+
const credit = await actions.superPaymasterGetAvailableCredit({ operator: MOCK_OPERATOR, user: MOCK_USER });
|
|
236
|
+
const tracked = await actions.superPaymasterTotalTrackedBalance();
|
|
237
|
+
const ts = await actions.superPaymasterLastUserOpTimestamp({ user: MOCK_USER });
|
|
238
|
+
expect(deposit).toBe(parseEther('10'));
|
|
239
|
+
expect(credit).toBe(parseEther('1'));
|
|
240
|
+
expect(tracked).toBe(123456n);
|
|
241
|
+
expect(ts).toBe(999999n);
|
|
242
|
+
});
|
|
243
|
+
it('should get operator balance using convenience function', async () => {
|
|
244
|
+
mockPublicClient.readContract.mockResolvedValue([parseEther('5'), '0x...']); // operators returns struct
|
|
245
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
246
|
+
const balance = await actions.superPaymasterBalanceOfOperator({ operator: MOCK_OPERATOR });
|
|
247
|
+
expect(balance).toBe(parseEther('5'));
|
|
248
|
+
});
|
|
249
|
+
it('should query slashes specifically', async () => {
|
|
250
|
+
const mockSlash = { amount: 100n, reason: 'Test' };
|
|
251
|
+
mockPublicClient.readContract.mockResolvedValue(mockSlash);
|
|
252
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
253
|
+
const slash = await actions.superPaymasterSlashHistory({ operator: MOCK_OPERATOR, index: 0n });
|
|
254
|
+
expect(slash.amount).toBe(100n);
|
|
255
|
+
});
|
|
256
|
+
it('should query price feed and parameters', async () => {
|
|
257
|
+
mockPublicClient.readContract.mockResolvedValue(100n);
|
|
258
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
259
|
+
const bps = await actions.superPaymasterBPS_DENOMINATOR();
|
|
260
|
+
const rate = await actions.superPaymasterRATE_OFFSET();
|
|
261
|
+
expect(bps).toBe(100n);
|
|
262
|
+
expect(rate).toBe(100n);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
describe('Constants & System References', () => {
|
|
266
|
+
it('should query all system constants', async () => {
|
|
267
|
+
mockPublicClient.readContract.mockResolvedValue(MOCK_USER);
|
|
268
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
269
|
+
const results = await Promise.all([
|
|
270
|
+
actions.superPaymasterAPNTS_TOKEN(),
|
|
271
|
+
actions.superPaymasterBLS_AGGREGATOR(),
|
|
272
|
+
actions.superPaymasterETH_USD_PRICE_FEED(),
|
|
273
|
+
actions.superPaymasterXpntsFactory(),
|
|
274
|
+
actions.superPaymasterTreasury(),
|
|
275
|
+
actions.superPaymasterEntryPoint(),
|
|
276
|
+
actions.superPaymasterOwner()
|
|
277
|
+
]);
|
|
278
|
+
results.forEach(res => expect(res).toBe(MOCK_USER));
|
|
279
|
+
});
|
|
280
|
+
it('should get version', async () => {
|
|
281
|
+
mockPublicClient.readContract.mockResolvedValue('v0.16.4');
|
|
282
|
+
const actions = superPaymasterActions(mockPaymasterAddress)(mockPublicClient);
|
|
283
|
+
const v = await actions.superPaymasterVersion();
|
|
284
|
+
expect(v).toBe('v0.16.4');
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export type TokenActions = {
|
|
3
|
+
tokenTotalSupply: (args: {
|
|
4
|
+
token: Address;
|
|
5
|
+
}) => Promise<bigint>;
|
|
6
|
+
tokenBalanceOf: (args: {
|
|
7
|
+
token: Address;
|
|
8
|
+
account: Address;
|
|
9
|
+
}) => Promise<bigint>;
|
|
10
|
+
tokenCap: (args: {
|
|
11
|
+
token: Address;
|
|
12
|
+
}) => Promise<bigint>;
|
|
13
|
+
tokenRemainingMintableSupply: (args: {
|
|
14
|
+
token: Address;
|
|
15
|
+
}) => Promise<bigint>;
|
|
16
|
+
tokenTransfer: (args: {
|
|
17
|
+
token: Address;
|
|
18
|
+
to: Address;
|
|
19
|
+
amount: bigint;
|
|
20
|
+
account?: Account | Address;
|
|
21
|
+
}) => Promise<Hash>;
|
|
22
|
+
tokenTransferFrom: (args: {
|
|
23
|
+
token: Address;
|
|
24
|
+
from: Address;
|
|
25
|
+
to: Address;
|
|
26
|
+
amount: bigint;
|
|
27
|
+
account?: Account | Address;
|
|
28
|
+
}) => Promise<Hash>;
|
|
29
|
+
tokenApprove: (args: {
|
|
30
|
+
token: Address;
|
|
31
|
+
spender: Address;
|
|
32
|
+
amount: bigint;
|
|
33
|
+
account?: Account | Address;
|
|
34
|
+
}) => Promise<Hash>;
|
|
35
|
+
tokenAllowance: (args: {
|
|
36
|
+
token: Address;
|
|
37
|
+
owner: Address;
|
|
38
|
+
spender: Address;
|
|
39
|
+
}) => Promise<bigint>;
|
|
40
|
+
tokenMint: (args: {
|
|
41
|
+
token: Address;
|
|
42
|
+
to: Address;
|
|
43
|
+
amount: bigint;
|
|
44
|
+
account?: Account | Address;
|
|
45
|
+
}) => Promise<Hash>;
|
|
46
|
+
tokenBurn: (args: {
|
|
47
|
+
token: Address;
|
|
48
|
+
amount: bigint;
|
|
49
|
+
account?: Account | Address;
|
|
50
|
+
}) => Promise<Hash>;
|
|
51
|
+
tokenBurnFrom: (args: {
|
|
52
|
+
token: Address;
|
|
53
|
+
from: Address;
|
|
54
|
+
amount: bigint;
|
|
55
|
+
account?: Account | Address;
|
|
56
|
+
}) => Promise<Hash>;
|
|
57
|
+
tokenName: (args: {
|
|
58
|
+
token: Address;
|
|
59
|
+
}) => Promise<string>;
|
|
60
|
+
tokenSymbol: (args: {
|
|
61
|
+
token: Address;
|
|
62
|
+
}) => Promise<string>;
|
|
63
|
+
tokenDecimals: (args: {
|
|
64
|
+
token: Address;
|
|
65
|
+
}) => Promise<number>;
|
|
66
|
+
tokenOwner: (args: {
|
|
67
|
+
token: Address;
|
|
68
|
+
}) => Promise<Address>;
|
|
69
|
+
tokenTransferTokenOwnership: (args: {
|
|
70
|
+
token: Address;
|
|
71
|
+
newOwner: Address;
|
|
72
|
+
account?: Account | Address;
|
|
73
|
+
}) => Promise<Hash>;
|
|
74
|
+
tokenRenounceOwnership: (args: {
|
|
75
|
+
token: Address;
|
|
76
|
+
account?: Account | Address;
|
|
77
|
+
}) => Promise<Hash>;
|
|
78
|
+
tokenUpdateExchangeRate: (args: {
|
|
79
|
+
token: Address;
|
|
80
|
+
newRate: bigint;
|
|
81
|
+
account?: Account | Address;
|
|
82
|
+
}) => Promise<Hash>;
|
|
83
|
+
tokenGetDebt: (args: {
|
|
84
|
+
token: Address;
|
|
85
|
+
user: Address;
|
|
86
|
+
}) => Promise<bigint>;
|
|
87
|
+
tokenRepayDebt: (args: {
|
|
88
|
+
token: Address;
|
|
89
|
+
amount: bigint;
|
|
90
|
+
account?: Account | Address;
|
|
91
|
+
}) => Promise<Hash>;
|
|
92
|
+
tokenTransferAndCall: (args: {
|
|
93
|
+
token: Address;
|
|
94
|
+
to: Address;
|
|
95
|
+
amount: bigint;
|
|
96
|
+
data?: Hex;
|
|
97
|
+
account?: Account | Address;
|
|
98
|
+
}) => Promise<Hash>;
|
|
99
|
+
tokenAddAutoApprovedSpender: (args: {
|
|
100
|
+
token: Address;
|
|
101
|
+
spender: Address;
|
|
102
|
+
account?: Account | Address;
|
|
103
|
+
}) => Promise<Hash>;
|
|
104
|
+
tokenRemoveAutoApprovedSpender: (args: {
|
|
105
|
+
token: Address;
|
|
106
|
+
spender: Address;
|
|
107
|
+
account?: Account | Address;
|
|
108
|
+
}) => Promise<Hash>;
|
|
109
|
+
tokenIsAutoApprovedSpender: (args: {
|
|
110
|
+
token: Address;
|
|
111
|
+
spender: Address;
|
|
112
|
+
}) => Promise<boolean>;
|
|
113
|
+
tokenSUPERPAYMASTER_ADDRESS: (args: {
|
|
114
|
+
token: Address;
|
|
115
|
+
}) => Promise<Address>;
|
|
116
|
+
tokenFACTORY: (args: {
|
|
117
|
+
token: Address;
|
|
118
|
+
}) => Promise<Address>;
|
|
119
|
+
tokenTransferOwnership: (args: {
|
|
120
|
+
token: Address;
|
|
121
|
+
newOwner: Address;
|
|
122
|
+
account?: Account | Address;
|
|
123
|
+
}) => Promise<Hash>;
|
|
124
|
+
tokenTransferCommunityOwnership: (args: {
|
|
125
|
+
token: Address;
|
|
126
|
+
newOwner: Address;
|
|
127
|
+
account?: Account | Address;
|
|
128
|
+
}) => Promise<Hash>;
|
|
129
|
+
tokenCommunityName: (args: {
|
|
130
|
+
token: Address;
|
|
131
|
+
}) => Promise<string>;
|
|
132
|
+
tokenCommunityENS: (args: {
|
|
133
|
+
token: Address;
|
|
134
|
+
}) => Promise<string>;
|
|
135
|
+
tokenExchangeRate: (args: {
|
|
136
|
+
token: Address;
|
|
137
|
+
}) => Promise<bigint>;
|
|
138
|
+
tokenSpendingLimits: (args: {
|
|
139
|
+
token: Address;
|
|
140
|
+
user: Address;
|
|
141
|
+
}) => Promise<bigint>;
|
|
142
|
+
tokenDefaultSpendingLimitXPNTs: (args: {
|
|
143
|
+
token: Address;
|
|
144
|
+
}) => Promise<bigint>;
|
|
145
|
+
tokenCumulativeSpent: (args: {
|
|
146
|
+
token: Address;
|
|
147
|
+
user: Address;
|
|
148
|
+
}) => Promise<bigint>;
|
|
149
|
+
tokenDebts: (args: {
|
|
150
|
+
token: Address;
|
|
151
|
+
user: Address;
|
|
152
|
+
}) => Promise<bigint>;
|
|
153
|
+
tokenUsedOpHashes: (args: {
|
|
154
|
+
token: Address;
|
|
155
|
+
hash: Hex;
|
|
156
|
+
}) => Promise<boolean>;
|
|
157
|
+
tokenDOMAIN_SEPARATOR: (args: {
|
|
158
|
+
token: Address;
|
|
159
|
+
}) => Promise<Hex>;
|
|
160
|
+
tokenNonces: (args: {
|
|
161
|
+
token: Address;
|
|
162
|
+
owner: Address;
|
|
163
|
+
}) => Promise<bigint>;
|
|
164
|
+
tokenPermit: (args: {
|
|
165
|
+
token: Address;
|
|
166
|
+
owner: Address;
|
|
167
|
+
spender: Address;
|
|
168
|
+
value: bigint;
|
|
169
|
+
deadline: bigint;
|
|
170
|
+
v: number;
|
|
171
|
+
r: Hex;
|
|
172
|
+
s: Hex;
|
|
173
|
+
account?: Account | Address;
|
|
174
|
+
}) => Promise<Hash>;
|
|
175
|
+
tokenAutoApprovedSpenders: (args: {
|
|
176
|
+
token: Address;
|
|
177
|
+
spender: Address;
|
|
178
|
+
}) => Promise<boolean>;
|
|
179
|
+
tokenBurnFromWithOpHash: (args: {
|
|
180
|
+
token: Address;
|
|
181
|
+
account: Address;
|
|
182
|
+
amount: bigint;
|
|
183
|
+
opHash: Hex;
|
|
184
|
+
userOpAccount?: Account | Address;
|
|
185
|
+
}) => Promise<Hash>;
|
|
186
|
+
tokenCommunityOwner: (args: {
|
|
187
|
+
token: Address;
|
|
188
|
+
}) => Promise<Address>;
|
|
189
|
+
tokenEip712Domain: (args: {
|
|
190
|
+
token: Address;
|
|
191
|
+
}) => Promise<any>;
|
|
192
|
+
tokenGetDefaultSpendingLimitXPNTs: (args: {
|
|
193
|
+
token: Address;
|
|
194
|
+
}) => Promise<bigint>;
|
|
195
|
+
tokenGetMetadata: (args: {
|
|
196
|
+
token: Address;
|
|
197
|
+
}) => Promise<string>;
|
|
198
|
+
tokenNeedsApproval: (args: {
|
|
199
|
+
token: Address;
|
|
200
|
+
owner: Address;
|
|
201
|
+
spender: Address;
|
|
202
|
+
amount: bigint;
|
|
203
|
+
}) => Promise<boolean>;
|
|
204
|
+
tokenRecordDebt: (args: {
|
|
205
|
+
token: Address;
|
|
206
|
+
user: Address;
|
|
207
|
+
amount: bigint;
|
|
208
|
+
account?: Account | Address;
|
|
209
|
+
}) => Promise<Hash>;
|
|
210
|
+
tokenDEFAULT_SPENDING_LIMIT_APNTS: (args: {
|
|
211
|
+
token: Address;
|
|
212
|
+
}) => Promise<bigint>;
|
|
213
|
+
tokenSetPaymasterLimit: (args: {
|
|
214
|
+
token: Address;
|
|
215
|
+
user: Address;
|
|
216
|
+
limit: bigint;
|
|
217
|
+
account?: Account | Address;
|
|
218
|
+
}) => Promise<Hash>;
|
|
219
|
+
tokenSetSuperPaymasterAddress: (args: {
|
|
220
|
+
token: Address;
|
|
221
|
+
superPaymaster: Address;
|
|
222
|
+
account?: Account | Address;
|
|
223
|
+
}) => Promise<Hash>;
|
|
224
|
+
tokenVersion: (args: {
|
|
225
|
+
token: Address;
|
|
226
|
+
}) => Promise<string>;
|
|
227
|
+
};
|
|
228
|
+
export declare const gTokenActions: () => (client: PublicClient | WalletClient) => TokenActions;
|
|
229
|
+
export declare const tokenActions: () => (client: PublicClient | WalletClient) => TokenActions;
|