@kontor/kontor-sdk 1.0.0-alpha.11 → 1.0.0-alpha.13
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/src/sdk/actions/kontor/public/proc-contract.js +1 -1
- package/dist/src/sdk/actions/kontor/public/proc-contract.js.map +1 -1
- package/dist/src/sdk/clients/decorators/kontor/public.js +1 -1
- package/dist/src/sdk/clients/decorators/kontor/public.js.map +1 -1
- package/dist/src/sdk/contracts/wits.js +26 -0
- package/dist/src/sdk/contracts/wits.js.map +1 -0
- package/dist/src/sdk/test/e2e.test.js +166 -0
- package/dist/src/sdk/test/e2e.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/sdk/actions/kontor/public/proc-contract.ts +1 -1
- package/src/sdk/clients/decorators/kontor/public.ts +2 -2
- package/src/sdk/contracts/wits.ts +5 -5
- package/src/sdk/test/e2e.test.ts +9 -93
package/package.json
CHANGED
|
@@ -83,7 +83,7 @@ export type KontorPublicActions<
|
|
|
83
83
|
args: BuildComposeQueryParameters<chain>,
|
|
84
84
|
) => Promise<BuildComposeQueryReturnType>;
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
callCompose: <chain extends Chain | undefined>(
|
|
87
87
|
args: CallComposeParameters<chain>,
|
|
88
88
|
) => Promise<CallComposeReturnType>;
|
|
89
89
|
inspect: <_chain extends Chain | undefined>(
|
|
@@ -102,7 +102,7 @@ export function kontorPublicActions<
|
|
|
102
102
|
viewContract: (args) => viewContract(client, args),
|
|
103
103
|
procContract: (args) => procContract(client, args),
|
|
104
104
|
callView: (args) => callView(client, args),
|
|
105
|
-
|
|
105
|
+
callCompose: (args) => callCompose(client, args),
|
|
106
106
|
buildInstructionQuery: (args) => buildInstructionQuery(client, args),
|
|
107
107
|
buildComposeQuery: (args) => buildComposeQuery(client, args),
|
|
108
108
|
inspect: (args) => inspect(client, args),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ResolvedRegister } from "../../wit/register.js";
|
|
2
|
-
import { parseWit } from "../../wit/wit-parser/parse-wit.js";
|
|
2
|
+
import { parseWit, type ParseWit } from "../../wit/wit-parser/parse-wit.js";
|
|
3
3
|
|
|
4
|
-
type ContractExport = {
|
|
5
|
-
raw:
|
|
6
|
-
wit:
|
|
4
|
+
type ContractExport<signatures extends readonly string[]> = {
|
|
5
|
+
raw: signatures;
|
|
6
|
+
wit: ParseWit<signatures>;
|
|
7
7
|
address: ResolvedRegister["contractAddress"];
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ const nativeTokenRaw = [
|
|
|
29
29
|
|
|
30
30
|
const nativeTokenWit = parseWit(nativeTokenRaw);
|
|
31
31
|
|
|
32
|
-
export const nativeToken: ContractExport = {
|
|
32
|
+
export const nativeToken: ContractExport<typeof nativeTokenRaw> = {
|
|
33
33
|
raw: nativeTokenRaw,
|
|
34
34
|
wit: nativeTokenWit,
|
|
35
35
|
address: "token_0_0",
|
package/src/sdk/test/e2e.test.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { custom } from "../clients/transports/custom.js";
|
|
|
10
10
|
import { Transaction } from "@scure/btc-signer";
|
|
11
11
|
import { hex } from "@scure/base";
|
|
12
12
|
import { signet } from "../chains/definitions/signet.js";
|
|
13
|
+
import { Instruction } from "../types/kontor.js";
|
|
13
14
|
|
|
14
15
|
export const nativeTokenRaw = [
|
|
15
16
|
"record balance { acc: string, amt: decimal }",
|
|
@@ -117,86 +118,20 @@ export const wit = parseWit(nativeTokenRaw);
|
|
|
117
118
|
test("e2e kontor wallet client", async () => {
|
|
118
119
|
const account = mnemonicToAccount(process.env.TEST_MNEMONIC!);
|
|
119
120
|
|
|
120
|
-
const res = {
|
|
121
|
-
result: {
|
|
122
|
-
commit_transaction: {
|
|
123
|
-
version: 2,
|
|
124
|
-
lock_time: 0,
|
|
125
|
-
input: [
|
|
126
|
-
{
|
|
127
|
-
previous_output:
|
|
128
|
-
"641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
129
|
-
script_sig: "",
|
|
130
|
-
sequence: 4294967295,
|
|
131
|
-
witness: [],
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
output: [
|
|
135
|
-
{
|
|
136
|
-
value: 570,
|
|
137
|
-
script_pubkey:
|
|
138
|
-
"51207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
value: 8502,
|
|
142
|
-
script_pubkey:
|
|
143
|
-
"5120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f",
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
commit_transaction_hex:
|
|
148
|
-
"0200000001332a0e2d0c369ebb984ce8addb4387bd6702f59b255ceada1c0fcff4ed401c640100000000ffffffff023a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f3621000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f00000000",
|
|
149
|
-
commit_psbt_hex:
|
|
150
|
-
"70736274ff0100890200000001332a0e2d0c369ebb984ce8addb4387bd6702f59b255ceada1c0fcff4ed401c640100000000ffffffff023a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f3621000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f000000000001012b8e24000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f0117202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f000000",
|
|
151
|
-
reveal_transaction: {
|
|
152
|
-
version: 2,
|
|
153
|
-
lock_time: 0,
|
|
154
|
-
input: [
|
|
155
|
-
{
|
|
156
|
-
previous_output:
|
|
157
|
-
"4b195fabb3bd5360de2e2db6821df9d8909f0dbd5f1ba50ae1ca71a841080c3d:0",
|
|
158
|
-
script_sig: "",
|
|
159
|
-
sequence: 4294967295,
|
|
160
|
-
witness: [],
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
output: [
|
|
164
|
-
{
|
|
165
|
-
value: 330,
|
|
166
|
-
script_pubkey:
|
|
167
|
-
"5120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f",
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
reveal_transaction_hex:
|
|
172
|
-
"02000000013d0c0841a871cae10aa51b5fbd0d9f90d8f91d82b62d2ede6053bdb3ab5f194b0000000000ffffffff014a01000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f00000000",
|
|
173
|
-
reveal_psbt_hex:
|
|
174
|
-
"70736274ff01005e02000000013d0c0841a871cae10aa51b5fbd0d9f90d8f91d82b62d2ede6053bdb3ab5f194b0000000000ffffffff014a01000000000000225120929c39410fb437b4ff387ec898cbc098365d91965073004fc43e013d410d417f000000000001012b3a020000000000002251207fe892a65813b770346d37f8fbbdf5c1e6bee0bc34b0c625e8f4ca5ff3ad144f0117202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f0000",
|
|
175
|
-
per_participant: [
|
|
176
|
-
{
|
|
177
|
-
address:
|
|
178
|
-
"tb1pj2wrjsg0ksmmflec0myf3j7qnqm9myvk2pesqn7y8cqn6sgdg9ls9u6tar",
|
|
179
|
-
x_only_public_key:
|
|
180
|
-
"2c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f",
|
|
181
|
-
commit_tap_leaf_script: {
|
|
182
|
-
leafVersion: 192,
|
|
183
|
-
script:
|
|
184
|
-
"202c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51fac0063036b6f6e00010268",
|
|
185
|
-
controlBlock:
|
|
186
|
-
"c12c7b730daa0036e8276cdd8fabe844b2dd324a6d227dd209663805189d03e51f",
|
|
187
|
-
},
|
|
188
|
-
chained_tap_leaf_script: null,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
|
|
194
121
|
const kontorPublicClient = createKontorPublicClient({
|
|
195
122
|
transport: http("https://signet-staging.kontor.network:35000/api"),
|
|
196
123
|
account,
|
|
197
124
|
chain: signet,
|
|
198
125
|
});
|
|
199
126
|
|
|
127
|
+
const res = await kontorPublicClient.callCompose({
|
|
128
|
+
utxos: [
|
|
129
|
+
"641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
130
|
+
],
|
|
131
|
+
instruction: Instruction.issuance(),
|
|
132
|
+
satsPerVByte: 1,
|
|
133
|
+
});
|
|
134
|
+
|
|
200
135
|
const kontorWalletClient = createKontorWalletClient({
|
|
201
136
|
account,
|
|
202
137
|
// TODO: transport is not used for local account.
|
|
@@ -205,20 +140,6 @@ test("e2e kontor wallet client", async () => {
|
|
|
205
140
|
}),
|
|
206
141
|
});
|
|
207
142
|
|
|
208
|
-
// const res = await kontorPublicClient.procContract({
|
|
209
|
-
// wit: wit,
|
|
210
|
-
// // TODO: add optional account override
|
|
211
|
-
//
|
|
212
|
-
// functionName: "mint", // functin name is only valid if it's got a proc-context
|
|
213
|
-
// contractAddress: "token_0_0",
|
|
214
|
-
// args: [[7n, 18]],
|
|
215
|
-
// satsPerVByte: 1,
|
|
216
|
-
// utxos: [
|
|
217
|
-
// "641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
218
|
-
// ],
|
|
219
|
-
// gas: 10n,
|
|
220
|
-
// });
|
|
221
|
-
|
|
222
143
|
const commit: Transaction = await kontorWalletClient.signCommit({
|
|
223
144
|
account: account,
|
|
224
145
|
chain: signet,
|
|
@@ -235,11 +156,6 @@ test("e2e kontor wallet client", async () => {
|
|
|
235
156
|
const commitExtracted = commit.extract();
|
|
236
157
|
const revealExtracted = reveal.extract();
|
|
237
158
|
|
|
238
|
-
// const m = await btcPublicClient.testMempoolAccept({
|
|
239
|
-
// rawtx: [hex.encode(commitExtracted), hex.encode(revealExtracted)],
|
|
240
|
-
// options: {},
|
|
241
|
-
// });
|
|
242
|
-
|
|
243
159
|
const r = await fetch("https://signet.kontor.network:38332", {
|
|
244
160
|
method: "POST",
|
|
245
161
|
headers: {
|