@kontor/kontor-sdk 1.0.0-alpha.20 → 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/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/wit/wit-parser/parse-wit.test.ts +6 -0
- package/dist/src/exports/index.test.js +0 -27
- package/dist/src/exports/index.test.js.map +0 -1
- package/dist/src/sdk/accounts/private-key-to-account.js +0 -42
- package/dist/src/sdk/accounts/private-key-to-account.js.map +0 -1
- package/dist/src/sdk/actions/get-contract.js +0 -50
- package/dist/src/sdk/actions/get-contract.js.map +0 -1
- package/dist/src/sdk/actions/get-contract.test-d.js +0 -43
- package/dist/src/sdk/actions/get-contract.test-d.js.map +0 -1
- package/dist/src/sdk/actions/kontor/public/call-view.js +0 -21
- package/dist/src/sdk/actions/kontor/public/call-view.js.map +0 -1
- package/dist/src/sdk/actions/kontor/public/inspect.js +0 -20
- package/dist/src/sdk/actions/kontor/public/inspect.js.map +0 -1
- package/dist/src/sdk/actions/kontor/public/proc-contract.test.js +0 -47
- package/dist/src/sdk/actions/kontor/public/proc-contract.test.js.map +0 -1
- package/dist/src/sdk/actions/kontor/public/view-contract.js +0 -47
- package/dist/src/sdk/actions/kontor/public/view-contract.js.map +0 -1
- package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js +0 -29
- package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js.map +0 -1
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +0 -59
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +0 -1
- package/dist/src/sdk/actions/wallet/get-addresses.js +0 -20
- package/dist/src/sdk/actions/wallet/get-addresses.js.map +0 -1
- package/dist/src/sdk/actions/wallet/sign-psbt.js +0 -28
- package/dist/src/sdk/actions/wallet/sign-psbt.js.map +0 -1
- package/dist/src/sdk/clients/base/create-http-client.js +0 -41
- package/dist/src/sdk/clients/base/create-http-client.js.map +0 -1
- package/dist/src/sdk/clients/base/create-rpc-client.js +0 -41
- package/dist/src/sdk/clients/base/create-rpc-client.js.map +0 -1
- package/dist/src/sdk/clients/base/create-rpc-client.test.js +0 -151
- package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +0 -1
- package/dist/src/sdk/clients/create-public-client.js +0 -13
- package/dist/src/sdk/clients/create-public-client.js.map +0 -1
- package/dist/src/sdk/clients/create-public-client.test.js +0 -121
- package/dist/src/sdk/clients/create-public-client.test.js.map +0 -1
- package/dist/src/sdk/clients/create-wallet-client.js +0 -14
- package/dist/src/sdk/clients/create-wallet-client.js.map +0 -1
- package/dist/src/sdk/clients/kontor/create-public-client.js +0 -14
- package/dist/src/sdk/clients/kontor/create-public-client.js.map +0 -1
- package/dist/src/sdk/clients/kontor/create-public-client.test.js +0 -45
- package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +0 -1
- package/dist/src/sdk/clients/transports/create-rpc-transport.js +0 -36
- package/dist/src/sdk/clients/transports/create-rpc-transport.js.map +0 -1
- package/dist/src/sdk/contracts/wits.js +0 -26
- package/dist/src/sdk/contracts/wits.js.map +0 -1
- package/dist/src/sdk/types/chain.js +0 -2
- package/dist/src/sdk/types/chain.js.map +0 -1
- package/dist/src/sdk/types/contract.js +0 -2
- package/dist/src/sdk/types/contract.js.map +0 -1
- package/dist/src/sdk/types/contract.test-d.js +0 -34
- package/dist/src/sdk/types/contract.test-d.js.map +0 -1
- package/dist/src/sdk/types/http-schema.js +0 -73
- package/dist/src/sdk/types/http-schema.js.map +0 -1
- package/dist/src/sdk/types/rpc-schema.js +0 -2
- package/dist/src/sdk/types/rpc-schema.js.map +0 -1
- package/dist/src/sdk/utils/chain/defineChain.js +0 -9
- package/dist/src/sdk/utils/chain/defineChain.js.map +0 -1
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js +0 -289
- package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +0 -24
- package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-function-data.test.js +0 -91
- package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +0 -1
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js +0 -261
- package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +0 -1
- package/dist/src/sdk/utils/wit/get-wit-item.test.js +0 -167
- package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +0 -1
- package/dist/src/wit/wit-parser/core/records.test.js +0 -63
- package/dist/src/wit/wit-parser/core/records.test.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/records.test-d.js +0 -19
- package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/utils.js +0 -2
- package/dist/src/wit/wit-parser/core/types/utils.js.map +0 -1
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js +0 -159
- package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +0 -1
- package/dist/src/wit/wit-parser/core/utils.js +0 -213
- package/dist/src/wit/wit-parser/core/utils.js.map +0 -1
- package/dist/src/wit/wit-parser/core/utils.test.js +0 -316
- package/dist/src/wit/wit-parser/core/utils.test.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +0 -93
- package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +0 -1
- package/dist/src/wit/wit-parser/parse-wit.test.js +0 -80
- package/dist/src/wit/wit-parser/parse-wit.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src → esm}/sdk/utils/wit/codecs/u64.js +0 -0
- /package/dist/{src → esm}/sdk/utils/wit/codecs/u64.js.map +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { buildRpcRequest } from "../../utils/build-rpc-request.js";
|
|
2
|
-
import { createHttpTransport, } from "./create-http-transport.js";
|
|
3
|
-
import { uid as uid_ } from "../../utils/uid.js";
|
|
4
|
-
export function createRpcTransport({ key, methods, name, request, retryCount = 3, retryDelay = 150, timeout, type, }, value) {
|
|
5
|
-
const uid = uid_();
|
|
6
|
-
// Wrap the low-level request with RPC-specific behavior
|
|
7
|
-
const rpcRequest = buildRpcRequest(request, {
|
|
8
|
-
methods,
|
|
9
|
-
retryCount,
|
|
10
|
-
retryDelay,
|
|
11
|
-
uid,
|
|
12
|
-
});
|
|
13
|
-
// Use the base factory, but pass the *original* request into config
|
|
14
|
-
// (so config describes the underlying primitive), and expose the
|
|
15
|
-
// RPC-wrapped `rpcRequest` externally.
|
|
16
|
-
const base = createHttpTransport({
|
|
17
|
-
key,
|
|
18
|
-
name,
|
|
19
|
-
request,
|
|
20
|
-
retryCount,
|
|
21
|
-
retryDelay,
|
|
22
|
-
timeout,
|
|
23
|
-
type,
|
|
24
|
-
}, value);
|
|
25
|
-
return {
|
|
26
|
-
...base,
|
|
27
|
-
request: rpcRequest,
|
|
28
|
-
config: {
|
|
29
|
-
...base.config,
|
|
30
|
-
// carry methods along in config if you want
|
|
31
|
-
// @ts-expect-error – config type doesn’t know about methods by default
|
|
32
|
-
methods,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=create-rpc-transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-transport.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/transports/create-rpc-transport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAGL,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,oBAAoB,CAAC;AA4BjD,MAAM,UAAU,kBAAkB,CAKhC,EACE,GAAG,EACH,OAAO,EACP,IAAI,EACJ,OAAO,EACP,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,GAAG,EAChB,OAAO,EACP,IAAI,GAC6B,EACnC,KAAiC;IAEjC,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;IAEnB,wDAAwD;IACxD,MAAM,UAAU,GAAG,eAAe,CAA+B,OAAO,EAAE;QACxE,OAAO;QACP,UAAU;QACV,UAAU;QACV,GAAG;KACJ,CAAC,CAAC;IAEH,oEAAoE;IACpE,iEAAiE;IACjE,uCAAuC;IACvC,MAAM,IAAI,GAAG,mBAAmB,CAC9B;QACE,GAAG;QACH,IAAI;QACJ,OAAO;QACP,UAAU;QACV,UAAU;QACV,OAAO;QACP,IAAI;KACL,EACD,KAAK,CACN,CAAC;IAEF,OAAO;QACL,GAAG,IAAI;QACP,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE;YACN,GAAG,IAAI,CAAC,MAAM;YACd,4CAA4C;YAC5C,uEAAuE;YACvE,OAAO;SACR;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { parseWit } from "../../wit/wit-parser/parse-wit.js";
|
|
2
|
-
const nativeTokenRaw = [
|
|
3
|
-
"record balance { acc: string, amt: decimal }",
|
|
4
|
-
"record transfer { src: string, dst: string, amt: decimal }",
|
|
5
|
-
"record burn { src: string, amt: decimal }",
|
|
6
|
-
"record mint { dst: string, amt: decimal }",
|
|
7
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
8
|
-
"export hold: func(ctx: borrow<core-context>, amt: decimal) -> result<transfer, error>;",
|
|
9
|
-
"export release: func(ctx: borrow<core-context>, burn-amt: decimal) -> result<burn, error>;",
|
|
10
|
-
"export init: func(ctx: borrow<proc-context>);",
|
|
11
|
-
"export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;",
|
|
12
|
-
"export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;",
|
|
13
|
-
"export transfer: func(ctx: borrow<proc-context>, dst: string, amt: decimal) -> result<transfer, error>;",
|
|
14
|
-
"export balance: func(ctx: borrow<view-context>, acc: string) -> option<decimal>;",
|
|
15
|
-
"export balances: func(ctx: borrow<view-context>) -> list<balance>;",
|
|
16
|
-
"export total-supply: func(ctx: borrow<view-context>) -> decimal;",
|
|
17
|
-
// "export attach: func(ctx: borrow<proc-context>, vout: u64, amt: decimal) -> result<transfer, error>;",
|
|
18
|
-
"export detach: func(ctx: borrow<proc-context>) -> result<transfer, error>;",
|
|
19
|
-
];
|
|
20
|
-
const nativeTokenWit = parseWit(nativeTokenRaw);
|
|
21
|
-
export const nativeToken = {
|
|
22
|
-
raw: nativeTokenRaw,
|
|
23
|
-
wit: nativeTokenWit,
|
|
24
|
-
address: "token_0_0",
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=wits.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wits.js","sourceRoot":"","sources":["../../../../src/sdk/contracts/wits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAiB,MAAM,mCAAmC,CAAC;AAQ5E,MAAM,cAAc,GAAG;IACrB,8CAA8C;IAC9C,4DAA4D;IAC5D,2CAA2C;IAC3C,2CAA2C;IAE3C,wFAAwF;IACxF,wFAAwF;IACxF,4FAA4F;IAC5F,+CAA+C;IAC/C,oFAAoF;IACpF,oFAAoF;IACpF,yGAAyG;IACzG,kFAAkF;IAClF,oEAAoE;IACpE,kEAAkE;IAClE,yGAAyG;IACzG,4EAA4E;CACpE,CAAC;AAEX,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAA0C;IAChE,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,cAAc;IACnB,OAAO,EAAE,WAAW;CACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../src/sdk/types/chain.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/sdk/types/contract.ts"],"names":[],"mappings":""}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from "vitest";
|
|
2
|
-
import { nativeToken as nativeToken_ } from "../contracts/wits.js";
|
|
3
|
-
const nativeToken = nativeToken_.wit;
|
|
4
|
-
test("ContractFunctionName", () => {
|
|
5
|
-
expectTypeOf().toEqualTypeOf;
|
|
6
|
-
expectTypeOf().toEqualTypeOf;
|
|
7
|
-
expectTypeOf().toEqualTypeOf;
|
|
8
|
-
expectTypeOf().toEqualTypeOf;
|
|
9
|
-
});
|
|
10
|
-
test("ContractFunctionArgs", () => {
|
|
11
|
-
expectTypeOf().toEqualTypeOf;
|
|
12
|
-
expectTypeOf().toEqualTypeOf;
|
|
13
|
-
expectTypeOf().toEqualTypeOf;
|
|
14
|
-
expectTypeOf().toEqualTypeOf;
|
|
15
|
-
expectTypeOf().toEqualTypeOf;
|
|
16
|
-
expectTypeOf().toEqualTypeOf;
|
|
17
|
-
expectTypeOf().toEqualTypeOf;
|
|
18
|
-
expectTypeOf().toEqualTypeOf;
|
|
19
|
-
expectTypeOf().toEqualTypeOf;
|
|
20
|
-
expectTypeOf().toEqualTypeOf;
|
|
21
|
-
});
|
|
22
|
-
test("ContractFunctionReturnType", () => {
|
|
23
|
-
expectTypeOf().toEqualTypeOf;
|
|
24
|
-
expectTypeOf().toEqualTypeOf;
|
|
25
|
-
expectTypeOf().toEqualTypeOf;
|
|
26
|
-
expectTypeOf().toEqualTypeOf;
|
|
27
|
-
expectTypeOf().toEqualTypeOf;
|
|
28
|
-
expectTypeOf().toEqualTypeOf;
|
|
29
|
-
expectTypeOf().toEqualTypeOf;
|
|
30
|
-
expectTypeOf().toEqualTypeOf;
|
|
31
|
-
expectTypeOf().toEqualTypeOf;
|
|
32
|
-
expectTypeOf().toEqualTypeOf;
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=contract.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract.test-d.js","sourceRoot":"","sources":["../../../../src/sdk/types/contract.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAM5C,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC;AAErC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAEhC,YAAY,EAAO,CAAC,aAanB,CAAC;IAGF,YAAY,EAAQ,CAAC,aAA8C,CAAC;IAGpE,YAAY,EAAQ,CAAC,aAAsD,CAAC;IAG5E,YAAY,EAAQ,CAAC,aAMpB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAEhC,YAAY,EAAY,CAAC,aAA0C,CAAC;IAGpE,YAAY,EAAQ,CAAC,aAA0C,CAAC;IAGhE,YAAY,EAAW,CAAC,aAA0C,CAAC;IAGnE,YAAY,EAAQ,CAAC,aAA0C,CAAC;IAGhE,YAAY,EAAQ,CAAC,aAA0C,CAAC;IAGhE,YAAY,EAAY,CAAC,aAAkD,CAAC;IAG5E,YAAY,EAAW,CAAC,aAAgC,CAAC;IAGzD,YAAY,EAAY,CAAC,aAA0B,CAAC;IAOpD,YAAY,EAAe,CAAC,aAA0B,CAAC;IAMvD,YAAY,EAAU,CAAC,aAA0B,CAAC;AACpD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAMtC,YAAY,EAAY,CAAC,aAYxB,CAAC;IAGF,YAAY,EAAQ,CAAC,aAapB,CAAC;IAOF,YAAY,EAAW,CAAC,aAYvB,CAAC;IAGF,YAAY,EAAQ,CAAC,aAYpB,CAAC;IAEF,YAAY,EAAQ,CAAC,aAYpB,CAAC;IAOF,YAAY,EAAY,CAAC,aAaxB,CAAC;IAMF,YAAY,EAAW,CAAC,aAQvB,CAAC;IAOF,YAAY,EAAY,CAAC,aAExB,CAAC;IAOF,YAAY,EAAe,CAAC,aAA+B,CAAC;IA2B5D,YAAY,EAAU,CAAC,aAatB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
/**
|
|
3
|
-
* Example usage:
|
|
4
|
-
*
|
|
5
|
-
* type MySchema = [
|
|
6
|
-
* {
|
|
7
|
-
* Route: "/users/:userId";
|
|
8
|
-
* Method: "GET";
|
|
9
|
-
* Parameters: HttpParameters<
|
|
10
|
-
* readonly [readonly ["userId", string]],
|
|
11
|
-
* { include?: string[] },
|
|
12
|
-
* never
|
|
13
|
-
* >;
|
|
14
|
-
* ReturnType: { id: string; name: string };
|
|
15
|
-
* },
|
|
16
|
-
* {
|
|
17
|
-
* Route: "/users/:userId/posts/:postId";
|
|
18
|
-
* Method: "GET";
|
|
19
|
-
* Parameters: HttpParameters<
|
|
20
|
-
* readonly [
|
|
21
|
-
* readonly ["userId", string],
|
|
22
|
-
* readonly ["postId", string]
|
|
23
|
-
* ],
|
|
24
|
-
* never,
|
|
25
|
-
* never
|
|
26
|
-
* >;
|
|
27
|
-
* ReturnType: { id: string; title: string };
|
|
28
|
-
* },
|
|
29
|
-
* {
|
|
30
|
-
* Route: "/users";
|
|
31
|
-
* Method: "POST";
|
|
32
|
-
* Parameters: HttpParameters<never, never, { name: string; email: string }>;
|
|
33
|
-
* ReturnType: { id: string };
|
|
34
|
-
* },
|
|
35
|
-
* {
|
|
36
|
-
* Route: "/users/:userId";
|
|
37
|
-
* Method: "PATCH";
|
|
38
|
-
* Parameters: HttpParameters<
|
|
39
|
-
* readonly [readonly ["userId", string]],
|
|
40
|
-
* never,
|
|
41
|
-
* { name?: string }
|
|
42
|
-
* >;
|
|
43
|
-
* ReturnType: { id: string; name: string };
|
|
44
|
-
* },
|
|
45
|
-
* ];
|
|
46
|
-
*
|
|
47
|
-
* const request: HttpRequestFn<MySchema> = async (args) => {
|
|
48
|
-
* // Implementation can access the method via schema
|
|
49
|
-
* // Path params maintain their order for URL construction
|
|
50
|
-
* };
|
|
51
|
-
*
|
|
52
|
-
* // Usage with ordered path params converted to object for convenience:
|
|
53
|
-
* await request({
|
|
54
|
-
* route: "/users/:userId",
|
|
55
|
-
* path: { userId: "123" },
|
|
56
|
-
* query: { include: ["posts"] }
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* await request({
|
|
60
|
-
* route: "/users/:userId/posts/:postId",
|
|
61
|
-
* path: { userId: "123", postId: "456" }
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* await request({
|
|
65
|
-
* route: "/users",
|
|
66
|
-
* body: { name: "John", email: "john@example.com" }
|
|
67
|
-
* });
|
|
68
|
-
*
|
|
69
|
-
* // Type helpers:
|
|
70
|
-
* type GetUserMethod = ExtractMethod<MySchema, "/users/:userId">; // "GET" | "PATCH"
|
|
71
|
-
* type CreateUserBody = ExtractBodyParams<MySchema, "/users">; // { name: string; email: string }
|
|
72
|
-
*/
|
|
73
|
-
//# sourceMappingURL=http-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-schema.js","sourceRoot":"","sources":["../../../../src/sdk/types/http-schema.ts"],"names":[],"mappings":";AAoUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-schema.js","sourceRoot":"","sources":["../../../../src/sdk/types/rpc-schema.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineChain.js","sourceRoot":"","sources":["../../../../../src/sdk/utils/chain/defineChain.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,WAAW,CACzB,KAAY;IAEZ,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,SAAS;QACtB,GAAG,KAAK;KAC0B,CAAC;AACvC,CAAC"}
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import { InvalidWitEncodingTypeError } from "../../errors/wit.js";
|
|
2
|
-
import { DecimalCodec } from "./codecs/decimal.js";
|
|
3
|
-
import { U64Codec } from "./codecs/u64.js";
|
|
4
|
-
import { StringCodec } from "./codecs/string.js";
|
|
5
|
-
import { OptionCodecFactory } from "./codecs/option.js";
|
|
6
|
-
import { ListCodecFactory } from "./codecs/list.js";
|
|
7
|
-
import { makeDecoder, } from "./codecs/types.js";
|
|
8
|
-
const u64Decoder = makeDecoder(U64Codec);
|
|
9
|
-
const stringDecoder = makeDecoder(StringCodec);
|
|
10
|
-
const decimalDecoder = makeDecoder(DecimalCodec);
|
|
11
|
-
const optionOfDecimalDecoder = makeDecoder(OptionCodecFactory.create(DecimalCodec));
|
|
12
|
-
const optionOfTupleDecoder = (param) => makeDecoder(OptionCodecFactory.create(makeTupleCodecConstructor(param)));
|
|
13
|
-
const listOfDecimalDecoder = makeDecoder(ListCodecFactory.create(DecimalCodec));
|
|
14
|
-
const listOfTupleDecoder = (param) => makeDecoder(ListCodecFactory.create(makeTupleCodecConstructor(param)));
|
|
15
|
-
const tupleDecoder = (param) => makeDecoder(makeTupleCodecConstructor(param));
|
|
16
|
-
//
|
|
17
|
-
export function decodeWitParameter(value, param) {
|
|
18
|
-
// TODO: type cast
|
|
19
|
-
const decoder = decoderForParam(param);
|
|
20
|
-
return {
|
|
21
|
-
decoded: decoder.decode(value),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function decodeTuple(record, param) {
|
|
25
|
-
if (!param.components) {
|
|
26
|
-
throw new Error("Tuple parameter missing components");
|
|
27
|
-
}
|
|
28
|
-
console.log("value");
|
|
29
|
-
return param.components.reduce((acc, component) => {
|
|
30
|
-
if (!component.name) {
|
|
31
|
-
throw new Error("Tuple component missing name");
|
|
32
|
-
}
|
|
33
|
-
const fieldValue = record[component.name];
|
|
34
|
-
const decoder = decoderForParam(component);
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
acc[component.name] = decoder.decode(fieldValue);
|
|
37
|
-
return acc;
|
|
38
|
-
}, {});
|
|
39
|
-
}
|
|
40
|
-
function decoderForParam(p) {
|
|
41
|
-
const t = p.type;
|
|
42
|
-
console.log({ t });
|
|
43
|
-
switch (t) {
|
|
44
|
-
case "tuple":
|
|
45
|
-
return tupleDecoder(p);
|
|
46
|
-
case "string":
|
|
47
|
-
return stringDecoder;
|
|
48
|
-
case "decimal":
|
|
49
|
-
return decimalDecoder;
|
|
50
|
-
case "option<decimal>":
|
|
51
|
-
return optionOfDecimalDecoder;
|
|
52
|
-
case "option<tuple>":
|
|
53
|
-
return optionOfTupleDecoder(p);
|
|
54
|
-
case "list<decimal>":
|
|
55
|
-
return listOfDecimalDecoder;
|
|
56
|
-
case "list<tuple>":
|
|
57
|
-
return listOfTupleDecoder(p);
|
|
58
|
-
case "error":
|
|
59
|
-
case "contract-address":
|
|
60
|
-
case "bool":
|
|
61
|
-
case "s8":
|
|
62
|
-
case "s16":
|
|
63
|
-
case "s32":
|
|
64
|
-
case "s64":
|
|
65
|
-
case "u8":
|
|
66
|
-
case "u16":
|
|
67
|
-
case "u32":
|
|
68
|
-
case "u64":
|
|
69
|
-
return u64Decoder;
|
|
70
|
-
case "integer":
|
|
71
|
-
case "option<string>":
|
|
72
|
-
case "option<bool>":
|
|
73
|
-
case "option<s8>":
|
|
74
|
-
case "option<s16>":
|
|
75
|
-
case "option<s32>":
|
|
76
|
-
case "option<s64>":
|
|
77
|
-
case "option<u8>":
|
|
78
|
-
case "option<u16>":
|
|
79
|
-
case "option<u32>":
|
|
80
|
-
case "option<u64>":
|
|
81
|
-
case "option<integer>":
|
|
82
|
-
case "option<_>":
|
|
83
|
-
case "list<string>":
|
|
84
|
-
case "list<bool>":
|
|
85
|
-
case "list<s8>":
|
|
86
|
-
case "list<s16>":
|
|
87
|
-
case "list<s32>":
|
|
88
|
-
case "list<s64>":
|
|
89
|
-
case "list<u8>":
|
|
90
|
-
case "list<u16>":
|
|
91
|
-
case "list<u32>":
|
|
92
|
-
case "list<u64>":
|
|
93
|
-
case "list<integer>":
|
|
94
|
-
case "list<_>":
|
|
95
|
-
case "result<_, error>":
|
|
96
|
-
case "result<string, error>":
|
|
97
|
-
case "result<bool, error>":
|
|
98
|
-
case "result<s8, error>":
|
|
99
|
-
case "result<s16, error>":
|
|
100
|
-
case "result<s32, error>":
|
|
101
|
-
case "result<s64, error>":
|
|
102
|
-
case "result<u8, error>":
|
|
103
|
-
case "result<u16, error>":
|
|
104
|
-
case "result<u32, error>":
|
|
105
|
-
case "result<u64, error>":
|
|
106
|
-
case "result<decimal, error>":
|
|
107
|
-
case "result<integer, error>":
|
|
108
|
-
case "result<tuple, error>":
|
|
109
|
-
case "result<option<string>, error>":
|
|
110
|
-
case "result<option<bool>, error>":
|
|
111
|
-
case "result<option<s8>, error>":
|
|
112
|
-
case "result<option<s16>, error>":
|
|
113
|
-
case "result<option<s32>, error>":
|
|
114
|
-
case "result<option<s64>, error>":
|
|
115
|
-
case "result<option<u8>, error>":
|
|
116
|
-
case "result<option<u16>, error>":
|
|
117
|
-
case "result<option<u32>, error>":
|
|
118
|
-
case "result<option<u64>, error>":
|
|
119
|
-
case "result<option<decimal>, error>":
|
|
120
|
-
case "result<option<integer>, error>":
|
|
121
|
-
case "result<option<_>, error>":
|
|
122
|
-
case "result<option<tuple>, error>":
|
|
123
|
-
case "option<list<string>>":
|
|
124
|
-
case "option<list<bool>>":
|
|
125
|
-
case "option<list<s8>>":
|
|
126
|
-
case "option<list<s16>>":
|
|
127
|
-
case "option<list<s32>>":
|
|
128
|
-
case "option<list<s64>>":
|
|
129
|
-
case "option<list<u8>>":
|
|
130
|
-
case "option<list<u16>>":
|
|
131
|
-
case "option<list<u32>>":
|
|
132
|
-
case "option<list<u64>>":
|
|
133
|
-
case "option<list<decimal>>":
|
|
134
|
-
case "option<list<integer>>":
|
|
135
|
-
case "option<list<_>>":
|
|
136
|
-
case "option<list<tuple>>":
|
|
137
|
-
case "result<option<list<string>>, error>":
|
|
138
|
-
case "result<option<list<bool>>, error>":
|
|
139
|
-
case "result<option<list<s8>>, error>":
|
|
140
|
-
case "result<option<list<s16>>, error>":
|
|
141
|
-
case "result<option<list<s32>>, error>":
|
|
142
|
-
case "result<option<list<s64>>, error>":
|
|
143
|
-
case "result<option<list<u8>>, error>":
|
|
144
|
-
case "result<option<list<u16>>, error>":
|
|
145
|
-
case "result<option<list<u32>>, error>":
|
|
146
|
-
case "result<option<list<u64>>, error>":
|
|
147
|
-
case "result<option<list<decimal>>, error>":
|
|
148
|
-
case "result<option<list<integer>>, error>":
|
|
149
|
-
case "result<option<list<_>>, error>":
|
|
150
|
-
case "result<option<list<tuple>>, error>":
|
|
151
|
-
case "result<list<string>, error>":
|
|
152
|
-
case "result<list<bool>, error>":
|
|
153
|
-
case "result<list<s8>, error>":
|
|
154
|
-
case "result<list<s16>, error>":
|
|
155
|
-
case "result<list<s32>, error>":
|
|
156
|
-
case "result<list<s64>, error>":
|
|
157
|
-
case "result<list<u8>, error>":
|
|
158
|
-
case "result<list<u16>, error>":
|
|
159
|
-
case "result<list<u32>, error>":
|
|
160
|
-
case "result<list<u64>, error>":
|
|
161
|
-
case "result<list<decimal>, error>":
|
|
162
|
-
case "result<list<integer>, error>":
|
|
163
|
-
case "result<list<_>, error>":
|
|
164
|
-
case "result<list<tuple>, error>":
|
|
165
|
-
throw new Error("not implemented");
|
|
166
|
-
default:
|
|
167
|
-
const exhaustive = t;
|
|
168
|
-
void exhaustive;
|
|
169
|
-
throw new InvalidWitEncodingTypeError(t, {
|
|
170
|
-
docsPath: "tk",
|
|
171
|
-
});
|
|
172
|
-
//
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
export class TupleCodecInstance {
|
|
176
|
-
// 'data' holds the raw parsed JSON object representing the encoded tuple
|
|
177
|
-
constructor(data, param) {
|
|
178
|
-
Object.defineProperty(this, "data", {
|
|
179
|
-
enumerable: true,
|
|
180
|
-
configurable: true,
|
|
181
|
-
writable: true,
|
|
182
|
-
value: data
|
|
183
|
-
});
|
|
184
|
-
Object.defineProperty(this, "param", {
|
|
185
|
-
enumerable: true,
|
|
186
|
-
configurable: true,
|
|
187
|
-
writable: true,
|
|
188
|
-
value: param
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
// Fixes Error 2416: Property 'toWave' must return the branded type WaveExpr
|
|
192
|
-
toWave() {
|
|
193
|
-
// Converts JS data back to the wave format (usually a stringified object)
|
|
194
|
-
throw new Error("TupleCodec.toWave not implemented for decoding context");
|
|
195
|
-
}
|
|
196
|
-
toJs() {
|
|
197
|
-
// The core decoding step: recursively call decodeTuple
|
|
198
|
-
return decodeTuple(this.data, this.param);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
export function makeTupleCodecConstructor(param) {
|
|
202
|
-
if (!param.components) {
|
|
203
|
-
throw new Error("Cannot create TupleCodec: Parameter missing components");
|
|
204
|
-
}
|
|
205
|
-
// 2. Define the CodecConstructor class with static methods
|
|
206
|
-
// We remove 'implements CodecConstructor<any, any, any>' as the function returns the class itself
|
|
207
|
-
// (Fixes Error 2420, although the original code had the static methods, this clarifies intent).
|
|
208
|
-
class TupleCodec {
|
|
209
|
-
// --- Static CodecConstructor methods ---
|
|
210
|
-
// Called to create an instance from a JavaScript value (e.g., when encoding)
|
|
211
|
-
static fromJs(_value) {
|
|
212
|
-
// NOTE: Full encoding implementation is omitted for focus
|
|
213
|
-
throw new Error("TupleCodec.fromJs not implemented for decoding context");
|
|
214
|
-
}
|
|
215
|
-
// Called to parse the raw encoded string into a JavaScript object (Wave Data)
|
|
216
|
-
static parseWave(expr) {
|
|
217
|
-
// For tuples, the raw encoded string is the JSON representation.
|
|
218
|
-
console.log("parsing tuple wave expr:", expr);
|
|
219
|
-
return parseWitRecord(expr);
|
|
220
|
-
}
|
|
221
|
-
// Called to create an instance from the parsed Wave Data
|
|
222
|
-
static fromKontor(data) {
|
|
223
|
-
// Pass the original parameter definition to the instance for use in toJs()
|
|
224
|
-
return new TupleCodecInstance(data, param);
|
|
225
|
-
}
|
|
226
|
-
// --- Instance constructor (optional, mainly for type checking compatibility) ---
|
|
227
|
-
constructor(data) {
|
|
228
|
-
// Delegate to the static factory to ensure the instance is correctly initialized
|
|
229
|
-
return TupleCodec.fromKontor(data);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// 3. Cast the class to the correct CodecConstructor type
|
|
233
|
-
return TupleCodec;
|
|
234
|
-
}
|
|
235
|
-
export function parseWitRecord(raw) {
|
|
236
|
-
// Remove leading/trailing whitespace and outer braces
|
|
237
|
-
const trimmed = raw.trim().replace(/^\{|\}$/g, "");
|
|
238
|
-
const result = {};
|
|
239
|
-
let depth = 0;
|
|
240
|
-
let currentKey = "";
|
|
241
|
-
let currentValue = "";
|
|
242
|
-
let inKey = true;
|
|
243
|
-
let i = 0;
|
|
244
|
-
while (i < trimmed.length) {
|
|
245
|
-
const char = trimmed[i];
|
|
246
|
-
if (char === "{" || char === "[") {
|
|
247
|
-
depth++;
|
|
248
|
-
if (!inKey)
|
|
249
|
-
currentValue += char;
|
|
250
|
-
}
|
|
251
|
-
else if (char === "}" || char === "]") {
|
|
252
|
-
depth--;
|
|
253
|
-
if (!inKey)
|
|
254
|
-
currentValue += char;
|
|
255
|
-
}
|
|
256
|
-
else if (char === ":" && depth === 0 && inKey) {
|
|
257
|
-
// Found the separator between key and value
|
|
258
|
-
inKey = false;
|
|
259
|
-
i++;
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
else if (char === "," && depth === 0) {
|
|
263
|
-
// Found separator between key-value pairs
|
|
264
|
-
// @ts-ignore
|
|
265
|
-
result[currentKey.trim()] = currentValue.trim();
|
|
266
|
-
currentKey = "";
|
|
267
|
-
currentValue = "";
|
|
268
|
-
inKey = true;
|
|
269
|
-
i++;
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
if (inKey) {
|
|
274
|
-
currentKey += char;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
currentValue += char;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
i++;
|
|
281
|
-
}
|
|
282
|
-
// Add the last key-value pair
|
|
283
|
-
if (currentKey.trim()) {
|
|
284
|
-
// @ts-ignore
|
|
285
|
-
result[currentKey.trim()] = currentValue.trim();
|
|
286
|
-
}
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
|
-
//# sourceMappingURL=decode-wit-parameter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode-wit-parameter.js","sourceRoot":"","sources":["../../../../../src/sdk/utils/wit/decode-wit-parameter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM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AI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxC,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,KAAK;gBAAE,YAAY,IAAI,IAAI,CAAC;QACnC,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;YAChD,4CAA4C;YAC5C,KAAK,GAAG,KAAK,CAAC;YACd,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACvC,0CAA0C;YAC1C,aAAa;YACb,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;YAChD,UAAU,GAAG,EAAE,CAAC;YAChB,YAAY,GAAG,EAAE,CAAC;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,CAAC,EAAE,CAAC;YACJ,SAAS;QACX,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,EAAE,CAAC;gBACV,UAAU,IAAI,IAAI,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,YAAY,IAAI,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;QAED,CAAC,EAAE,CAAC;IACN,CAAC;IAED,8BAA8B;IAC9B,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QACtB,aAAa;QACb,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from "vitest";
|
|
2
|
-
import { encodeFunctionData, } from "./encode-function-data.js";
|
|
3
|
-
import { nativeToken } from "../../contracts/wits.js";
|
|
4
|
-
import { parseWit } from "../../../wit/wit-parser/parse-wit.js";
|
|
5
|
-
test("single, function name not required", () => {
|
|
6
|
-
const singleRaw = [
|
|
7
|
-
"record mint { dst: string, amt: decimal }",
|
|
8
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
9
|
-
];
|
|
10
|
-
const single = parseWit(singleRaw);
|
|
11
|
-
// single entry does not require functionName
|
|
12
|
-
encodeFunctionData({ wit: single, args: [[7n, 18]] });
|
|
13
|
-
expectTypeOf().toEqualTypeOf();
|
|
14
|
-
});
|
|
15
|
-
test("native token", () => {
|
|
16
|
-
try {
|
|
17
|
-
// @ts-expect-error functionName required
|
|
18
|
-
encodeFunctionData({ wit: nativeToken });
|
|
19
|
-
}
|
|
20
|
-
catch (e) { }
|
|
21
|
-
expectTypeOf().not.toEqualTypeOf();
|
|
22
|
-
expectTypeOf().toEqualTypeOf();
|
|
23
|
-
});
|
|
24
|
-
//# sourceMappingURL=encode-function-data.test-d.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-function-data.test-d.js","sourceRoot":"","sources":["../../../../../src/sdk/utils/wit/encode-function-data.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAEL,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAC9C,MAAM,SAAS,GAAG;QAChB,2CAA2C;QAE3C,wFAAwF;KAChF,CAAC;IAEX,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnC,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAItD,YAAY,EAAqB,CAAC,aAAa,EAA0B,CAAC;AAC5E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC;QACH,yCAAyC;QACzC,kBAAkB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;IAId,YAAY,EAAqB,CAAC,GAAG,CAAC,aAAa,EAAa,CAAC;IAEjE,YAAY,EAAqB,CAAC,aAAa,EAY5C,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "vitest";
|
|
2
|
-
import { encodeFunctionData } from "./encode-function-data.js";
|
|
3
|
-
import { parseWit } from "../../../wit/wit-parser/parse-wit.js";
|
|
4
|
-
export const nativeToken = parseWit([
|
|
5
|
-
"record balance { acc: string, amt: decimal }",
|
|
6
|
-
"record transfer { src: string, dst: string, amt: decimal }",
|
|
7
|
-
"record burn { src: string, amt: decimal }",
|
|
8
|
-
"record mint { dst: string, amt: decimal }",
|
|
9
|
-
"export issuance: func(ctx: borrow<core-context>, amt: decimal) -> result<mint, error>;",
|
|
10
|
-
"export hold: func(ctx: borrow<core-context>, amt: decimal) -> result<transfer, error>;",
|
|
11
|
-
"export release: func(ctx: borrow<core-context>, burn-amt: decimal) -> result<burn, error>;",
|
|
12
|
-
"export init: func(ctx: borrow<proc-context>);",
|
|
13
|
-
"export mint: func(ctx: borrow<proc-context>, amt: decimal) -> result<mint, error>;",
|
|
14
|
-
"export burn: func(ctx: borrow<proc-context>, amt: decimal) -> result<burn, error>;",
|
|
15
|
-
"export transfer: func(ctx: borrow<proc-context>, dst: string, amt: decimal) -> result<transfer, error>;",
|
|
16
|
-
"export balance: func(ctx: borrow<view-context>, acc: string) -> option<decimal>;",
|
|
17
|
-
"export balances: func(ctx: borrow<view-context>) -> list<balance>;",
|
|
18
|
-
"export total-supply: func(ctx: borrow<view-context>) -> decimal;",
|
|
19
|
-
"export attach: func(ctx: borrow<proc-context>, vout: u64, amt: decimal) -> result<transfer, error>;",
|
|
20
|
-
"export detach: func(ctx: borrow<proc-context>) -> result<transfer, error>;",
|
|
21
|
-
]);
|
|
22
|
-
//TODO: change functionName to func
|
|
23
|
-
test("issuance", () => {
|
|
24
|
-
expect(encodeFunctionData({
|
|
25
|
-
wit: nativeToken,
|
|
26
|
-
functionName: "issuance",
|
|
27
|
-
args: [[7n, 18]],
|
|
28
|
-
})).toEqual("issuance({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
29
|
-
});
|
|
30
|
-
test("hold", () => {
|
|
31
|
-
expect(encodeFunctionData({
|
|
32
|
-
wit: nativeToken,
|
|
33
|
-
functionName: "hold",
|
|
34
|
-
args: [[7n, 18]],
|
|
35
|
-
})).toEqual("hold({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
36
|
-
});
|
|
37
|
-
test("release", () => {
|
|
38
|
-
expect(encodeFunctionData({
|
|
39
|
-
wit: nativeToken,
|
|
40
|
-
functionName: "release",
|
|
41
|
-
args: [[7n, 18]],
|
|
42
|
-
})).toEqual("release({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
43
|
-
});
|
|
44
|
-
test("mint", () => {
|
|
45
|
-
expect(encodeFunctionData({
|
|
46
|
-
wit: nativeToken,
|
|
47
|
-
functionName: "mint",
|
|
48
|
-
args: [[7n, 18]],
|
|
49
|
-
})).toEqual("mint({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
50
|
-
});
|
|
51
|
-
test("burn", () => {
|
|
52
|
-
expect(encodeFunctionData({
|
|
53
|
-
wit: nativeToken,
|
|
54
|
-
functionName: "burn",
|
|
55
|
-
args: [[7n, 18]],
|
|
56
|
-
})).toEqual("burn({r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
57
|
-
});
|
|
58
|
-
test("transfer", () => {
|
|
59
|
-
expect(encodeFunctionData({
|
|
60
|
-
wit: nativeToken,
|
|
61
|
-
functionName: "transfer",
|
|
62
|
-
args: ["bc1deadbeef", [7n, 18]],
|
|
63
|
-
})).toEqual(`transfer("bc1deadbeef", {r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})`);
|
|
64
|
-
});
|
|
65
|
-
test("balance", () => {
|
|
66
|
-
expect(encodeFunctionData({
|
|
67
|
-
wit: nativeToken,
|
|
68
|
-
functionName: "balance",
|
|
69
|
-
args: ["bc1deadbeef"],
|
|
70
|
-
})).toEqual(`balance("bc1deadbeef")`);
|
|
71
|
-
});
|
|
72
|
-
test("balances", () => {
|
|
73
|
-
expect(encodeFunctionData({
|
|
74
|
-
wit: nativeToken,
|
|
75
|
-
functionName: "balances",
|
|
76
|
-
})).toEqual(`balances()`);
|
|
77
|
-
});
|
|
78
|
-
test("totalSupply", () => {
|
|
79
|
-
expect(encodeFunctionData({
|
|
80
|
-
wit: nativeToken,
|
|
81
|
-
functionName: "total-supply",
|
|
82
|
-
})).toEqual(`total-supply()`);
|
|
83
|
-
});
|
|
84
|
-
test("attach", () => {
|
|
85
|
-
expect(encodeFunctionData({
|
|
86
|
-
wit: nativeToken,
|
|
87
|
-
functionName: "attach",
|
|
88
|
-
args: [7n, [7n, 18]],
|
|
89
|
-
})).toEqual("attach(7, {r0: 7, r1: 0, r2: 0, r3: 0, sign: plus})");
|
|
90
|
-
});
|
|
91
|
-
//# sourceMappingURL=encode-function-data.test.js.map
|