@kontor/kontor-sdk 1.0.0-alpha.19 → 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.
Files changed (111) hide show
  1. package/dist/src/exports/index.test.js +27 -0
  2. package/dist/src/exports/index.test.js.map +1 -0
  3. package/dist/src/sdk/accounts/private-key-to-account.js +42 -0
  4. package/dist/src/sdk/accounts/private-key-to-account.js.map +1 -0
  5. package/dist/src/sdk/actions/get-contract.js +50 -0
  6. package/dist/src/sdk/actions/get-contract.js.map +1 -0
  7. package/dist/src/sdk/actions/get-contract.test-d.js +43 -0
  8. package/dist/src/sdk/actions/get-contract.test-d.js.map +1 -0
  9. package/dist/src/sdk/actions/kontor/public/call-view.js +21 -0
  10. package/dist/src/sdk/actions/kontor/public/call-view.js.map +1 -0
  11. package/dist/src/sdk/actions/kontor/public/inspect.js +20 -0
  12. package/dist/src/sdk/actions/kontor/public/inspect.js.map +1 -0
  13. package/dist/src/sdk/actions/kontor/public/proc-contract.test.js +47 -0
  14. package/dist/src/sdk/actions/kontor/public/proc-contract.test.js.map +1 -0
  15. package/dist/src/sdk/actions/kontor/public/view-contract.js +47 -0
  16. package/dist/src/sdk/actions/kontor/public/view-contract.js.map +1 -0
  17. package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js +29 -0
  18. package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js.map +1 -0
  19. package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +59 -0
  20. package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -0
  21. package/dist/src/sdk/actions/wallet/get-addresses.js +20 -0
  22. package/dist/src/sdk/actions/wallet/get-addresses.js.map +1 -0
  23. package/dist/src/sdk/actions/wallet/sign-psbt.js +28 -0
  24. package/dist/src/sdk/actions/wallet/sign-psbt.js.map +1 -0
  25. package/dist/src/sdk/clients/base/create-http-client.js +41 -0
  26. package/dist/src/sdk/clients/base/create-http-client.js.map +1 -0
  27. package/dist/src/sdk/clients/base/create-rpc-client.js +41 -0
  28. package/dist/src/sdk/clients/base/create-rpc-client.js.map +1 -0
  29. package/dist/src/sdk/clients/base/create-rpc-client.test.js +151 -0
  30. package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +1 -0
  31. package/dist/src/sdk/clients/create-public-client.js +13 -0
  32. package/dist/src/sdk/clients/create-public-client.js.map +1 -0
  33. package/dist/src/sdk/clients/create-public-client.test.js +121 -0
  34. package/dist/src/sdk/clients/create-public-client.test.js.map +1 -0
  35. package/dist/src/sdk/clients/create-wallet-client.js +14 -0
  36. package/dist/src/sdk/clients/create-wallet-client.js.map +1 -0
  37. package/dist/src/sdk/clients/kontor/create-public-client.js +14 -0
  38. package/dist/src/sdk/clients/kontor/create-public-client.js.map +1 -0
  39. package/dist/src/sdk/clients/kontor/create-public-client.test.js +45 -0
  40. package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +1 -0
  41. package/dist/src/sdk/clients/transports/create-rpc-transport.js +36 -0
  42. package/dist/src/sdk/clients/transports/create-rpc-transport.js.map +1 -0
  43. package/dist/src/sdk/contracts/wits.js +26 -0
  44. package/dist/src/sdk/contracts/wits.js.map +1 -0
  45. package/dist/src/sdk/types/chain.js +2 -0
  46. package/dist/src/sdk/types/chain.js.map +1 -0
  47. package/dist/src/sdk/types/contract.js +2 -0
  48. package/dist/src/sdk/types/contract.js.map +1 -0
  49. package/dist/src/sdk/types/contract.test-d.js +34 -0
  50. package/dist/src/sdk/types/contract.test-d.js.map +1 -0
  51. package/dist/src/sdk/types/http-schema.js +73 -0
  52. package/dist/src/sdk/types/http-schema.js.map +1 -0
  53. package/dist/src/sdk/types/rpc-schema.js +2 -0
  54. package/dist/src/sdk/types/rpc-schema.js.map +1 -0
  55. package/dist/src/sdk/utils/chain/defineChain.js +9 -0
  56. package/dist/src/sdk/utils/chain/defineChain.js.map +1 -0
  57. package/dist/src/sdk/utils/wit/codecs/u64.js +63 -0
  58. package/dist/src/sdk/utils/wit/codecs/u64.js.map +1 -0
  59. package/dist/src/sdk/utils/wit/decode-wit-parameter.js +289 -0
  60. package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +1 -0
  61. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +24 -0
  62. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +1 -0
  63. package/dist/src/sdk/utils/wit/encode-function-data.test.js +91 -0
  64. package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +1 -0
  65. package/dist/src/sdk/utils/wit/encode-wit-parameters.js +261 -0
  66. package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +1 -0
  67. package/dist/src/sdk/utils/wit/get-wit-item.test.js +167 -0
  68. package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +1 -0
  69. package/dist/src/wit/wit-parser/core/records.test.js +63 -0
  70. package/dist/src/wit/wit-parser/core/records.test.js.map +1 -0
  71. package/dist/src/wit/wit-parser/core/types/records.test-d.js +19 -0
  72. package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +1 -0
  73. package/dist/src/wit/wit-parser/core/types/utils.js +2 -0
  74. package/dist/src/wit/wit-parser/core/types/utils.js.map +1 -0
  75. package/dist/src/wit/wit-parser/core/types/utils.test-d.js +159 -0
  76. package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +1 -0
  77. package/dist/src/wit/wit-parser/core/utils.js +213 -0
  78. package/dist/src/wit/wit-parser/core/utils.js.map +1 -0
  79. package/dist/src/wit/wit-parser/core/utils.test.js +316 -0
  80. package/dist/src/wit/wit-parser/core/utils.test.js.map +1 -0
  81. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +93 -0
  82. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +1 -0
  83. package/dist/src/wit/wit-parser/parse-wit.test.js +80 -0
  84. package/dist/src/wit/wit-parser/parse-wit.test.js.map +1 -0
  85. package/dist/tsconfig.tsbuildinfo +1 -0
  86. package/package.json +1 -1
  87. package/src/exports/index.test.ts +18 -1
  88. package/src/sdk/actions/kontor/public/call-view.ts +6 -14
  89. package/src/sdk/actions/kontor/public/proc-contract.test.ts +1 -1
  90. package/src/sdk/actions/kontor/public/view-contract.test-d.ts +2 -17
  91. package/src/sdk/actions/kontor/public/view-contract.ts +8 -3
  92. package/src/sdk/actions/kontor/wallet/sign-reveal.ts +3 -35
  93. package/src/sdk/clients/base/create-rpc-client.test.ts +10 -4
  94. package/src/sdk/clients/create-public-client.test.ts +11 -3
  95. package/src/sdk/clients/kontor/create-public-client.test.ts +4 -3
  96. package/src/sdk/contracts/wits.ts +1 -1
  97. package/src/sdk/types/contract.test-d.ts +29 -24
  98. package/src/sdk/utils/wit/codecs/u64.ts +73 -0
  99. package/src/sdk/utils/wit/decode-wit-parameter.ts +5 -0
  100. package/src/sdk/utils/wit/encode-function-data.test-d.ts +15 -11
  101. package/src/sdk/utils/wit/encode-function-data.test.ts +1 -1
  102. package/src/sdk/utils/wit/encode-wit-parameters.ts +16 -1
  103. package/src/sdk/utils/wit/get-wit-item.test.ts +58 -9
  104. package/src/wit/wit-parser/core/records.test.ts +24 -14
  105. package/src/wit/wit-parser/core/types/records.test-d.ts +141 -28
  106. package/src/wit/wit-parser/core/types/utils.test-d.ts +23 -2
  107. package/src/wit/wit-parser/core/types/utils.ts +8 -41
  108. package/src/wit/wit-parser/core/utils.test.ts +14 -0
  109. package/src/wit/wit-parser/core/utils.ts +1 -0
  110. package/src/wit/wit-parser/parse-wit-parameter.test.ts +30 -3
  111. package/src/wit/wit-parser/parse-wit.test.ts +93 -102
@@ -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-2dk@1.0.0]
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: { name: "ctx", type: "borrow<proc-context>" },
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: { name: "arith-address", type: "contract-address" },
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
  },
@@ -11,8 +11,8 @@ test("ParseWit (types)", () => {
11
11
  [
12
12
  "record contract-address { name: string, height: s64, tx-index: s64 }",
13
13
  "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>;",
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>;",
16
16
  ]
17
17
  >
18
18
  >().toEqualTypeOf<
@@ -25,102 +25,90 @@ test("ParseWit (types)", () => {
25
25
  {
26
26
  readonly name: "arith-address";
27
27
  readonly type: "tuple";
28
+ readonly internalType: "contract-address";
28
29
  readonly components: readonly [
29
- { readonly name: "name"; readonly type: "string" },
30
- { readonly name: "height"; readonly type: "s64" },
31
- { readonly name: "tx-index"; readonly type: "s64" },
30
+ {
31
+ readonly name: "name";
32
+ readonly type: "string";
33
+ readonly internalType: "string";
34
+ },
35
+ {
36
+ readonly name: "height";
37
+ readonly type: "s64";
38
+ readonly internalType: "s64";
39
+ },
40
+ {
41
+ readonly name: "tx-index";
42
+ readonly type: "s64";
43
+ readonly internalType: "s64";
44
+ },
32
45
  ];
33
46
  },
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
47
  {
85
- readonly name: "arith-address";
86
- readonly type: "tuple";
87
- readonly components: readonly [
88
- { readonly name: "name"; readonly type: "string" },
89
- { readonly name: "height"; readonly type: "s64" },
90
- { readonly name: "tx-index"; readonly type: "s64" },
91
- ];
48
+ readonly name: "n";
49
+ readonly type: "u64";
50
+ readonly internalType: "u64";
92
51
  },
93
- { readonly name: "n"; readonly type: "u64" },
94
52
  ];
95
- readonly outputs: readonly [{ readonly type: "u64" }];
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" },
53
+ readonly outputs: readonly [
54
+ { readonly type: "u64"; readonly internalType: "u64" },
114
55
  ];
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
56
  },
57
+ // {
58
+ // readonly name: "fib-of-sub";
59
+ // readonly type: "function";
60
+ // readonly context: "proc";
61
+ // readonly inputs: readonly [
62
+ // {
63
+ // readonly name: "arith-address";
64
+ // readonly type: "tuple";
65
+ // readonly internalType: "contract-address";
66
+ //
67
+ // readonly components: readonly [
68
+ // {
69
+ // readonly name: "name";
70
+ // readonly type: "string";
71
+ // readonly internalType: "string";
72
+ // },
73
+ // {
74
+ // readonly name: "height";
75
+ // readonly type: "s64";
76
+ // readonly internalType: "s64";
77
+ // },
78
+ // {
79
+ // readonly name: "tx-index";
80
+ // readonly type: "s64";
81
+ // readonly internalType: "s64";
82
+ // },
83
+ // ];
84
+ // },
85
+ // {
86
+ // readonly name: "x";
87
+ // readonly type: "string";
88
+ // readonly internalType: "string";
89
+ // },
90
+ // {
91
+ // readonly name: "y";
92
+ // readonly type: "string";
93
+ // readonly internalType: "string";
94
+ // },
95
+ // ];
96
+ // readonly outputs: readonly [
97
+ // {
98
+ // readonly type: "result<u64, error>";
99
+ // readonly internalType: "result<u64, error>";
100
+ // },
101
+ // ];
102
+ // },
103
+ // {
104
+ // readonly name: "cached-values";
105
+ // readonly type: "function";
106
+ // readonly context: "view";
107
+ // readonly inputs: readonly [];
108
+ // readonly outputs: readonly [
109
+ // { readonly type: "list<u64>"; readonly internalType: "list<u64>" },
110
+ // ];
111
+ // },
124
112
  ]
125
113
  >();
126
114
  });
@@ -147,15 +135,16 @@ describe("parseWit (runtime)", () => {
147
135
  {
148
136
  name: "arith-address",
149
137
  type: "tuple",
138
+ internalType: "contract-address",
150
139
  components: [
151
- { name: "name", type: "string" },
152
- { name: "height", type: "s64" },
153
- { name: "tx-index", type: "s64" },
140
+ { name: "name", type: "string", internalType: "string" },
141
+ { name: "height", type: "s64", internalType: "s64" },
142
+ { name: "tx-index", type: "s64", internalType: "s64" },
154
143
  ],
155
144
  },
156
- { name: "n", type: "u64" },
145
+ { name: "n", type: "u64", internalType: "u64" },
157
146
  ],
158
- outputs: [{ type: "u64" }],
147
+ outputs: [{ type: "u64", internalType: "u64" }],
159
148
  },
160
149
  {
161
150
  name: "fib-of-sub",
@@ -165,19 +154,21 @@ describe("parseWit (runtime)", () => {
165
154
  {
166
155
  name: "arith-address",
167
156
  type: "tuple",
157
+ internalType: "contract-address",
168
158
 
169
159
  components: [
170
- { name: "name", type: "string" },
171
- { name: "height", type: "s64" },
172
- { name: "tx-index", type: "s64" },
160
+ { name: "name", type: "string", internalType: "string" },
161
+ { name: "height", type: "s64", internalType: "s64" },
162
+ { name: "tx-index", type: "s64", internalType: "s64" },
173
163
  ],
174
164
  },
175
- { name: "x", type: "string" },
176
- { name: "y", type: "string" },
165
+ { name: "x", type: "string", internalType: "string" },
166
+ { name: "y", type: "string", internalType: "string" },
177
167
  ],
178
168
  outputs: [
179
169
  {
180
170
  type: "result<u64, error>",
171
+ internalType: "result<u64, error>",
181
172
  },
182
173
  ],
183
174
  },
@@ -186,14 +177,14 @@ describe("parseWit (runtime)", () => {
186
177
  type: "function",
187
178
  context: "view",
188
179
  inputs: [],
189
- outputs: [{ type: "list<u64>" }],
180
+ outputs: [{ type: "list<u64>", internalType: "list<u64>" }],
190
181
  },
191
182
  {
192
183
  name: "return-option",
193
184
  type: "function",
194
185
  context: "view",
195
186
  inputs: [],
196
- outputs: [{ type: "option<u64>" }],
187
+ outputs: [{ type: "option<u64>", internalType: "option<u64>" }],
197
188
  },
198
189
  ]);
199
190
  });