@kontor/kontor-sdk 1.0.0-alpha.28 → 1.0.0-alpha.29
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/exports/index.js.map +1 -1
- package/dist/cjs/sdk/accounts/hd-key-to-account.js +1 -0
- package/dist/cjs/sdk/accounts/hd-key-to-account.js.map +1 -1
- package/dist/cjs/sdk/accounts/mnemonic-to-account.js +2 -4
- package/dist/cjs/sdk/accounts/mnemonic-to-account.js.map +1 -1
- package/dist/cjs/sdk/accounts/private-key-to-account.js +3 -8
- package/dist/cjs/sdk/accounts/private-key-to-account.js.map +1 -1
- package/dist/cjs/sdk/accounts/to-local-account.js.map +1 -1
- package/dist/cjs/sdk/actions/get-contract.js +36 -16
- package/dist/cjs/sdk/actions/get-contract.js.map +1 -1
- package/dist/cjs/sdk/actions/kontor/public/build-compose-query.js.map +1 -1
- package/dist/cjs/sdk/utils/wit/codecs/bool.js +29 -0
- package/dist/cjs/sdk/utils/wit/codecs/bool.js.map +1 -0
- package/dist/cjs/sdk/utils/wit/codecs/s64.js +57 -0
- package/dist/cjs/sdk/utils/wit/codecs/s64.js.map +1 -0
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js +134 -131
- package/dist/cjs/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/cjs/sdk/utils/wit/encode-wit-parameters.js +74 -26
- 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/errors/{splitParameters.js → split-parameters.js} +1 -1
- package/dist/cjs/wit/wit-parser/core/errors/split-parameters.js.map +1 -0
- package/dist/cjs/wit/wit-parser/core/utils.js +3 -3
- package/dist/cjs/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/esm/exports/index.js +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/sdk/accounts/hd-key-to-account.js +2 -5
- package/dist/esm/sdk/accounts/hd-key-to-account.js.map +1 -1
- package/dist/esm/sdk/accounts/mnemonic-to-account.js +2 -10
- package/dist/esm/sdk/accounts/mnemonic-to-account.js.map +1 -1
- package/dist/esm/sdk/accounts/private-key-to-account.js +3 -15
- package/dist/esm/sdk/accounts/private-key-to-account.js.map +1 -1
- package/dist/esm/sdk/accounts/to-local-account.js +0 -5
- package/dist/esm/sdk/accounts/to-local-account.js.map +1 -1
- package/dist/esm/sdk/actions/get-contract.js +37 -35
- package/dist/esm/sdk/actions/get-contract.js.map +1 -1
- package/dist/esm/sdk/actions/kontor/public/build-compose-query.js.map +1 -1
- package/dist/esm/sdk/utils/wit/codecs/bool.js +26 -0
- package/dist/esm/sdk/utils/wit/codecs/bool.js.map +1 -0
- package/dist/esm/sdk/utils/wit/codecs/s64.js +65 -0
- package/dist/esm/sdk/utils/wit/codecs/s64.js.map +1 -0
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js +155 -147
- package/dist/esm/sdk/utils/wit/decode-wit-parameter.js.map +1 -1
- package/dist/esm/sdk/utils/wit/encode-wit-parameters.js +74 -72
- 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/errors/{splitParameters.js → split-parameters.js} +1 -1
- package/dist/esm/wit/wit-parser/core/errors/split-parameters.js.map +1 -0
- package/dist/esm/wit/wit-parser/core/utils.js +1 -1
- package/dist/esm/wit/wit-parser/core/utils.js.map +1 -1
- package/dist/types/exports/index.d.ts +1 -1
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/sdk/accounts/hd-key-to-account.d.ts +0 -5
- package/dist/types/sdk/accounts/hd-key-to-account.d.ts.map +1 -1
- package/dist/types/sdk/accounts/mnemonic-to-account.d.ts +1 -6
- package/dist/types/sdk/accounts/mnemonic-to-account.d.ts.map +1 -1
- package/dist/types/sdk/accounts/private-key-to-account.d.ts +5 -3
- package/dist/types/sdk/accounts/private-key-to-account.d.ts.map +1 -1
- package/dist/types/sdk/accounts/to-local-account.d.ts +0 -5
- package/dist/types/sdk/accounts/to-local-account.d.ts.map +1 -1
- package/dist/types/sdk/actions/get-contract.d.ts +28 -5
- package/dist/types/sdk/actions/get-contract.d.ts.map +1 -1
- package/dist/types/sdk/actions/kontor/public/build-compose-query.d.ts +0 -2
- package/dist/types/sdk/actions/kontor/public/build-compose-query.d.ts.map +1 -1
- package/dist/types/sdk/types/contract.d.ts.map +1 -1
- package/dist/types/sdk/utils/wit/codecs/bool.d.ts +3 -0
- package/dist/types/sdk/utils/wit/codecs/bool.d.ts.map +1 -0
- package/dist/types/sdk/utils/wit/codecs/s64.d.ts +23 -0
- package/dist/types/sdk/utils/wit/codecs/s64.d.ts.map +1 -0
- package/dist/types/sdk/utils/wit/decode-wit-parameter.d.ts +12 -3
- 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/errors/{splitParameters.d.ts → split-parameters.d.ts} +1 -1
- package/dist/types/wit/wit-parser/core/errors/split-parameters.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/exports/index.ts +1 -1
- package/src/sdk/accounts/hd-key-to-account.ts +2 -5
- package/src/sdk/accounts/mnemonic-to-account.test.ts +7 -81
- package/src/sdk/accounts/mnemonic-to-account.ts +2 -11
- package/src/sdk/accounts/private-key-to-account.ts +10 -16
- package/src/sdk/accounts/to-local-account.ts +0 -5
- package/src/sdk/actions/get-contract.test-d.ts +10 -9
- package/src/sdk/actions/get-contract.test.ts +49 -0
- package/src/sdk/actions/get-contract.ts +312 -91
- package/src/sdk/actions/kontor/public/build-compose-query.ts +0 -3
- package/src/sdk/test/e2e.test.ts +4 -1
- package/src/sdk/types/contract.ts +3 -14
- package/src/sdk/utils/wit/codecs/bool.ts +29 -0
- package/src/sdk/utils/wit/codecs/s64.ts +76 -0
- package/src/sdk/utils/wit/decode-wit-parameter.ts +167 -164
- package/src/sdk/utils/wit/encode-wit-parameters.ts +78 -75
- package/src/wit/wit-parser/core/utils.ts +1 -1
- package/dist/cjs/wit/wit-parser/core/errors/splitParameters.js.map +0 -1
- package/dist/esm/wit/wit-parser/core/errors/splitParameters.js.map +0 -1
- package/dist/types/wit/wit-parser/core/errors/splitParameters.d.ts.map +0 -1
- /package/src/wit/wit-parser/core/errors/{splitParameters.ts → split-parameters.ts} +0 -0
|
@@ -10,11 +10,13 @@ import {
|
|
|
10
10
|
} from "../../errors/wit.js";
|
|
11
11
|
|
|
12
12
|
import { U64Codec } from "./codecs/u64.js";
|
|
13
|
+
import { S64Codec } from "./codecs/s64.js";
|
|
13
14
|
import { DecimalCodec } from "./codecs/decimal.js";
|
|
14
15
|
import { IntegerCodec } from "./codecs/integer.js";
|
|
15
16
|
import { ListCodecFactory } from "./codecs/list.js";
|
|
16
17
|
import { OptionCodecFactory } from "./codecs/option.js";
|
|
17
18
|
import { StringCodec } from "./codecs/string.js";
|
|
19
|
+
import { BoolCodec } from "./codecs/bool.js";
|
|
18
20
|
|
|
19
21
|
// TODO: consider renaming to Wave
|
|
20
22
|
export type EncodeWitParametersReturnType = string;
|
|
@@ -72,11 +74,11 @@ function prepareParam<const param extends WitParameter>({
|
|
|
72
74
|
|
|
73
75
|
switch (type) {
|
|
74
76
|
case "option<bool>":
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
77
|
+
return {
|
|
78
|
+
encoded: OptionCodecFactory.create(BoolCodec)
|
|
79
|
+
.fromJs(value as unknown as Option<boolean>)
|
|
80
|
+
.toWave(),
|
|
81
|
+
};
|
|
80
82
|
|
|
81
83
|
case "option<string>": {
|
|
82
84
|
return {
|
|
@@ -107,23 +109,40 @@ function prepareParam<const param extends WitParameter>({
|
|
|
107
109
|
case "option<s8>":
|
|
108
110
|
case "option<s16>":
|
|
109
111
|
case "option<s32>":
|
|
110
|
-
case "option<s64>":
|
|
111
|
-
// TODO: wire up once you have a signed-int codec
|
|
112
112
|
throw new InvalidWitEncodingTypeError(param.type, {
|
|
113
113
|
docsPath: "tk",
|
|
114
114
|
});
|
|
115
|
+
case "option<s64>":
|
|
116
|
+
return {
|
|
117
|
+
encoded: OptionCodecFactory.create(S64Codec)
|
|
118
|
+
.fromJs(value as unknown as Option<bigint>)
|
|
119
|
+
.toWave(),
|
|
120
|
+
};
|
|
121
|
+
case "option<u64>":
|
|
122
|
+
return {
|
|
123
|
+
encoded: OptionCodecFactory.create(U64Codec)
|
|
124
|
+
.fromJs(value as unknown as Option<bigint>)
|
|
125
|
+
.toWave(),
|
|
126
|
+
};
|
|
115
127
|
|
|
116
|
-
// unsigned ints
|
|
117
128
|
case "option<u8>":
|
|
118
129
|
case "option<u16>":
|
|
119
130
|
case "option<u32>":
|
|
120
|
-
case "option<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
case "option<list<string>>":
|
|
132
|
+
case "option<list<bool>>":
|
|
133
|
+
case "option<list<s8>>":
|
|
134
|
+
case "option<list<s16>>":
|
|
135
|
+
case "option<list<s32>>":
|
|
136
|
+
case "option<list<s64>>":
|
|
137
|
+
case "option<list<u8>>":
|
|
138
|
+
case "option<list<u16>>":
|
|
139
|
+
case "option<list<u32>>":
|
|
140
|
+
case "option<list<u64>>":
|
|
141
|
+
case "option<list<integer>>":
|
|
142
|
+
case "option<list<decimal>>":
|
|
143
|
+
case "option<list<_>>":
|
|
144
|
+
case "option<list<tuple>>":
|
|
145
|
+
case "option<_>":
|
|
127
146
|
case "option<tuple>":
|
|
128
147
|
// TODO: OptionCodecFactory.create(TupleCodec) once it exists
|
|
129
148
|
throw new InvalidWitEncodingTypeError(param.type, {
|
|
@@ -131,11 +150,9 @@ function prepareParam<const param extends WitParameter>({
|
|
|
131
150
|
});
|
|
132
151
|
|
|
133
152
|
default: {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const _exhaustive: never = type;
|
|
138
|
-
throw new InvalidWitEncodingTypeError(param.type, {
|
|
153
|
+
const _: never = type;
|
|
154
|
+
|
|
155
|
+
throw new InvalidWitEncodingTypeError(_, {
|
|
139
156
|
docsPath: "tk",
|
|
140
157
|
});
|
|
141
158
|
}
|
|
@@ -148,11 +165,11 @@ function prepareParam<const param extends WitParameter>({
|
|
|
148
165
|
|
|
149
166
|
switch (type) {
|
|
150
167
|
case "list<bool>":
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
168
|
+
return {
|
|
169
|
+
encoded: ListCodecFactory.create(BoolCodec)
|
|
170
|
+
.fromJs(value as unknown as boolean[])
|
|
171
|
+
.toWave(),
|
|
172
|
+
};
|
|
156
173
|
|
|
157
174
|
case "list<string>": {
|
|
158
175
|
return {
|
|
@@ -178,79 +195,54 @@ function prepareParam<const param extends WitParameter>({
|
|
|
178
195
|
};
|
|
179
196
|
}
|
|
180
197
|
|
|
181
|
-
// signed ints
|
|
182
|
-
case "list<s8>":
|
|
183
|
-
case "list<s16>":
|
|
184
|
-
case "list<s32>":
|
|
185
198
|
case "list<s64>":
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
return {
|
|
200
|
+
encoded: ListCodecFactory.create(S64Codec)
|
|
201
|
+
.fromJs(value as unknown as bigint[])
|
|
202
|
+
.toWave(),
|
|
203
|
+
};
|
|
204
|
+
case "list<u64>":
|
|
205
|
+
return {
|
|
206
|
+
encoded: ListCodecFactory.create(U64Codec)
|
|
207
|
+
.fromJs(value as unknown as bigint[])
|
|
208
|
+
.toWave(),
|
|
209
|
+
};
|
|
190
210
|
|
|
191
|
-
|
|
211
|
+
case "list<_>":
|
|
192
212
|
case "list<u8>":
|
|
193
213
|
case "list<u16>":
|
|
194
214
|
case "list<u32>":
|
|
195
|
-
case "list<u64>":
|
|
196
|
-
// TODO: wire up once you have an unsigned-int codec
|
|
197
|
-
throw new InvalidWitEncodingTypeError(param.type, {
|
|
198
|
-
docsPath: "tk",
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// tuples
|
|
202
215
|
case "list<tuple>":
|
|
216
|
+
case "list<s8>":
|
|
217
|
+
case "list<s16>":
|
|
218
|
+
case "list<s32>":
|
|
203
219
|
// TODO: ListCodecFactory.create(TupleCodec) once it exists
|
|
204
220
|
throw new InvalidWitEncodingTypeError(param.type, {
|
|
205
221
|
docsPath: "tk",
|
|
206
222
|
});
|
|
207
223
|
|
|
208
224
|
default: {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const _exhaustive: never = type;
|
|
213
|
-
throw new InvalidWitEncodingTypeError(param.type, {
|
|
225
|
+
const _: never = type;
|
|
226
|
+
|
|
227
|
+
throw new InvalidWitEncodingTypeError(_, {
|
|
214
228
|
docsPath: "tk",
|
|
215
229
|
});
|
|
216
230
|
}
|
|
217
231
|
}
|
|
218
232
|
}
|
|
219
233
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// }
|
|
224
|
-
// if (param.type === "tuple") {
|
|
225
|
-
// return encodeTuple(value as unknown as Tuple, {
|
|
226
|
-
// param: param as TupleAbiParameter,
|
|
227
|
-
// });
|
|
228
|
-
// }
|
|
229
|
-
// if (param.type === "address") {
|
|
230
|
-
// return encodeAddress(value as unknown as Hex);
|
|
231
|
-
// }
|
|
232
|
-
// if (param.type === "bool") {
|
|
233
|
-
// return encodeBool(value as unknown as boolean);
|
|
234
|
-
// }
|
|
235
|
-
// if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
|
236
|
-
// const signed = param.type.startsWith("int");
|
|
237
|
-
// const [, , size = "256"] = integerRegex.exec(param.type) ?? [];
|
|
238
|
-
// return encodeNumber(value as unknown as number, {
|
|
239
|
-
// signed,
|
|
240
|
-
// size: Number(size),
|
|
241
|
-
// });
|
|
242
|
-
// }
|
|
243
|
-
// if (param.type.startsWith("bytes")) {
|
|
244
|
-
// return encodeBytes(value as unknown as Hex, { param });
|
|
245
|
-
// }
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
console.log(param);
|
|
234
|
+
if (param.type === "bool") {
|
|
235
|
+
return encodeBool(value as unknown as boolean);
|
|
236
|
+
}
|
|
249
237
|
|
|
250
238
|
if (param.type === "u64") {
|
|
251
239
|
return encodeU64(value as unknown as bigint);
|
|
252
240
|
}
|
|
253
241
|
|
|
242
|
+
if (param.type === "s64") {
|
|
243
|
+
return encodeS64(value as unknown as bigint);
|
|
244
|
+
}
|
|
245
|
+
|
|
254
246
|
if (param.type === "integer") {
|
|
255
247
|
return encodeInteger(value as unknown as bigint);
|
|
256
248
|
}
|
|
@@ -307,12 +299,23 @@ export function getResultComponentsStrict(
|
|
|
307
299
|
return [okType, "error"];
|
|
308
300
|
}
|
|
309
301
|
|
|
302
|
+
function encodeBool(value: boolean): PreparedParam {
|
|
303
|
+
return {
|
|
304
|
+
encoded: BoolCodec.fromJs(value).toWave(),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
310
308
|
function encodeU64(value: bigint): PreparedParam {
|
|
311
309
|
return {
|
|
312
310
|
encoded: U64Codec.fromJs(value).toWave(),
|
|
313
311
|
};
|
|
314
312
|
}
|
|
315
313
|
|
|
314
|
+
function encodeS64(value: bigint): PreparedParam {
|
|
315
|
+
return {
|
|
316
|
+
encoded: S64Codec.fromJs(value).toWave(),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
316
319
|
function encodeInteger(value: bigint): PreparedParam {
|
|
317
320
|
return {
|
|
318
321
|
encoded: IntegerCodec.fromJs(value).toWave(),
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
InvalidSignatureError,
|
|
9
9
|
UnknownSignatureError,
|
|
10
10
|
} from "./errors/signature.js";
|
|
11
|
-
import { InvalidGenericDepthError } from "./errors/
|
|
11
|
+
import { InvalidGenericDepthError } from "./errors/split-parameters.js";
|
|
12
12
|
import { execFunctionSignature, isFunctionSignature } from "./signatures.js";
|
|
13
13
|
import type { RecordLookup } from "./types/records.js";
|
|
14
14
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splitParameters.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/errors/splitParameters.ts"],"names":[],"mappings":";;;AAAA,gDAA8C;AAE9C,MAAa,wBAAyB,SAAQ,oBAAS;IAGrD,YAAY,EAAE,OAAO,EAAE,KAAK,EAAsC;QAChE,KAAK,CAAC,4BAA4B,EAAE;YAClC,YAAY,EAAE;gBACZ,IAAI,OAAO,CAAC,IAAI,EAAE,kBAChB,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAC1B,YAAY;aACb;YACD,OAAO,EAAE,UAAU,KAAK,GAAG;SAC5B,CAAC,CAAC;QAVI;;;;mBAAO,0BAA0B;WAAC;IAW3C,CAAC;CACF;AAbD,4DAaC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splitParameters.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/errors/splitParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IAGrD,YAAY,EAAE,OAAO,EAAE,KAAK,EAAsC;QAChE,KAAK,CAAC,4BAA4B,EAAE;YAClC,YAAY,EAAE;gBACZ,IAAI,OAAO,CAAC,IAAI,EAAE,kBAChB,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAC1B,YAAY;aACb;YACD,OAAO,EAAE,UAAU,KAAK,GAAG;SAC5B,CAAC,CAAC;QAVI;;;;mBAAO,0BAA0B;WAAC;IAW3C,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splitParameters.d.ts","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/errors/splitParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,qBAAa,wBAAyB,SAAQ,SAAS;IAC5C,IAAI,SAA8B;gBAE/B,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;CAUnE"}
|
|
File without changes
|