@kontor/kontor-sdk 1.0.0-alpha.1 → 1.0.0-alpha.4
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/kwit/error.js +59 -0
- package/dist/src/kwit/error.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/errors/kwit-parameter.js +29 -0
- package/dist/src/kwit/kwit-parser/core/errors/kwit-parameter.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/errors/signature.js +42 -0
- package/dist/src/kwit/kwit-parser/core/errors/signature.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/errors/splitParameters.js +18 -0
- package/dist/src/kwit/kwit-parser/core/errors/splitParameters.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/records.js +73 -0
- package/dist/src/kwit/kwit-parser/core/records.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/records.test.js +53 -0
- package/dist/src/kwit/kwit-parser/core/records.test.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/signatures.js +33 -0
- package/dist/src/kwit/kwit-parser/core/signatures.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/signatures.test.js +54 -0
- package/dist/src/kwit/kwit-parser/core/signatures.test.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/records.js +2 -0
- package/dist/src/kwit/kwit-parser/core/types/records.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/records.test-d.js +19 -0
- package/dist/src/kwit/kwit-parser/core/types/records.test-d.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/signatures.js +3 -0
- package/dist/src/kwit/kwit-parser/core/types/signatures.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/signatures.test-d.js +18 -0
- package/dist/src/kwit/kwit-parser/core/types/signatures.test-d.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/utils.js +2 -0
- package/dist/src/kwit/kwit-parser/core/types/utils.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/types/utils.test-d.js +159 -0
- package/dist/src/kwit/kwit-parser/core/types/utils.test-d.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/utils.js +212 -0
- package/dist/src/kwit/kwit-parser/core/utils.js.map +1 -0
- package/dist/src/kwit/kwit-parser/core/utils.test.js +302 -0
- package/dist/src/kwit/kwit-parser/core/utils.test.js.map +1 -0
- package/dist/src/kwit/kwit-parser/parse-kwit-parameter.js +26 -0
- package/dist/src/kwit/kwit-parser/parse-kwit-parameter.js.map +1 -0
- package/dist/src/kwit/kwit-parser/parse-kwit-parameter.test.js +83 -0
- package/dist/src/kwit/kwit-parser/parse-kwit-parameter.test.js.map +1 -0
- package/dist/src/kwit/kwit-parser/parse-kwit.js +16 -0
- package/dist/src/kwit/kwit-parser/parse-kwit.js.map +1 -0
- package/dist/src/kwit/kwit-parser/parse-kwit.test.js +78 -0
- package/dist/src/kwit/kwit-parser/parse-kwit.test.js.map +1 -0
- package/dist/src/kwit/kwit.js +2 -0
- package/dist/src/kwit/kwit.js.map +1 -0
- package/dist/src/kwit/kwit.test.js +9 -0
- package/dist/src/kwit/kwit.test.js.map +1 -0
- package/dist/src/kwit/narrow.js +14 -0
- package/dist/src/kwit/narrow.js.map +1 -0
- package/dist/src/kwit/regex.js +6 -0
- package/dist/src/kwit/regex.js.map +1 -0
- package/dist/src/kwit/register.js +2 -0
- package/dist/src/kwit/register.js.map +1 -0
- package/dist/src/kwit/type-utils.js +2 -0
- package/dist/src/kwit/type-utils.js.map +1 -0
- package/dist/src/kwit/utils.js +2 -0
- package/dist/src/kwit/utils.js.map +1 -0
- package/dist/src/kwit/utils.test-d.js +17 -0
- package/dist/src/kwit/utils.test-d.js.map +1 -0
- package/dist/src/kwit/version.js +2 -0
- package/dist/src/kwit/version.js.map +1 -0
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +0 -3
- package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +1 -1
- package/dist/src/sdk/actions/public/test-mempool-accept.js +8 -32
- package/dist/src/sdk/actions/public/test-mempool-accept.js.map +1 -1
- package/dist/src/sdk/clients/decorators/public.js +2 -0
- package/dist/src/sdk/clients/decorators/public.js.map +1 -1
- package/dist/src/sdk/errors/kwit.js +19 -0
- package/dist/src/sdk/errors/kwit.js.map +1 -0
- package/dist/src/sdk/test/e2e.test.js +27 -6
- package/dist/src/sdk/test/e2e.test.js.map +1 -1
- package/dist/src/sdk/utils/kwit/codecs/decimal.js +165 -0
- package/dist/src/sdk/utils/kwit/codecs/decimal.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/enum.js +104 -0
- package/dist/src/sdk/utils/kwit/codecs/enum.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/integer.js +167 -0
- package/dist/src/sdk/utils/kwit/codecs/integer.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/list.js +117 -0
- package/dist/src/sdk/utils/kwit/codecs/list.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/option.js +91 -0
- package/dist/src/sdk/utils/kwit/codecs/option.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/string.js +27 -0
- package/dist/src/sdk/utils/kwit/codecs/string.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/types.js +45 -0
- package/dist/src/sdk/utils/kwit/codecs/types.js.map +1 -0
- package/dist/src/sdk/utils/kwit/codecs/unit.js +22 -0
- package/dist/src/sdk/utils/kwit/codecs/unit.js.map +1 -0
- package/dist/src/sdk/utils/kwit/decode-function-result.js +36 -0
- package/dist/src/sdk/utils/kwit/decode-function-result.js.map +1 -0
- package/dist/src/sdk/utils/kwit/decode-kwit-parameter.js +286 -0
- package/dist/src/sdk/utils/kwit/decode-kwit-parameter.js.map +1 -0
- package/dist/src/sdk/utils/kwit/decode-kwit-parameter.test.js +75 -0
- package/dist/src/sdk/utils/kwit/decode-kwit-parameter.test.js.map +1 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.js +17 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.js.map +1 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.test-d.js +21 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.test-d.js.map +1 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.test.js +91 -0
- package/dist/src/sdk/utils/kwit/encode-function-data.test.js.map +1 -0
- package/dist/src/sdk/utils/kwit/encode-kwit-parameters.js +250 -0
- package/dist/src/sdk/utils/kwit/encode-kwit-parameters.js.map +1 -0
- package/dist/src/sdk/utils/kwit/encode-kwit-parameters.test.js +62 -0
- package/dist/src/sdk/utils/kwit/encode-kwit-parameters.test.js.map +1 -0
- package/dist/src/sdk/utils/kwit/get-kwit-item.js +186 -0
- package/dist/src/sdk/utils/kwit/get-kwit-item.js.map +1 -0
- package/dist/src/sdk/utils/kwit/get-kwit-item.test.js +119 -0
- package/dist/src/sdk/utils/kwit/get-kwit-item.test.js.map +1 -0
- package/dist/src/sdk/utils/kwit/prepare-encode-function-data.js +24 -0
- package/dist/src/sdk/utils/kwit/prepare-encode-function-data.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/src/sdk/actions/kontor/wallet/sign-reveal.ts +0 -4
- package/src/sdk/actions/public/test-mempool-accept.ts +34 -31
- package/src/sdk/clients/decorators/public.ts +11 -0
- package/src/sdk/test/e2e.test.ts +31 -6
- package/src/sdk/types/btc-rpc.ts +12 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontor/kontor-sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"author": "Unspendable Labs <dev@unspendablelabs.com>",
|
|
5
5
|
"description": "The official SDK to the Kontor Bitcoin metaprotocol",
|
|
6
6
|
"repository": {
|
|
@@ -65,5 +65,9 @@
|
|
|
65
65
|
"micro-packed": "^0.8.0",
|
|
66
66
|
"sats-connect": "^4.2.1",
|
|
67
67
|
"zod": "^4.1.12"
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
|
+
"workspaces": [
|
|
70
|
+
".",
|
|
71
|
+
"demo"
|
|
72
|
+
]
|
|
69
73
|
}
|
|
@@ -120,15 +120,11 @@ export async function signReveal<
|
|
|
120
120
|
signedTx.updateInput(i, {
|
|
121
121
|
finalScriptWitness: [
|
|
122
122
|
input.tapScriptSig![0]![1],
|
|
123
|
-
// @ts-ignore
|
|
124
123
|
hex.decode(p.commit_tap_leaf_script.script),
|
|
125
|
-
// @ts-ignore
|
|
126
124
|
hex.decode(p.commit_tap_leaf_script.controlBlock),
|
|
127
125
|
],
|
|
128
126
|
});
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
signedTx.finalize();
|
|
132
|
-
|
|
133
129
|
return signedTx;
|
|
134
130
|
}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import type { Chain } from "../../types/chain.js";
|
|
2
|
+
|
|
3
|
+
import type { RpcTransport } from "../../clients/transports/create-rpc-transport.js";
|
|
4
|
+
import type { PublicClient } from "../../clients/create-public-client.js";
|
|
5
|
+
import type { Account } from "../../accounts/types.js";
|
|
6
|
+
|
|
7
|
+
export type TestMempoolAcceptOptions = {
|
|
8
|
+
/** Max feerate in BTC/kvB. If omitted, Core uses default relay feerate. */
|
|
9
|
+
maxfeerate?: string | number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface TestMempoolAcceptParams {
|
|
13
|
+
rawtx: string | string[];
|
|
14
|
+
options: TestMempoolAcceptOptions;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type TestMempoolAcceptReturnType = any;
|
|
18
|
+
|
|
19
|
+
export async function testMempoolAccept<
|
|
20
|
+
chain extends Chain | undefined,
|
|
21
|
+
account extends Account | undefined = Account | undefined,
|
|
22
|
+
>(
|
|
23
|
+
client: PublicClient<RpcTransport, chain, account>,
|
|
24
|
+
{ rawtx, options = {} }: TestMempoolAcceptParams,
|
|
25
|
+
): Promise<TestMempoolAcceptReturnType> {
|
|
26
|
+
const txs = Array.isArray(rawtx) ? rawtx : [rawtx];
|
|
27
|
+
|
|
28
|
+
const params = options.maxfeerate !== undefined ? [txs, options] : [txs];
|
|
29
|
+
|
|
30
|
+
return client.request({
|
|
31
|
+
method: "testmempoolaccept",
|
|
32
|
+
params: params as any,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
// export async function testMempoolAccept(
|
|
34
37
|
// rawtx: string | string[],
|
|
@@ -8,6 +8,13 @@ import {
|
|
|
8
8
|
type SendRawTransactionReturnType,
|
|
9
9
|
sendRawTransaction,
|
|
10
10
|
} from "../../actions/public/send-raw-transaction.js";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type TestMempoolAcceptParams,
|
|
14
|
+
type TestMempoolAcceptReturnType,
|
|
15
|
+
testMempoolAccept,
|
|
16
|
+
} from "../../actions/public/test-mempool-accept.js";
|
|
17
|
+
|
|
11
18
|
import type { PublicClient as PublicClient } from "../create-public-client.js";
|
|
12
19
|
|
|
13
20
|
export type PublicActions<
|
|
@@ -20,6 +27,9 @@ export type PublicActions<
|
|
|
20
27
|
sendRawTransaction: (
|
|
21
28
|
parameters: SendRawTransactionParams,
|
|
22
29
|
) => Promise<SendRawTransactionReturnType>;
|
|
30
|
+
testMempoolAccept: (
|
|
31
|
+
parameters: TestMempoolAcceptParams,
|
|
32
|
+
) => Promise<TestMempoolAcceptReturnType>;
|
|
23
33
|
};
|
|
24
34
|
|
|
25
35
|
export function publicActions<
|
|
@@ -31,5 +41,6 @@ export function publicActions<
|
|
|
31
41
|
): PublicActions<chain, account> {
|
|
32
42
|
return {
|
|
33
43
|
sendRawTransaction: (args) => sendRawTransaction(client, args),
|
|
44
|
+
testMempoolAccept: (args) => testMempoolAccept(client, args),
|
|
34
45
|
};
|
|
35
46
|
}
|
package/src/sdk/test/e2e.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { createPublicClient as createKontorPublicClient } from "../clients/konto
|
|
|
5
5
|
import { http } from "../clients/transports/http.js";
|
|
6
6
|
import { mnemonicToAccount } from "../accounts/mnemonic-to-account.js";
|
|
7
7
|
import { createWalletClient as createKontorWalletClient } from "../clients/kontor/create-wallet-client.js";
|
|
8
|
+
|
|
8
9
|
import { custom } from "../clients/transports/custom.js";
|
|
9
10
|
import { Transaction } from "@scure/btc-signer";
|
|
10
11
|
import { hex } from "@scure/base";
|
|
@@ -38,6 +39,7 @@ test("e2e kontor wallet client", async () => {
|
|
|
38
39
|
const kontorPublicClient = createKontorPublicClient({
|
|
39
40
|
transport: http("https://signet-staging.kontor.network:35000/api"),
|
|
40
41
|
account,
|
|
42
|
+
chain: signet,
|
|
41
43
|
});
|
|
42
44
|
|
|
43
45
|
const kontorWalletClient = createKontorWalletClient({
|
|
@@ -57,13 +59,12 @@ test("e2e kontor wallet client", async () => {
|
|
|
57
59
|
args: [[7n, 18]],
|
|
58
60
|
satsPerVByte: 1,
|
|
59
61
|
utxos: [
|
|
60
|
-
"
|
|
62
|
+
"641c40edf4cf0f1cdaea5c259bf50267bd8743dbade84c98bb9e360c2d0e2a33:1",
|
|
61
63
|
],
|
|
62
64
|
gas: 10n,
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
const commit_: Transaction = await kontorWalletClient.signCommit({
|
|
67
|
+
const commit: Transaction = await kontorWalletClient.signCommit({
|
|
67
68
|
account: account,
|
|
68
69
|
chain: signet,
|
|
69
70
|
psbt: res.result.commit_psbt_hex,
|
|
@@ -76,12 +77,36 @@ test("e2e kontor wallet client", async () => {
|
|
|
76
77
|
parcipantScripts: res.result.per_participant,
|
|
77
78
|
});
|
|
78
79
|
|
|
80
|
+
const commitExtracted = commit.extract();
|
|
79
81
|
const revealExtracted = reveal.extract();
|
|
80
82
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
+
// const m = await btcPublicClient.testMempoolAccept({
|
|
84
|
+
// rawtx: [hex.encode(commitExtracted), hex.encode(revealExtracted)],
|
|
85
|
+
// options: {},
|
|
86
|
+
// });
|
|
87
|
+
//
|
|
88
|
+
|
|
89
|
+
const r = await fetch("https://signet.kontor.network:38332", {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
Authorization: `Basic ${Buffer.from("rpc:rpc").toString("base64")}`,
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
method: "testmempoolaccept",
|
|
97
|
+
params: [[hex.encode(commitExtracted), hex.encode(revealExtracted)]],
|
|
98
|
+
}),
|
|
83
99
|
});
|
|
100
|
+
console.log({ r, reveal: hex.encode(revealExtracted) });
|
|
101
|
+
|
|
102
|
+
const j = await r.json();
|
|
103
|
+
|
|
104
|
+
console.log(j);
|
|
105
|
+
//
|
|
106
|
+
// const op = await kontorPublicClient.inspect({
|
|
107
|
+
// hex: hex.encode(revealExtracted),
|
|
108
|
+
// });
|
|
84
109
|
|
|
85
|
-
console.log(JSON.stringify(op.result[0]!.op));
|
|
110
|
+
// console.log(JSON.stringify(op.result[0]!.op));
|
|
86
111
|
//
|
|
87
112
|
});
|
package/src/sdk/types/btc-rpc.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Prettify } from "../../wit/type-utils.js";
|
|
2
2
|
|
|
3
|
-
// import type {
|
|
4
|
-
// TestMempoolAcceptParams,
|
|
5
|
-
// TestMempoolAcceptReturnType,
|
|
6
|
-
// } from "../actions/public/test-mempool-accept.js";
|
|
7
|
-
|
|
8
3
|
import type { RpcRequestFn, RpcSchema, RpcSchemaEntry } from "./rpc-schema.js";
|
|
9
4
|
|
|
10
5
|
export type SendRawTransactionParams = [
|
|
@@ -16,18 +11,24 @@ export interface SendRawTransactionReturnType {
|
|
|
16
11
|
txid: string;
|
|
17
12
|
}
|
|
18
13
|
|
|
14
|
+
export type TestMempoolAcceptParams = [
|
|
15
|
+
txs: string[],
|
|
16
|
+
opts?: { maxFeeRate: number | string },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export type TestMempoolAcceptReturnType = any;
|
|
20
|
+
|
|
19
21
|
export type BtcRpcSchema = readonly [
|
|
20
22
|
RpcSchemaEntry<
|
|
21
23
|
"sendrawtransaction",
|
|
22
24
|
SendRawTransactionParams,
|
|
23
25
|
SendRawTransactionReturnType
|
|
24
26
|
>,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// >,
|
|
27
|
+
RpcSchemaEntry<
|
|
28
|
+
"testmempoolaccept",
|
|
29
|
+
TestMempoolAcceptParams,
|
|
30
|
+
TestMempoolAcceptReturnType
|
|
31
|
+
>,
|
|
31
32
|
];
|
|
32
33
|
|
|
33
34
|
export type BtcNodeRequestFn<
|