@thalalabs/surf 0.0.13 → 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.
- package/.changeset/README.md +1 -1
- package/.github/dependabot.yml +3 -3
- package/.github/workflows/publish.yml +2 -2
- package/CHANGELOG.md +6 -0
- package/README.md +18 -11
- package/build/cjs/abi/aggregator.js +56 -74
- package/build/cjs/abi/aggregator.js.map +1 -1
- package/build/cjs/abi/aptos_coin.js +98 -125
- package/build/cjs/abi/aptos_coin.js.map +1 -1
- package/build/cjs/abi/coin.js +456 -587
- package/build/cjs/abi/coin.js.map +1 -1
- package/build/cjs/abi/event.js +66 -106
- package/build/cjs/abi/event.js.map +1 -1
- package/build/cjs/abi/fixed_point64.js +287 -320
- package/build/cjs/abi/fixed_point64.js.map +1 -1
- package/build/cjs/abi/guid.js +84 -129
- package/build/cjs/abi/guid.js.map +1 -1
- package/build/cjs/abi/optional_aggregator.js +79 -108
- package/build/cjs/abi/optional_aggregator.js.map +1 -1
- package/build/cjs/abi/table.js +131 -222
- package/build/cjs/abi/table.js.map +1 -1
- package/build/cjs/core/Client.js +6 -2
- package/build/cjs/core/Client.js.map +1 -1
- package/build/cjs/core/createEntryPayload.js.map +1 -1
- package/build/cjs/ensureTypes.js +11 -10
- package/build/cjs/ensureTypes.js.map +1 -1
- package/build/cjs/index.js.map +1 -1
- package/build/esm/abi/aggregator.js +56 -74
- package/build/esm/abi/aggregator.js.map +1 -1
- package/build/esm/abi/aptos_coin.js +98 -125
- package/build/esm/abi/aptos_coin.js.map +1 -1
- package/build/esm/abi/coin.js +456 -587
- package/build/esm/abi/coin.js.map +1 -1
- package/build/esm/abi/event.js +66 -106
- package/build/esm/abi/event.js.map +1 -1
- package/build/esm/abi/fixed_point64.js +287 -320
- package/build/esm/abi/fixed_point64.js.map +1 -1
- package/build/esm/abi/guid.js +84 -129
- package/build/esm/abi/guid.js.map +1 -1
- package/build/esm/abi/optional_aggregator.js +79 -108
- package/build/esm/abi/optional_aggregator.js.map +1 -1
- package/build/esm/abi/table.js +131 -222
- package/build/esm/abi/table.js.map +1 -1
- package/build/esm/core/Client.js +6 -2
- package/build/esm/core/Client.js.map +1 -1
- package/build/esm/core/createEntryPayload.js.map +1 -1
- package/build/esm/ensureTypes.js +11 -10
- package/build/esm/ensureTypes.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/abi/aggregator.d.ts.map +1 -1
- package/build/types/abi/aptos_coin.d.ts.map +1 -1
- package/build/types/abi/coin.d.ts.map +1 -1
- package/build/types/abi/event.d.ts.map +1 -1
- package/build/types/abi/fixed_point64.d.ts.map +1 -1
- package/build/types/abi/guid.d.ts.map +1 -1
- package/build/types/abi/optional_aggregator.d.ts.map +1 -1
- package/build/types/abi/table.d.ts.map +1 -1
- package/build/types/core/Client.d.ts.map +1 -1
- package/build/types/ensureTypes.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/client/abiClient.d.ts +2 -0
- package/build/types/types/client/abiClient.d.ts.map +1 -1
- package/build/types/types/convertor/argsConvertor.d.ts +1 -1
- package/build/types/types/convertor/argsConvertor.d.ts.map +1 -1
- package/build/types/types/convertor/structConvertor.d.ts.map +1 -1
- package/build/types/types/moveTypes.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/abi/aggregator.ts +73 -91
- package/src/abi/aptos_coin.ts +117 -144
- package/src/abi/coin.ts +646 -777
- package/src/abi/event.ts +83 -123
- package/src/abi/fixed_point64.ts +340 -373
- package/src/abi/guid.ts +102 -147
- package/src/abi/optional_aggregator.ts +103 -132
- package/src/abi/table.ts +181 -272
- package/src/core/Client.ts +6 -1
- package/src/core/__tests__/accountResource.test.ts +54 -14
- package/src/core/__tests__/createEntryPayload.test.ts +244 -250
- package/src/core/__tests__/createViewPayload.test.ts +44 -58
- package/src/core/__tests__/option.test.ts +1 -1
- package/src/core/__tests__/useABI.test.ts +72 -63
- package/src/core/__tests__/view.test.ts +76 -60
- package/src/core/createEntryPayload.ts +4 -3
- package/src/ensureTypes.ts +31 -28
- package/src/index.ts +8 -8
- package/src/types/client/abiClient.ts +2 -0
- package/src/types/convertor/argsConvertor.ts +1 -1
- package/src/types/convertor/structConvertor.ts +16 -15
- package/src/types/moveTypes.ts +5 -1
package/src/abi/table.ts
CHANGED
|
@@ -1,295 +1,204 @@
|
|
|
1
1
|
export const TABLE_ABI = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
address: '0x1',
|
|
3
|
+
name: 'table',
|
|
4
|
+
friends: ['0x1::table_with_length'],
|
|
5
|
+
exposed_functions: [
|
|
6
|
+
{
|
|
7
|
+
name: 'add',
|
|
8
|
+
visibility: 'public',
|
|
9
|
+
is_entry: false,
|
|
10
|
+
is_view: false,
|
|
11
|
+
generic_type_params: [
|
|
8
12
|
{
|
|
9
|
-
|
|
10
|
-
"visibility": "public",
|
|
11
|
-
"is_entry": false,
|
|
12
|
-
"is_view": false,
|
|
13
|
-
"generic_type_params": [
|
|
14
|
-
{
|
|
15
|
-
"constraints": [
|
|
16
|
-
"copy",
|
|
17
|
-
"drop"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"constraints": []
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"params": [
|
|
25
|
-
"&mut 0x1::table::Table<T0, T1>",
|
|
26
|
-
"T0",
|
|
27
|
-
"T1"
|
|
28
|
-
],
|
|
29
|
-
"return": []
|
|
13
|
+
constraints: ['copy', 'drop'],
|
|
30
14
|
},
|
|
31
15
|
{
|
|
32
|
-
|
|
33
|
-
"visibility": "public",
|
|
34
|
-
"is_entry": false,
|
|
35
|
-
"is_view": false,
|
|
36
|
-
"generic_type_params": [
|
|
37
|
-
{
|
|
38
|
-
"constraints": [
|
|
39
|
-
"copy",
|
|
40
|
-
"drop"
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"constraints": []
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"params": [
|
|
48
|
-
"&0x1::table::Table<T0, T1>",
|
|
49
|
-
"T0"
|
|
50
|
-
],
|
|
51
|
-
"return": [
|
|
52
|
-
"&T1"
|
|
53
|
-
]
|
|
16
|
+
constraints: [],
|
|
54
17
|
},
|
|
18
|
+
],
|
|
19
|
+
params: ['&mut 0x1::table::Table<T0, T1>', 'T0', 'T1'],
|
|
20
|
+
return: [],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'borrow',
|
|
24
|
+
visibility: 'public',
|
|
25
|
+
is_entry: false,
|
|
26
|
+
is_view: false,
|
|
27
|
+
generic_type_params: [
|
|
55
28
|
{
|
|
56
|
-
|
|
57
|
-
"visibility": "public",
|
|
58
|
-
"is_entry": false,
|
|
59
|
-
"is_view": false,
|
|
60
|
-
"generic_type_params": [
|
|
61
|
-
{
|
|
62
|
-
"constraints": [
|
|
63
|
-
"copy",
|
|
64
|
-
"drop"
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"constraints": []
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
"params": [
|
|
72
|
-
"&mut 0x1::table::Table<T0, T1>",
|
|
73
|
-
"T0"
|
|
74
|
-
],
|
|
75
|
-
"return": [
|
|
76
|
-
"&mut T1"
|
|
77
|
-
]
|
|
29
|
+
constraints: ['copy', 'drop'],
|
|
78
30
|
},
|
|
79
31
|
{
|
|
80
|
-
|
|
81
|
-
"visibility": "public",
|
|
82
|
-
"is_entry": false,
|
|
83
|
-
"is_view": false,
|
|
84
|
-
"generic_type_params": [
|
|
85
|
-
{
|
|
86
|
-
"constraints": [
|
|
87
|
-
"copy",
|
|
88
|
-
"drop"
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"constraints": [
|
|
93
|
-
"drop"
|
|
94
|
-
]
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"params": [
|
|
98
|
-
"&mut 0x1::table::Table<T0, T1>",
|
|
99
|
-
"T0",
|
|
100
|
-
"T1"
|
|
101
|
-
],
|
|
102
|
-
"return": [
|
|
103
|
-
"&mut T1"
|
|
104
|
-
]
|
|
32
|
+
constraints: [],
|
|
105
33
|
},
|
|
34
|
+
],
|
|
35
|
+
params: ['&0x1::table::Table<T0, T1>', 'T0'],
|
|
36
|
+
return: ['&T1'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'borrow_mut',
|
|
40
|
+
visibility: 'public',
|
|
41
|
+
is_entry: false,
|
|
42
|
+
is_view: false,
|
|
43
|
+
generic_type_params: [
|
|
106
44
|
{
|
|
107
|
-
|
|
108
|
-
"visibility": "public",
|
|
109
|
-
"is_entry": false,
|
|
110
|
-
"is_view": false,
|
|
111
|
-
"generic_type_params": [
|
|
112
|
-
{
|
|
113
|
-
"constraints": [
|
|
114
|
-
"copy",
|
|
115
|
-
"drop"
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
"constraints": []
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
"params": [
|
|
123
|
-
"&0x1::table::Table<T0, T1>",
|
|
124
|
-
"T0",
|
|
125
|
-
"&T1"
|
|
126
|
-
],
|
|
127
|
-
"return": [
|
|
128
|
-
"&T1"
|
|
129
|
-
]
|
|
45
|
+
constraints: ['copy', 'drop'],
|
|
130
46
|
},
|
|
131
47
|
{
|
|
132
|
-
|
|
133
|
-
"visibility": "public",
|
|
134
|
-
"is_entry": false,
|
|
135
|
-
"is_view": false,
|
|
136
|
-
"generic_type_params": [
|
|
137
|
-
{
|
|
138
|
-
"constraints": [
|
|
139
|
-
"copy",
|
|
140
|
-
"drop"
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"constraints": []
|
|
145
|
-
}
|
|
146
|
-
],
|
|
147
|
-
"params": [
|
|
148
|
-
"&0x1::table::Table<T0, T1>",
|
|
149
|
-
"T0"
|
|
150
|
-
],
|
|
151
|
-
"return": [
|
|
152
|
-
"bool"
|
|
153
|
-
]
|
|
48
|
+
constraints: [],
|
|
154
49
|
},
|
|
50
|
+
],
|
|
51
|
+
params: ['&mut 0x1::table::Table<T0, T1>', 'T0'],
|
|
52
|
+
return: ['&mut T1'],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'borrow_mut_with_default',
|
|
56
|
+
visibility: 'public',
|
|
57
|
+
is_entry: false,
|
|
58
|
+
is_view: false,
|
|
59
|
+
generic_type_params: [
|
|
155
60
|
{
|
|
156
|
-
|
|
157
|
-
"visibility": "friend",
|
|
158
|
-
"is_entry": false,
|
|
159
|
-
"is_view": false,
|
|
160
|
-
"generic_type_params": [
|
|
161
|
-
{
|
|
162
|
-
"constraints": [
|
|
163
|
-
"copy",
|
|
164
|
-
"drop"
|
|
165
|
-
]
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
"constraints": []
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
"params": [
|
|
172
|
-
"0x1::table::Table<T0, T1>"
|
|
173
|
-
],
|
|
174
|
-
"return": []
|
|
61
|
+
constraints: ['copy', 'drop'],
|
|
175
62
|
},
|
|
176
63
|
{
|
|
177
|
-
|
|
178
|
-
"visibility": "public",
|
|
179
|
-
"is_entry": false,
|
|
180
|
-
"is_view": false,
|
|
181
|
-
"generic_type_params": [
|
|
182
|
-
{
|
|
183
|
-
"constraints": [
|
|
184
|
-
"copy",
|
|
185
|
-
"drop"
|
|
186
|
-
]
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"constraints": [
|
|
190
|
-
"store"
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"params": [],
|
|
195
|
-
"return": [
|
|
196
|
-
"0x1::table::Table<T0, T1>"
|
|
197
|
-
]
|
|
64
|
+
constraints: ['drop'],
|
|
198
65
|
},
|
|
66
|
+
],
|
|
67
|
+
params: ['&mut 0x1::table::Table<T0, T1>', 'T0', 'T1'],
|
|
68
|
+
return: ['&mut T1'],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'borrow_with_default',
|
|
72
|
+
visibility: 'public',
|
|
73
|
+
is_entry: false,
|
|
74
|
+
is_view: false,
|
|
75
|
+
generic_type_params: [
|
|
199
76
|
{
|
|
200
|
-
|
|
201
|
-
"visibility": "public",
|
|
202
|
-
"is_entry": false,
|
|
203
|
-
"is_view": false,
|
|
204
|
-
"generic_type_params": [
|
|
205
|
-
{
|
|
206
|
-
"constraints": [
|
|
207
|
-
"copy",
|
|
208
|
-
"drop"
|
|
209
|
-
]
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"constraints": []
|
|
213
|
-
}
|
|
214
|
-
],
|
|
215
|
-
"params": [
|
|
216
|
-
"&mut 0x1::table::Table<T0, T1>",
|
|
217
|
-
"T0"
|
|
218
|
-
],
|
|
219
|
-
"return": [
|
|
220
|
-
"T1"
|
|
221
|
-
]
|
|
77
|
+
constraints: ['copy', 'drop'],
|
|
222
78
|
},
|
|
223
79
|
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
80
|
+
constraints: [],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
params: ['&0x1::table::Table<T0, T1>', 'T0', '&T1'],
|
|
84
|
+
return: ['&T1'],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'contains',
|
|
88
|
+
visibility: 'public',
|
|
89
|
+
is_entry: false,
|
|
90
|
+
is_view: false,
|
|
91
|
+
generic_type_params: [
|
|
92
|
+
{
|
|
93
|
+
constraints: ['copy', 'drop'],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
constraints: [],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
params: ['&0x1::table::Table<T0, T1>', 'T0'],
|
|
100
|
+
return: ['bool'],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'destroy',
|
|
104
|
+
visibility: 'friend',
|
|
105
|
+
is_entry: false,
|
|
106
|
+
is_view: false,
|
|
107
|
+
generic_type_params: [
|
|
108
|
+
{
|
|
109
|
+
constraints: ['copy', 'drop'],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
constraints: [],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
params: ['0x1::table::Table<T0, T1>'],
|
|
116
|
+
return: [],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'new',
|
|
120
|
+
visibility: 'public',
|
|
121
|
+
is_entry: false,
|
|
122
|
+
is_view: false,
|
|
123
|
+
generic_type_params: [
|
|
124
|
+
{
|
|
125
|
+
constraints: ['copy', 'drop'],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
constraints: ['store'],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
params: [],
|
|
132
|
+
return: ['0x1::table::Table<T0, T1>'],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'remove',
|
|
136
|
+
visibility: 'public',
|
|
137
|
+
is_entry: false,
|
|
138
|
+
is_view: false,
|
|
139
|
+
generic_type_params: [
|
|
140
|
+
{
|
|
141
|
+
constraints: ['copy', 'drop'],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
constraints: [],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
params: ['&mut 0x1::table::Table<T0, T1>', 'T0'],
|
|
148
|
+
return: ['T1'],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'upsert',
|
|
152
|
+
visibility: 'public',
|
|
153
|
+
is_entry: false,
|
|
154
|
+
is_view: false,
|
|
155
|
+
generic_type_params: [
|
|
156
|
+
{
|
|
157
|
+
constraints: ['copy', 'drop'],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
constraints: ['drop'],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
params: ['&mut 0x1::table::Table<T0, T1>', 'T0', 'T1'],
|
|
164
|
+
return: [],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
structs: [
|
|
168
|
+
{
|
|
169
|
+
name: 'Box',
|
|
170
|
+
is_native: false,
|
|
171
|
+
abilities: ['drop', 'store', 'key'],
|
|
172
|
+
generic_type_params: [
|
|
250
173
|
{
|
|
251
|
-
|
|
252
|
-
"is_native": false,
|
|
253
|
-
"abilities": [
|
|
254
|
-
"drop",
|
|
255
|
-
"store",
|
|
256
|
-
"key"
|
|
257
|
-
],
|
|
258
|
-
"generic_type_params": [
|
|
259
|
-
{
|
|
260
|
-
"constraints": []
|
|
261
|
-
}
|
|
262
|
-
],
|
|
263
|
-
"fields": [
|
|
264
|
-
{
|
|
265
|
-
"name": "val",
|
|
266
|
-
"type": "T0"
|
|
267
|
-
}
|
|
268
|
-
]
|
|
174
|
+
constraints: [],
|
|
269
175
|
},
|
|
176
|
+
],
|
|
177
|
+
fields: [
|
|
270
178
|
{
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
179
|
+
name: 'val',
|
|
180
|
+
type: 'T0',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'Table',
|
|
186
|
+
is_native: false,
|
|
187
|
+
abilities: ['store'],
|
|
188
|
+
generic_type_params: [
|
|
189
|
+
{
|
|
190
|
+
constraints: ['copy', 'drop'],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
constraints: [],
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
fields: [
|
|
197
|
+
{
|
|
198
|
+
name: 'handle',
|
|
199
|
+
type: 'address',
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
} as const;
|
package/src/core/Client.ts
CHANGED
|
@@ -168,7 +168,9 @@ export class Client<TABITable extends ABITable> {
|
|
|
168
168
|
type_arguments: args[0].type_arguments,
|
|
169
169
|
arguments: args[0].arguments,
|
|
170
170
|
});
|
|
171
|
-
return this.view(payload
|
|
171
|
+
return this.view(payload, {
|
|
172
|
+
ledger_version: args[0].ledger_version,
|
|
173
|
+
});
|
|
172
174
|
};
|
|
173
175
|
},
|
|
174
176
|
}),
|
|
@@ -218,6 +220,9 @@ export class Client<TABITable extends ABITable> {
|
|
|
218
220
|
return this.client.getAccountResource(
|
|
219
221
|
args[0].account,
|
|
220
222
|
`${abi.address}::${abi.name}::${structName}`,
|
|
223
|
+
{
|
|
224
|
+
ledgerVersion: args[0].ledger_version,
|
|
225
|
+
},
|
|
221
226
|
);
|
|
222
227
|
|
|
223
228
|
// TODO: decode the u64, u128, u256 to bigint
|
|
@@ -13,10 +13,10 @@ describe('get account resource', () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
// Act before assertions
|
|
16
|
-
beforeAll(async () => {
|
|
16
|
+
beforeAll(async () => {});
|
|
17
17
|
|
|
18
18
|
// Teardown (cleanup) after assertions
|
|
19
|
-
afterAll(() => {
|
|
19
|
+
afterAll(() => {});
|
|
20
20
|
|
|
21
21
|
it('get CoinStore', async () => {
|
|
22
22
|
const result = await client.useABI(COIN_ABI).resource.CoinStore({
|
|
@@ -30,7 +30,9 @@ describe('get account resource', () => {
|
|
|
30
30
|
expect(result.data.withdraw_events).toBeDefined();
|
|
31
31
|
|
|
32
32
|
// can inference nested struct
|
|
33
|
-
expect(
|
|
33
|
+
expect(
|
|
34
|
+
result.data.deposit_events.guid.id.creation_num.startsWith,
|
|
35
|
+
).toBeDefined();
|
|
34
36
|
|
|
35
37
|
// @ts-expect-error field not exist
|
|
36
38
|
expect(result.data.deposit_events.guid.id.abc).toBeUndefined();
|
|
@@ -39,10 +41,48 @@ describe('get account resource', () => {
|
|
|
39
41
|
expect(result.abc).toBeUndefined();
|
|
40
42
|
}, 60000);
|
|
41
43
|
|
|
44
|
+
it('get CoinStore with ledger version', async () => {
|
|
45
|
+
const result = await client.useABI(COIN_ABI).resource.CoinStore({
|
|
46
|
+
type_arguments: ['0x1::aptos_coin::AptosCoin'],
|
|
47
|
+
account: '0x1',
|
|
48
|
+
ledger_version: '562606728',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(result).toMatchInlineSnapshot(`
|
|
52
|
+
{
|
|
53
|
+
"data": {
|
|
54
|
+
"coin": {
|
|
55
|
+
"value": "50000358",
|
|
56
|
+
},
|
|
57
|
+
"deposit_events": {
|
|
58
|
+
"counter": "61",
|
|
59
|
+
"guid": {
|
|
60
|
+
"id": {
|
|
61
|
+
"addr": "0x1",
|
|
62
|
+
"creation_num": "12",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
"frozen": false,
|
|
67
|
+
"withdraw_events": {
|
|
68
|
+
"counter": "0",
|
|
69
|
+
"guid": {
|
|
70
|
+
"id": {
|
|
71
|
+
"addr": "0x1",
|
|
72
|
+
"creation_num": "13",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
"type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
78
|
+
}
|
|
79
|
+
`);
|
|
80
|
+
}, 60000);
|
|
81
|
+
|
|
42
82
|
it('use customized ABITable', async () => {
|
|
43
83
|
async () => {
|
|
44
84
|
type ABITAble = DefaultABITable & {
|
|
45
|
-
'0x4dcae85fc5559071906cd5c76b7420fcbb4b0a92f00ab40ffc394aadbbff5ee9::fixed_point64': typeof FIXED_POINT64_ABI
|
|
85
|
+
'0x4dcae85fc5559071906cd5c76b7420fcbb4b0a92f00ab40ffc394aadbbff5ee9::fixed_point64': typeof FIXED_POINT64_ABI;
|
|
46
86
|
};
|
|
47
87
|
|
|
48
88
|
const client = createClient<ABITAble>({
|
|
@@ -60,7 +100,7 @@ describe('get account resource', () => {
|
|
|
60
100
|
|
|
61
101
|
// @ts-expect-error field not exist
|
|
62
102
|
result.data.ratio.abc;
|
|
63
|
-
}
|
|
103
|
+
};
|
|
64
104
|
}, 60000);
|
|
65
105
|
|
|
66
106
|
it('vector struct type', async () => {
|
|
@@ -71,12 +111,12 @@ describe('get account resource', () => {
|
|
|
71
111
|
});
|
|
72
112
|
|
|
73
113
|
result.data.coins[0]?.value.startsWith;
|
|
74
|
-
}
|
|
114
|
+
};
|
|
75
115
|
}, 60000);
|
|
76
116
|
|
|
77
117
|
it('option type', async () => {
|
|
78
118
|
const { data } = await client.useABI(COIN_ABI).resource.CoinInfo({
|
|
79
|
-
type_arguments: [
|
|
119
|
+
type_arguments: ['0x1::aptos_coin::AptosCoin'],
|
|
80
120
|
account: '0x1',
|
|
81
121
|
});
|
|
82
122
|
|
|
@@ -84,7 +124,7 @@ describe('get account resource', () => {
|
|
|
84
124
|
expect(data.supply.vec[0]?.integer.vec).toBeDefined();
|
|
85
125
|
|
|
86
126
|
// @ts-expect-error out of index, option only has 0 or 1 item
|
|
87
|
-
expect(data.supply.vec[1]).toBeUndefined();
|
|
127
|
+
expect(data.supply.vec[1]).toBeUndefined();
|
|
88
128
|
}, 60000);
|
|
89
129
|
});
|
|
90
130
|
|
|
@@ -101,12 +141,12 @@ const TEST_ABI = {
|
|
|
101
141
|
generic_type_params: [],
|
|
102
142
|
fields: [
|
|
103
143
|
{
|
|
104
|
-
|
|
105
|
-
|
|
144
|
+
name: 'ratio',
|
|
145
|
+
type: '0x4dcae85fc5559071906cd5c76b7420fcbb4b0a92f00ab40ffc394aadbbff5ee9::fixed_point64::FixedPoint64',
|
|
106
146
|
},
|
|
107
147
|
{
|
|
108
|
-
|
|
109
|
-
|
|
148
|
+
name: 'coin',
|
|
149
|
+
type: '0x1::coin::Coin<T0>',
|
|
110
150
|
},
|
|
111
151
|
],
|
|
112
152
|
},
|
|
@@ -117,8 +157,8 @@ const TEST_ABI = {
|
|
|
117
157
|
generic_type_params: [],
|
|
118
158
|
fields: [
|
|
119
159
|
{
|
|
120
|
-
|
|
121
|
-
|
|
160
|
+
name: 'coins',
|
|
161
|
+
type: 'vector<0x1::coin::Coin<T0>>',
|
|
122
162
|
},
|
|
123
163
|
],
|
|
124
164
|
},
|