@aastar/sdk 0.16.23 → 0.17.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 (57) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +2 -0
  3. package/package.json +11 -10
  4. package/dist/clients/ExperimentClient.test.d.ts +0 -1
  5. package/dist/clients/ExperimentClient.test.js +0 -53
  6. package/dist/clients/admin.test.d.ts +0 -1
  7. package/dist/clients/admin.test.js +0 -79
  8. package/dist/clients/clients.test.d.ts +0 -1
  9. package/dist/clients/clients.test.js +0 -91
  10. package/dist/clients/community.test.d.ts +0 -1
  11. package/dist/clients/community.test.js +0 -99
  12. package/dist/clients/endUser.test.d.ts +0 -1
  13. package/dist/clients/endUser.test.js +0 -188
  14. package/dist/clients/operator.test.d.ts +0 -1
  15. package/dist/clients/operator.test.js +0 -139
  16. package/dist/core/src/abis/BLSAggregator.json +0 -686
  17. package/dist/core/src/abis/BLSValidator.json +0 -42
  18. package/dist/core/src/abis/DVTValidator.json +0 -368
  19. package/dist/core/src/abis/EntryPoint.json +0 -1382
  20. package/dist/core/src/abis/GToken.json +0 -513
  21. package/dist/core/src/abis/GTokenStaking.json +0 -949
  22. package/dist/core/src/abis/MySBT.json +0 -1518
  23. package/dist/core/src/abis/Paymaster.json +0 -1143
  24. package/dist/core/src/abis/PaymasterFactory.json +0 -640
  25. package/dist/core/src/abis/Registry.json +0 -1942
  26. package/dist/core/src/abis/ReputationSystem.json +0 -699
  27. package/dist/core/src/abis/SimpleAccount.json +0 -560
  28. package/dist/core/src/abis/SimpleAccountFactory.json +0 -111
  29. package/dist/core/src/abis/SuperPaymaster.json +0 -1781
  30. package/dist/core/src/abis/xPNTsFactory.json +0 -718
  31. package/dist/core/src/abis/xPNTsToken.json +0 -1280
  32. package/dist/errors/AAStarError.d.ts +0 -26
  33. package/dist/errors/AAStarError.js +0 -32
  34. package/dist/errors/AAStarError.test.d.ts +0 -1
  35. package/dist/errors/AAStarError.test.js +0 -74
  36. package/dist/errors/decoder.test.d.ts +0 -1
  37. package/dist/errors/decoder.test.js +0 -90
  38. package/dist/node/index.d.ts +0 -7
  39. package/dist/node/index.js +0 -7
  40. package/dist/types/result.d.ts +0 -15
  41. package/dist/types/result.js +0 -23
  42. package/dist/utils/errorHandler.test.d.ts +0 -1
  43. package/dist/utils/errorHandler.test.js +0 -89
  44. package/dist/utils/eventDecoder.d.ts +0 -7
  45. package/dist/utils/eventDecoder.js +0 -54
  46. package/dist/utils/eventDecoder.test.d.ts +0 -1
  47. package/dist/utils/eventDecoder.test.js +0 -48
  48. package/dist/utils/funding.test.d.ts +0 -1
  49. package/dist/utils/funding.test.js +0 -105
  50. package/dist/utils/keys.test.d.ts +0 -1
  51. package/dist/utils/keys.test.js +0 -81
  52. package/dist/utils/roleData.test.d.ts +0 -1
  53. package/dist/utils/roleData.test.js +0 -74
  54. package/dist/utils/testScenarios.test.d.ts +0 -1
  55. package/dist/utils/testScenarios.test.js +0 -68
  56. package/dist/utils/userOp.test.d.ts +0 -1
  57. package/dist/utils/userOp.test.js +0 -152
@@ -1,139 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { createOperatorClient } from './operator.js';
3
- import { mainnet } from 'viem/chains';
4
- import { http, keccak256, stringToBytes } from 'viem';
5
- vi.mock('@aastar/core', async () => {
6
- const actual = await vi.importActual('@aastar/core');
7
- return {
8
- ...actual,
9
- registryActions: vi.fn(() => vi.fn(() => ({
10
- registryHasRole: vi.fn().mockResolvedValue(false),
11
- registryRegisterRoleSelf: vi.fn().mockResolvedValue('0xhash')
12
- }))),
13
- stakingActions: vi.fn(() => vi.fn(() => ({
14
- // any staking methods if needed
15
- }))),
16
- superPaymasterActions: vi.fn(() => vi.fn(() => ({
17
- superPaymasterDepositFor: vi.fn().mockResolvedValue('0xhash'),
18
- superPaymasterOperators: vi.fn().mockResolvedValue([1000n, 1000n, true, false]),
19
- superPaymasterGetDeposit: vi.fn().mockResolvedValue(555n)
20
- }))),
21
- paymasterV4Actions: vi.fn(() => vi.fn(() => ({
22
- // pmv4 methods
23
- }))),
24
- tokenActions: vi.fn(() => vi.fn(() => ({
25
- tokenApprove: vi.fn().mockResolvedValue('0xhash')
26
- }))),
27
- };
28
- });
29
- describe('OperatorClient', () => {
30
- const MOCK_ADDR = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
31
- it('should create operator client', () => {
32
- const client = createOperatorClient({ chain: mainnet, transport: http() });
33
- expect(client.setup).toBeDefined();
34
- });
35
- describe('onboardFully', () => {
36
- it('should complete onboarding flow', async () => {
37
- const client = createOperatorClient({
38
- chain: mainnet,
39
- transport: http(),
40
- account: { address: MOCK_ADDR }
41
- });
42
- // Mock base client methods
43
- client.readContract = vi.fn().mockResolvedValue([0n, 0n, 0n]);
44
- client.waitForTransactionReceipt = vi.fn().mockResolvedValue({ logs: [] });
45
- const results = await client.onboardFully({
46
- stakeAmount: 100n,
47
- depositAmount: 200n,
48
- roleId: keccak256(stringToBytes('PAYMASTER_SUPER'))
49
- });
50
- expect(results).toHaveLength(3);
51
- expect(client.tokenApprove).toHaveBeenCalled();
52
- expect(client.registryRegisterRoleSelf).toHaveBeenCalled();
53
- expect(client.superPaymasterDepositFor).toHaveBeenCalled();
54
- });
55
- });
56
- describe('Advanced Setup', () => {
57
- it('should call configureOperator', async () => {
58
- const client = createOperatorClient({ chain: mainnet, transport: http() });
59
- client.configureOperator = vi.fn().mockResolvedValue('0xhash');
60
- const hash = await client.configureOperator({
61
- xPNTsToken: MOCK_ADDR,
62
- treasury: MOCK_ADDR,
63
- exchangeRate: 100n
64
- });
65
- expect(hash).toBe('0xhash');
66
- });
67
- it('should onboard to Super Paymaster', async () => {
68
- const client = createOperatorClient({
69
- chain: mainnet,
70
- transport: http(),
71
- account: { address: MOCK_ADDR }
72
- });
73
- client.onboardFully = vi.fn().mockResolvedValue([]);
74
- // onboardToSuperPaymaster is an internal action alias in OperatorClient
75
- await client.onboardToSuperPaymaster({ stakeAmount: 100n, depositAmount: 200n, roleId: '0x1' });
76
- expect(client.onboardFully).toHaveBeenCalled();
77
- });
78
- it('should deploy PaymasterV4', async () => {
79
- const client = createOperatorClient({ chain: mainnet, transport: http(), account: { address: MOCK_ADDR } });
80
- client.writeContract = vi.fn().mockResolvedValue('0xdeployhash');
81
- client.waitForTransactionReceipt = vi.fn().mockResolvedValue({});
82
- const hash = await client.deployPaymasterV4({ version: 'v4.2' });
83
- expect(hash).toBe('0xdeployhash');
84
- });
85
- it('should validate inputs in configureOperator', async () => {
86
- const opClient = createOperatorClient({
87
- account: { address: MOCK_ADDR },
88
- chain: mainnet,
89
- transport: http()
90
- });
91
- // No need to mock internal configureOperator for validation testing
92
- // as validation happens before internal call.
93
- await expect(opClient.configureOperator({
94
- xPNTsToken: '0xInvalid',
95
- treasury: '0x123',
96
- exchangeRate: 100n
97
- })).rejects.toThrow('xPNTs Token must be a valid Ethereum address');
98
- await expect(opClient.configureOperator({
99
- xPNTsToken: MOCK_ADDR,
100
- treasury: '0xInvalid',
101
- exchangeRate: 100n
102
- })).rejects.toThrow('Treasury must be a valid Ethereum address');
103
- });
104
- it('should check readiness', async () => {
105
- const opClient = createOperatorClient({
106
- account: { address: MOCK_ADDR },
107
- chain: mainnet,
108
- transport: http()
109
- });
110
- // Global mock for registryActions.hasRole returns false
111
- // Global mock for superPaymasterActions.operators returns [1000n, 1000n, true, false]
112
- const status = await opClient.checkReadiness();
113
- expect(status.isRegistered).toBe(false); // mocked val
114
- expect(status.isConfigured).toBe(true); // mocked val (index 2)
115
- expect(status.collateralBalance).toBe(1000n); // mocked val (index 0)
116
- });
117
- });
118
- describe('Operator Status and Queries', () => {
119
- it('should get operator status', async () => {
120
- const client = createOperatorClient({ chain: mainnet, transport: http() });
121
- client.readContract = vi.fn()
122
- .mockResolvedValueOnce(true) // hasRole
123
- .mockResolvedValueOnce([1000n, 100n, true, false, 0n, 0n, MOCK_ADDR]); // operator data
124
- const status = await client.getOperatorStatus(MOCK_ADDR);
125
- expect(status.type).toBe('super');
126
- expect(status.superPaymaster?.isConfigured).toBe(true);
127
- });
128
- it('should check if address is operator', async () => {
129
- const client = createOperatorClient({ chain: mainnet, transport: http() });
130
- const result = await client.isOperator(MOCK_ADDR);
131
- expect(result).toBe(true); // from mocked operators
132
- });
133
- it('should get deposit details', async () => {
134
- const client = createOperatorClient({ chain: mainnet, transport: http() });
135
- const details = await client.getDepositDetails();
136
- expect(details.deposit).toBe(555n); // from mocked getDeposit
137
- });
138
- });
139
- });