@kontor/kontor-sdk 1.0.0-alpha.19 → 1.0.0-alpha.21
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-view.js +1 -1
- package/dist/cjs/sdk/actions/kontor/public/call-view.js.map +1 -1
- package/dist/cjs/sdk/actions/kontor/public/view-contract.js +5 -3
- package/dist/cjs/sdk/actions/kontor/public/view-contract.js.map +1 -1
- package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js +2 -6
- package/dist/cjs/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/cjs/sdk/contracts/wits.js +0 -1
- package/dist/cjs/sdk/contracts/wits.js.map +1 -1
- package/dist/cjs/sdk/utils/wit/codecs/u64.js +56 -0
- package/dist/cjs/sdk/utils/wit/codecs/u64.js.map +1 -0
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js +3 -0
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/cjs/sdk/utils/wit/encode-wit-parameters.js +10 -0
- package/dist/cjs/sdk/utils/wit/encode-wit-parameters.js.map +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/cjs/wit/wit-parser/core/utils.js +1 -0
- package/dist/cjs/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/public/call-view.js +1 -1
- package/dist/esm/sdk/actions/kontor/public/call-view.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/public/view-contract.js +7 -3
- package/dist/esm/sdk/actions/kontor/public/view-contract.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js +2 -31
- package/dist/esm/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/esm/sdk/contracts/wits.js +1 -1
- package/dist/esm/sdk/contracts/wits.js.map +1 -1
- package/dist/esm/sdk/utils/wit/codecs/u64.js +63 -0
- package/dist/esm/sdk/utils/wit/codecs/u64.js.map +1 -0
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js +3 -0
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/esm/sdk/utils/wit/encode-wit-parameters.js +11 -0
- package/dist/esm/sdk/utils/wit/encode-wit-parameters.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/wit/wit-parser/core/utils.js +1 -0
- package/dist/esm/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/types/sdk/actions/kontor/public/call-view.d.ts +2 -11
- package/dist/types/sdk/actions/kontor/public/call-view.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/public/view-contract.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/wallet/sign-reveal.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/utils/wit/codecs/u64.d.ts +23 -0
- package/dist/types/sdk/utils/wit/codecs/u64.d.ts.map +1 -0
- package/dist/types/sdk/utils/wit/decode-wit-parameter.d.ts +1 -1
- package/dist/types/sdk/utils/wit/decode-wit-parameter.d.ts.map +1 -1
- package/dist/types/sdk/utils/wit/encode-wit-parameters.d.ts.map +1 -1
- package/dist/types/wit/wit-parser/core/types/utils.d.ts +4 -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/package.json +1 -1
- package/src/exports/index.test.ts +18 -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 +99 -102
|
@@ -46,30 +46,36 @@ test("ParseWitParameter", () => {
|
|
|
46
46
|
assertType<ParseWitParameter<"ctx: borrow<proc-context>">>({
|
|
47
47
|
name: "ctx",
|
|
48
48
|
type: "borrow<proc-context>",
|
|
49
|
+
internalType: "borrow<proc-context>",
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
assertType<ParseWitParameter<"arith-address: contract-address">>({
|
|
52
53
|
name: "arith-address",
|
|
53
54
|
type: "contract-address",
|
|
55
|
+
internalType: "contract-address",
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
assertType<ParseWitParameter<"n: u64">>({
|
|
57
59
|
name: "n",
|
|
58
60
|
type: "u64",
|
|
61
|
+
internalType: "u64",
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
assertType<ParseWitParameter<"u64">>({
|
|
62
65
|
type: "u64",
|
|
66
|
+
internalType: "u64",
|
|
63
67
|
});
|
|
64
68
|
|
|
65
69
|
assertType<ParseWitParameter<"x: string">>({
|
|
66
70
|
name: "x",
|
|
67
71
|
type: "string",
|
|
72
|
+
internalType: "string",
|
|
68
73
|
});
|
|
69
74
|
|
|
70
75
|
assertType<ParseWitParameter<"y: string">>({
|
|
71
76
|
name: "y",
|
|
72
77
|
type: "string",
|
|
78
|
+
internalType: "string",
|
|
73
79
|
});
|
|
74
80
|
|
|
75
81
|
assertType<ParseWitParameter<"option-string: option<string>">>({
|
|
@@ -91,15 +97,18 @@ test("ParseWitParameter", () => {
|
|
|
91
97
|
|
|
92
98
|
assertType<ParseWitParameter<"contract-address">>({
|
|
93
99
|
type: "contract-address",
|
|
100
|
+
internalType: "contract-address",
|
|
94
101
|
});
|
|
95
102
|
assertType<ParseWitParameter<"ctx: borrow<view-context>">>({
|
|
96
103
|
name: "ctx",
|
|
97
104
|
type: "borrow<view-context>",
|
|
105
|
+
internalType: "borrow<view-context>",
|
|
98
106
|
});
|
|
99
107
|
|
|
100
108
|
assertType<ParseWitParameter<"arith-address: contract-address">>({
|
|
101
109
|
name: "arith-address",
|
|
102
110
|
type: "contract-address",
|
|
111
|
+
internalType: "contract-address",
|
|
103
112
|
});
|
|
104
113
|
});
|
|
105
114
|
|
|
@@ -149,12 +158,17 @@ test("Parse Signature", () => {
|
|
|
149
158
|
name: "fib",
|
|
150
159
|
context: "proc",
|
|
151
160
|
inputs: [
|
|
152
|
-
{
|
|
161
|
+
{
|
|
162
|
+
name: "arith-address",
|
|
163
|
+
type: "contract-address",
|
|
164
|
+
internalType: "contract-address",
|
|
165
|
+
},
|
|
153
166
|
{ name: "n", type: "list<u64>" },
|
|
154
167
|
],
|
|
155
168
|
outputs: [
|
|
156
169
|
{
|
|
157
170
|
type: "u64",
|
|
171
|
+
internalType: "u64",
|
|
158
172
|
},
|
|
159
173
|
],
|
|
160
174
|
});
|
|
@@ -165,12 +179,17 @@ test("Parse Signature", () => {
|
|
|
165
179
|
name: "fib",
|
|
166
180
|
context: "proc",
|
|
167
181
|
inputs: [
|
|
168
|
-
{
|
|
182
|
+
{
|
|
183
|
+
name: "arith-address",
|
|
184
|
+
type: "contract-address",
|
|
185
|
+
internalType: "contract-address",
|
|
186
|
+
},
|
|
169
187
|
{ name: "n", type: "list<u64>" },
|
|
170
188
|
],
|
|
171
189
|
outputs: [
|
|
172
190
|
{
|
|
173
191
|
type: "contract-address",
|
|
192
|
+
internalType: "contract-address",
|
|
174
193
|
},
|
|
175
194
|
],
|
|
176
195
|
});
|
|
@@ -184,12 +203,14 @@ test("Parse Signature", () => {
|
|
|
184
203
|
{
|
|
185
204
|
name: "arith-address",
|
|
186
205
|
type: "contract-address",
|
|
206
|
+
internalType: "contract-address",
|
|
187
207
|
},
|
|
188
208
|
{ name: "n", type: "list<u64>" },
|
|
189
209
|
],
|
|
190
210
|
outputs: [
|
|
191
211
|
{
|
|
192
212
|
type: "contract-address",
|
|
213
|
+
internalType: "contract-address",
|
|
193
214
|
},
|
|
194
215
|
],
|
|
195
216
|
});
|
|
@@ -26,9 +26,13 @@ type GetComponents<T> = T extends { components: infer C }
|
|
|
26
26
|
type AsTupleFromRecord<T extends string, Opts extends ParseOptions> =
|
|
27
27
|
HasRecords<Opts> extends true
|
|
28
28
|
? T extends keyof RecordsOf<Opts>
|
|
29
|
-
? Readonlyify<{
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
? Readonlyify<{
|
|
30
|
+
type: "tuple";
|
|
31
|
+
components: RecordsOf<Opts>[T];
|
|
32
|
+
internalType: T;
|
|
33
|
+
}>
|
|
34
|
+
: Readonlyify<{ type: T; internalType: T }>
|
|
35
|
+
: Readonlyify<{ type: T; internalType: T }>;
|
|
32
36
|
|
|
33
37
|
type SplitResultInner<S extends string> = S extends `${infer L}, ${infer R}`
|
|
34
38
|
? [Trim<L>, Trim<R>]
|
|
@@ -40,44 +44,6 @@ type MaybeResultComponents<
|
|
|
40
44
|
_Err extends { type: string },
|
|
41
45
|
> = Ok extends { components: infer _C } ? GetComponents<Ok> : {};
|
|
42
46
|
|
|
43
|
-
// type MaybeResultComponents<
|
|
44
|
-
// L extends { type: string },
|
|
45
|
-
// R extends { type: string },
|
|
46
|
-
// > = L extends { components: infer _LC }
|
|
47
|
-
// ? R extends { components: infer _RC }
|
|
48
|
-
// ? {
|
|
49
|
-
// readonly components: [
|
|
50
|
-
// {
|
|
51
|
-
// readonly name: "left";
|
|
52
|
-
// readonly type: L["type"];
|
|
53
|
-
// } & GetComponents<L>,
|
|
54
|
-
// {
|
|
55
|
-
// readonly name: "right";
|
|
56
|
-
// readonly type: R["type"];
|
|
57
|
-
// } & GetComponents<R>,
|
|
58
|
-
// ];
|
|
59
|
-
// }
|
|
60
|
-
// : {
|
|
61
|
-
// readonly components: [
|
|
62
|
-
// {
|
|
63
|
-
// readonly name: "left";
|
|
64
|
-
// readonly type: L["type"];
|
|
65
|
-
// } & GetComponents<L>,
|
|
66
|
-
// { readonly name: "right"; readonly type: R["type"] },
|
|
67
|
-
// ];
|
|
68
|
-
// }
|
|
69
|
-
// : R extends { components: infer _RC }
|
|
70
|
-
// ? {
|
|
71
|
-
// readonly components: [
|
|
72
|
-
// { readonly name: "left"; readonly type: L["type"] },
|
|
73
|
-
// {
|
|
74
|
-
// readonly name: "right";
|
|
75
|
-
// readonly type: R["type"];
|
|
76
|
-
// } & GetComponents<R>,
|
|
77
|
-
// ];
|
|
78
|
-
// }
|
|
79
|
-
// : {}; // neither side has components → omit components entirely
|
|
80
|
-
|
|
81
47
|
type MapGenericType<T extends string, Opts extends ParseOptions> =
|
|
82
48
|
// list<...>
|
|
83
49
|
T extends `list<${infer U}>`
|
|
@@ -103,6 +69,7 @@ type MapGenericType<T extends string, Opts extends ParseOptions> =
|
|
|
103
69
|
? Readonlyify<
|
|
104
70
|
{
|
|
105
71
|
type: `result<${LMapped["type"]}, ${RMapped["type"]}>`;
|
|
72
|
+
internalType: T;
|
|
106
73
|
} & MaybeResultComponents<LMapped, RMapped>
|
|
107
74
|
>
|
|
108
75
|
: never
|
|
@@ -28,16 +28,19 @@ describe("parseFunctionSignature", () => {
|
|
|
28
28
|
{
|
|
29
29
|
name: "arith-address",
|
|
30
30
|
type: "contract-address",
|
|
31
|
+
internalType: "contract-address",
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
name: "n",
|
|
34
35
|
type: "u64",
|
|
36
|
+
internalType: "u64",
|
|
35
37
|
},
|
|
36
38
|
],
|
|
37
39
|
name: "fib",
|
|
38
40
|
outputs: [
|
|
39
41
|
{
|
|
40
42
|
type: "u64",
|
|
43
|
+
internalType: "u64",
|
|
41
44
|
},
|
|
42
45
|
],
|
|
43
46
|
type: "function",
|
|
@@ -53,6 +56,7 @@ describe("parseFunctionSignature", () => {
|
|
|
53
56
|
outputs: [
|
|
54
57
|
{
|
|
55
58
|
type: "list<u64>",
|
|
59
|
+
internalType: "list<u64>",
|
|
56
60
|
},
|
|
57
61
|
],
|
|
58
62
|
type: "function",
|
|
@@ -70,6 +74,7 @@ describe("parseWitParameter", () => {
|
|
|
70
74
|
expected: {
|
|
71
75
|
name: "ctx",
|
|
72
76
|
type: "borrow<proc-context>",
|
|
77
|
+
internalType: "borrow<proc-context>",
|
|
73
78
|
},
|
|
74
79
|
},
|
|
75
80
|
{
|
|
@@ -77,6 +82,7 @@ describe("parseWitParameter", () => {
|
|
|
77
82
|
expected: {
|
|
78
83
|
name: "arith-address",
|
|
79
84
|
type: "tuple",
|
|
85
|
+
internalType: "contract-address",
|
|
80
86
|
components: [
|
|
81
87
|
{ name: "name", type: "string" },
|
|
82
88
|
{ name: "height", type: "s64" },
|
|
@@ -89,6 +95,7 @@ describe("parseWitParameter", () => {
|
|
|
89
95
|
expected: {
|
|
90
96
|
name: "n",
|
|
91
97
|
type: "u64",
|
|
98
|
+
internalType: "u64",
|
|
92
99
|
},
|
|
93
100
|
},
|
|
94
101
|
{
|
|
@@ -96,6 +103,7 @@ describe("parseWitParameter", () => {
|
|
|
96
103
|
expected: {
|
|
97
104
|
name: "y",
|
|
98
105
|
type: "string",
|
|
106
|
+
internalType: "string",
|
|
99
107
|
},
|
|
100
108
|
},
|
|
101
109
|
{
|
|
@@ -103,6 +111,7 @@ describe("parseWitParameter", () => {
|
|
|
103
111
|
expected: {
|
|
104
112
|
name: "list-of-strings",
|
|
105
113
|
type: "list<string>",
|
|
114
|
+
internalType: "list<string>",
|
|
106
115
|
},
|
|
107
116
|
},
|
|
108
117
|
{
|
|
@@ -110,6 +119,7 @@ describe("parseWitParameter", () => {
|
|
|
110
119
|
expected: {
|
|
111
120
|
name: "arith-addresses",
|
|
112
121
|
type: "list<tuple>",
|
|
122
|
+
internalType: "list<contract-address>",
|
|
113
123
|
components: [
|
|
114
124
|
{ name: "name", type: "string" },
|
|
115
125
|
{ name: "height", type: "s64" },
|
|
@@ -121,6 +131,7 @@ describe("parseWitParameter", () => {
|
|
|
121
131
|
parameter: "list<contract-address>",
|
|
122
132
|
expected: {
|
|
123
133
|
type: "list<tuple>",
|
|
134
|
+
internalType: "list<contract-address>",
|
|
124
135
|
components: [
|
|
125
136
|
{ name: "name", type: "string" },
|
|
126
137
|
{ name: "height", type: "s64" },
|
|
@@ -132,6 +143,7 @@ describe("parseWitParameter", () => {
|
|
|
132
143
|
parameter: "option<contract-address>",
|
|
133
144
|
expected: {
|
|
134
145
|
type: "option<tuple>",
|
|
146
|
+
internalType: "option<contract-address>",
|
|
135
147
|
components: [
|
|
136
148
|
{ name: "name", type: "string" },
|
|
137
149
|
{ name: "height", type: "s64" },
|
|
@@ -143,6 +155,7 @@ describe("parseWitParameter", () => {
|
|
|
143
155
|
parameter: "result<contract-address, error>",
|
|
144
156
|
expected: {
|
|
145
157
|
type: "result<tuple, error>",
|
|
158
|
+
internalType: "result<contract-address, error>",
|
|
146
159
|
components: [
|
|
147
160
|
{ name: "name", type: "string" },
|
|
148
161
|
{ name: "height", type: "s64" },
|
|
@@ -154,6 +167,7 @@ describe("parseWitParameter", () => {
|
|
|
154
167
|
parameter: "result<list<contract-address>, error>",
|
|
155
168
|
expected: {
|
|
156
169
|
type: "result<list<tuple>, error>",
|
|
170
|
+
internalType: "result<list<contract-address>, error>",
|
|
157
171
|
components: [
|
|
158
172
|
{ name: "name", type: "string" },
|
|
159
173
|
{ name: "height", type: "s64" },
|
|
@@ -7,6 +7,7 @@ test("ParseWitParameter", () => {
|
|
|
7
7
|
expectTypeOf<ParseWitParameter<["arith-address: contract-address"]>>()
|
|
8
8
|
.toEqualTypeOf<{
|
|
9
9
|
name: "arith-address";
|
|
10
|
+
internalType: "contract-address";
|
|
10
11
|
type: "contract-address";
|
|
11
12
|
}>;
|
|
12
13
|
|
|
@@ -20,18 +21,22 @@ test("ParseWitParameter", () => {
|
|
|
20
21
|
>().toEqualTypeOf<{
|
|
21
22
|
readonly name: "arith-address";
|
|
22
23
|
readonly type: "tuple";
|
|
24
|
+
readonly internalType: "contract-address";
|
|
23
25
|
readonly components: readonly [
|
|
24
26
|
{
|
|
25
27
|
readonly name: "name";
|
|
26
28
|
readonly type: "string";
|
|
29
|
+
readonly internalType: "string";
|
|
27
30
|
},
|
|
28
31
|
{
|
|
29
32
|
readonly name: "height";
|
|
30
33
|
readonly type: "s64";
|
|
34
|
+
readonly internalType: "s64";
|
|
31
35
|
},
|
|
32
36
|
{
|
|
33
37
|
readonly name: "tx-index";
|
|
34
38
|
readonly type: "s64";
|
|
39
|
+
readonly internalType: "s64";
|
|
35
40
|
},
|
|
36
41
|
];
|
|
37
42
|
}>();
|
|
@@ -46,18 +51,22 @@ test("ParseWitParameter", () => {
|
|
|
46
51
|
>().toEqualTypeOf<{
|
|
47
52
|
readonly name: "arith-address";
|
|
48
53
|
readonly type: "result<tuple, error>";
|
|
54
|
+
readonly internalType: "result<contract-address, error>";
|
|
49
55
|
readonly components: readonly [
|
|
50
56
|
{
|
|
51
57
|
readonly name: "name";
|
|
52
58
|
readonly type: "string";
|
|
59
|
+
readonly internalType: "string";
|
|
53
60
|
},
|
|
54
61
|
{
|
|
55
62
|
readonly name: "height";
|
|
56
63
|
readonly type: "s64";
|
|
64
|
+
readonly internalType: "s64";
|
|
57
65
|
},
|
|
58
66
|
{
|
|
59
67
|
readonly name: "tx-index";
|
|
60
68
|
readonly type: "s64";
|
|
69
|
+
readonly internalType: "s64";
|
|
61
70
|
},
|
|
62
71
|
];
|
|
63
72
|
}>();
|
|
@@ -69,7 +78,7 @@ test("parseWitParameter", () => {
|
|
|
69
78
|
[InvalidWitParameterError: Failed to parse Wit parameter.
|
|
70
79
|
|
|
71
80
|
Details: parseWitParameter(" ")
|
|
72
|
-
Version: kontor-
|
|
81
|
+
Version: kontor-sdk@1.0.0]
|
|
73
82
|
`,
|
|
74
83
|
);
|
|
75
84
|
});
|
|
@@ -77,11 +86,20 @@ test("parseWitParameter", () => {
|
|
|
77
86
|
test.each([
|
|
78
87
|
{
|
|
79
88
|
signature: "ctx: borrow<proc-context>",
|
|
80
|
-
expected: {
|
|
89
|
+
expected: {
|
|
90
|
+
name: "ctx",
|
|
91
|
+
type: "borrow<proc-context>",
|
|
92
|
+
internalType: "borrow<proc-context>",
|
|
93
|
+
},
|
|
81
94
|
},
|
|
82
95
|
{
|
|
83
96
|
signature: "arith-address: contract-address",
|
|
84
|
-
expected: {
|
|
97
|
+
expected: {
|
|
98
|
+
name: "arith-address",
|
|
99
|
+
type: "contract-address",
|
|
100
|
+
|
|
101
|
+
internalType: "contract-address",
|
|
102
|
+
},
|
|
85
103
|
},
|
|
86
104
|
{
|
|
87
105
|
signature: [
|
|
@@ -90,19 +108,24 @@ test.each([
|
|
|
90
108
|
],
|
|
91
109
|
expected: {
|
|
92
110
|
name: "arith-address",
|
|
111
|
+
|
|
93
112
|
type: "tuple",
|
|
113
|
+
internalType: "contract-address",
|
|
94
114
|
components: [
|
|
95
115
|
{
|
|
96
116
|
name: "name",
|
|
97
117
|
type: "string",
|
|
118
|
+
internalType: "string",
|
|
98
119
|
},
|
|
99
120
|
{
|
|
100
121
|
name: "height",
|
|
101
122
|
type: "s64",
|
|
123
|
+
internalType: "s64",
|
|
102
124
|
},
|
|
103
125
|
{
|
|
104
126
|
name: "tx-index",
|
|
105
127
|
type: "s64",
|
|
128
|
+
internalType: "s64",
|
|
106
129
|
},
|
|
107
130
|
],
|
|
108
131
|
},
|
|
@@ -115,18 +138,22 @@ test.each([
|
|
|
115
138
|
expected: {
|
|
116
139
|
name: "arith-address",
|
|
117
140
|
type: "result<tuple, error>",
|
|
141
|
+
internalType: "result<contract-address, error>",
|
|
118
142
|
components: [
|
|
119
143
|
{
|
|
120
144
|
name: "name",
|
|
121
145
|
type: "string",
|
|
146
|
+
internalType: "string",
|
|
122
147
|
},
|
|
123
148
|
{
|
|
124
149
|
name: "height",
|
|
125
150
|
type: "s64",
|
|
151
|
+
internalType: "s64",
|
|
126
152
|
},
|
|
127
153
|
{
|
|
128
154
|
name: "tx-index",
|
|
129
155
|
type: "s64",
|
|
156
|
+
internalType: "s64",
|
|
130
157
|
},
|
|
131
158
|
],
|
|
132
159
|
},
|
|
@@ -2,6 +2,12 @@ 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
|
+
// import type { nativeToken } from "../../sdk/contracts/wits.js";
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
// type t = ParseWit<typeof nativeToken.raw>;
|
|
10
|
+
//
|
|
5
11
|
|
|
6
12
|
test("ParseWit (types)", () => {
|
|
7
13
|
// type-level assertions
|
|
@@ -11,8 +17,8 @@ test("ParseWit (types)", () => {
|
|
|
11
17
|
[
|
|
12
18
|
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
13
19
|
"export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
|
|
14
|
-
"export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
|
|
15
|
-
"export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
20
|
+
// "export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
|
|
21
|
+
// "export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
16
22
|
]
|
|
17
23
|
>
|
|
18
24
|
>().toEqualTypeOf<
|
|
@@ -25,102 +31,90 @@ test("ParseWit (types)", () => {
|
|
|
25
31
|
{
|
|
26
32
|
readonly name: "arith-address";
|
|
27
33
|
readonly type: "tuple";
|
|
34
|
+
readonly internalType: "contract-address";
|
|
28
35
|
readonly components: readonly [
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
{
|
|
37
|
+
readonly name: "name";
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly internalType: "string";
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
readonly name: "height";
|
|
43
|
+
readonly type: "s64";
|
|
44
|
+
readonly internalType: "s64";
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
readonly name: "tx-index";
|
|
48
|
+
readonly type: "s64";
|
|
49
|
+
readonly internalType: "s64";
|
|
50
|
+
},
|
|
32
51
|
];
|
|
33
52
|
},
|
|
34
|
-
{ readonly name: "n"; readonly type: "u64" },
|
|
35
|
-
];
|
|
36
|
-
readonly outputs: readonly [{ readonly type: "u64" }];
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
readonly name: "fib-of-sub";
|
|
40
|
-
readonly type: "function";
|
|
41
|
-
readonly context: "proc";
|
|
42
|
-
readonly inputs: readonly [
|
|
43
|
-
{
|
|
44
|
-
readonly name: "arith-address";
|
|
45
|
-
readonly type: "tuple";
|
|
46
|
-
|
|
47
|
-
readonly components: readonly [
|
|
48
|
-
{ readonly name: "name"; readonly type: "string" },
|
|
49
|
-
{ readonly name: "height"; readonly type: "s64" },
|
|
50
|
-
{ readonly name: "tx-index"; readonly type: "s64" },
|
|
51
|
-
];
|
|
52
|
-
},
|
|
53
|
-
{ readonly name: "x"; readonly type: "string" },
|
|
54
|
-
{ readonly name: "y"; readonly type: "string" },
|
|
55
|
-
];
|
|
56
|
-
readonly outputs: readonly [{ readonly type: "result<u64, error>" }];
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
readonly name: "cached-values";
|
|
60
|
-
readonly type: "function";
|
|
61
|
-
readonly context: "view";
|
|
62
|
-
readonly inputs: readonly [];
|
|
63
|
-
readonly outputs: readonly [{ readonly type: "list<u64>" }];
|
|
64
|
-
},
|
|
65
|
-
]
|
|
66
|
-
>();
|
|
67
|
-
|
|
68
|
-
expectTypeOf<
|
|
69
|
-
ParseWit<
|
|
70
|
-
[
|
|
71
|
-
"record contract-address { name: string, height: s64, tx-index: s64 }",
|
|
72
|
-
"export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
|
|
73
|
-
"export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
|
|
74
|
-
"export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
|
|
75
|
-
]
|
|
76
|
-
>
|
|
77
|
-
>().toEqualTypeOf<
|
|
78
|
-
readonly [
|
|
79
|
-
{
|
|
80
|
-
readonly name: "fib";
|
|
81
|
-
readonly type: "function";
|
|
82
|
-
readonly context: "proc";
|
|
83
|
-
readonly inputs: readonly [
|
|
84
53
|
{
|
|
85
|
-
readonly name: "
|
|
86
|
-
readonly type: "
|
|
87
|
-
readonly
|
|
88
|
-
{ readonly name: "name"; readonly type: "string" },
|
|
89
|
-
{ readonly name: "height"; readonly type: "s64" },
|
|
90
|
-
{ readonly name: "tx-index"; readonly type: "s64" },
|
|
91
|
-
];
|
|
54
|
+
readonly name: "n";
|
|
55
|
+
readonly type: "u64";
|
|
56
|
+
readonly internalType: "u64";
|
|
92
57
|
},
|
|
93
|
-
{ readonly name: "n"; readonly type: "u64" },
|
|
94
58
|
];
|
|
95
|
-
readonly outputs: readonly [
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
readonly name: "fib-of-sub";
|
|
99
|
-
readonly type: "function";
|
|
100
|
-
readonly context: "proc";
|
|
101
|
-
readonly inputs: readonly [
|
|
102
|
-
{
|
|
103
|
-
readonly name: "arith-address";
|
|
104
|
-
readonly type: "tuple";
|
|
105
|
-
|
|
106
|
-
readonly components: readonly [
|
|
107
|
-
{ readonly name: "name"; readonly type: "string" },
|
|
108
|
-
{ readonly name: "height"; readonly type: "s64" },
|
|
109
|
-
{ readonly name: "tx-index"; readonly type: "s64" },
|
|
110
|
-
];
|
|
111
|
-
},
|
|
112
|
-
{ readonly name: "x"; readonly type: "string" },
|
|
113
|
-
{ readonly name: "y"; readonly type: "string" },
|
|
59
|
+
readonly outputs: readonly [
|
|
60
|
+
{ readonly type: "u64"; readonly internalType: "u64" },
|
|
114
61
|
];
|
|
115
|
-
readonly outputs: readonly [{ readonly type: "result<u64, error>" }];
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
readonly name: "cached-values";
|
|
119
|
-
readonly type: "function";
|
|
120
|
-
readonly context: "view";
|
|
121
|
-
readonly inputs: readonly [];
|
|
122
|
-
readonly outputs: readonly [{ readonly type: "list<u64>" }];
|
|
123
62
|
},
|
|
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
|
+
// },
|
|
124
118
|
]
|
|
125
119
|
>();
|
|
126
120
|
});
|
|
@@ -147,15 +141,16 @@ describe("parseWit (runtime)", () => {
|
|
|
147
141
|
{
|
|
148
142
|
name: "arith-address",
|
|
149
143
|
type: "tuple",
|
|
144
|
+
internalType: "contract-address",
|
|
150
145
|
components: [
|
|
151
|
-
{ name: "name", type: "string" },
|
|
152
|
-
{ name: "height", type: "s64" },
|
|
153
|
-
{ name: "tx-index", type: "s64" },
|
|
146
|
+
{ name: "name", type: "string", internalType: "string" },
|
|
147
|
+
{ name: "height", type: "s64", internalType: "s64" },
|
|
148
|
+
{ name: "tx-index", type: "s64", internalType: "s64" },
|
|
154
149
|
],
|
|
155
150
|
},
|
|
156
|
-
{ name: "n", type: "u64" },
|
|
151
|
+
{ name: "n", type: "u64", internalType: "u64" },
|
|
157
152
|
],
|
|
158
|
-
outputs: [{ type: "u64" }],
|
|
153
|
+
outputs: [{ type: "u64", internalType: "u64" }],
|
|
159
154
|
},
|
|
160
155
|
{
|
|
161
156
|
name: "fib-of-sub",
|
|
@@ -165,19 +160,21 @@ describe("parseWit (runtime)", () => {
|
|
|
165
160
|
{
|
|
166
161
|
name: "arith-address",
|
|
167
162
|
type: "tuple",
|
|
163
|
+
internalType: "contract-address",
|
|
168
164
|
|
|
169
165
|
components: [
|
|
170
|
-
{ name: "name", type: "string" },
|
|
171
|
-
{ name: "height", type: "s64" },
|
|
172
|
-
{ name: "tx-index", type: "s64" },
|
|
166
|
+
{ name: "name", type: "string", internalType: "string" },
|
|
167
|
+
{ name: "height", type: "s64", internalType: "s64" },
|
|
168
|
+
{ name: "tx-index", type: "s64", internalType: "s64" },
|
|
173
169
|
],
|
|
174
170
|
},
|
|
175
|
-
{ name: "x", type: "string" },
|
|
176
|
-
{ name: "y", type: "string" },
|
|
171
|
+
{ name: "x", type: "string", internalType: "string" },
|
|
172
|
+
{ name: "y", type: "string", internalType: "string" },
|
|
177
173
|
],
|
|
178
174
|
outputs: [
|
|
179
175
|
{
|
|
180
176
|
type: "result<u64, error>",
|
|
177
|
+
internalType: "result<u64, error>",
|
|
181
178
|
},
|
|
182
179
|
],
|
|
183
180
|
},
|
|
@@ -186,14 +183,14 @@ describe("parseWit (runtime)", () => {
|
|
|
186
183
|
type: "function",
|
|
187
184
|
context: "view",
|
|
188
185
|
inputs: [],
|
|
189
|
-
outputs: [{ type: "list<u64>" }],
|
|
186
|
+
outputs: [{ type: "list<u64>", internalType: "list<u64>" }],
|
|
190
187
|
},
|
|
191
188
|
{
|
|
192
189
|
name: "return-option",
|
|
193
190
|
type: "function",
|
|
194
191
|
context: "view",
|
|
195
192
|
inputs: [],
|
|
196
|
-
outputs: [{ type: "option<u64>" }],
|
|
193
|
+
outputs: [{ type: "option<u64>", internalType: "option<u64>" }],
|
|
197
194
|
},
|
|
198
195
|
]);
|
|
199
196
|
});
|