@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,211 @@
|
|
|
1
|
+
import { EntryPointABI } from '../abis/index.js';
|
|
2
|
+
export var EntryPointVersion;
|
|
3
|
+
(function (EntryPointVersion) {
|
|
4
|
+
EntryPointVersion["V06"] = "0.6";
|
|
5
|
+
EntryPointVersion["V07"] = "0.7";
|
|
6
|
+
})(EntryPointVersion || (EntryPointVersion = {}));
|
|
7
|
+
export const entryPointActions = (address, version = EntryPointVersion.V07) => (client) => ({
|
|
8
|
+
version,
|
|
9
|
+
async balanceOf({ account }) {
|
|
10
|
+
// v0.6 and v0.7 both use balanceOf(address)
|
|
11
|
+
return client.readContract({
|
|
12
|
+
address,
|
|
13
|
+
abi: [{ name: 'balanceOf', inputs: [{ type: 'address' }], outputs: [{ type: 'uint256' }], type: 'function', stateMutability: 'view' }],
|
|
14
|
+
functionName: 'balanceOf',
|
|
15
|
+
args: [account]
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
async depositTo({ account, amount, txAccount }) {
|
|
19
|
+
// v0.6 and v0.7 both use depositTo(address)
|
|
20
|
+
return client.writeContract({
|
|
21
|
+
address,
|
|
22
|
+
abi: [{ name: 'depositTo', type: 'function', inputs: [{ type: 'address' }], outputs: [], stateMutability: 'payable' }],
|
|
23
|
+
functionName: 'depositTo',
|
|
24
|
+
args: [account],
|
|
25
|
+
value: amount,
|
|
26
|
+
account: txAccount,
|
|
27
|
+
chain: client.chain
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
async getNonce({ sender, key }) {
|
|
31
|
+
if (version === EntryPointVersion.V06) {
|
|
32
|
+
// v0.6: getNonce(address, uint192)
|
|
33
|
+
return client.readContract({
|
|
34
|
+
address,
|
|
35
|
+
abi: [{ name: 'getNonce', type: 'function', inputs: [{ type: 'address', name: 'sender' }, { type: 'uint256', name: 'key' }], outputs: [{ type: 'uint256' }], stateMutability: 'view' }],
|
|
36
|
+
functionName: 'getNonce',
|
|
37
|
+
args: [sender, key]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// v0.7: getNonce(address, uint192) - Note: v0.7 actually uses 192 bit key but in ABI it's uint192
|
|
42
|
+
return client.readContract({
|
|
43
|
+
address,
|
|
44
|
+
abi: [{ name: 'getNonce', type: 'function', inputs: [{ type: 'address', name: 'sender' }, { type: 'uint192', name: 'key' }], outputs: [{ type: 'uint256' }], stateMutability: 'view' }],
|
|
45
|
+
functionName: 'getNonce',
|
|
46
|
+
args: [sender, key]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
async getDepositInfo({ account }) {
|
|
51
|
+
const result = await client.readContract({
|
|
52
|
+
address,
|
|
53
|
+
abi: [{
|
|
54
|
+
name: 'getDepositInfo',
|
|
55
|
+
type: 'function',
|
|
56
|
+
inputs: [{ type: 'address', name: 'account' }],
|
|
57
|
+
outputs: [
|
|
58
|
+
{ type: 'uint112', name: 'deposit' },
|
|
59
|
+
{ type: 'bool', name: 'staked' },
|
|
60
|
+
{ type: 'uint112', name: 'stake' },
|
|
61
|
+
{ type: 'uint32', name: 'unstakeDelaySec' },
|
|
62
|
+
{ type: 'uint48', name: 'withdrawTime' }
|
|
63
|
+
],
|
|
64
|
+
stateMutability: 'view'
|
|
65
|
+
}],
|
|
66
|
+
functionName: 'getDepositInfo',
|
|
67
|
+
args: [account]
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
deposit: result[0],
|
|
71
|
+
staked: result[1],
|
|
72
|
+
stake: result[2],
|
|
73
|
+
unstakeDelaySec: result[3],
|
|
74
|
+
withdrawTime: result[4]
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
async addStake({ unstakeDelaySec, amount, account }) {
|
|
78
|
+
return client.writeContract({
|
|
79
|
+
address,
|
|
80
|
+
abi: EntryPointABI,
|
|
81
|
+
functionName: 'addStake',
|
|
82
|
+
args: [unstakeDelaySec],
|
|
83
|
+
value: amount,
|
|
84
|
+
account: account,
|
|
85
|
+
chain: client.chain
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
async unlockStake({ account }) {
|
|
89
|
+
return client.writeContract({
|
|
90
|
+
address,
|
|
91
|
+
abi: EntryPointABI,
|
|
92
|
+
functionName: 'unlockStake',
|
|
93
|
+
args: [],
|
|
94
|
+
account: account,
|
|
95
|
+
chain: client.chain
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
async withdrawStake({ withdrawAddress, account }) {
|
|
99
|
+
return client.writeContract({
|
|
100
|
+
address,
|
|
101
|
+
abi: EntryPointABI,
|
|
102
|
+
functionName: 'withdrawStake',
|
|
103
|
+
args: [withdrawAddress],
|
|
104
|
+
account: account,
|
|
105
|
+
chain: client.chain
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
async withdrawTo({ withdrawAddress, amount, account }) {
|
|
109
|
+
return client.writeContract({
|
|
110
|
+
address,
|
|
111
|
+
abi: EntryPointABI,
|
|
112
|
+
functionName: 'withdrawTo',
|
|
113
|
+
args: [withdrawAddress, amount],
|
|
114
|
+
account: account,
|
|
115
|
+
chain: client.chain
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
async handleOps({ ops, beneficiary, account }) {
|
|
119
|
+
return client.writeContract({
|
|
120
|
+
address,
|
|
121
|
+
abi: EntryPointABI,
|
|
122
|
+
functionName: 'handleOps',
|
|
123
|
+
args: [ops, beneficiary],
|
|
124
|
+
account: account,
|
|
125
|
+
chain: client.chain
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
async handleAggregatedOps({ opsPerAggregator, beneficiary, account }) {
|
|
129
|
+
return client.writeContract({
|
|
130
|
+
address,
|
|
131
|
+
abi: EntryPointABI,
|
|
132
|
+
functionName: 'handleAggregatedOps',
|
|
133
|
+
args: [opsPerAggregator, beneficiary],
|
|
134
|
+
account: account,
|
|
135
|
+
chain: client.chain
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
async innerHandleOp({ callData, opInfo, context, account }) {
|
|
139
|
+
return client.writeContract({
|
|
140
|
+
address,
|
|
141
|
+
abi: EntryPointABI,
|
|
142
|
+
functionName: 'innerHandleOp',
|
|
143
|
+
args: [callData, opInfo, context],
|
|
144
|
+
account: account,
|
|
145
|
+
chain: client.chain
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
async delegateAndRevert({ target, data, account }) {
|
|
149
|
+
// This typically reverts, but we act as a writer
|
|
150
|
+
return client.writeContract({
|
|
151
|
+
address,
|
|
152
|
+
abi: EntryPointABI,
|
|
153
|
+
functionName: 'delegateAndRevert',
|
|
154
|
+
args: [target, data],
|
|
155
|
+
account: account,
|
|
156
|
+
chain: client.chain
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
async getUserOpHash({ op }) {
|
|
160
|
+
return client.readContract({
|
|
161
|
+
address,
|
|
162
|
+
abi: EntryPointABI,
|
|
163
|
+
functionName: 'getUserOpHash',
|
|
164
|
+
args: [op]
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
async getSenderAddress({ initCode }) {
|
|
168
|
+
// getSenderAddress usually reverts with the address. Viem might throw.
|
|
169
|
+
// But let's assume standard call first.
|
|
170
|
+
// Actually in EP v0.7 it might return if called off-chain or revert.
|
|
171
|
+
// We will try readContract.
|
|
172
|
+
try {
|
|
173
|
+
return await client.readContract({
|
|
174
|
+
address,
|
|
175
|
+
abi: EntryPointABI,
|
|
176
|
+
functionName: 'getSenderAddress',
|
|
177
|
+
args: [initCode]
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
// Extract address from error if needed, but for now just implementing the method call.
|
|
182
|
+
// Usually this method reverts with SenderAddressResult(address)
|
|
183
|
+
throw e;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
async senderCreator() {
|
|
187
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'senderCreator', args: [] });
|
|
188
|
+
},
|
|
189
|
+
async incrementNonce({ key, account }) {
|
|
190
|
+
return client.writeContract({ address, abi: EntryPointABI, functionName: 'incrementNonce', args: [key], account: account, chain: client.chain });
|
|
191
|
+
},
|
|
192
|
+
async nonceSequenceNumber({ sender, key }) {
|
|
193
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'nonceSequenceNumber', args: [sender, key] });
|
|
194
|
+
},
|
|
195
|
+
async supportsInterface({ interfaceId }) {
|
|
196
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'supportsInterface', args: [interfaceId] });
|
|
197
|
+
},
|
|
198
|
+
async eip712Domain() {
|
|
199
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'eip712Domain', args: [] });
|
|
200
|
+
},
|
|
201
|
+
async getCurrentUserOpHash() {
|
|
202
|
+
// View that returns 'bytes32'
|
|
203
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'getCurrentUserOpHash', args: [] });
|
|
204
|
+
},
|
|
205
|
+
async getDomainSeparatorV4() {
|
|
206
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'getDomainSeparatorV4', args: [] });
|
|
207
|
+
},
|
|
208
|
+
async getPackedUserOpTypeHash() {
|
|
209
|
+
return client.readContract({ address, abi: EntryPointABI, functionName: 'getPackedUserOpTypeHash', args: [] });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { parseEther } from 'viem';
|
|
3
|
+
import { entryPointActions, EntryPointVersion } from './entryPoint.js';
|
|
4
|
+
describe('EntryPoint Actions', () => {
|
|
5
|
+
const mockEntryPointAddress = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
|
|
6
|
+
const MOCK_USER = '0x1234567890123456789012345678901234567890';
|
|
7
|
+
let mockPublicClient;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockPublicClient = {
|
|
10
|
+
readContract: vi.fn(),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
describe('getDepositInfo', () => {
|
|
14
|
+
it('should get deposit info for account', async () => {
|
|
15
|
+
// EntryPoint returns array that gets destructured into object
|
|
16
|
+
const mockDepositArray = [
|
|
17
|
+
1000000000000000000n, // deposit
|
|
18
|
+
true, // staked
|
|
19
|
+
500000000000000000n, // stake
|
|
20
|
+
86400, // unstakeDelaySec
|
|
21
|
+
0 // withdrawTime
|
|
22
|
+
];
|
|
23
|
+
mockPublicClient.readContract.mockResolvedValue(mockDepositArray);
|
|
24
|
+
const account = '0x1234567890123456789012345678901234567890';
|
|
25
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
26
|
+
const depositInfo = await actions.getDepositInfo({ account });
|
|
27
|
+
expect(depositInfo.deposit).toBe(1000000000000000000n);
|
|
28
|
+
expect(depositInfo.staked).toBe(true);
|
|
29
|
+
expect(depositInfo.stake).toBe(500000000000000000n);
|
|
30
|
+
expect(depositInfo.unstakeDelaySec).toBe(86400);
|
|
31
|
+
expect(depositInfo.withdrawTime).toBe(0);
|
|
32
|
+
expect(mockPublicClient.readContract).toHaveBeenCalledWith(expect.objectContaining({
|
|
33
|
+
functionName: 'getDepositInfo',
|
|
34
|
+
args: [account],
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
it('should handle zero deposit', async () => {
|
|
38
|
+
const mockDepositArray = [0n, false, 0n, 0, 0];
|
|
39
|
+
mockPublicClient.readContract.mockResolvedValue(mockDepositArray);
|
|
40
|
+
const account = '0xabcd1234567890123456789012345678901234ab';
|
|
41
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
42
|
+
const depositInfo = await actions.getDepositInfo({ account });
|
|
43
|
+
expect(depositInfo.deposit).toBe(0n);
|
|
44
|
+
expect(depositInfo.staked).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('getNonce', () => {
|
|
48
|
+
it('should get nonce for sender with key', async () => {
|
|
49
|
+
const expectedNonce = 5n;
|
|
50
|
+
mockPublicClient.readContract.mockResolvedValue(expectedNonce);
|
|
51
|
+
const sender = '0x2222222222222222222222222222222222222222';
|
|
52
|
+
const key = 0n;
|
|
53
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
54
|
+
const nonce = await actions.getNonce({ sender, key });
|
|
55
|
+
expect(nonce).toBe(expectedNonce);
|
|
56
|
+
expect(mockPublicClient.readContract).toHaveBeenCalledWith(expect.objectContaining({
|
|
57
|
+
functionName: 'getNonce',
|
|
58
|
+
args: [sender, key],
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
it('should handle different key spaces', async () => {
|
|
62
|
+
const expectedNonce = 0n;
|
|
63
|
+
mockPublicClient.readContract.mockResolvedValue(expectedNonce);
|
|
64
|
+
const sender = '0x3333333333333333333333333333333333333333';
|
|
65
|
+
const key = 123n;
|
|
66
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
67
|
+
const nonce = await actions.getNonce({ sender, key });
|
|
68
|
+
expect(nonce).toBe(expectedNonce);
|
|
69
|
+
expect(mockPublicClient.readContract).toHaveBeenCalledWith(expect.objectContaining({
|
|
70
|
+
args: [sender, key],
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('balanceOf', () => {
|
|
75
|
+
it('should get balance of account', async () => {
|
|
76
|
+
const expectedBalance = 2000000000000000000n; // 2 ETH
|
|
77
|
+
mockPublicClient.readContract.mockResolvedValue(expectedBalance);
|
|
78
|
+
const account = '0x4444444444444444444444444444444444444444';
|
|
79
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
80
|
+
const balance = await actions.balanceOf({ account });
|
|
81
|
+
expect(balance).toBe(expectedBalance);
|
|
82
|
+
expect(mockPublicClient.readContract).toHaveBeenCalledWith(expect.objectContaining({
|
|
83
|
+
functionName: 'balanceOf',
|
|
84
|
+
args: [account],
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
it('should handle zero balance', async () => {
|
|
88
|
+
const expectedBalance = 0n;
|
|
89
|
+
mockPublicClient.readContract.mockResolvedValue(expectedBalance);
|
|
90
|
+
const account = '0x5555555555555555555555555555555555555555';
|
|
91
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
92
|
+
const balance = await actions.balanceOf({ account });
|
|
93
|
+
expect(balance).toBe(0n);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('Version Handling', () => {
|
|
97
|
+
it('should include version in actions', () => {
|
|
98
|
+
const actions = entryPointActions(mockEntryPointAddress, EntryPointVersion.V07)(mockPublicClient);
|
|
99
|
+
expect(actions.version).toBe(EntryPointVersion.V07);
|
|
100
|
+
});
|
|
101
|
+
it('should default to V07', () => {
|
|
102
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
103
|
+
expect(actions.version).toBe(EntryPointVersion.V07);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('Contract Address', () => {
|
|
107
|
+
it('should use provided contract address', async () => {
|
|
108
|
+
const customAddress = '0x6666666666666666666666666666666666666666';
|
|
109
|
+
mockPublicClient.readContract.mockResolvedValue(1n);
|
|
110
|
+
const account = '0x7777777777777777777777777777777777777777';
|
|
111
|
+
const actions = entryPointActions(customAddress)(mockPublicClient);
|
|
112
|
+
await actions.balanceOf({ account });
|
|
113
|
+
expect(mockPublicClient.readContract).toHaveBeenCalledWith(expect.objectContaining({
|
|
114
|
+
address: customAddress,
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('depositTo', () => {
|
|
119
|
+
it('should deposit to account', async () => {
|
|
120
|
+
const txHash = '0xhash';
|
|
121
|
+
mockPublicClient.writeContract = vi.fn().mockResolvedValue(txHash);
|
|
122
|
+
const actions = entryPointActions(mockEntryPointAddress)(mockPublicClient);
|
|
123
|
+
const result = await actions.depositTo({
|
|
124
|
+
account: MOCK_USER,
|
|
125
|
+
amount: parseEther('1'),
|
|
126
|
+
txAccount: MOCK_USER
|
|
127
|
+
});
|
|
128
|
+
expect(result).toBe(txHash);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
describe('getNonce V06', () => {
|
|
132
|
+
it('should get nonce for V06', async () => {
|
|
133
|
+
mockPublicClient.readContract.mockResolvedValue(10n);
|
|
134
|
+
const actions = entryPointActions(mockEntryPointAddress, EntryPointVersion.V06)(mockPublicClient);
|
|
135
|
+
const nonce = await actions.getNonce({ sender: MOCK_USER, key: 0n });
|
|
136
|
+
expect(nonce).toBe(10n);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
|
|
2
|
+
export type XPNTsFactoryActions = {
|
|
3
|
+
createToken: (args: {
|
|
4
|
+
name: string;
|
|
5
|
+
symbol: string;
|
|
6
|
+
community: Address;
|
|
7
|
+
account?: Account | Address;
|
|
8
|
+
}) => Promise<Hash>;
|
|
9
|
+
deployForCommunity: (args: {
|
|
10
|
+
community: Address;
|
|
11
|
+
account?: Account | Address;
|
|
12
|
+
}) => Promise<Hash>;
|
|
13
|
+
getTokenAddress: (args: {
|
|
14
|
+
community: Address;
|
|
15
|
+
}) => Promise<Address>;
|
|
16
|
+
predictAddress: (args: {
|
|
17
|
+
community: Address;
|
|
18
|
+
salt?: bigint;
|
|
19
|
+
}) => Promise<Address>;
|
|
20
|
+
isTokenDeployed: (args: {
|
|
21
|
+
community: Address;
|
|
22
|
+
}) => Promise<boolean>;
|
|
23
|
+
getCommunityByToken: (args: {
|
|
24
|
+
token: Address;
|
|
25
|
+
}) => Promise<Address>;
|
|
26
|
+
getAllTokens: () => Promise<Address[]>;
|
|
27
|
+
getTokenCount: () => Promise<bigint>;
|
|
28
|
+
deployedTokens: (args: {
|
|
29
|
+
index: bigint;
|
|
30
|
+
}) => Promise<Address>;
|
|
31
|
+
communityToToken: (args: {
|
|
32
|
+
community: Address;
|
|
33
|
+
}) => Promise<Address>;
|
|
34
|
+
setRegistry: (args: {
|
|
35
|
+
registry: Address;
|
|
36
|
+
account?: Account | Address;
|
|
37
|
+
}) => Promise<Hash>;
|
|
38
|
+
setSuperPaymaster: (args: {
|
|
39
|
+
paymaster: Address;
|
|
40
|
+
account?: Account | Address;
|
|
41
|
+
}) => Promise<Hash>;
|
|
42
|
+
setImplementation: (args: {
|
|
43
|
+
impl: Address;
|
|
44
|
+
account?: Account | Address;
|
|
45
|
+
}) => Promise<Hash>;
|
|
46
|
+
getImplementation: () => Promise<Address>;
|
|
47
|
+
REGISTRY: () => Promise<Address>;
|
|
48
|
+
SUPER_PAYMASTER: () => Promise<Address>;
|
|
49
|
+
tokenImplementation: () => Promise<Address>;
|
|
50
|
+
xPNTsFactoryOwner: () => Promise<Address>;
|
|
51
|
+
transferXPNTsFactoryOwnership: (args: {
|
|
52
|
+
newOwner: Address;
|
|
53
|
+
account?: Account | Address;
|
|
54
|
+
}) => Promise<Hash>;
|
|
55
|
+
renounceXPNTsFactoryOwnership: (args: {
|
|
56
|
+
account?: Account | Address;
|
|
57
|
+
}) => Promise<Hash>;
|
|
58
|
+
deployxPNTsToken: (args: {
|
|
59
|
+
name: string;
|
|
60
|
+
symbol: string;
|
|
61
|
+
community: Address;
|
|
62
|
+
account?: Account | Address;
|
|
63
|
+
}) => Promise<Hash>;
|
|
64
|
+
predictDepositAmount: (args: {
|
|
65
|
+
community: Address;
|
|
66
|
+
userCount: bigint;
|
|
67
|
+
}) => Promise<bigint>;
|
|
68
|
+
getPredictionParams: (args: {
|
|
69
|
+
community: Address;
|
|
70
|
+
}) => Promise<any>;
|
|
71
|
+
getDepositBreakdown: (args: {
|
|
72
|
+
community: Address;
|
|
73
|
+
}) => Promise<any>;
|
|
74
|
+
getAPNTsPrice: () => Promise<bigint>;
|
|
75
|
+
aPNTsPriceUSD: () => Promise<bigint>;
|
|
76
|
+
setIndustryMultiplier: (args: {
|
|
77
|
+
industry: string;
|
|
78
|
+
multiplier: bigint;
|
|
79
|
+
account?: Account | Address;
|
|
80
|
+
}) => Promise<Hash>;
|
|
81
|
+
setSuperPaymasterAddress: (args: {
|
|
82
|
+
paymaster: Address;
|
|
83
|
+
account?: Account | Address;
|
|
84
|
+
}) => Promise<Hash>;
|
|
85
|
+
updateAPNTsPrice: (args: {
|
|
86
|
+
newPrice: bigint;
|
|
87
|
+
account?: Account | Address;
|
|
88
|
+
}) => Promise<Hash>;
|
|
89
|
+
updatePrediction: (args: {
|
|
90
|
+
community: Address;
|
|
91
|
+
userCount: bigint;
|
|
92
|
+
account?: Account | Address;
|
|
93
|
+
}) => Promise<Hash>;
|
|
94
|
+
updatePredictionCustom: (args: {
|
|
95
|
+
community: Address;
|
|
96
|
+
params: any;
|
|
97
|
+
account?: Account | Address;
|
|
98
|
+
}) => Promise<Hash>;
|
|
99
|
+
hasToken: (args: {
|
|
100
|
+
token: Address;
|
|
101
|
+
}) => Promise<boolean>;
|
|
102
|
+
getDeployedCount: () => Promise<bigint>;
|
|
103
|
+
industryMultipliers: (args: {
|
|
104
|
+
industry: string;
|
|
105
|
+
}) => Promise<bigint>;
|
|
106
|
+
getIndustryMultiplier: (args: {
|
|
107
|
+
industry: string;
|
|
108
|
+
}) => Promise<bigint>;
|
|
109
|
+
predictions: (args: {
|
|
110
|
+
community: Address;
|
|
111
|
+
}) => Promise<any>;
|
|
112
|
+
MIN_SUGGESTED_AMOUNT: () => Promise<bigint>;
|
|
113
|
+
DEFAULT_SAFETY_FACTOR: () => Promise<bigint>;
|
|
114
|
+
SUPERPAYMASTER: () => Promise<Address>;
|
|
115
|
+
xPNTsFactoryVersion: () => Promise<string>;
|
|
116
|
+
};
|
|
117
|
+
export type PaymasterFactoryActions = {
|
|
118
|
+
deployPaymaster: (args: {
|
|
119
|
+
owner: Address;
|
|
120
|
+
version?: string;
|
|
121
|
+
initData?: Hex;
|
|
122
|
+
account?: Account | Address;
|
|
123
|
+
}) => Promise<Hash>;
|
|
124
|
+
deployPaymasterDeterministic: (args: {
|
|
125
|
+
owner: Address;
|
|
126
|
+
version?: string;
|
|
127
|
+
initData?: Hex;
|
|
128
|
+
salt: Hex;
|
|
129
|
+
account?: Account | Address;
|
|
130
|
+
}) => Promise<Hash>;
|
|
131
|
+
predictPaymasterAddress: (args: {
|
|
132
|
+
owner: Address;
|
|
133
|
+
salt: Hex;
|
|
134
|
+
}) => Promise<Address>;
|
|
135
|
+
calculateAddress: (args: {
|
|
136
|
+
owner: Address;
|
|
137
|
+
}) => Promise<Address>;
|
|
138
|
+
getPaymaster: (args: {
|
|
139
|
+
owner: Address;
|
|
140
|
+
}) => Promise<Address>;
|
|
141
|
+
getPaymasterCount: () => Promise<bigint>;
|
|
142
|
+
getAllPaymasters: () => Promise<Address[]>;
|
|
143
|
+
isPaymasterDeployed: (args: {
|
|
144
|
+
owner: Address;
|
|
145
|
+
}) => Promise<boolean>;
|
|
146
|
+
hasPaymaster: (args: {
|
|
147
|
+
owner: Address;
|
|
148
|
+
}) => Promise<boolean>;
|
|
149
|
+
getPaymasterList: (args: {
|
|
150
|
+
offset: bigint;
|
|
151
|
+
limit: bigint;
|
|
152
|
+
}) => Promise<Address[]>;
|
|
153
|
+
paymasterList: (args: {
|
|
154
|
+
index: bigint;
|
|
155
|
+
}) => Promise<Address>;
|
|
156
|
+
totalDeployed: () => Promise<bigint>;
|
|
157
|
+
getOperatorByPaymaster: (args: {
|
|
158
|
+
paymaster: Address;
|
|
159
|
+
}) => Promise<Address>;
|
|
160
|
+
operatorByPaymaster: (args: {
|
|
161
|
+
paymaster: Address;
|
|
162
|
+
}) => Promise<Address>;
|
|
163
|
+
getPaymasterByOperator: (args: {
|
|
164
|
+
operator: Address;
|
|
165
|
+
}) => Promise<Address>;
|
|
166
|
+
paymasterByOperator: (args: {
|
|
167
|
+
operator: Address;
|
|
168
|
+
}) => Promise<Address>;
|
|
169
|
+
getPaymasterInfo: (args: {
|
|
170
|
+
paymaster: Address;
|
|
171
|
+
}) => Promise<any>;
|
|
172
|
+
hasImplementation: (args: {
|
|
173
|
+
version: string;
|
|
174
|
+
}) => Promise<boolean>;
|
|
175
|
+
implementations: (args: {
|
|
176
|
+
version: string;
|
|
177
|
+
}) => Promise<Address>;
|
|
178
|
+
setImplementationV4: (args: {
|
|
179
|
+
impl: Address;
|
|
180
|
+
account?: Account | Address;
|
|
181
|
+
}) => Promise<Hash>;
|
|
182
|
+
getImplementationV4: () => Promise<Address>;
|
|
183
|
+
setRegistry: (args: {
|
|
184
|
+
registry: Address;
|
|
185
|
+
account?: Account | Address;
|
|
186
|
+
}) => Promise<Hash>;
|
|
187
|
+
addImplementation: (args: {
|
|
188
|
+
version: string;
|
|
189
|
+
implementation: Address;
|
|
190
|
+
account?: Account | Address;
|
|
191
|
+
}) => Promise<Hash>;
|
|
192
|
+
upgradeImplementation: (args: {
|
|
193
|
+
version: string;
|
|
194
|
+
newImplementation: Address;
|
|
195
|
+
account?: Account | Address;
|
|
196
|
+
}) => Promise<Hash>;
|
|
197
|
+
setDefaultVersion: (args: {
|
|
198
|
+
version: string;
|
|
199
|
+
account?: Account | Address;
|
|
200
|
+
}) => Promise<Hash>;
|
|
201
|
+
REGISTRY: () => Promise<Address>;
|
|
202
|
+
ENTRY_POINT: () => Promise<Address>;
|
|
203
|
+
paymasterFactoryOwner: () => Promise<Address>;
|
|
204
|
+
transferPaymasterFactoryOwnership: (args: {
|
|
205
|
+
newOwner: Address;
|
|
206
|
+
account?: Account | Address;
|
|
207
|
+
}) => Promise<Hash>;
|
|
208
|
+
renouncePaymasterFactoryOwnership: (args: {
|
|
209
|
+
account?: Account | Address;
|
|
210
|
+
}) => Promise<Hash>;
|
|
211
|
+
defaultVersion: () => Promise<string>;
|
|
212
|
+
paymasterFactoryVersion: () => Promise<string>;
|
|
213
|
+
};
|
|
214
|
+
export declare const xPNTsFactoryActions: (address: Address) => (client: PublicClient | WalletClient) => XPNTsFactoryActions;
|
|
215
|
+
export declare const paymasterFactoryActions: (address: Address) => (client: PublicClient | WalletClient) => PaymasterFactoryActions;
|