@kontor/kontor-sdk 1.0.0-alpha.24 → 1.0.0-alpha.26
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/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/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/types/sdk/contracts/wits.d.ts +1 -1
- package/dist/types/sdk/contracts/wits.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/package.json +1 -1
- package/src/sdk/contracts/wits.ts +1 -5
- 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/parse-wit.test.ts +426 -146
- package/test/src/wits.ts +0 -4
|
@@ -5,7 +5,7 @@ type ContractExport<signatures extends readonly string[]> = {
|
|
|
5
5
|
wit: ParseWit<signatures>;
|
|
6
6
|
address: ResolvedRegister["contractAddress"];
|
|
7
7
|
};
|
|
8
|
-
declare const nativeTokenRaw: readonly ["record balance { acc: string, amt: decimal }", "record transfer { src: string, dst: string, amt: decimal }", "record burn { src: string, amt: decimal }", "record mint { dst: string, amt: decimal }", "export
|
|
8
|
+
declare const nativeTokenRaw: readonly ["record balance { acc: string, amt: decimal }", "record transfer { src: string, dst: string, amt: decimal }", "record burn { src: string, amt: decimal }", "record mint { dst: string, amt: decimal }", "export init: func(ctx: borrow<proc-context>);", "export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;", "export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;", "export transfer: func(ctx: borrow<proc-context>, dst: string, amt: decimal) -> result<transfer, error>;", "export balance: func(ctx: borrow<view-context>, acc: string) -> option<decimal>;", "export balances: func(ctx: borrow<view-context>) -> list<balance>;", "export total-supply: func(ctx: borrow<view-context>) -> decimal;", "export attach: func(ctx: borrow<proc-context>, vout: u64, amt: decimal) -> result<transfer, error>;", "export detach: func(ctx: borrow<proc-context>) -> result<transfer, error>;"];
|
|
9
9
|
export declare const nativeToken: ContractExport<typeof nativeTokenRaw>;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=wits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wits.d.ts","sourceRoot":"","sources":["../../../../src/sdk/contracts/wits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE5E,KAAK,cAAc,CAAC,UAAU,SAAS,SAAS,MAAM,EAAE,IAAI;IAC1D,GAAG,EAAE,UAAU,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF,QAAA,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"wits.d.ts","sourceRoot":"","sources":["../../../../src/sdk/contracts/wits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE5E,KAAK,cAAc,CAAC,UAAU,SAAS,SAAS,MAAM,EAAE,IAAI;IAC1D,GAAG,EAAE,UAAU,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF,QAAA,MAAM,cAAc,86BAcV,CAAC;AAIX,eAAO,MAAM,WAAW,EAAE,cAAc,CAAC,OAAO,cAAc,CAI7D,CAAC"}
|
|
@@ -48,10 +48,12 @@ type MapGenericType<T extends string, Opts extends ParseOptions> = T extends `li
|
|
|
48
48
|
type: string;
|
|
49
49
|
} ? Readonlyify<{
|
|
50
50
|
type: `list<${M["type"]}>`;
|
|
51
|
+
internalType: T;
|
|
51
52
|
} & GetComponents<M>> : never : T extends `option<${infer U}>` ? MapGenericType<Trim<U>, Opts> extends infer M extends {
|
|
52
53
|
type: string;
|
|
53
54
|
} ? Readonlyify<{
|
|
54
55
|
type: `option<${M["type"]}>`;
|
|
56
|
+
internalType: T;
|
|
55
57
|
} & GetComponents<M>> : never : T extends `result<${infer Inner}>` ? SplitResultInner<Trim<Inner>> extends [
|
|
56
58
|
infer LRaw extends string,
|
|
57
59
|
infer RRaw extends string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAA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,MAAM,cAAc,CACxB,SAAS,SAAS,MAAM,EACxB,OAAO,SAAS,YAAY,GAAG,OAAO,GAAG,OAAO,IAEhD,mBAAmB,CAAC,SAAS,CAAC,SAAS,IAAI,GACvC,SAAS,SAAS,iBAAiB,CAAC,MAAM,IAAI,EAAE,MAAM,IAAI,CAAC,GACzD;IACE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,kCAAkC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3E,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CACjC,eAAe,CACb,kCAAkC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CACxD,EACD;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CACrB,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,IAAI,SAAS,GAAG,MAAM,OAAO,MAAM,OAAO,GAAG,GAC3D,kBAAkB,CAChB,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAC9B;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CACrB,GACD,SAAS,EAAE,CAAC;CACjB,GACD,KAAK,GACP,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -12,10 +12,6 @@ const nativeTokenRaw = [
|
|
|
12
12
|
"record transfer { src: string, dst: string, amt: decimal }",
|
|
13
13
|
"record burn { src: string, amt: decimal }",
|
|
14
14
|
"record mint { dst: string, amt: decimal }",
|
|
15
|
-
|
|
16
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
17
|
-
"export hold: func(ctx: borrow<core-context>, amt: decimal) -> result<transfer, error>;",
|
|
18
|
-
"export release: func(ctx: borrow<core-context>, burn-amt: decimal) -> result<burn, error>;",
|
|
19
15
|
"export init: func(ctx: borrow<proc-context>);",
|
|
20
16
|
"export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;",
|
|
21
17
|
"export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;",
|
|
@@ -23,7 +19,7 @@ const nativeTokenRaw = [
|
|
|
23
19
|
"export balance: func(ctx: borrow<view-context>, acc: string) -> option<decimal>;",
|
|
24
20
|
"export balances: func(ctx: borrow<view-context>) -> list<balance>;",
|
|
25
21
|
"export total-supply: func(ctx: borrow<view-context>) -> decimal;",
|
|
26
|
-
|
|
22
|
+
"export attach: func(ctx: borrow<proc-context>, vout: u64, amt: decimal) -> result<transfer, error>;",
|
|
27
23
|
"export detach: func(ctx: borrow<proc-context>) -> result<transfer, error>;",
|
|
28
24
|
] as const;
|
|
29
25
|
|
|
@@ -2,63 +2,35 @@ import { expectTypeOf, test } from "vitest";
|
|
|
2
2
|
import type {
|
|
3
3
|
ContractFunctionName,
|
|
4
4
|
ContractFunctionArgs,
|
|
5
|
-
ExtractWitFunctionForArgs,
|
|
6
5
|
ContractFunctionReturnType,
|
|
7
6
|
} from "./contract.js";
|
|
8
7
|
import { nativeToken as nativeToken_ } from "../contracts/wits.js";
|
|
9
8
|
|
|
10
9
|
const nativeToken = nativeToken_.wit;
|
|
11
10
|
|
|
12
|
-
type t = ExtractWitFunctionForArgs<
|
|
13
|
-
typeof nativeToken,
|
|
14
|
-
"proc",
|
|
15
|
-
"transfer",
|
|
16
|
-
[string, [bigint, number]]
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
11
|
test("ContractFunctionName", () => {
|
|
20
12
|
type All = ContractFunctionName<typeof nativeToken>;
|
|
21
13
|
expectTypeOf<All>().toEqualTypeOf<
|
|
22
|
-
| "issuance"
|
|
23
|
-
| "hold"
|
|
24
|
-
| "release"
|
|
25
|
-
// | "init" // init is not valid
|
|
26
14
|
| "mint"
|
|
27
15
|
| "burn"
|
|
28
16
|
| "transfer"
|
|
29
17
|
| "balance"
|
|
30
18
|
| "balances"
|
|
31
19
|
| "total-supply"
|
|
32
|
-
|
|
20
|
+
| "attach"
|
|
33
21
|
| "detach"
|
|
34
22
|
>;
|
|
35
23
|
|
|
36
|
-
type Core = ContractFunctionName<typeof nativeToken, "core">;
|
|
37
|
-
expectTypeOf<Core>().toEqualTypeOf<"issuance" | "hold" | "release">;
|
|
38
|
-
|
|
39
24
|
type View = ContractFunctionName<typeof nativeToken, "view">;
|
|
40
25
|
expectTypeOf<View>().toEqualTypeOf<"balance" | "balances" | "total-supply">;
|
|
41
26
|
|
|
42
27
|
type Proc = ContractFunctionName<typeof nativeToken, "proc">;
|
|
43
28
|
expectTypeOf<Proc>().toEqualTypeOf<
|
|
44
|
-
| "
|
|
45
|
-
| "burn"
|
|
46
|
-
| "transfer"
|
|
47
|
-
//| "attach"
|
|
48
|
-
| "detach"
|
|
29
|
+
"mint" | "burn" | "transfer" | "attach" | "detach"
|
|
49
30
|
>;
|
|
50
31
|
});
|
|
51
32
|
|
|
52
33
|
test("ContractFunctionArgs", () => {
|
|
53
|
-
type Issuance = ContractFunctionArgs<typeof nativeToken, "core", "issuance">;
|
|
54
|
-
expectTypeOf<Issuance>().toEqualTypeOf<readonly [[bigint, number]]>;
|
|
55
|
-
|
|
56
|
-
type Hold = ContractFunctionArgs<typeof nativeToken, "core", "hold">;
|
|
57
|
-
expectTypeOf<Hold>().toEqualTypeOf<readonly [[bigint, number]]>;
|
|
58
|
-
|
|
59
|
-
type Release = ContractFunctionArgs<typeof nativeToken, "core", "release">;
|
|
60
|
-
expectTypeOf<Release>().toEqualTypeOf<readonly [[bigint, number]]>;
|
|
61
|
-
|
|
62
34
|
type Mint = ContractFunctionArgs<typeof nativeToken, "proc", "mint">;
|
|
63
35
|
expectTypeOf<Mint>().toEqualTypeOf<readonly [[bigint, number]]>;
|
|
64
36
|
|
|
@@ -89,60 +61,6 @@ test("ContractFunctionArgs", () => {
|
|
|
89
61
|
});
|
|
90
62
|
|
|
91
63
|
test("ContractFunctionReturnType", () => {
|
|
92
|
-
type Issuance = ContractFunctionReturnType<
|
|
93
|
-
typeof nativeToken,
|
|
94
|
-
"core",
|
|
95
|
-
"issuance"
|
|
96
|
-
>;
|
|
97
|
-
expectTypeOf<Issuance>().toEqualTypeOf<
|
|
98
|
-
| {
|
|
99
|
-
ok: false;
|
|
100
|
-
error: string;
|
|
101
|
-
}
|
|
102
|
-
| {
|
|
103
|
-
ok: true;
|
|
104
|
-
value: {
|
|
105
|
-
dst: string;
|
|
106
|
-
amt: [bigint, number];
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
>;
|
|
110
|
-
|
|
111
|
-
type Hold = ContractFunctionReturnType<typeof nativeToken, "core", "hold">;
|
|
112
|
-
expectTypeOf<Hold>().toEqualTypeOf<
|
|
113
|
-
| {
|
|
114
|
-
ok: false;
|
|
115
|
-
error: string;
|
|
116
|
-
}
|
|
117
|
-
| {
|
|
118
|
-
ok: true;
|
|
119
|
-
value: {
|
|
120
|
-
src: string;
|
|
121
|
-
dst: string;
|
|
122
|
-
amt: [bigint, number];
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
>;
|
|
126
|
-
|
|
127
|
-
type Release = ContractFunctionReturnType<
|
|
128
|
-
typeof nativeToken,
|
|
129
|
-
"core",
|
|
130
|
-
"release"
|
|
131
|
-
>;
|
|
132
|
-
expectTypeOf<Release>().toEqualTypeOf<
|
|
133
|
-
| {
|
|
134
|
-
ok: false;
|
|
135
|
-
error: string;
|
|
136
|
-
}
|
|
137
|
-
| {
|
|
138
|
-
ok: true;
|
|
139
|
-
value: {
|
|
140
|
-
src: string;
|
|
141
|
-
amt: [bigint, number];
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
>;
|
|
145
|
-
|
|
146
64
|
type Mint = ContractFunctionReturnType<typeof nativeToken, "proc", "mint">;
|
|
147
65
|
expectTypeOf<Mint>().toEqualTypeOf<
|
|
148
66
|
| {
|
|
@@ -222,25 +140,25 @@ test("ContractFunctionReturnType", () => {
|
|
|
222
140
|
>;
|
|
223
141
|
expectTypeOf<TotalSupply>().toEqualTypeOf<[bigint, number]>;
|
|
224
142
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
143
|
+
type Attach = ContractFunctionReturnType<
|
|
144
|
+
typeof nativeToken,
|
|
145
|
+
"proc",
|
|
146
|
+
"attach"
|
|
147
|
+
>;
|
|
148
|
+
expectTypeOf<Attach>().toEqualTypeOf<
|
|
149
|
+
| {
|
|
150
|
+
ok: false;
|
|
151
|
+
error: string;
|
|
152
|
+
}
|
|
153
|
+
| {
|
|
154
|
+
ok: true;
|
|
155
|
+
value: {
|
|
156
|
+
src: string;
|
|
157
|
+
dst: string;
|
|
158
|
+
amt: [bigint, number];
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
>;
|
|
244
162
|
|
|
245
163
|
type Detach = ContractFunctionReturnType<
|
|
246
164
|
typeof nativeToken,
|
|
@@ -87,6 +87,8 @@ function decoderForParam(p: WitParameter) {
|
|
|
87
87
|
return listOfDecimalDecoder;
|
|
88
88
|
case "list<tuple>":
|
|
89
89
|
return listOfTupleDecoder(p);
|
|
90
|
+
case "u64":
|
|
91
|
+
return u64Decoder;
|
|
90
92
|
|
|
91
93
|
case "error":
|
|
92
94
|
case "contract-address":
|
|
@@ -98,8 +100,6 @@ function decoderForParam(p: WitParameter) {
|
|
|
98
100
|
case "u8":
|
|
99
101
|
case "u16":
|
|
100
102
|
case "u32":
|
|
101
|
-
case "u64":
|
|
102
|
-
return u64Decoder;
|
|
103
103
|
case "integer":
|
|
104
104
|
case "option<string>":
|
|
105
105
|
case "option<bool>":
|
|
@@ -34,18 +34,16 @@ test("native token", () => {
|
|
|
34
34
|
type P = EncodeFunctionDataParameters<typeof nativeToken.wit>;
|
|
35
35
|
|
|
36
36
|
expectTypeOf<P["functionName"]>().not.toEqualTypeOf<undefined>();
|
|
37
|
-
|
|
38
37
|
expectTypeOf<P["functionName"]>().toEqualTypeOf<
|
|
39
|
-
| "mint"
|
|
40
|
-
| "issuance"
|
|
41
38
|
| "balance"
|
|
42
39
|
| "transfer"
|
|
43
40
|
| "burn"
|
|
44
|
-
| "
|
|
45
|
-
| "release"
|
|
41
|
+
| "mint"
|
|
46
42
|
| "balances"
|
|
47
43
|
| "total-supply"
|
|
44
|
+
| "attach"
|
|
48
45
|
| "detach"
|
|
49
|
-
// | "attach" // TODO: need to handle attach parsing
|
|
50
46
|
>();
|
|
47
|
+
|
|
48
|
+
// TODO: fill out tests
|
|
51
49
|
});
|
|
@@ -2,55 +2,11 @@ import { expect, test } from "vitest";
|
|
|
2
2
|
import { encodeFunctionData } from "./encode-function-data.js";
|
|
3
3
|
import { parseWit } from "../../../wit/wit-parser/parse-wit.js";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
"record balance { acc: string, amt: decimal }",
|
|
7
|
-
"record transfer { src: string, dst: string, amt: decimal }",
|
|
8
|
-
"record burn { src: string, amt: decimal }",
|
|
9
|
-
"record mint { dst: string, amt: decimal }",
|
|
10
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
11
|
-
"export hold: func(ctx: borrow<core-context>, amt: decimal) -> result<transfer, error>;",
|
|
12
|
-
"export release: func(ctx: borrow<core-context>, burn-amt: decimal) -> result<burn, error>;",
|
|
13
|
-
"export init: func(ctx: borrow<proc-context>);",
|
|
14
|
-
"export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;",
|
|
15
|
-
"export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;",
|
|
16
|
-
"export transfer: func(ctx: borrow<proc-context>, dst: string, amt: decimal) -> result<transfer, error>;",
|
|
17
|
-
"export balance: func(ctx: borrow<view-context>, acc: string) -> option<decimal>;",
|
|
18
|
-
"export balances: func(ctx: borrow<view-context>) -> list<balance>;",
|
|
19
|
-
"export total-supply: func(ctx: borrow<view-context>) -> decimal;",
|
|
20
|
-
"export attach: func(ctx: borrow<proc-context>, vout: u64, amt: decimal) -> result<transfer, error>;",
|
|
21
|
-
"export detach: func(ctx: borrow<proc-context>) -> result<transfer, error>;",
|
|
22
|
-
]);
|
|
5
|
+
import { nativeToken as nativeToken_ } from "../../../sdk/contracts/wits.js";
|
|
23
6
|
|
|
24
|
-
|
|
25
|
-
test("issuance", () => {
|
|
26
|
-
expect(
|
|
27
|
-
encodeFunctionData({
|
|
28
|
-
wit: nativeToken,
|
|
29
|
-
functionName: "issuance",
|
|
30
|
-
args: [[7n, 18]],
|
|
31
|
-
}),
|
|
32
|
-
).toEqual("issuance({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
33
|
-
});
|
|
7
|
+
export const nativeToken = parseWit(nativeToken_.raw);
|
|
34
8
|
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
encodeFunctionData({
|
|
38
|
-
wit: nativeToken,
|
|
39
|
-
functionName: "hold",
|
|
40
|
-
args: [[7n, 18]],
|
|
41
|
-
}),
|
|
42
|
-
).toEqual("hold({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("release", () => {
|
|
46
|
-
expect(
|
|
47
|
-
encodeFunctionData({
|
|
48
|
-
wit: nativeToken,
|
|
49
|
-
functionName: "release",
|
|
50
|
-
args: [[7n, 18]],
|
|
51
|
-
}),
|
|
52
|
-
).toEqual("release({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
53
|
-
});
|
|
9
|
+
//TODO: change functionName to func
|
|
54
10
|
|
|
55
11
|
test("mint", () => {
|
|
56
12
|
expect(
|
|
@@ -119,6 +119,7 @@ test("ParseRecords", () => {
|
|
|
119
119
|
{
|
|
120
120
|
readonly name: "values";
|
|
121
121
|
readonly type: "list<contract-address>";
|
|
122
|
+
readonly internalType: "list<contract-address>";
|
|
122
123
|
},
|
|
123
124
|
];
|
|
124
125
|
}>();
|
|
@@ -306,6 +307,7 @@ test("ParseRecordProperties", () => {
|
|
|
306
307
|
{
|
|
307
308
|
readonly name: "values";
|
|
308
309
|
readonly type: "list<string>";
|
|
310
|
+
readonly internalType: "list<string>";
|
|
309
311
|
},
|
|
310
312
|
]
|
|
311
313
|
>();
|
|
@@ -317,6 +319,7 @@ test("ParseRecordProperties", () => {
|
|
|
317
319
|
{
|
|
318
320
|
readonly name: "values";
|
|
319
321
|
readonly type: "list<tuple>";
|
|
322
|
+
readonly internalType: "list<contract-address>";
|
|
320
323
|
readonly components: readonly [
|
|
321
324
|
{ readonly name: "name"; readonly type: "string" },
|
|
322
325
|
{ readonly name: "height"; readonly type: "s64" },
|
|
@@ -81,11 +81,13 @@ test("ParseWitParameter", () => {
|
|
|
81
81
|
assertType<ParseWitParameter<"option-string: option<string>">>({
|
|
82
82
|
name: "option-string",
|
|
83
83
|
type: "option<string>",
|
|
84
|
+
internalType: "option<string>",
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
assertType<ParseWitParameter<"option-list-string: option<list<string>>">>({
|
|
87
88
|
name: "option-list-string",
|
|
88
89
|
type: "option<list<string>>",
|
|
90
|
+
internalType: "option<list<string>>",
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
assertType<
|
|
@@ -93,6 +95,7 @@ test("ParseWitParameter", () => {
|
|
|
93
95
|
>({
|
|
94
96
|
name: "option-list-result-string-contract-address",
|
|
95
97
|
type: "option<list<result<string, contract-address>>>",
|
|
98
|
+
internalType: "option<list<result<string, contract-address>>>",
|
|
96
99
|
});
|
|
97
100
|
|
|
98
101
|
assertType<ParseWitParameter<"contract-address">>({
|
|
@@ -163,7 +166,7 @@ test("Parse Signature", () => {
|
|
|
163
166
|
type: "contract-address",
|
|
164
167
|
internalType: "contract-address",
|
|
165
168
|
},
|
|
166
|
-
{ name: "n", type: "list<u64>" },
|
|
169
|
+
{ name: "n", type: "list<u64>", internalType: "list<u64>" },
|
|
167
170
|
],
|
|
168
171
|
outputs: [
|
|
169
172
|
{
|
|
@@ -184,7 +187,7 @@ test("Parse Signature", () => {
|
|
|
184
187
|
type: "contract-address",
|
|
185
188
|
internalType: "contract-address",
|
|
186
189
|
},
|
|
187
|
-
{ name: "n", type: "list<u64>" },
|
|
190
|
+
{ name: "n", type: "list<u64>", internalType: "list<u64>" },
|
|
188
191
|
],
|
|
189
192
|
outputs: [
|
|
190
193
|
{
|
|
@@ -205,7 +208,7 @@ test("Parse Signature", () => {
|
|
|
205
208
|
type: "contract-address",
|
|
206
209
|
internalType: "contract-address",
|
|
207
210
|
},
|
|
208
|
-
{ name: "n", type: "list<u64>" },
|
|
211
|
+
{ name: "n", type: "list<u64>", internalType: "list<u64>" },
|
|
209
212
|
],
|
|
210
213
|
outputs: [
|
|
211
214
|
{
|
|
@@ -227,6 +230,7 @@ test("Parse Signature", () => {
|
|
|
227
230
|
outputs: [
|
|
228
231
|
{
|
|
229
232
|
type: "list<tuple>",
|
|
233
|
+
internalType: "list<dog>",
|
|
230
234
|
components: [
|
|
231
235
|
{ type: "string", name: "name" },
|
|
232
236
|
{ type: "string", name: "breed" },
|
|
@@ -48,11 +48,15 @@ type MapGenericType<T extends string, Opts extends ParseOptions> =
|
|
|
48
48
|
// list<...>
|
|
49
49
|
T extends `list<${infer U}>`
|
|
50
50
|
? MapGenericType<Trim<U>, Opts> extends infer M extends { type: string }
|
|
51
|
-
? Readonlyify<
|
|
51
|
+
? Readonlyify<
|
|
52
|
+
{ type: `list<${M["type"]}>`; internalType: T } & GetComponents<M>
|
|
53
|
+
>
|
|
52
54
|
: never
|
|
53
55
|
: T extends `option<${infer U}>`
|
|
54
56
|
? MapGenericType<Trim<U>, Opts> extends infer M extends { type: string }
|
|
55
|
-
? Readonlyify<
|
|
57
|
+
? Readonlyify<
|
|
58
|
+
{ type: `option<${M["type"]}>`; internalType: T } & GetComponents<M>
|
|
59
|
+
>
|
|
56
60
|
: never
|
|
57
61
|
: // result<L, R>
|
|
58
62
|
T extends `result<${infer Inner}>`
|