@kontor/kontor-sdk 1.0.0-alpha.24 → 1.0.0-alpha.27
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/dist/cjs/sdk/actions/kontor/public/call-compose.js +7 -9
- package/dist/cjs/sdk/actions/kontor/public/call-compose.js.map +1 -1
- package/dist/cjs/sdk/actions/kontor/public/proc-contract.js +5 -8
- package/dist/cjs/sdk/actions/kontor/public/proc-contract.js.map +1 -1
- package/dist/cjs/sdk/actions/kontor/wallet/sign-commit.js.map +1 -1
- package/dist/cjs/sdk/contracts/wits.js +1 -3
- package/dist/cjs/sdk/contracts/wits.js.map +1 -1
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js +2 -2
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/cjs/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/cjs/wit/wit-parser/parse-wit.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/public/call-compose.js +8 -10
- package/dist/esm/sdk/actions/kontor/public/call-compose.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/public/proc-contract.js +5 -9
- package/dist/esm/sdk/actions/kontor/public/proc-contract.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/wallet/sign-commit.js +1 -0
- package/dist/esm/sdk/actions/kontor/wallet/sign-commit.js.map +1 -1
- package/dist/esm/sdk/contracts/wits.js +1 -4
- package/dist/esm/sdk/contracts/wits.js.map +1 -1
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js +2 -2
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/wit/wit-parser/core/utils.js +0 -5
- package/dist/esm/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/esm/wit/wit-parser/parse-wit.js.map +1 -1
- package/dist/types/sdk/actions/kontor/public/call-compose.d.ts +6 -5
- package/dist/types/sdk/actions/kontor/public/call-compose.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/public/proc-contract.d.ts +5 -5
- package/dist/types/sdk/actions/kontor/public/proc-contract.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/wallet/sign-commit.d.ts +4 -2
- package/dist/types/sdk/actions/kontor/wallet/sign-commit.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/wallet/sign-reveal.d.ts +1 -1
- package/dist/types/sdk/actions/kontor/wallet/sign-reveal.d.ts.map +1 -1
- package/dist/types/sdk/clients/decorators/kontor/public.d.ts +2 -2
- package/dist/types/sdk/clients/decorators/kontor/public.d.ts.map +1 -1
- package/dist/types/sdk/clients/decorators/kontor/wallet.d.ts +1 -1
- package/dist/types/sdk/clients/decorators/kontor/wallet.d.ts.map +1 -1
- package/dist/types/sdk/clients/kontor/create-public-client.d.ts +1 -1
- package/dist/types/sdk/clients/kontor/create-public-client.d.ts.map +1 -1
- package/dist/types/sdk/clients/kontor/create-wallet-client.d.ts +1 -1
- package/dist/types/sdk/clients/kontor/create-wallet-client.d.ts.map +1 -1
- package/dist/types/sdk/contracts/wits.d.ts +1 -1
- package/dist/types/sdk/contracts/wits.d.ts.map +1 -1
- package/dist/types/sdk/types/chain.d.ts +1 -0
- package/dist/types/sdk/types/chain.d.ts.map +1 -1
- package/dist/types/wit/wit-parser/core/types/utils.d.ts +2 -0
- package/dist/types/wit/wit-parser/core/types/utils.d.ts.map +1 -1
- package/dist/types/wit/wit-parser/core/utils.d.ts.map +1 -1
- package/dist/types/wit/wit-parser/parse-wit.d.ts +0 -15
- package/dist/types/wit/wit-parser/parse-wit.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/sdk/actions/kontor/public/call-compose.ts +29 -22
- package/src/sdk/actions/kontor/public/proc-contract.test.ts +3 -0
- package/src/sdk/actions/kontor/public/proc-contract.ts +60 -15
- package/src/sdk/actions/kontor/wallet/sign-commit.ts +18 -7
- package/src/sdk/actions/kontor/wallet/sign-reveal.ts +1 -1
- package/src/sdk/clients/decorators/kontor/public.ts +4 -4
- package/src/sdk/clients/decorators/kontor/wallet.ts +2 -2
- package/src/sdk/clients/kontor/create-public-client.ts +3 -3
- package/src/sdk/clients/kontor/create-wallet-client.ts +3 -3
- package/src/sdk/contracts/wits.ts +1 -5
- package/src/sdk/test/e2e.test.ts +8 -12
- package/src/sdk/types/chain.ts +5 -0
- package/src/sdk/types/contract.test-d.ts +21 -103
- package/src/sdk/utils/wit/decode-wit-parameter.ts +2 -2
- package/src/sdk/utils/wit/encode-function-data.test-d.ts +4 -6
- package/src/sdk/utils/wit/encode-function-data.test.ts +3 -47
- package/src/wit/wit-parser/core/types/records.test-d.ts +3 -0
- package/src/wit/wit-parser/core/types/utils.test-d.ts +7 -3
- package/src/wit/wit-parser/core/types/utils.ts +6 -2
- package/src/wit/wit-parser/core/utils.ts +1 -5
- package/src/wit/wit-parser/parse-wit.test.ts +426 -146
- package/src/wit/wit-parser/parse-wit.ts +0 -15
- package/test/src/wits.ts +0 -4
|
@@ -2,195 +2,475 @@ import { expectTypeOf, describe, expect, test } from "vitest";
|
|
|
2
2
|
|
|
3
3
|
import type { ParseWit } from "./parse-wit.js";
|
|
4
4
|
import { parseWit } from "./parse-wit.js";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// type t = ParseWit<typeof nativeToken.raw>;
|
|
10
|
-
//
|
|
5
|
+
import { nativeToken } from "../../sdk/contracts/wits.js";
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
expectTypeOf<ParseWit<typeof nativeToken.raw>>().toEqualTypeOf<
|
|
8
|
+
readonly [
|
|
9
|
+
{
|
|
10
|
+
readonly name: "mint";
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly context: "proc";
|
|
13
|
+
readonly inputs: readonly [
|
|
14
|
+
{
|
|
15
|
+
readonly name: "amt";
|
|
16
|
+
readonly type: "decimal";
|
|
17
|
+
readonly internalType: "decimal";
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
readonly outputs: readonly [
|
|
21
|
+
{
|
|
22
|
+
readonly type: "result<tuple, error>";
|
|
23
|
+
readonly internalType: "result<mint, error>";
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
readonly components: readonly [
|
|
26
|
+
{
|
|
27
|
+
readonly name: "dst";
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly internalType: "string";
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
readonly name: "amt";
|
|
33
|
+
readonly type: "decimal";
|
|
34
|
+
readonly internalType: "decimal";
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
readonly name: "burn";
|
|
42
|
+
readonly type: "function";
|
|
43
|
+
readonly context: "proc";
|
|
44
|
+
readonly inputs: readonly [
|
|
45
|
+
{
|
|
46
|
+
readonly name: "amt";
|
|
47
|
+
readonly type: "decimal";
|
|
48
|
+
readonly internalType: "decimal";
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
readonly outputs: readonly [
|
|
52
|
+
{
|
|
53
|
+
readonly type: "result<tuple, error>";
|
|
54
|
+
readonly internalType: "result<burn, error>";
|
|
55
|
+
|
|
56
|
+
readonly components: readonly [
|
|
57
|
+
{
|
|
58
|
+
readonly name: "src";
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
readonly internalType: "string";
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
readonly name: "amt";
|
|
64
|
+
readonly type: "decimal";
|
|
65
|
+
readonly internalType: "decimal";
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
readonly name: "transfer";
|
|
73
|
+
readonly type: "function";
|
|
74
|
+
readonly context: "proc";
|
|
75
|
+
readonly inputs: readonly [
|
|
76
|
+
{
|
|
77
|
+
readonly name: "dst";
|
|
78
|
+
readonly type: "string";
|
|
79
|
+
readonly internalType: "string";
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
readonly name: "amt";
|
|
83
|
+
readonly type: "decimal";
|
|
84
|
+
readonly internalType: "decimal";
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
readonly outputs: readonly [
|
|
88
|
+
{
|
|
89
|
+
readonly type: "result<tuple, error>";
|
|
90
|
+
readonly internalType: "result<transfer, error>";
|
|
91
|
+
|
|
92
|
+
readonly components: readonly [
|
|
93
|
+
{
|
|
94
|
+
readonly name: "src";
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
readonly internalType: "string";
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
readonly name: "dst";
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly internalType: "string";
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
readonly name: "amt";
|
|
105
|
+
readonly type: "decimal";
|
|
106
|
+
readonly internalType: "decimal";
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
readonly name: "balance";
|
|
114
|
+
readonly type: "function";
|
|
115
|
+
readonly context: "view";
|
|
116
|
+
readonly inputs: readonly [
|
|
117
|
+
{
|
|
118
|
+
readonly name: "acc";
|
|
119
|
+
readonly type: "string";
|
|
120
|
+
readonly internalType: "string";
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
readonly outputs: readonly [
|
|
124
|
+
{
|
|
125
|
+
readonly type: "option<decimal>";
|
|
126
|
+
readonly internalType: "option<decimal>";
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
{
|
|
132
|
+
readonly name: "balances";
|
|
133
|
+
readonly type: "function";
|
|
134
|
+
readonly context: "view";
|
|
135
|
+
readonly inputs: readonly [];
|
|
136
|
+
readonly outputs: readonly [
|
|
137
|
+
{
|
|
138
|
+
readonly type: "list<tuple>";
|
|
139
|
+
readonly internalType: "list<balance>";
|
|
140
|
+
readonly components: readonly [
|
|
141
|
+
{
|
|
142
|
+
readonly name: "acc";
|
|
143
|
+
readonly type: "string";
|
|
144
|
+
readonly internalType: "string";
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
readonly name: "amt";
|
|
148
|
+
readonly type: "decimal";
|
|
149
|
+
readonly internalType: "decimal";
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
{
|
|
157
|
+
readonly name: "total-supply";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly context: "view";
|
|
160
|
+
readonly inputs: readonly [];
|
|
161
|
+
readonly outputs: readonly [
|
|
162
|
+
{
|
|
163
|
+
readonly type: "decimal";
|
|
164
|
+
readonly internalType: "decimal";
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
readonly name: "attach";
|
|
170
|
+
readonly type: "function";
|
|
171
|
+
readonly context: "proc";
|
|
172
|
+
readonly inputs: readonly [
|
|
173
|
+
{
|
|
174
|
+
readonly name: "vout";
|
|
175
|
+
readonly type: "u64";
|
|
176
|
+
readonly internalType: "u64";
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
readonly name: "amt";
|
|
180
|
+
readonly type: "decimal";
|
|
181
|
+
readonly internalType: "decimal";
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
readonly outputs: readonly [
|
|
185
|
+
{
|
|
186
|
+
readonly type: "result<tuple, error>";
|
|
187
|
+
readonly internalType: "result<transfer, error>";
|
|
188
|
+
readonly components: readonly [
|
|
189
|
+
{
|
|
190
|
+
readonly name: "src";
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
readonly internalType: "string";
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
readonly name: "dst";
|
|
196
|
+
readonly type: "string";
|
|
197
|
+
readonly internalType: "string";
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
readonly name: "amt";
|
|
201
|
+
readonly type: "decimal";
|
|
202
|
+
readonly internalType: "decimal";
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
readonly name: "detach";
|
|
210
|
+
readonly type: "function";
|
|
211
|
+
readonly context: "proc";
|
|
212
|
+
readonly inputs: readonly [];
|
|
213
|
+
readonly outputs: readonly [
|
|
214
|
+
{
|
|
215
|
+
readonly type: "result<tuple, error>";
|
|
216
|
+
readonly internalType: "result<transfer, error>";
|
|
217
|
+
readonly components: readonly [
|
|
218
|
+
{
|
|
219
|
+
readonly name: "src";
|
|
220
|
+
readonly type: "string";
|
|
221
|
+
readonly internalType: "string";
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
readonly name: "dst";
|
|
225
|
+
readonly type: "string";
|
|
226
|
+
readonly internalType: "string";
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
readonly name: "amt";
|
|
230
|
+
readonly type: "decimal";
|
|
231
|
+
readonly internalType: "decimal";
|
|
232
|
+
},
|
|
233
|
+
];
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
},
|
|
237
|
+
]
|
|
238
|
+
>();
|
|
239
|
+
|
|
240
|
+
describe("parseWit (runtime)", () => {
|
|
241
|
+
test("parses nativeToken WIT into the expected ABI shape", () => {
|
|
242
|
+
const out = parseWit(nativeToken.raw);
|
|
243
|
+
|
|
244
|
+
expect(out).toEqual([
|
|
26
245
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
246
|
+
name: "init",
|
|
247
|
+
type: "function",
|
|
248
|
+
context: "proc",
|
|
249
|
+
inputs: [],
|
|
250
|
+
outputs: [],
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "mint",
|
|
254
|
+
type: "function",
|
|
255
|
+
context: "proc",
|
|
256
|
+
inputs: [
|
|
31
257
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
258
|
+
name: "amt",
|
|
259
|
+
type: "decimal",
|
|
260
|
+
internalType: "decimal",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
outputs: [
|
|
264
|
+
{
|
|
265
|
+
type: "result<tuple, error>",
|
|
266
|
+
internalType: "result<mint, error>",
|
|
267
|
+
components: [
|
|
41
268
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
269
|
+
name: "dst",
|
|
270
|
+
type: "string",
|
|
271
|
+
internalType: "string",
|
|
45
272
|
},
|
|
46
273
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
274
|
+
name: "amt",
|
|
275
|
+
type: "decimal",
|
|
276
|
+
internalType: "decimal",
|
|
50
277
|
},
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
readonly name: "n";
|
|
55
|
-
readonly type: "u64";
|
|
56
|
-
readonly internalType: "u64";
|
|
278
|
+
],
|
|
57
279
|
},
|
|
58
|
-
]
|
|
59
|
-
readonly outputs: readonly [
|
|
60
|
-
{ readonly type: "u64"; readonly internalType: "u64" },
|
|
61
|
-
];
|
|
280
|
+
],
|
|
62
281
|
},
|
|
63
|
-
// {
|
|
64
|
-
// readonly name: "fib-of-sub";
|
|
65
|
-
// readonly type: "function";
|
|
66
|
-
// readonly context: "proc";
|
|
67
|
-
// readonly inputs: readonly [
|
|
68
|
-
// {
|
|
69
|
-
// readonly name: "arith-address";
|
|
70
|
-
// readonly type: "tuple";
|
|
71
|
-
// readonly internalType: "contract-address";
|
|
72
|
-
//
|
|
73
|
-
// readonly components: readonly [
|
|
74
|
-
// {
|
|
75
|
-
// readonly name: "name";
|
|
76
|
-
// readonly type: "string";
|
|
77
|
-
// readonly internalType: "string";
|
|
78
|
-
// },
|
|
79
|
-
// {
|
|
80
|
-
// readonly name: "height";
|
|
81
|
-
// readonly type: "s64";
|
|
82
|
-
// readonly internalType: "s64";
|
|
83
|
-
// },
|
|
84
|
-
// {
|
|
85
|
-
// readonly name: "tx-index";
|
|
86
|
-
// readonly type: "s64";
|
|
87
|
-
// readonly internalType: "s64";
|
|
88
|
-
// },
|
|
89
|
-
// ];
|
|
90
|
-
// },
|
|
91
|
-
// {
|
|
92
|
-
// readonly name: "x";
|
|
93
|
-
// readonly type: "string";
|
|
94
|
-
// readonly internalType: "string";
|
|
95
|
-
// },
|
|
96
|
-
// {
|
|
97
|
-
// readonly name: "y";
|
|
98
|
-
// readonly type: "string";
|
|
99
|
-
// readonly internalType: "string";
|
|
100
|
-
// },
|
|
101
|
-
// ];
|
|
102
|
-
// readonly outputs: readonly [
|
|
103
|
-
// {
|
|
104
|
-
// readonly type: "result<u64, error>";
|
|
105
|
-
// readonly internalType: "result<u64, error>";
|
|
106
|
-
// },
|
|
107
|
-
// ];
|
|
108
|
-
// },
|
|
109
|
-
// {
|
|
110
|
-
// readonly name: "cached-values";
|
|
111
|
-
// readonly type: "function";
|
|
112
|
-
// readonly context: "view";
|
|
113
|
-
// readonly inputs: readonly [];
|
|
114
|
-
// readonly outputs: readonly [
|
|
115
|
-
// { readonly type: "list<u64>"; readonly internalType: "list<u64>" },
|
|
116
|
-
// ];
|
|
117
|
-
// },
|
|
118
|
-
]
|
|
119
|
-
>();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe("parseWit (runtime)", () => {
|
|
123
|
-
test("parses proc + view functions and strips ctx from inputs", () => {
|
|
124
|
-
const input = [
|
|
125
|
-
// TODO: build in record defs should be defined under the hood
|
|
126
|
-
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
127
|
-
"export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
|
|
128
|
-
"export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
|
|
129
|
-
"export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
130
|
-
"export return-option: func(ctx: borrow<view-context>) -> option<u64>;",
|
|
131
|
-
] as const;
|
|
132
|
-
|
|
133
|
-
const out = parseWit(input);
|
|
134
|
-
|
|
135
|
-
expect(out).toEqual([
|
|
136
282
|
{
|
|
137
|
-
name: "
|
|
283
|
+
name: "burn",
|
|
138
284
|
type: "function",
|
|
139
285
|
context: "proc",
|
|
140
286
|
inputs: [
|
|
141
287
|
{
|
|
142
|
-
name: "
|
|
143
|
-
type: "
|
|
144
|
-
internalType: "
|
|
288
|
+
name: "amt",
|
|
289
|
+
type: "decimal",
|
|
290
|
+
internalType: "decimal",
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
outputs: [
|
|
294
|
+
{
|
|
295
|
+
type: "result<tuple, error>",
|
|
296
|
+
internalType: "result<burn, error>",
|
|
145
297
|
components: [
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
298
|
+
{
|
|
299
|
+
name: "src",
|
|
300
|
+
type: "string",
|
|
301
|
+
internalType: "string",
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: "amt",
|
|
305
|
+
type: "decimal",
|
|
306
|
+
internalType: "decimal",
|
|
307
|
+
},
|
|
149
308
|
],
|
|
150
309
|
},
|
|
151
|
-
{ name: "n", type: "u64", internalType: "u64" },
|
|
152
310
|
],
|
|
153
|
-
outputs: [{ type: "u64", internalType: "u64" }],
|
|
154
311
|
},
|
|
155
312
|
{
|
|
156
|
-
name: "
|
|
313
|
+
name: "transfer",
|
|
157
314
|
type: "function",
|
|
158
315
|
context: "proc",
|
|
159
316
|
inputs: [
|
|
160
317
|
{
|
|
161
|
-
name: "
|
|
162
|
-
type: "
|
|
163
|
-
internalType: "
|
|
164
|
-
|
|
318
|
+
name: "dst",
|
|
319
|
+
type: "string",
|
|
320
|
+
internalType: "string",
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "amt",
|
|
324
|
+
type: "decimal",
|
|
325
|
+
internalType: "decimal",
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
outputs: [
|
|
329
|
+
{
|
|
330
|
+
type: "result<tuple, error>",
|
|
331
|
+
internalType: "result<transfer, error>",
|
|
165
332
|
components: [
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
333
|
+
{
|
|
334
|
+
name: "src",
|
|
335
|
+
type: "string",
|
|
336
|
+
internalType: "string",
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: "dst",
|
|
340
|
+
type: "string",
|
|
341
|
+
internalType: "string",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "amt",
|
|
345
|
+
type: "decimal",
|
|
346
|
+
internalType: "decimal",
|
|
347
|
+
},
|
|
169
348
|
],
|
|
170
349
|
},
|
|
171
|
-
|
|
172
|
-
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "balance",
|
|
354
|
+
type: "function",
|
|
355
|
+
context: "view",
|
|
356
|
+
inputs: [
|
|
357
|
+
{
|
|
358
|
+
name: "acc",
|
|
359
|
+
type: "string",
|
|
360
|
+
internalType: "string",
|
|
361
|
+
},
|
|
173
362
|
],
|
|
174
363
|
outputs: [
|
|
175
364
|
{
|
|
176
|
-
type: "
|
|
177
|
-
internalType: "
|
|
365
|
+
type: "option<decimal>",
|
|
366
|
+
internalType: "option<decimal>",
|
|
178
367
|
},
|
|
179
368
|
],
|
|
180
369
|
},
|
|
181
370
|
{
|
|
182
|
-
name: "
|
|
371
|
+
name: "balances",
|
|
183
372
|
type: "function",
|
|
184
373
|
context: "view",
|
|
185
374
|
inputs: [],
|
|
186
|
-
outputs: [
|
|
375
|
+
outputs: [
|
|
376
|
+
{
|
|
377
|
+
type: "list<tuple>",
|
|
378
|
+
internalType: "list<balance>",
|
|
379
|
+
components: [
|
|
380
|
+
{
|
|
381
|
+
name: "acc",
|
|
382
|
+
type: "string",
|
|
383
|
+
internalType: "string",
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: "amt",
|
|
387
|
+
type: "decimal",
|
|
388
|
+
internalType: "decimal",
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
],
|
|
187
393
|
},
|
|
188
394
|
{
|
|
189
|
-
name: "
|
|
395
|
+
name: "total-supply",
|
|
190
396
|
type: "function",
|
|
191
397
|
context: "view",
|
|
192
398
|
inputs: [],
|
|
193
|
-
outputs: [
|
|
399
|
+
outputs: [
|
|
400
|
+
{
|
|
401
|
+
type: "decimal",
|
|
402
|
+
internalType: "decimal",
|
|
403
|
+
},
|
|
404
|
+
],
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "attach",
|
|
408
|
+
type: "function",
|
|
409
|
+
context: "proc",
|
|
410
|
+
inputs: [
|
|
411
|
+
{
|
|
412
|
+
name: "vout",
|
|
413
|
+
type: "u64",
|
|
414
|
+
internalType: "u64",
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "amt",
|
|
418
|
+
type: "decimal",
|
|
419
|
+
internalType: "decimal",
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
outputs: [
|
|
423
|
+
{
|
|
424
|
+
type: "result<tuple, error>",
|
|
425
|
+
internalType: "result<transfer, error>",
|
|
426
|
+
components: [
|
|
427
|
+
{
|
|
428
|
+
name: "src",
|
|
429
|
+
type: "string",
|
|
430
|
+
internalType: "string",
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: "dst",
|
|
434
|
+
type: "string",
|
|
435
|
+
internalType: "string",
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "amt",
|
|
439
|
+
type: "decimal",
|
|
440
|
+
internalType: "decimal",
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "detach",
|
|
448
|
+
type: "function",
|
|
449
|
+
context: "proc",
|
|
450
|
+
inputs: [],
|
|
451
|
+
outputs: [
|
|
452
|
+
{
|
|
453
|
+
type: "result<tuple, error>",
|
|
454
|
+
internalType: "result<transfer, error>",
|
|
455
|
+
components: [
|
|
456
|
+
{
|
|
457
|
+
name: "src",
|
|
458
|
+
type: "string",
|
|
459
|
+
internalType: "string",
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "dst",
|
|
463
|
+
type: "string",
|
|
464
|
+
internalType: "string",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
name: "amt",
|
|
468
|
+
type: "decimal",
|
|
469
|
+
internalType: "decimal",
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
},
|
|
473
|
+
],
|
|
194
474
|
},
|
|
195
475
|
]);
|
|
196
476
|
});
|
|
@@ -10,21 +10,6 @@ import type { Signatures } from "./core/types/signatures.js";
|
|
|
10
10
|
import type { ParseRecords } from "./core/types/records.js";
|
|
11
11
|
import type { ParseSignature } from "./core/types/utils.js";
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Parses human-readable ABI into JSON {@link Abi}
|
|
15
|
-
*
|
|
16
|
-
* @param signatures - Human-readable ABI
|
|
17
|
-
* @returns Parsed {@link Abi}
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* type Result = ParseAbi<
|
|
21
|
-
* // ^? type Result = readonly [{ name: "balanceOf"; type: "function"; stateMutability:...
|
|
22
|
-
* [
|
|
23
|
-
* 'function balanceOf(address owner) view returns (uint256)',
|
|
24
|
-
* 'event Transfer(address indexed from, address indexed to, uint256 amount)',
|
|
25
|
-
* ]
|
|
26
|
-
* >
|
|
27
|
-
*/
|
|
28
13
|
export type ParseWit<signatures extends readonly string[]> =
|
|
29
14
|
string[] extends signatures
|
|
30
15
|
? Wit // If `T` was not able to be inferred (e.g. just `string[]`), return `Abi`
|
package/test/src/wits.ts
CHANGED
|
@@ -5,10 +5,6 @@ export const nativeTokenRaw = [
|
|
|
5
5
|
"record transfer { src: string, dst: string, amt: decimal }",
|
|
6
6
|
"record burn { src: string, amt: decimal }",
|
|
7
7
|
"record mint { dst: string, amt: decimal }",
|
|
8
|
-
|
|
9
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
10
|
-
"export hold: func(ctx: borrow<core-context>, amt: decimal) -> result<transfer, error>;",
|
|
11
|
-
"export release: func(ctx: borrow<core-context>, burn-amt: decimal) -> result<burn, error>;",
|
|
12
8
|
"export init: func(ctx: borrow<proc-context>);",
|
|
13
9
|
"export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;",
|
|
14
10
|
"export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;",
|