@thalalabs/surf 0.0.12 → 0.0.14

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 (105) hide show
  1. package/.changeset/README.md +1 -1
  2. package/.github/dependabot.yml +3 -3
  3. package/.github/workflows/publish.yml +2 -2
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +22 -11
  6. package/build/cjs/abi/aggregator.js +56 -74
  7. package/build/cjs/abi/aggregator.js.map +1 -1
  8. package/build/cjs/abi/aptos_coin.js +98 -125
  9. package/build/cjs/abi/aptos_coin.js.map +1 -1
  10. package/build/cjs/abi/coin.js +456 -587
  11. package/build/cjs/abi/coin.js.map +1 -1
  12. package/build/cjs/abi/event.js +66 -106
  13. package/build/cjs/abi/event.js.map +1 -1
  14. package/build/cjs/abi/fixed_point64.js +287 -320
  15. package/build/cjs/abi/fixed_point64.js.map +1 -1
  16. package/build/cjs/abi/guid.js +84 -129
  17. package/build/cjs/abi/guid.js.map +1 -1
  18. package/build/cjs/abi/optional_aggregator.js +79 -108
  19. package/build/cjs/abi/optional_aggregator.js.map +1 -1
  20. package/build/cjs/abi/table.js +131 -222
  21. package/build/cjs/abi/table.js.map +1 -1
  22. package/build/cjs/core/Client.js +6 -2
  23. package/build/cjs/core/Client.js.map +1 -1
  24. package/build/cjs/core/createEntryPayload.js.map +1 -1
  25. package/build/cjs/core/index.js +1 -3
  26. package/build/cjs/core/index.js.map +1 -1
  27. package/build/cjs/ensureTypes.js +11 -10
  28. package/build/cjs/ensureTypes.js.map +1 -1
  29. package/build/cjs/hooks/useWalletClient.js +2 -2
  30. package/build/cjs/hooks/useWalletClient.js.map +1 -1
  31. package/build/cjs/index.js.map +1 -1
  32. package/build/esm/abi/aggregator.js +56 -74
  33. package/build/esm/abi/aggregator.js.map +1 -1
  34. package/build/esm/abi/aptos_coin.js +98 -125
  35. package/build/esm/abi/aptos_coin.js.map +1 -1
  36. package/build/esm/abi/coin.js +456 -587
  37. package/build/esm/abi/coin.js.map +1 -1
  38. package/build/esm/abi/event.js +66 -106
  39. package/build/esm/abi/event.js.map +1 -1
  40. package/build/esm/abi/fixed_point64.js +287 -320
  41. package/build/esm/abi/fixed_point64.js.map +1 -1
  42. package/build/esm/abi/guid.js +84 -129
  43. package/build/esm/abi/guid.js.map +1 -1
  44. package/build/esm/abi/optional_aggregator.js +79 -108
  45. package/build/esm/abi/optional_aggregator.js.map +1 -1
  46. package/build/esm/abi/table.js +131 -222
  47. package/build/esm/abi/table.js.map +1 -1
  48. package/build/esm/core/Client.js +6 -2
  49. package/build/esm/core/Client.js.map +1 -1
  50. package/build/esm/core/createEntryPayload.js.map +1 -1
  51. package/build/esm/core/index.js +0 -1
  52. package/build/esm/core/index.js.map +1 -1
  53. package/build/esm/ensureTypes.js +11 -10
  54. package/build/esm/ensureTypes.js.map +1 -1
  55. package/build/esm/hooks/useWalletClient.js +2 -2
  56. package/build/esm/hooks/useWalletClient.js.map +1 -1
  57. package/build/esm/index.js +1 -1
  58. package/build/esm/index.js.map +1 -1
  59. package/build/types/abi/aggregator.d.ts.map +1 -1
  60. package/build/types/abi/aptos_coin.d.ts.map +1 -1
  61. package/build/types/abi/coin.d.ts.map +1 -1
  62. package/build/types/abi/event.d.ts.map +1 -1
  63. package/build/types/abi/fixed_point64.d.ts.map +1 -1
  64. package/build/types/abi/guid.d.ts.map +1 -1
  65. package/build/types/abi/optional_aggregator.d.ts.map +1 -1
  66. package/build/types/abi/table.d.ts.map +1 -1
  67. package/build/types/core/Client.d.ts.map +1 -1
  68. package/build/types/core/index.d.ts +0 -1
  69. package/build/types/core/index.d.ts.map +1 -1
  70. package/build/types/ensureTypes.d.ts.map +1 -1
  71. package/build/types/hooks/useWalletClient.d.ts +2 -2
  72. package/build/types/hooks/useWalletClient.d.ts.map +1 -1
  73. package/build/types/index.d.ts +2 -2
  74. package/build/types/index.d.ts.map +1 -1
  75. package/build/types/types/client/abiClient.d.ts +2 -0
  76. package/build/types/types/client/abiClient.d.ts.map +1 -1
  77. package/build/types/types/convertor/argsConvertor.d.ts +1 -1
  78. package/build/types/types/convertor/argsConvertor.d.ts.map +1 -1
  79. package/build/types/types/convertor/structConvertor.d.ts.map +1 -1
  80. package/build/types/types/moveTypes.d.ts.map +1 -1
  81. package/package.json +4 -4
  82. package/src/abi/aggregator.ts +73 -91
  83. package/src/abi/aptos_coin.ts +117 -144
  84. package/src/abi/coin.ts +646 -777
  85. package/src/abi/event.ts +83 -123
  86. package/src/abi/fixed_point64.ts +340 -373
  87. package/src/abi/guid.ts +102 -147
  88. package/src/abi/optional_aggregator.ts +103 -132
  89. package/src/abi/table.ts +181 -272
  90. package/src/core/Client.ts +6 -1
  91. package/src/core/__tests__/accountResource.test.ts +54 -14
  92. package/src/core/__tests__/createEntryPayload.test.ts +244 -250
  93. package/src/core/__tests__/createViewPayload.test.ts +44 -58
  94. package/src/core/__tests__/option.test.ts +1 -1
  95. package/src/core/__tests__/useABI.test.ts +72 -63
  96. package/src/core/__tests__/view.test.ts +76 -60
  97. package/src/core/createEntryPayload.ts +4 -3
  98. package/src/core/index.ts +0 -1
  99. package/src/ensureTypes.ts +31 -28
  100. package/src/hooks/useWalletClient.ts +2 -2
  101. package/src/index.ts +8 -8
  102. package/src/types/client/abiClient.ts +2 -0
  103. package/src/types/convertor/argsConvertor.ts +1 -1
  104. package/src/types/convertor/structConvertor.ts +16 -15
  105. package/src/types/moveTypes.ts +5 -1
@@ -1,281 +1,275 @@
1
- import { COIN_ABI } from "../../abi/coin";
2
- import { createEntryPayload } from "../createEntryPayload";
1
+ import { COIN_ABI } from '../../abi/coin';
2
+ import { createEntryPayload } from '../createEntryPayload';
3
3
 
4
4
  // TODO: add vector of vector, vector
5
5
  describe('createEntryPayload', () => {
6
- // Act before assertions
7
- beforeAll(async () => { });
6
+ // Act before assertions
7
+ beforeAll(async () => {});
8
8
 
9
- // Teardown (cleanup) after assertions
10
- afterAll(() => { });
9
+ // Teardown (cleanup) after assertions
10
+ afterAll(() => {});
11
11
 
12
- it('basic type checking', async () => {
13
- // no need to run, type check only.
14
- () => {
15
- createEntryPayload(COIN_ABI, {
16
- // @ts-expect-error abc is not a function
17
- function: 'abc',
18
- arguments: ['0x1', 1],
19
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
20
- });
12
+ it('basic type checking', async () => {
13
+ // no need to run, type check only.
14
+ () => {
15
+ createEntryPayload(COIN_ABI, {
16
+ // @ts-expect-error abc is not a function
17
+ function: 'abc',
18
+ arguments: ['0x1', 1],
19
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
20
+ });
21
21
 
22
- createEntryPayload(COIN_ABI, {
23
- // @ts-expect-error balance is not a view function
24
- function: 'balance',
25
- arguments: ['0x1', 1],
26
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
27
- });
22
+ createEntryPayload(COIN_ABI, {
23
+ // @ts-expect-error balance is not a view function
24
+ function: 'balance',
25
+ arguments: ['0x1', 1],
26
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
27
+ });
28
28
 
29
- createEntryPayload(COIN_ABI, {
30
- function: 'transfer',
31
- // @ts-expect-error require a address type
32
- arguments: [1, 1],
33
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
34
- });
29
+ createEntryPayload(COIN_ABI, {
30
+ function: 'transfer',
31
+ // @ts-expect-error require a address type
32
+ arguments: [1, 1],
33
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
34
+ });
35
35
 
36
- createEntryPayload(COIN_ABI, {
37
- function: 'transfer',
38
- // @ts-expect-error require 2 args
39
- arguments: ['0x1', 1, 1],
40
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
41
- });
36
+ createEntryPayload(COIN_ABI, {
37
+ function: 'transfer',
38
+ // @ts-expect-error require 2 args
39
+ arguments: ['0x1', 1, 1],
40
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
41
+ });
42
42
 
43
- createEntryPayload(COIN_ABI, {
44
- function: 'transfer',
45
- arguments: ['0x1', 1],
46
- // @ts-expect-error require a type_argument
47
- type_arguments: [],
48
- });
43
+ createEntryPayload(COIN_ABI, {
44
+ function: 'transfer',
45
+ arguments: ['0x1', 1],
46
+ // @ts-expect-error require a type_argument
47
+ type_arguments: [],
48
+ });
49
49
 
50
- createEntryPayload(COIN_ABI, {
51
- function: 'transfer',
52
- arguments: ['0x1', 1],
53
- type_arguments: ['0x1::aptos_coin::AptosCoin'],
54
- });
55
- }
56
- });
57
-
58
- it('number', async () => {
59
- createEntryPayload(TEST_ABI, {
60
- function: 'number_as_input',
61
- arguments: [1, 2, 3, BigInt(4), BigInt(5), BigInt(6)],
62
- type_arguments: [],
63
- });
50
+ createEntryPayload(COIN_ABI, {
51
+ function: 'transfer',
52
+ arguments: ['0x1', 1],
53
+ type_arguments: ['0x1::aptos_coin::AptosCoin'],
54
+ });
55
+ };
56
+ });
64
57
 
65
- // no need to run, type check only.
66
- () => {
67
- createEntryPayload(TEST_ABI, {
68
- function: 'number_as_input',
69
- arguments: [
70
- // @ts-expect-error the input type for u8 should be number, not bigint
71
- BigInt(1),
72
- // @ts-expect-error the input type for u16 should be number, not bigint
73
- BigInt(2),
74
- // @ts-expect-error the input type for u32 should be number, not bigint
75
- BigInt(2),
76
- BigInt(4), BigInt(5), BigInt(6)],
77
- type_arguments: [],
78
- });
79
- }
58
+ it('number', async () => {
59
+ createEntryPayload(TEST_ABI, {
60
+ function: 'number_as_input',
61
+ arguments: [1, 2, 3, BigInt(4), BigInt(5), BigInt(6)],
62
+ type_arguments: [],
80
63
  });
81
64
 
82
- it('bool', async () => {
83
- createEntryPayload(TEST_ABI, {
84
- function: 'bool_as_input',
85
- arguments: [true, false],
86
- type_arguments: [],
87
- });
65
+ // no need to run, type check only.
66
+ () => {
67
+ createEntryPayload(TEST_ABI, {
68
+ function: 'number_as_input',
69
+ arguments: [
70
+ // @ts-expect-error the input type for u8 should be number, not bigint
71
+ BigInt(1),
72
+ // @ts-expect-error the input type for u16 should be number, not bigint
73
+ BigInt(2),
74
+ // @ts-expect-error the input type for u32 should be number, not bigint
75
+ BigInt(2),
76
+ BigInt(4),
77
+ BigInt(5),
78
+ BigInt(6),
79
+ ],
80
+ type_arguments: [],
81
+ });
82
+ };
83
+ });
88
84
 
89
- // no need to run, type check only.
90
- () => {
91
- createEntryPayload(TEST_ABI, {
92
- function: 'bool_as_input',
93
- arguments: [
94
- // @ts-expect-error invalid bool
95
- 1,
96
- // @ts-expect-error invalid bool
97
- 'true',
98
- ],
99
- type_arguments: [],
100
- });
101
-
102
- }
85
+ it('bool', async () => {
86
+ createEntryPayload(TEST_ABI, {
87
+ function: 'bool_as_input',
88
+ arguments: [true, false],
89
+ type_arguments: [],
103
90
  });
104
91
 
105
- it('address', async () => {
106
- createEntryPayload(TEST_ABI, {
107
- function: 'address_as_input',
108
- arguments: ['0x1', '0x2'],
109
- type_arguments: [],
110
- });
92
+ // no need to run, type check only.
93
+ () => {
94
+ createEntryPayload(TEST_ABI, {
95
+ function: 'bool_as_input',
96
+ arguments: [
97
+ // @ts-expect-error invalid bool
98
+ 1,
99
+ // @ts-expect-error invalid bool
100
+ 'true',
101
+ ],
102
+ type_arguments: [],
103
+ });
104
+ };
105
+ });
111
106
 
112
- // no need to run, type check only.
113
- () => {
114
- createEntryPayload(TEST_ABI, {
115
- function: 'address_as_input',
116
- arguments: [
117
- // @ts-expect-error invalid address
118
- 1,
119
- // @ts-expect-error invalid address
120
- '1',
121
- ],
122
- type_arguments: [],
123
- });
124
- }
107
+ it('address', async () => {
108
+ createEntryPayload(TEST_ABI, {
109
+ function: 'address_as_input',
110
+ arguments: ['0x1', '0x2'],
111
+ type_arguments: [],
125
112
  });
126
113
 
127
- it('vector', async () => {
128
- createEntryPayload(TEST_ABI, {
129
- function: 'vector_as_input',
130
- arguments: [
131
- [],
132
- [1, 2, 3],
133
- [BigInt(1), BigInt(2), BigInt(3)],
134
- [true, false, true],
135
- ['0x1', '0x2', '0x3']
136
- ],
137
- type_arguments: [],
138
- });
114
+ // no need to run, type check only.
115
+ () => {
116
+ createEntryPayload(TEST_ABI, {
117
+ function: 'address_as_input',
118
+ arguments: [
119
+ // @ts-expect-error invalid address
120
+ 1,
121
+ // @ts-expect-error invalid address
122
+ '1',
123
+ ],
124
+ type_arguments: [],
125
+ });
126
+ };
127
+ });
139
128
 
140
- // no need to run, type check only.
141
- () => {
142
- createEntryPayload(TEST_ABI, {
143
- function: 'vector_as_input',
144
- arguments: [
145
- // @ts-expect-error invalid vector<u8>
146
- [1, 2, '3'],
147
- // @ts-expect-error invalid vector<u16>
148
- [1, 2, '3'],
149
- // @ts-expect-error invalid vector<u64>
150
- true,
151
- // @ts-expect-error invalid vector<bool>
152
- [true, false, 1],
153
- // @ts-expect-error invalid vector<address>
154
- ['0x1', '0x2', 1],
155
- ],
156
- type_arguments: [],
157
- });
158
- }
129
+ it('vector', async () => {
130
+ createEntryPayload(TEST_ABI, {
131
+ function: 'vector_as_input',
132
+ arguments: [
133
+ [],
134
+ [1, 2, 3],
135
+ [BigInt(1), BigInt(2), BigInt(3)],
136
+ [true, false, true],
137
+ ['0x1', '0x2', '0x3'],
138
+ ],
139
+ type_arguments: [],
159
140
  });
160
141
 
161
- it('vector of vector', async () => {
162
- createEntryPayload(TEST_ABI, {
163
- function: 'vector_of_vector_as_input',
164
- arguments: [
165
- [[1, 2], [3, 4], [5, 6]],
166
- [['0x1', '0x2'], ['0x3', '0x4'], ['0x5', '0x6']]
167
- ],
168
- type_arguments: [],
169
- });
142
+ // no need to run, type check only.
143
+ () => {
144
+ createEntryPayload(TEST_ABI, {
145
+ function: 'vector_as_input',
146
+ arguments: [
147
+ // @ts-expect-error invalid vector<u8>
148
+ [1, 2, '3'],
149
+ // @ts-expect-error invalid vector<u16>
150
+ [1, 2, '3'],
151
+ // @ts-expect-error invalid vector<u64>
152
+ true,
153
+ // @ts-expect-error invalid vector<bool>
154
+ [true, false, 1],
155
+ // @ts-expect-error invalid vector<address>
156
+ ['0x1', '0x2', 1],
157
+ ],
158
+ type_arguments: [],
159
+ });
160
+ };
161
+ });
170
162
 
171
- // no need to run, type check only.
172
- () => {
173
- createEntryPayload(TEST_ABI, {
174
- function: 'vector_of_vector_as_input',
175
- arguments: [
176
- // @ts-expect-error invalid vector<vector<u8>>
177
- [[], 1, 2, '3'],
178
- // @ts-expect-error invalid vector<vector<address>>
179
- [[], 1, 2, '3'],
180
- ],
181
- type_arguments: [],
182
- });
183
- }
163
+ it('vector of vector', async () => {
164
+ createEntryPayload(TEST_ABI, {
165
+ function: 'vector_of_vector_as_input',
166
+ arguments: [
167
+ [
168
+ [1, 2],
169
+ [3, 4],
170
+ [5, 6],
171
+ ],
172
+ [
173
+ ['0x1', '0x2'],
174
+ ['0x3', '0x4'],
175
+ ['0x5', '0x6'],
176
+ ],
177
+ ],
178
+ type_arguments: [],
184
179
  });
185
180
 
186
- it('0x1::object::Object', async () => {
187
- createEntryPayload(TEST_ABI, {
188
- function: 'object_as_input',
189
- arguments: ["0x123456"],
190
- type_arguments: [],
191
- });
181
+ // no need to run, type check only.
182
+ () => {
183
+ createEntryPayload(TEST_ABI, {
184
+ function: 'vector_of_vector_as_input',
185
+ arguments: [
186
+ // @ts-expect-error invalid vector<vector<u8>>
187
+ [[], 1, 2, '3'],
188
+ // @ts-expect-error invalid vector<vector<address>>
189
+ [[], 1, 2, '3'],
190
+ ],
191
+ type_arguments: [],
192
+ });
193
+ };
194
+ });
195
+
196
+ it('0x1::object::Object', async () => {
197
+ createEntryPayload(TEST_ABI, {
198
+ function: 'object_as_input',
199
+ arguments: ['0x123456'],
200
+ type_arguments: [],
192
201
  });
202
+ });
193
203
  });
194
204
 
195
205
  const TEST_ABI = {
196
- "address": "0x123",
197
- "name": "test",
198
- "friends": [],
199
- "exposed_functions": [
200
- {
201
- "name": "address_as_input",
202
- "visibility": "public",
203
- "is_entry": true,
204
- "is_view": false,
205
- "generic_type_params": [],
206
- "params": [
207
- "address",
208
- "address",
209
- ],
210
- "return": []
211
- },
212
- {
213
- "name": "bool_as_input",
214
- "visibility": "public",
215
- "is_entry": true,
216
- "is_view": false,
217
- "generic_type_params": [],
218
- "params": [
219
- "bool",
220
- "bool",
221
- ],
222
- "return": []
223
- },
224
- {
225
- "name": "number_as_input",
226
- "visibility": "public",
227
- "is_entry": true,
228
- "is_view": false,
229
- "generic_type_params": [],
230
- "params": [
231
- "u8",
232
- "u16",
233
- "u32",
234
- "u64",
235
- "u128",
236
- "u256",
237
- ],
238
- "return": []
239
- },
240
- {
241
- "name": "vector_as_input",
242
- "visibility": "public",
243
- "is_entry": true,
244
- "is_view": false,
245
- "generic_type_params": [],
246
- "params": [
247
- "vector<u8>",
248
- "vector<u16>",
249
- "vector<u64>",
250
- "vector<bool>",
251
- "vector<address>",
252
- ],
253
- "return": []
254
- },
255
- {
256
- "name": "vector_of_vector_as_input",
257
- "visibility": "public",
258
- "is_entry": true,
259
- "is_view": false,
260
- "generic_type_params": [],
261
- "params": [
262
- "vector<vector<u8>>",
263
- "vector<vector<address>>",
264
- ],
265
- "return": []
266
- },
267
- {
268
- "name": "object_as_input",
269
- "visibility": "public",
270
- "is_entry": true,
271
- "is_view": false,
272
- "generic_type_params": [],
273
- "params": [
274
- "0x1::object::Object<0xb8a4015d231899eaf1de8eb6dc6547f296f215b7ca46ea01b22b3d1ba24b6eb1::overflow::Overflow<T0, T1>>",
275
- ],
276
- "return": []
277
- },
278
- ],
206
+ address: '0x123',
207
+ name: 'test',
208
+ friends: [],
209
+ exposed_functions: [
210
+ {
211
+ name: 'address_as_input',
212
+ visibility: 'public',
213
+ is_entry: true,
214
+ is_view: false,
215
+ generic_type_params: [],
216
+ params: ['address', 'address'],
217
+ return: [],
218
+ },
219
+ {
220
+ name: 'bool_as_input',
221
+ visibility: 'public',
222
+ is_entry: true,
223
+ is_view: false,
224
+ generic_type_params: [],
225
+ params: ['bool', 'bool'],
226
+ return: [],
227
+ },
228
+ {
229
+ name: 'number_as_input',
230
+ visibility: 'public',
231
+ is_entry: true,
232
+ is_view: false,
233
+ generic_type_params: [],
234
+ params: ['u8', 'u16', 'u32', 'u64', 'u128', 'u256'],
235
+ return: [],
236
+ },
237
+ {
238
+ name: 'vector_as_input',
239
+ visibility: 'public',
240
+ is_entry: true,
241
+ is_view: false,
242
+ generic_type_params: [],
243
+ params: [
244
+ 'vector<u8>',
245
+ 'vector<u16>',
246
+ 'vector<u64>',
247
+ 'vector<bool>',
248
+ 'vector<address>',
249
+ ],
250
+ return: [],
251
+ },
252
+ {
253
+ name: 'vector_of_vector_as_input',
254
+ visibility: 'public',
255
+ is_entry: true,
256
+ is_view: false,
257
+ generic_type_params: [],
258
+ params: ['vector<vector<u8>>', 'vector<vector<address>>'],
259
+ return: [],
260
+ },
261
+ {
262
+ name: 'object_as_input',
263
+ visibility: 'public',
264
+ is_entry: true,
265
+ is_view: false,
266
+ generic_type_params: [],
267
+ params: [
268
+ '0x1::object::Object<0xb8a4015d231899eaf1de8eb6dc6547f296f215b7ca46ea01b22b3d1ba24b6eb1::overflow::Overflow<T0, T1>>',
269
+ ],
270
+ return: [],
271
+ },
272
+ ],
279
273
 
280
- "structs": []
274
+ structs: [],
281
275
  } as const;