@kontor/kontor-sdk 1.0.0-alpha.18 → 1.0.0-alpha.20
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/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/src/exports/index.test.js +27 -0
- package/dist/src/exports/index.test.js.map +1 -0
- package/dist/src/sdk/accounts/private-key-to-account.js +42 -0
- package/dist/src/sdk/accounts/private-key-to-account.js.map +1 -0
- package/dist/src/sdk/actions/get-contract.js +50 -0
- package/dist/src/sdk/actions/get-contract.js.map +1 -0
- package/dist/src/sdk/actions/get-contract.test-d.js +43 -0
- package/dist/src/sdk/actions/get-contract.test-d.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/call-view.js +21 -0
- package/dist/src/sdk/actions/kontor/public/call-view.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/inspect.js +20 -0
- package/dist/src/sdk/actions/kontor/public/inspect.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/proc-contract.test.js +47 -0
- package/dist/src/sdk/actions/kontor/public/proc-contract.test.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/view-contract.js +47 -0
- package/dist/src/sdk/actions/kontor/public/view-contract.js.map +1 -0
- package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js +29 -0
- package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js.map +1 -0
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +59 -0
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -0
- package/dist/src/sdk/actions/wallet/get-addresses.js +20 -0
- package/dist/src/sdk/actions/wallet/get-addresses.js.map +1 -0
- package/dist/src/sdk/actions/wallet/sign-psbt.js +28 -0
- package/dist/src/sdk/actions/wallet/sign-psbt.js.map +1 -0
- package/dist/src/sdk/clients/base/create-http-client.js +41 -0
- package/dist/src/sdk/clients/base/create-http-client.js.map +1 -0
- package/dist/src/sdk/clients/base/create-rpc-client.js +41 -0
- package/dist/src/sdk/clients/base/create-rpc-client.js.map +1 -0
- package/dist/src/sdk/clients/base/create-rpc-client.test.js +151 -0
- package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +1 -0
- package/dist/src/sdk/clients/create-public-client.js +13 -0
- package/dist/src/sdk/clients/create-public-client.js.map +1 -0
- package/dist/src/sdk/clients/create-public-client.test.js +121 -0
- package/dist/src/sdk/clients/create-public-client.test.js.map +1 -0
- package/dist/src/sdk/clients/create-wallet-client.js +14 -0
- package/dist/src/sdk/clients/create-wallet-client.js.map +1 -0
- package/dist/src/sdk/clients/kontor/create-public-client.js +14 -0
- package/dist/src/sdk/clients/kontor/create-public-client.js.map +1 -0
- package/dist/src/sdk/clients/kontor/create-public-client.test.js +45 -0
- package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +1 -0
- package/dist/src/sdk/clients/transports/create-rpc-transport.js +36 -0
- package/dist/src/sdk/clients/transports/create-rpc-transport.js.map +1 -0
- package/dist/src/sdk/contracts/wits.js +26 -0
- package/dist/src/sdk/contracts/wits.js.map +1 -0
- package/dist/src/sdk/types/chain.js +2 -0
- package/dist/src/sdk/types/chain.js.map +1 -0
- package/dist/src/sdk/types/contract.js +2 -0
- package/dist/src/sdk/types/contract.js.map +1 -0
- package/dist/src/sdk/types/contract.test-d.js +34 -0
- package/dist/src/sdk/types/contract.test-d.js.map +1 -0
- package/dist/src/sdk/types/http-schema.js +73 -0
- package/dist/src/sdk/types/http-schema.js.map +1 -0
- package/dist/src/sdk/types/rpc-schema.js +2 -0
- package/dist/src/sdk/types/rpc-schema.js.map +1 -0
- package/dist/src/sdk/utils/chain/defineChain.js +9 -0
- package/dist/src/sdk/utils/chain/defineChain.js.map +1 -0
- package/dist/src/sdk/utils/wit/codecs/u64.js +63 -0
- package/dist/src/sdk/utils/wit/codecs/u64.js.map +1 -0
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js +289 -0
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +1 -0
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +24 -0
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +1 -0
- package/dist/src/sdk/utils/wit/encode-function-data.test.js +91 -0
- package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +1 -0
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js +261 -0
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +1 -0
- package/dist/src/sdk/utils/wit/get-wit-item.test.js +167 -0
- package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +1 -0
- package/dist/src/wit/wit-parser/core/records.test.js +63 -0
- package/dist/src/wit/wit-parser/core/records.test.js.map +1 -0
- package/dist/src/wit/wit-parser/core/types/records.test-d.js +19 -0
- package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +1 -0
- package/dist/src/wit/wit-parser/core/types/utils.js +2 -0
- package/dist/src/wit/wit-parser/core/types/utils.js.map +1 -0
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js +159 -0
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +1 -0
- package/dist/src/wit/wit-parser/core/utils.js +213 -0
- package/dist/src/wit/wit-parser/core/utils.js.map +1 -0
- package/dist/src/wit/wit-parser/core/utils.test.js +316 -0
- package/dist/src/wit/wit-parser/core/utils.test.js.map +1 -0
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +93 -0
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +1 -0
- package/dist/src/wit/wit-parser/parse-wit.test.js +80 -0
- package/dist/src/wit/wit-parser/parse-wit.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/exports/index.d.ts +1 -1
- package/dist/types/exports/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/index.test.ts +18 -1
- package/src/exports/index.ts +1 -1
- package/src/sdk/actions/kontor/public/call-view.ts +6 -14
- package/src/sdk/actions/kontor/public/proc-contract.test.ts +1 -1
- package/src/sdk/actions/kontor/public/view-contract.test-d.ts +2 -17
- package/src/sdk/actions/kontor/public/view-contract.ts +8 -3
- package/src/sdk/actions/kontor/wallet/sign-reveal.ts +3 -35
- package/src/sdk/clients/base/create-rpc-client.test.ts +10 -4
- package/src/sdk/clients/create-public-client.test.ts +11 -3
- package/src/sdk/clients/kontor/create-public-client.test.ts +4 -3
- package/src/sdk/contracts/wits.ts +1 -1
- package/src/sdk/types/contract.test-d.ts +29 -24
- package/src/sdk/utils/wit/codecs/u64.ts +73 -0
- package/src/sdk/utils/wit/decode-wit-parameter.ts +5 -0
- package/src/sdk/utils/wit/encode-function-data.test-d.ts +15 -11
- package/src/sdk/utils/wit/encode-function-data.test.ts +1 -1
- package/src/sdk/utils/wit/encode-wit-parameters.ts +16 -1
- package/src/sdk/utils/wit/get-wit-item.test.ts +58 -9
- package/src/wit/wit-parser/core/records.test.ts +24 -14
- package/src/wit/wit-parser/core/types/records.test-d.ts +141 -28
- package/src/wit/wit-parser/core/types/utils.test-d.ts +23 -2
- package/src/wit/wit-parser/core/types/utils.ts +8 -41
- package/src/wit/wit-parser/core/utils.test.ts +14 -0
- package/src/wit/wit-parser/core/utils.ts +1 -0
- package/src/wit/wit-parser/parse-wit-parameter.test.ts +30 -3
- package/src/wit/wit-parser/parse-wit.test.ts +93 -102
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { expect, test, describe } from "vitest";
|
|
2
|
+
import { parseWitParameter, splitParameters, parseFunctionSignature, } from "./utils.js";
|
|
3
|
+
const parseOptions = {
|
|
4
|
+
records: {
|
|
5
|
+
"contract-address": [
|
|
6
|
+
{ name: "name", type: "string" },
|
|
7
|
+
{ name: "height", type: "s64" },
|
|
8
|
+
{ name: "tx-index", type: "s64" },
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
describe("parseFunctionSignature", () => {
|
|
13
|
+
test.each([
|
|
14
|
+
{
|
|
15
|
+
input: "export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
|
|
16
|
+
expected: {
|
|
17
|
+
context: "proc",
|
|
18
|
+
inputs: [
|
|
19
|
+
{
|
|
20
|
+
name: "arith-address",
|
|
21
|
+
type: "contract-address",
|
|
22
|
+
internalType: "contract-address",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "n",
|
|
26
|
+
type: "u64",
|
|
27
|
+
internalType: "u64",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
name: "fib",
|
|
31
|
+
outputs: [
|
|
32
|
+
{
|
|
33
|
+
type: "u64",
|
|
34
|
+
internalType: "u64",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
type: "function",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
input: "export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
42
|
+
expected: {
|
|
43
|
+
context: "view",
|
|
44
|
+
inputs: [],
|
|
45
|
+
name: "cached-values",
|
|
46
|
+
outputs: [
|
|
47
|
+
{
|
|
48
|
+
type: "list<u64>",
|
|
49
|
+
internalType: "list<u64>",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
type: "function",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
])("parseFunctionSignature($input)", ({ input, expected }) => {
|
|
56
|
+
expect(parseFunctionSignature(input)).toEqual(expected);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe("parseWitParameter", () => {
|
|
60
|
+
test.each([
|
|
61
|
+
{
|
|
62
|
+
parameter: "ctx: borrow<proc-context>",
|
|
63
|
+
expected: {
|
|
64
|
+
name: "ctx",
|
|
65
|
+
type: "borrow<proc-context>",
|
|
66
|
+
internalType: "borrow<proc-context>",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
parameter: "arith-address: contract-address",
|
|
71
|
+
expected: {
|
|
72
|
+
name: "arith-address",
|
|
73
|
+
type: "tuple",
|
|
74
|
+
internalType: "contract-address",
|
|
75
|
+
components: [
|
|
76
|
+
{ name: "name", type: "string" },
|
|
77
|
+
{ name: "height", type: "s64" },
|
|
78
|
+
{ name: "tx-index", type: "s64" },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
parameter: "n: u64",
|
|
84
|
+
expected: {
|
|
85
|
+
name: "n",
|
|
86
|
+
type: "u64",
|
|
87
|
+
internalType: "u64",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
parameter: "y: string",
|
|
92
|
+
expected: {
|
|
93
|
+
name: "y",
|
|
94
|
+
type: "string",
|
|
95
|
+
internalType: "string",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
parameter: "list-of-strings: list<string>",
|
|
100
|
+
expected: {
|
|
101
|
+
name: "list-of-strings",
|
|
102
|
+
type: "list<string>",
|
|
103
|
+
internalType: "list<string>",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
parameter: "arith-addresses: list<contract-address>",
|
|
108
|
+
expected: {
|
|
109
|
+
name: "arith-addresses",
|
|
110
|
+
type: "list<tuple>",
|
|
111
|
+
internalType: "list<contract-address>",
|
|
112
|
+
components: [
|
|
113
|
+
{ name: "name", type: "string" },
|
|
114
|
+
{ name: "height", type: "s64" },
|
|
115
|
+
{ name: "tx-index", type: "s64" },
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
parameter: "list<contract-address>",
|
|
121
|
+
expected: {
|
|
122
|
+
type: "list<tuple>",
|
|
123
|
+
internalType: "list<contract-address>",
|
|
124
|
+
components: [
|
|
125
|
+
{ name: "name", type: "string" },
|
|
126
|
+
{ name: "height", type: "s64" },
|
|
127
|
+
{ name: "tx-index", type: "s64" },
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
parameter: "option<contract-address>",
|
|
133
|
+
expected: {
|
|
134
|
+
type: "option<tuple>",
|
|
135
|
+
internalType: "option<contract-address>",
|
|
136
|
+
components: [
|
|
137
|
+
{ name: "name", type: "string" },
|
|
138
|
+
{ name: "height", type: "s64" },
|
|
139
|
+
{ name: "tx-index", type: "s64" },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
parameter: "result<contract-address, error>",
|
|
145
|
+
expected: {
|
|
146
|
+
type: "result<tuple, error>",
|
|
147
|
+
internalType: "result<contract-address, error>",
|
|
148
|
+
components: [
|
|
149
|
+
{ name: "name", type: "string" },
|
|
150
|
+
{ name: "height", type: "s64" },
|
|
151
|
+
{ name: "tx-index", type: "s64" },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
parameter: "result<list<contract-address>, error>",
|
|
157
|
+
expected: {
|
|
158
|
+
type: "result<list<tuple>, error>",
|
|
159
|
+
internalType: "result<list<contract-address>, error>",
|
|
160
|
+
components: [
|
|
161
|
+
{ name: "name", type: "string" },
|
|
162
|
+
{ name: "height", type: "s64" },
|
|
163
|
+
{ name: "tx-index", type: "s64" },
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
// {
|
|
168
|
+
// parameter: "result<string, list<option<contract-address>>>",
|
|
169
|
+
// expected: {
|
|
170
|
+
// type: "result<string, list<option<tuple>>>",
|
|
171
|
+
// components: [
|
|
172
|
+
// { name: "left", type: "string" },
|
|
173
|
+
// {
|
|
174
|
+
// name: "right",
|
|
175
|
+
// type: "list<option<tuple>>",
|
|
176
|
+
// components: [
|
|
177
|
+
// { name: "name", type: "string" },
|
|
178
|
+
// { name: "height", type: "s64" },
|
|
179
|
+
// { name: "tx-index", type: "s64" },
|
|
180
|
+
// ],
|
|
181
|
+
// },
|
|
182
|
+
// ],
|
|
183
|
+
// },
|
|
184
|
+
// },
|
|
185
|
+
// {
|
|
186
|
+
// parameter: "result<string, list<result<string, contract-address>>>",
|
|
187
|
+
// expected: {
|
|
188
|
+
// type: "result<string, list<result<string, tuple>>>",
|
|
189
|
+
// components: [
|
|
190
|
+
// { name: "left", type: "string" },
|
|
191
|
+
// {
|
|
192
|
+
// name: "right",
|
|
193
|
+
// type: "list<result<string, tuple>>",
|
|
194
|
+
// components: [
|
|
195
|
+
// { name: "left", type: "string" },
|
|
196
|
+
// {
|
|
197
|
+
// name: "right",
|
|
198
|
+
// type: "tuple",
|
|
199
|
+
// components: [
|
|
200
|
+
// { name: "name", type: "string" },
|
|
201
|
+
// { name: "height", type: "s64" },
|
|
202
|
+
// { name: "tx-index", type: "s64" },
|
|
203
|
+
// ],
|
|
204
|
+
// },
|
|
205
|
+
// ],
|
|
206
|
+
// },
|
|
207
|
+
// ],
|
|
208
|
+
// },
|
|
209
|
+
// },
|
|
210
|
+
// {
|
|
211
|
+
// parameter:
|
|
212
|
+
// "result<string, list<result<string, option<contract-address>>>>",
|
|
213
|
+
// expected: {
|
|
214
|
+
// type: "result<string, list<result<string, option<tuple>>>>",
|
|
215
|
+
// components: [
|
|
216
|
+
// { name: "left", type: "string" },
|
|
217
|
+
// {
|
|
218
|
+
// name: "right",
|
|
219
|
+
// type: "list<result<string, option<tuple>>>",
|
|
220
|
+
// components: [
|
|
221
|
+
// { name: "left", type: "string" },
|
|
222
|
+
// {
|
|
223
|
+
// name: "right",
|
|
224
|
+
// type: "option<tuple>",
|
|
225
|
+
// components: [
|
|
226
|
+
// { name: "name", type: "string" },
|
|
227
|
+
// { name: "height", type: "s64" },
|
|
228
|
+
// { name: "tx-index", type: "s64" },
|
|
229
|
+
// ],
|
|
230
|
+
// },
|
|
231
|
+
// ],
|
|
232
|
+
// },
|
|
233
|
+
// ],
|
|
234
|
+
// },
|
|
235
|
+
// },
|
|
236
|
+
// {
|
|
237
|
+
// parameter: "option<list<result<string, contract-address>>>",
|
|
238
|
+
// expected: {
|
|
239
|
+
// type: "option<list<result<string, tuple>>>",
|
|
240
|
+
// components: [
|
|
241
|
+
// { type: "string", name: "left" },
|
|
242
|
+
// {
|
|
243
|
+
// name: "right",
|
|
244
|
+
// type: "tuple",
|
|
245
|
+
// components: [
|
|
246
|
+
// { type: "string", name: "name" },
|
|
247
|
+
// { name: "height", type: "s64" },
|
|
248
|
+
// { name: "tx-index", type: "s64" },
|
|
249
|
+
// ],
|
|
250
|
+
// },
|
|
251
|
+
// ],
|
|
252
|
+
// },
|
|
253
|
+
// },
|
|
254
|
+
])("parseWitParameter($parameter)", ({ parameter, expected }) => {
|
|
255
|
+
expect(parseWitParameter(parameter, parseOptions)).toEqual(expected);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
// import { InvalidGenericSyntaxError } from "./errors";
|
|
259
|
+
describe("splitParameters (WIT generics, only < > nesting)", () => {
|
|
260
|
+
test("empty / whitespace", () => {
|
|
261
|
+
expect(splitParameters("")).toEqual([]);
|
|
262
|
+
expect(splitParameters(" ")).toEqual([]);
|
|
263
|
+
});
|
|
264
|
+
test("simple top-level commas", () => {
|
|
265
|
+
expect(splitParameters("a, b, c")).toEqual(["a", "b", "c"]);
|
|
266
|
+
expect(splitParameters(" a , b ,c ")).toEqual(["a", "b", "c"]);
|
|
267
|
+
});
|
|
268
|
+
test("does not split inside < >", () => {
|
|
269
|
+
expect(splitParameters("tuple<u64, list<string>>")).toEqual([
|
|
270
|
+
"tuple<u64, list<string>>",
|
|
271
|
+
]);
|
|
272
|
+
expect(splitParameters("result<integer, error>")).toEqual([
|
|
273
|
+
"result<integer, error>",
|
|
274
|
+
]);
|
|
275
|
+
expect(splitParameters("map<string, list<result<u64, error>>>")).toEqual([
|
|
276
|
+
"map<string, list<result<u64, error>>>",
|
|
277
|
+
]);
|
|
278
|
+
});
|
|
279
|
+
test("mixed: top-level params that contain nested generics", () => {
|
|
280
|
+
const input = "ctx: borrow<proc-context>, pair: list<result<token-pair, error>>, n: u64";
|
|
281
|
+
expect(splitParameters(input)).toEqual([
|
|
282
|
+
"ctx: borrow<proc-context>",
|
|
283
|
+
"pair: list<result<token-pair, error>>",
|
|
284
|
+
"n: u64",
|
|
285
|
+
]);
|
|
286
|
+
});
|
|
287
|
+
test("deep nesting", () => {
|
|
288
|
+
const input = "outer<mid<inner<u8, list<u16>>>>";
|
|
289
|
+
expect(splitParameters(input)).toEqual([
|
|
290
|
+
"outer<mid<inner<u8, list<u16>>>>",
|
|
291
|
+
]);
|
|
292
|
+
});
|
|
293
|
+
test("handles trailing comma by ignoring empty token", () => {
|
|
294
|
+
expect(splitParameters("a, b<z, y>,")) // trailing comma
|
|
295
|
+
.toEqual(["a", "b<z, y>"]);
|
|
296
|
+
});
|
|
297
|
+
test("ignores empty segments from duplicate commas", () => {
|
|
298
|
+
expect(splitParameters("a,,b")).toEqual(["a", "b"]);
|
|
299
|
+
expect(splitParameters(",a,b,")).toEqual(["a", "b"]);
|
|
300
|
+
});
|
|
301
|
+
test("throws on unbalanced opener", () => {
|
|
302
|
+
expect(() => splitParameters("a<b,c")).toThrow(); // e.g., InvalidGenericSyntaxError
|
|
303
|
+
});
|
|
304
|
+
test("throws on stray closer", () => {
|
|
305
|
+
expect(() => splitParameters("a,b>")).toThrow();
|
|
306
|
+
});
|
|
307
|
+
test("complex function-style params", () => {
|
|
308
|
+
const input = "ctx: borrow<proc-context>, result: result<tuple<u64, list<string>>, error>, flag: bool";
|
|
309
|
+
expect(splitParameters(input)).toEqual([
|
|
310
|
+
"ctx: borrow<proc-context>",
|
|
311
|
+
"result: result<tuple<u64, list<string>>, error>",
|
|
312
|
+
"flag: bool",
|
|
313
|
+
]);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../src/wit/wit-parser/core/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EA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OAAO,EAAE,CAAC,CAAC,kCAAkC;IACtF,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GACT,wFAAwF,CAAC;QAC3F,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;YACrC,2BAA2B;YAC3B,iDAAiD;YACjD,YAAY;SACb,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { expectTypeOf, expect, test } from "vitest";
|
|
2
|
+
import { parseWitParameter } from "./parse-wit-parameter.js";
|
|
3
|
+
test("ParseWitParameter", () => {
|
|
4
|
+
expectTypeOf()
|
|
5
|
+
.toEqualTypeOf;
|
|
6
|
+
expectTypeOf().toEqualTypeOf();
|
|
7
|
+
expectTypeOf().toEqualTypeOf();
|
|
8
|
+
});
|
|
9
|
+
test("parseWitParameter", () => {
|
|
10
|
+
expect(() => parseWitParameter(" ")).toThrowErrorMatchingInlineSnapshot(`
|
|
11
|
+
[InvalidWitParameterError: Failed to parse Wit parameter.
|
|
12
|
+
|
|
13
|
+
Details: parseWitParameter(" ")
|
|
14
|
+
Version: kontor-sdk@1.0.0]
|
|
15
|
+
`);
|
|
16
|
+
});
|
|
17
|
+
test.each([
|
|
18
|
+
{
|
|
19
|
+
signature: "ctx: borrow<proc-context>",
|
|
20
|
+
expected: {
|
|
21
|
+
name: "ctx",
|
|
22
|
+
type: "borrow<proc-context>",
|
|
23
|
+
internalType: "borrow<proc-context>",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
signature: "arith-address: contract-address",
|
|
28
|
+
expected: {
|
|
29
|
+
name: "arith-address",
|
|
30
|
+
type: "contract-address",
|
|
31
|
+
internalType: "contract-address",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
signature: [
|
|
36
|
+
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
37
|
+
"arith-address: contract-address",
|
|
38
|
+
],
|
|
39
|
+
expected: {
|
|
40
|
+
name: "arith-address",
|
|
41
|
+
type: "tuple",
|
|
42
|
+
internalType: "contract-address",
|
|
43
|
+
components: [
|
|
44
|
+
{
|
|
45
|
+
name: "name",
|
|
46
|
+
type: "string",
|
|
47
|
+
internalType: "string",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "height",
|
|
51
|
+
type: "s64",
|
|
52
|
+
internalType: "s64",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "tx-index",
|
|
56
|
+
type: "s64",
|
|
57
|
+
internalType: "s64",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
signature: [
|
|
64
|
+
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
65
|
+
"arith-address: result<contract-address, error>",
|
|
66
|
+
],
|
|
67
|
+
expected: {
|
|
68
|
+
name: "arith-address",
|
|
69
|
+
type: "result<tuple, error>",
|
|
70
|
+
internalType: "result<contract-address, error>",
|
|
71
|
+
components: [
|
|
72
|
+
{
|
|
73
|
+
name: "name",
|
|
74
|
+
type: "string",
|
|
75
|
+
internalType: "string",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "height",
|
|
79
|
+
type: "s64",
|
|
80
|
+
internalType: "s64",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "tx-index",
|
|
84
|
+
type: "s64",
|
|
85
|
+
internalType: "s64",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
])("parseAbiParameter($signature)", ({ signature, expected }) => {
|
|
91
|
+
expect(parseWitParameter(signature)).toEqual(expected);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=parse-wit-parameter.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-wit-parameter.test.js","sourceRoot":"","sources":["../../../../src/wit/wit-parser/parse-wit-parameter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,YAAY,EAA0D;SACnE,aAID,CAAC;IAEH,YAAY,EAOT,CAAC,aAAa,EAqBb,CAAC;IAEL,YAAY,EAOT,CAAC,aAAa,EAqBb,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,kCAAkC,CACrE;;;;;GAKD,CACA,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC;IACR;QACE,SAAS,EAAE,2BAA2B;QACtC,QAAQ,EAAE;YACR,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,sBAAsB;YAC5B,YAAY,EAAE,sBAAsB;SACrC;KACF;IACD;QACE,SAAS,EAAE,iCAAiC;QAC5C,QAAQ,EAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAkB;YAExB,YAAY,EAAE,kBAAkB;SACjC;KACF;IACD;QACE,SAAS,EAAE;YACT,uEAAuE;YACvE,iCAAiC;SAClC;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,eAAe;YAErB,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,kBAAkB;YAChC,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,YAAY,EAAE,QAAQ;iBACvB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,KAAK;iBACpB;gBACD;oBACE,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,KAAK;iBACpB;aACF;SACF;KACF;IACD;QACE,SAAS,EAAE;YACT,uEAAuE;YACvE,iDAAiD;SAClD;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,sBAAsB;YAC5B,YAAY,EAAE,iCAAiC;YAC/C,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,YAAY,EAAE,QAAQ;iBACvB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,KAAK;iBACpB;gBACD;oBACE,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,KAAK;iBACpB;aACF;SACF;KACF;CACF,CAAC,CAAC,+BAA+B,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9D,MAAM,CAAC,iBAAiB,CAAoB,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { expectTypeOf, describe, expect, test } from "vitest";
|
|
2
|
+
import { parseWit } from "./parse-wit.js";
|
|
3
|
+
test("ParseWit (types)", () => {
|
|
4
|
+
// type-level assertions
|
|
5
|
+
expectTypeOf().toEqualTypeOf();
|
|
6
|
+
});
|
|
7
|
+
describe("parseWit (runtime)", () => {
|
|
8
|
+
test("parses proc + view functions and strips ctx from inputs", () => {
|
|
9
|
+
const input = [
|
|
10
|
+
// TODO: build in record defs should be defined under the hood
|
|
11
|
+
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
12
|
+
"export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
|
|
13
|
+
"export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
|
|
14
|
+
"export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
15
|
+
"export return-option: func(ctx: borrow<view-context>) -> option<u64>;",
|
|
16
|
+
];
|
|
17
|
+
const out = parseWit(input);
|
|
18
|
+
expect(out).toEqual([
|
|
19
|
+
{
|
|
20
|
+
name: "fib",
|
|
21
|
+
type: "function",
|
|
22
|
+
context: "proc",
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
name: "arith-address",
|
|
26
|
+
type: "tuple",
|
|
27
|
+
internalType: "contract-address",
|
|
28
|
+
components: [
|
|
29
|
+
{ name: "name", type: "string", internalType: "string" },
|
|
30
|
+
{ name: "height", type: "s64", internalType: "s64" },
|
|
31
|
+
{ name: "tx-index", type: "s64", internalType: "s64" },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{ name: "n", type: "u64", internalType: "u64" },
|
|
35
|
+
],
|
|
36
|
+
outputs: [{ type: "u64", internalType: "u64" }],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "fib-of-sub",
|
|
40
|
+
type: "function",
|
|
41
|
+
context: "proc",
|
|
42
|
+
inputs: [
|
|
43
|
+
{
|
|
44
|
+
name: "arith-address",
|
|
45
|
+
type: "tuple",
|
|
46
|
+
internalType: "contract-address",
|
|
47
|
+
components: [
|
|
48
|
+
{ name: "name", type: "string", internalType: "string" },
|
|
49
|
+
{ name: "height", type: "s64", internalType: "s64" },
|
|
50
|
+
{ name: "tx-index", type: "s64", internalType: "s64" },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{ name: "x", type: "string", internalType: "string" },
|
|
54
|
+
{ name: "y", type: "string", internalType: "string" },
|
|
55
|
+
],
|
|
56
|
+
outputs: [
|
|
57
|
+
{
|
|
58
|
+
type: "result<u64, error>",
|
|
59
|
+
internalType: "result<u64, error>",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "cached-values",
|
|
65
|
+
type: "function",
|
|
66
|
+
context: "view",
|
|
67
|
+
inputs: [],
|
|
68
|
+
outputs: [{ type: "list<u64>", internalType: "list<u64>" }],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "return-option",
|
|
72
|
+
type: "function",
|
|
73
|
+
context: "view",
|
|
74
|
+
inputs: [],
|
|
75
|
+
outputs: [{ type: "option<u64>", internalType: "option<u64>" }],
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=parse-wit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-wit.test.js","sourceRoot":"","sources":["../../../../src/wit/wit-parser/parse-wit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC5B,wBAAwB;IAExB,YAAY,EAST,CAAC,aAAa,EA+Fd,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACnE,MAAM,KAAK,GAAG;YACZ,8DAA8D;YAC9D,uEAAuE;YACvE,8FAA8F;YAC9F,kIAAkI;YAClI,qEAAqE;YACrE,uEAAuE;SAC/D,CAAC;QAEX,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE5B,MAAM,CA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