@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
@@ -0,0 +1,151 @@
1
+ import { assertType, describe, expect, test, vi } from "vitest";
2
+ import { signet } from "../../chains/definitions/signet.js";
3
+ import { createRpcTransport } from "../transports/create-rpc-transport.js";
4
+ import { createRpcClient } from "./create-rpc-client.js";
5
+ import { httpRpc } from "../transports/http-rpc.js";
6
+ import { custom } from "../transports/custom.js";
7
+ test("creates", () => {
8
+ const mockTransport = () => createRpcTransport({
9
+ key: "mock",
10
+ name: "Mock Transport",
11
+ request: vi.fn(async () => null),
12
+ type: "mock",
13
+ });
14
+ const { uid, ...client } = createRpcClient({
15
+ transport: mockTransport,
16
+ });
17
+ assertType(client.request);
18
+ expect(uid).toBeDefined();
19
+ expect(client).toMatchInlineSnapshot(`
20
+ {
21
+ "account": undefined,
22
+ "cacheTime": 4000,
23
+ "chain": undefined,
24
+ "extend": [Function],
25
+ "key": "base",
26
+ "name": "Base Client",
27
+ "pollingInterval": 4000,
28
+ "request": [Function],
29
+ "transport": {
30
+ "key": "mock",
31
+ "methods": undefined,
32
+ "name": "Mock Transport",
33
+ "request": [MockFunction],
34
+ "retryCount": 3,
35
+ "retryDelay": 150,
36
+ "timeout": undefined,
37
+ "type": "mock",
38
+ },
39
+ "type": "base",
40
+ }
41
+ `);
42
+ });
43
+ describe("transports", () => {
44
+ test("http", () => {
45
+ const { uid, ...client } = createRpcClient({
46
+ chain: signet,
47
+ transport: httpRpc(),
48
+ });
49
+ expect(uid).toBeDefined();
50
+ expect(client).toMatchInlineSnapshot(`
51
+ {
52
+ "account": undefined,
53
+ "cacheTime": 4000,
54
+ "chain": {
55
+ "blockExplorers": {
56
+ "default": {
57
+ "apiUrl": "https://mempool.space/signet/api",
58
+ "name": "mempool.space",
59
+ "url": "https://mempool.space/signet",
60
+ },
61
+ },
62
+ "blockTime": 600000,
63
+ "contracts": {
64
+ "nativeToken": {
65
+ "blockHeight": 0,
66
+ "name": "token",
67
+ "txIndex": 0,
68
+ },
69
+ },
70
+ "fees": undefined,
71
+ "formatters": undefined,
72
+ "id": 0,
73
+ "name": "signet",
74
+ "nativeCurrency": {
75
+ "decimals": 18,
76
+ "name": "Kontor",
77
+ "symbol": "KOR",
78
+ },
79
+ "networkConfig": {
80
+ "bech32": "tb",
81
+ "pubKeyHash": 111,
82
+ "scriptHash": 196,
83
+ "wif": 239,
84
+ },
85
+ "serializers": undefined,
86
+ "urls": {
87
+ "default": {
88
+ "bitcoinRpc": [
89
+ "https://signet-staging.kontor.network:38332",
90
+ ],
91
+ "http": [
92
+ "https://signet-staging.kontor.network:35000/api",
93
+ ],
94
+ "webSocket": [
95
+ "wss://signet-staging.kontor.network:35000/ws",
96
+ ],
97
+ },
98
+ },
99
+ },
100
+ "extend": [Function],
101
+ "key": "base",
102
+ "name": "Base Client",
103
+ "pollingInterval": 4000,
104
+ "request": [Function],
105
+ "transport": {
106
+ "fetchOptions": undefined,
107
+ "key": "http",
108
+ "methods": undefined,
109
+ "name": "HTTP JSON-RPC",
110
+ "request": [Function],
111
+ "retryCount": 3,
112
+ "retryDelay": 150,
113
+ "timeout": 10000,
114
+ "type": "http-rpc",
115
+ "url": "https://signet-staging.kontor.network:38332",
116
+ },
117
+ "type": "base",
118
+ }
119
+ `);
120
+ });
121
+ });
122
+ test("custom", () => {
123
+ const { uid, ...client } = createRpcClient({
124
+ transport: custom({ request: async () => null }),
125
+ });
126
+ expect(uid).toBeDefined();
127
+ expect(client).toMatchInlineSnapshot(`
128
+ {
129
+ "account": undefined,
130
+ "cacheTime": 4000,
131
+ "chain": undefined,
132
+ "extend": [Function],
133
+ "key": "base",
134
+ "name": "Base Client",
135
+ "pollingInterval": 4000,
136
+ "request": [Function],
137
+ "transport": {
138
+ "key": "custom",
139
+ "methods": undefined,
140
+ "name": "Custom Provider",
141
+ "request": [Function],
142
+ "retryCount": 3,
143
+ "retryDelay": 150,
144
+ "timeout": undefined,
145
+ "type": "custom",
146
+ },
147
+ "type": "base",
148
+ }
149
+ `);
150
+ });
151
+ //# sourceMappingURL=create-rpc-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-rpc-client.test.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/base/create-rpc-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,aAAa,GAAG,GAAG,EAAE,CACzB,kBAAkB,CAAC;QACjB,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAuC;QACtE,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IACL,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,eAAe,CAAC;QACzC,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC;IAEH,UAAU,CAA0B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;GAsBpC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QAChB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,eAAe,CAAC;YACzC,KAAK,EAAE,MAAM;YAEb,SAAS,EAAE,OAAO,EAAa;SAChC,CAAC,CAAC;QAEH,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAE1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqEpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;IAClB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,eAAe,CAAC;QACzC,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;KACjD,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;KAsBlC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { createRpcClient, } from "./base/create-rpc-client.js";
2
+ import { publicActions } from "./decorators/public.js";
3
+ export function createPublicClient(parameters) {
4
+ const { key = "btc-rpc", name = "BTC-RPC Client" } = parameters;
5
+ const client = createRpcClient({
6
+ ...parameters,
7
+ key,
8
+ name,
9
+ type: "btc-rpc-client",
10
+ }); // TODO: figure out what deal is with this any
11
+ return client.extend(publicActions);
12
+ }
13
+ //# sourceMappingURL=create-public-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.js","sourceRoot":"","sources":["../../../../src/sdk/clients/create-public-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAsB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA4C3E,MAAM,UAAU,kBAAkB,CAUhC,UAA6E;IAE7E,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,gBAAgB;KACvB,CAAQ,CAAC,CAAC,8CAA8C;IAEzD,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAQ,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { assertType, expect, test, vi } from "vitest";
2
+ import { createPublicClient } from "./create-public-client.js";
3
+ import { createRpcTransport } from "./transports/create-rpc-transport.js";
4
+ import { signet } from "../chains/definitions/signet.js";
5
+ const mockTransport = () => createRpcTransport({
6
+ key: "mock",
7
+ name: "Mock Transport",
8
+ request: vi.fn(() => null),
9
+ type: "mock",
10
+ });
11
+ test("creates", () => {
12
+ const { uid, ...client } = createPublicClient({
13
+ transport: mockTransport,
14
+ });
15
+ assertType(client.request);
16
+ expect(uid).toBeDefined();
17
+ expect(client).toMatchInlineSnapshot(`
18
+ {
19
+ "account": undefined,
20
+ "cacheTime": 4000,
21
+ "chain": undefined,
22
+ "extend": [Function],
23
+ "key": "btc-rpc",
24
+ "name": "BTC-RPC Client",
25
+ "pollingInterval": 4000,
26
+ "request": [Function],
27
+ "sendRawTransaction": [Function],
28
+ "testMempoolAccept": [Function],
29
+ "transport": {
30
+ "key": "mock",
31
+ "methods": undefined,
32
+ "name": "Mock Transport",
33
+ "request": [MockFunction],
34
+ "retryCount": 3,
35
+ "retryDelay": 150,
36
+ "timeout": undefined,
37
+ "type": "mock",
38
+ },
39
+ "type": "btc-rpc-client",
40
+ }
41
+ `);
42
+ });
43
+ test("with chain", () => {
44
+ const { uid, ...client } = createPublicClient({
45
+ transport: mockTransport,
46
+ chain: signet,
47
+ });
48
+ assertType(client.request);
49
+ expect(uid).toBeDefined();
50
+ expect(client).toMatchInlineSnapshot(`
51
+ {
52
+ "account": undefined,
53
+ "cacheTime": 4000,
54
+ "chain": {
55
+ "blockExplorers": {
56
+ "default": {
57
+ "apiUrl": "https://mempool.space/signet/api",
58
+ "name": "mempool.space",
59
+ "url": "https://mempool.space/signet",
60
+ },
61
+ },
62
+ "blockTime": 600000,
63
+ "contracts": {
64
+ "nativeToken": {
65
+ "blockHeight": 0,
66
+ "name": "token",
67
+ "txIndex": 0,
68
+ },
69
+ },
70
+ "fees": undefined,
71
+ "formatters": undefined,
72
+ "id": 0,
73
+ "name": "signet",
74
+ "nativeCurrency": {
75
+ "decimals": 18,
76
+ "name": "Kontor",
77
+ "symbol": "KOR",
78
+ },
79
+ "networkConfig": {
80
+ "bech32": "tb",
81
+ "pubKeyHash": 111,
82
+ "scriptHash": 196,
83
+ "wif": 239,
84
+ },
85
+ "serializers": undefined,
86
+ "urls": {
87
+ "default": {
88
+ "bitcoinRpc": [
89
+ "https://signet-staging.kontor.network:38332",
90
+ ],
91
+ "http": [
92
+ "https://signet-staging.kontor.network:35000/api",
93
+ ],
94
+ "webSocket": [
95
+ "wss://signet-staging.kontor.network:35000/ws",
96
+ ],
97
+ },
98
+ },
99
+ },
100
+ "extend": [Function],
101
+ "key": "btc-rpc",
102
+ "name": "BTC-RPC Client",
103
+ "pollingInterval": 4000,
104
+ "request": [Function],
105
+ "sendRawTransaction": [Function],
106
+ "testMempoolAccept": [Function],
107
+ "transport": {
108
+ "key": "mock",
109
+ "methods": undefined,
110
+ "name": "Mock Transport",
111
+ "request": [MockFunction],
112
+ "retryCount": 3,
113
+ "retryDelay": 150,
114
+ "timeout": undefined,
115
+ "type": "mock",
116
+ },
117
+ "type": "btc-rpc-client",
118
+ }
119
+ `);
120
+ });
121
+ //# sourceMappingURL=create-public-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.test.js","sourceRoot":"","sources":["../../../../src/sdk/clients/create-public-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,MAAM,aAAa,GAAG,GAAG,EAAE,CACzB,kBAAkB,CAAC;IACjB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAQ;IACjC,IAAI,EAAE,MAAM;CACb,CAAC,CAAC;AAEL,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACnB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,aAAa;KACzB,CAAC,CAAC;IAEH,UAAU,CAA6B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEvD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;GAwBpC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;IACtB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,MAAM;KACd,CAAC,CAAC;IAEH,UAAU,CAA6B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEvD,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqErC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { createRpcClient, } from "./base/create-rpc-client.js";
2
+ import { walletActions } from "./decorators/wallet.js";
3
+ export function createWalletClient(parameters) {
4
+ const { key = "btc-rpc", name = "BTC-RPC Client" } = parameters;
5
+ const client = createRpcClient({
6
+ ...parameters,
7
+ key,
8
+ name,
9
+ type: "btcRpcClient",
10
+ });
11
+ // TODO: fix any if possible
12
+ return client.extend(walletActions);
13
+ }
14
+ //# sourceMappingURL=create-wallet-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-wallet-client.js","sourceRoot":"","sources":["../../../../src/sdk/clients/create-wallet-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,eAAe,GAChB,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAAE,aAAa,EAAsB,MAAM,wBAAwB,CAAC;AA2C3E,MAAM,UAAU,kBAAkB,CAShC,UAA6E;IAE7E,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,cAAc;KACrB,CAAQ,CAAC;IAEV,4BAA4B;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAKjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { kontorPublicActions, } from "../decorators/kontor/public.js";
2
+ import { createHttpClient, } from "../base/create-http-client.js";
3
+ export function createPublicClient(parameters) {
4
+ const { key = "kontor-http", name = "KONTOR-HTTP Client" } = parameters;
5
+ const client = createHttpClient({
6
+ ...parameters,
7
+ key,
8
+ name,
9
+ type: "kontor-http-client",
10
+ });
11
+ // TODO: refactor this any
12
+ return client.extend(kontorPublicActions);
13
+ }
14
+ //# sourceMappingURL=create-public-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/kontor/create-public-client.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,GAIjB,MAAM,+BAA+B,CAAC;AAgDvC,MAAM,UAAU,kBAAkB,CAUhC,UAKC;IAOD,MAAM,EAAE,GAAG,GAAG,aAAa,EAAE,IAAI,GAAG,oBAAoB,EAAE,GAAG,UAAU,CAAC;IAExE,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,oBAAoB;KAC3B,CAAQ,CAAC;IACV,0BAA0B;IAE1B,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { expect, test } from "vitest";
2
+ import { createPublicClient } from "./create-public-client.js";
3
+ import { http } from "../transports/http.js";
4
+ test("creates", async () => {
5
+ const { uid, ...client } = createPublicClient({
6
+ transport: http("https://signet.kontor.network:35000/api"),
7
+ });
8
+ expect(client).toMatchInlineSnapshot(`
9
+ {
10
+ "account": undefined,
11
+ "buildComposeQuery": [Function],
12
+ "buildInstructionQuery": [Function],
13
+ "cacheTime": 4000,
14
+ "callCompose": [Function],
15
+ "callView": [Function],
16
+ "chain": undefined,
17
+ "extend": [Function],
18
+ "inspect": [Function],
19
+ "key": "kontor-http",
20
+ "name": "KONTOR-HTTP Client",
21
+ "pollingInterval": 4000,
22
+ "procContract": [Function],
23
+ "request": [Function],
24
+ "transport": {
25
+ "fetchOptions": undefined,
26
+ "key": "http",
27
+ "name": "HTTP Transport",
28
+ "request": [Function],
29
+ "retryCount": 3,
30
+ "retryDelay": 150,
31
+ "timeout": 10000,
32
+ "type": "http",
33
+ "url": "https://signet.kontor.network:35000/api",
34
+ },
35
+ "type": "kontor-http-client",
36
+ "viewContract": [Function],
37
+ }
38
+ `);
39
+ const x = await client.callView({
40
+ contractAddress: "token_0_0",
41
+ wave: "balances()",
42
+ });
43
+ console.log({ x });
44
+ });
45
+ //# sourceMappingURL=create-public-client.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-client.test.js","sourceRoot":"","sources":["../../../../../src/sdk/clients/kontor/create-public-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACzB,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC5C,SAAS,EAAE,IAAI,CAAC,yCAAyC,CAAC;KAC3D,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BpC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;QAC9B,eAAe,EAAE,WAAW;QAC5B,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,36 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,26 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../src/sdk/types/chain.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/sdk/types/contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,73 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-schema.js","sourceRoot":"","sources":["../../../../src/sdk/types/http-schema.ts"],"names":[],"mappings":";AAoUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rpc-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-schema.js","sourceRoot":"","sources":["../../../../src/sdk/types/rpc-schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export function defineChain(chain) {
2
+ return {
3
+ formatters: undefined,
4
+ fees: undefined,
5
+ serializers: undefined,
6
+ ...chain,
7
+ };
8
+ }
9
+ //# sourceMappingURL=defineChain.js.map
@@ -0,0 +1 @@
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"}