@kontor/kontor-sdk 1.0.0-alpha.0 → 1.0.0-alpha.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontor/kontor-sdk",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.3",
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
  }
@@ -113,20 +113,18 @@ export async function signReveal<
113
113
 
114
114
  // this is technically unnecessary as scure/btc-signer
115
115
  // will product this witness by default
116
- for (let i = 0; i < params.parcipantScripts.length; i++) {
117
- const input = signedTx.getInput(i);
118
- const p = params.parcipantScripts[i]!;
119
- console.log({ input, tapscriptsig: input.tapScriptSig });
120
- signedTx.updateInput(i, {
121
- finalScriptWitness: [
122
- input.tapScriptSig![0]![1],
123
- // @ts-ignore
124
- hex.decode(p.commit_tap_leaf_script.script),
125
- // @ts-ignore
126
- hex.decode(p.commit_tap_leaf_script.controlBlock),
127
- ],
128
- });
129
- }
116
+ // for (let i = 0; i < params.parcipantScripts.length; i++) {
117
+ // const input = signedTx.getInput(i);
118
+ // const p = params.parcipantScripts[i]!;
119
+ // console.log({ input, tapscriptsig: input.tapScriptSig });
120
+ // signedTx.updateInput(i, {
121
+ // finalScriptWitness: [
122
+ // input.tapScriptSig![0]![1],
123
+ // hex.decode(p.commit_tap_leaf_script.script),
124
+ // hex.decode(p.commit_tap_leaf_script.controlBlock),
125
+ // ],
126
+ // });
127
+ // }
130
128
 
131
129
  signedTx.finalize();
132
130
 
@@ -1,34 +1,38 @@
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
- // export type TestMempoolAcceptReturnType = any;
17
- //
18
- // export async function testMempoolAccept<
19
- // chain extends Chain | undefined,
20
- // account extends Account | undefined = Account | undefined,
21
- // >(
22
- // client: PublicClient<RpcTransport, chain, account>,
23
- // { rawtx, options = {} }: TestMempoolAcceptParams,
24
- // ): Promise<TestMempoolAcceptReturnType> {
25
- // const txs = Array.isArray(rawtx) ? rawtx : [rawtx];
26
- //
27
- // return client.request({
28
- // method: "testmempoolaccept",
29
- // params: [txs],
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 =
29
+ options.maxfeerate !== undefined ? [txs, options.maxfeerate] : [txs];
30
+
31
+ return client.request({
32
+ method: "testmempoolaccept",
33
+ params: params,
34
+ });
35
+ }
32
36
 
33
37
  // export async function testMempoolAccept(
34
38
  // rawtx: string | string[],
@@ -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
+ 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
- // RpcSchemaEntry<
26
- // "testmempoolaccept",
27
- // // todo add options
28
- // [TestMempoolAcceptParams["rawtx"]],
29
- // string[][]
30
- // >,
27
+ RpcSchemaEntry<
28
+ "testmempoolaccept",
29
+ TestMempoolAcceptParams,
30
+ TestMempoolAcceptReturnType
31
+ >,
31
32
  ];
32
33
 
33
34
  export type BtcNodeRequestFn<
@@ -57,6 +57,9 @@ export function buildRpcRequest<
57
57
  } catch (err_) {
58
58
  // Map non-BaseError → UnknownRpcError at the RPC layer.
59
59
  if (err_ instanceof BaseError) throw err_;
60
+
61
+ console.log({ args, baseOverrideOptions, err_ });
62
+
60
63
  throw new UnknownRpcError(err_ as Error);
61
64
  }
62
65
  };