@buildonspark/spark-sdk 0.0.9 → 0.0.11

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 (82) hide show
  1. package/dist/services/config.d.ts +20 -16
  2. package/dist/services/config.js +26 -18
  3. package/dist/services/config.js.map +1 -1
  4. package/dist/services/connection.js +1 -1
  5. package/dist/services/connection.js.map +1 -1
  6. package/dist/services/deposit.js +2 -2
  7. package/dist/services/deposit.js.map +1 -1
  8. package/dist/services/lightning.js +4 -4
  9. package/dist/services/lightning.js.map +1 -1
  10. package/dist/services/token-transactions.js +8 -7
  11. package/dist/services/token-transactions.js.map +1 -1
  12. package/dist/services/transfer.js +12 -10
  13. package/dist/services/transfer.js.map +1 -1
  14. package/dist/spark-sdk.d.ts +2 -3
  15. package/dist/spark-sdk.js +2 -7
  16. package/dist/spark-sdk.js.map +1 -1
  17. package/dist/tests/coop-exit.test.js +8 -5
  18. package/dist/tests/coop-exit.test.js.map +1 -1
  19. package/dist/tests/deposit.test.js +8 -10
  20. package/dist/tests/deposit.test.js.map +1 -1
  21. package/dist/tests/keys.test.js +0 -1
  22. package/dist/tests/keys.test.js.map +1 -1
  23. package/dist/tests/lightning.test.js +10 -7
  24. package/dist/tests/lightning.test.js.map +1 -1
  25. package/dist/tests/swap.test.js +8 -5
  26. package/dist/tests/swap.test.js.map +1 -1
  27. package/dist/tests/test-util.d.ts +8 -44
  28. package/dist/tests/test-util.js +10 -7
  29. package/dist/tests/test-util.js.map +1 -1
  30. package/dist/tests/transfer.test.js +30 -19
  31. package/dist/tests/transfer.test.js.map +1 -1
  32. package/package.json +2 -2
  33. package/dist/LightningSendRequest-CNJFhLVc.d.cts +0 -374
  34. package/dist/LightningSendRequest-CNJFhLVc.d.ts +0 -374
  35. package/dist/auto-bind.d.ts +0 -7
  36. package/dist/auto-bind.js +0 -41
  37. package/dist/auto-bind.js.map +0 -1
  38. package/dist/chunk-5SAJ52IV.js +0 -10309
  39. package/dist/chunk-COXVABEU.js +0 -1524
  40. package/dist/chunk-F4JW24C4.js +0 -78
  41. package/dist/chunk-H4A2WXR3.js +0 -331
  42. package/dist/chunk-HTNOFUHX.js +0 -1547
  43. package/dist/chunk-JQFHUW4I.js +0 -21
  44. package/dist/chunk-K3Y7DVLD.js +0 -19
  45. package/dist/chunk-NDKNVHGP.js +0 -127
  46. package/dist/chunk-PMVJGQCP.js +0 -627
  47. package/dist/chunk-QX3ZJH2S.js +0 -527
  48. package/dist/chunk-SL2YOBVM.js +0 -127
  49. package/dist/chunk-SWCOMKD6.js +0 -333
  50. package/dist/chunk-SWFFNBSR.js +0 -1244
  51. package/dist/chunk-WLK5POBV.js +0 -527
  52. package/dist/chunk-WZ74TD7N.js +0 -660
  53. package/dist/chunk-WZYVI3M3.js +0 -1244
  54. package/dist/chunk-ZGU3XW7W.js +0 -78
  55. package/dist/connection-BgWj7Hnd.d.cts +0 -77
  56. package/dist/connection-BgbVJtzh.d.ts +0 -77
  57. package/dist/connection-DX-9yFl8.d.ts +0 -77
  58. package/dist/connection-hITj9Mgk.d.cts +0 -77
  59. package/dist/graphql/objects/index.cjs +0 -626
  60. package/dist/graphql/objects/index.d.cts +0 -140
  61. package/dist/index.cjs +0 -17202
  62. package/dist/index.d.cts +0 -413
  63. package/dist/index.d.ts +0 -413
  64. package/dist/index.js +0 -3390
  65. package/dist/proto/spark.cjs +0 -10451
  66. package/dist/proto/spark.d.cts +0 -3
  67. package/dist/services/index.cjs +0 -12503
  68. package/dist/services/index.d.cts +0 -23
  69. package/dist/services/index.d.ts +0 -23
  70. package/dist/services/index.js +0 -17
  71. package/dist/signer/signer.cjs +0 -894
  72. package/dist/signer/signer.d.cts +0 -5
  73. package/dist/signer-BaC_ZP1g.d.ts +0 -138
  74. package/dist/signer-C6h1OnSQ.d.cts +0 -138
  75. package/dist/signer-CO4owhHI.d.ts +0 -154
  76. package/dist/signer-DDkpXvNZ.d.cts +0 -154
  77. package/dist/spark-BUTdOtMz.d.cts +0 -1170
  78. package/dist/spark-BUTdOtMz.d.ts +0 -1170
  79. package/dist/tests/test-util.cjs +0 -12269
  80. package/dist/tests/test-util.d.cts +0 -90
  81. package/dist/utils/index.cjs +0 -1825
  82. package/dist/utils/index.d.cts +0 -280
@@ -1,78 +0,0 @@
1
- import {
2
- getP2TRScriptFromPublicKey
3
- } from "./chunk-SL2YOBVM.js";
4
- import {
5
- spark_bindings_default
6
- } from "./chunk-HTNOFUHX.js";
7
-
8
- // src/utils/transaction.ts
9
- import { Transaction } from "@scure/btc-signer";
10
- var TIME_LOCK_INTERVAL = 100;
11
- function createRefundTx(sequence, nodeOutPoint, amountSats, receivingPubkey, network) {
12
- const newRefundTx = new Transaction({ allowUnknownOutputs: true });
13
- newRefundTx.addInput({
14
- ...nodeOutPoint,
15
- sequence
16
- });
17
- const refundPkScript = getP2TRScriptFromPublicKey(receivingPubkey, network);
18
- newRefundTx.addOutput({
19
- script: refundPkScript,
20
- amount: amountSats
21
- });
22
- newRefundTx.addOutput(getEphemeralAnchorOutput());
23
- return newRefundTx;
24
- }
25
- function getNextTransactionSequence(currSequence) {
26
- const currentTimelock = (currSequence || 0) & 65535;
27
- if (currentTimelock - TIME_LOCK_INTERVAL <= 0) {
28
- throw new Error("timelock interval is less or equal to 0");
29
- }
30
- return 1 << 30 | currentTimelock - TIME_LOCK_INTERVAL;
31
- }
32
- function getEphemeralAnchorOutput() {
33
- return {
34
- script: new Uint8Array([81]),
35
- // OP_TRUE
36
- amount: 0n
37
- };
38
- }
39
-
40
- // src/utils/wasm-wrapper.ts
41
- async function initWasm() {
42
- let wasmModule;
43
- try {
44
- if (typeof window === "undefined") {
45
- const fs = await import("fs/promises");
46
- const path = await import("path");
47
- const { fileURLToPath } = await import("url");
48
- const __filename = fileURLToPath(import.meta.url);
49
- const __dirname = path.dirname(__filename);
50
- const wasmPath = path.resolve(
51
- __dirname,
52
- "../wasm/spark_bindings_bg.wasm"
53
- );
54
- const wasmBuffer = await fs.readFile(wasmPath);
55
- wasmModule = await spark_bindings_default({ module_or_path: wasmBuffer }).catch((e) => {
56
- console.error("WASM initialization error:", e);
57
- throw e;
58
- });
59
- return wasmModule;
60
- } else {
61
- wasmModule = await spark_bindings_default();
62
- }
63
- } catch (e) {
64
- console.error("WASM initialization error:", e);
65
- throw e;
66
- }
67
- if (!wasmModule || typeof wasmModule !== "object") {
68
- throw new Error("WASM module not properly initialized");
69
- }
70
- return wasmModule;
71
- }
72
-
73
- export {
74
- createRefundTx,
75
- getNextTransactionSequence,
76
- getEphemeralAnchorOutput,
77
- initWasm
78
- };
@@ -1,77 +0,0 @@
1
- import { N as Network$1, E as Empty, S as SparkServiceClient } from './spark-BUTdOtMz.cjs';
2
- import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
- import { CallOptions } from 'nice-grpc-common';
4
- import { S as SparkSigner, N as Network } from './signer-C6h1OnSQ.cjs';
5
-
6
- type SigningOperator = {
7
- id: number;
8
- identifier: string;
9
- address: string;
10
- identityPublicKey: Uint8Array;
11
- };
12
- type WalletConfig = {
13
- network: Network;
14
- signingOperators: Record<string, SigningOperator>;
15
- coodinatorIdentifier: string;
16
- frostSignerAddress: string;
17
- threshold: number;
18
- useTokenTransactionSchnorrSignatures: boolean;
19
- };
20
- declare class WalletConfigService {
21
- private config;
22
- readonly signer: SparkSigner;
23
- constructor(network: Network, signer?: SparkSigner);
24
- static withConfig(config: WalletConfig, signer?: SparkSigner): WalletConfigService;
25
- getCoordinatorAddress(): string;
26
- getConfig(): WalletConfig;
27
- getNetwork(): Network;
28
- getNetworkProto(): Network$1;
29
- }
30
-
31
- interface CleanUpPreimageShareRequest {
32
- paymentHash: Uint8Array;
33
- }
34
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
35
- interface MockServiceClient<CallOptionsExt = {}> {
36
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
37
- }
38
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
39
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
40
- $case: string;
41
- } ? {
42
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
43
- } & {
44
- $case: T["$case"];
45
- } : T extends {} ? {
46
- [K in keyof T]?: DeepPartial<T[K]>;
47
- } : Partial<T>;
48
- interface MessageFns<T> {
49
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
50
- decode(input: BinaryReader | Uint8Array, length?: number): T;
51
- fromJSON(object: any): T;
52
- toJSON(message: T): unknown;
53
- create(base?: DeepPartial<T>): T;
54
- fromPartial(object: DeepPartial<T>): T;
55
- }
56
-
57
- declare class ConnectionManager {
58
- private config;
59
- private clients;
60
- constructor(config: WalletConfigService);
61
- createClients(): Promise<void>;
62
- static createMockClient(address: string): MockServiceClient & {
63
- close: () => void;
64
- };
65
- private static createChannelWithTLS;
66
- createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
67
- close?: () => void;
68
- }>;
69
- private authenticate;
70
- private createSparkAuthnGrpcConnection;
71
- private createAuthMiddleWare;
72
- private createNodeMiddleware;
73
- private createBrowserMiddleware;
74
- private createGrpcClient;
75
- }
76
-
77
- export { ConnectionManager as C, type SigningOperator as S, WalletConfigService as W, type WalletConfig as a };
@@ -1,77 +0,0 @@
1
- import { N as Network$1, E as Empty, S as SparkServiceClient } from './spark-BUTdOtMz.js';
2
- import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
- import { CallOptions } from 'nice-grpc-common';
4
- import { S as SparkSigner, N as Network } from './signer-CO4owhHI.js';
5
-
6
- type SigningOperator = {
7
- id: number;
8
- identifier: string;
9
- address: string;
10
- identityPublicKey: Uint8Array;
11
- };
12
- type WalletConfig = {
13
- network: Network;
14
- signingOperators: Record<string, SigningOperator>;
15
- coodinatorIdentifier: string;
16
- frostSignerAddress: string;
17
- threshold: number;
18
- useTokenTransactionSchnorrSignatures: boolean;
19
- };
20
- declare class WalletConfigService {
21
- private config;
22
- readonly signer: SparkSigner;
23
- constructor(network: Network, signer?: SparkSigner);
24
- static withConfig(config: WalletConfig, signer?: SparkSigner): WalletConfigService;
25
- getCoordinatorAddress(): string;
26
- getConfig(): WalletConfig;
27
- getNetwork(): Network;
28
- getNetworkProto(): Network$1;
29
- }
30
-
31
- interface CleanUpPreimageShareRequest {
32
- paymentHash: Uint8Array;
33
- }
34
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
35
- interface MockServiceClient<CallOptionsExt = {}> {
36
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
37
- }
38
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
39
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
40
- $case: string;
41
- } ? {
42
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
43
- } & {
44
- $case: T["$case"];
45
- } : T extends {} ? {
46
- [K in keyof T]?: DeepPartial<T[K]>;
47
- } : Partial<T>;
48
- interface MessageFns<T> {
49
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
50
- decode(input: BinaryReader | Uint8Array, length?: number): T;
51
- fromJSON(object: any): T;
52
- toJSON(message: T): unknown;
53
- create(base?: DeepPartial<T>): T;
54
- fromPartial(object: DeepPartial<T>): T;
55
- }
56
-
57
- declare class ConnectionManager {
58
- private config;
59
- private clients;
60
- constructor(config: WalletConfigService);
61
- createClients(): Promise<void>;
62
- static createMockClient(address: string): MockServiceClient & {
63
- close: () => void;
64
- };
65
- private static createChannelWithTLS;
66
- createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
67
- close?: () => void;
68
- }>;
69
- private authenticate;
70
- private createSparkAuthnGrpcConnection;
71
- private createAuthMiddleWare;
72
- private createNodeMiddleware;
73
- private createBrowserMiddleware;
74
- private createGrpcClient;
75
- }
76
-
77
- export { ConnectionManager as C, type SigningOperator as S, WalletConfigService as W, type WalletConfig as a };
@@ -1,77 +0,0 @@
1
- import { N as Network$1, E as Empty, S as SparkServiceClient } from './spark-BUTdOtMz.js';
2
- import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
- import { CallOptions } from 'nice-grpc-common';
4
- import { S as SparkSigner, N as Network } from './signer-BaC_ZP1g.js';
5
-
6
- type SigningOperator = {
7
- id: number;
8
- identifier: string;
9
- address: string;
10
- identityPublicKey: Uint8Array;
11
- };
12
- type WalletConfig = {
13
- network: Network;
14
- signingOperators: Record<string, SigningOperator>;
15
- coodinatorIdentifier: string;
16
- frostSignerAddress: string;
17
- threshold: number;
18
- useTokenTransactionSchnorrSignatures: boolean;
19
- };
20
- declare class WalletConfigService {
21
- private config;
22
- readonly signer: SparkSigner;
23
- constructor(network: Network, signer?: SparkSigner);
24
- static withConfig(config: WalletConfig, signer?: SparkSigner): WalletConfigService;
25
- getCoordinatorAddress(): string;
26
- getConfig(): WalletConfig;
27
- getNetwork(): Network;
28
- getNetworkProto(): Network$1;
29
- }
30
-
31
- interface CleanUpPreimageShareRequest {
32
- paymentHash: Uint8Array;
33
- }
34
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
35
- interface MockServiceClient<CallOptionsExt = {}> {
36
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
37
- }
38
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
39
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
40
- $case: string;
41
- } ? {
42
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
43
- } & {
44
- $case: T["$case"];
45
- } : T extends {} ? {
46
- [K in keyof T]?: DeepPartial<T[K]>;
47
- } : Partial<T>;
48
- interface MessageFns<T> {
49
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
50
- decode(input: BinaryReader | Uint8Array, length?: number): T;
51
- fromJSON(object: any): T;
52
- toJSON(message: T): unknown;
53
- create(base?: DeepPartial<T>): T;
54
- fromPartial(object: DeepPartial<T>): T;
55
- }
56
-
57
- declare class ConnectionManager {
58
- private config;
59
- private clients;
60
- constructor(config: WalletConfigService);
61
- createClients(): Promise<void>;
62
- static createMockClient(address: string): MockServiceClient & {
63
- close: () => void;
64
- };
65
- private static createChannelWithTLS;
66
- createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
67
- close?: () => void;
68
- }>;
69
- private authenticate;
70
- private createSparkAuthnGrpcConnection;
71
- private createAuthMiddleWare;
72
- private createNodeMiddleware;
73
- private createBrowserMiddleware;
74
- private createGrpcClient;
75
- }
76
-
77
- export { ConnectionManager as C, type SigningOperator as S, WalletConfigService as W, type WalletConfig as a };
@@ -1,77 +0,0 @@
1
- import { N as Network$1, E as Empty, S as SparkServiceClient } from './spark-BUTdOtMz.cjs';
2
- import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
3
- import { CallOptions } from 'nice-grpc-common';
4
- import { S as SparkSigner, N as Network } from './signer-DDkpXvNZ.cjs';
5
-
6
- type SigningOperator = {
7
- id: number;
8
- identifier: string;
9
- address: string;
10
- identityPublicKey: Uint8Array;
11
- };
12
- type WalletConfig = {
13
- network: Network;
14
- signingOperators: Record<string, SigningOperator>;
15
- coodinatorIdentifier: string;
16
- frostSignerAddress: string;
17
- threshold: number;
18
- useTokenTransactionSchnorrSignatures: boolean;
19
- };
20
- declare class WalletConfigService {
21
- private config;
22
- readonly signer: SparkSigner;
23
- constructor(network: Network, signer?: SparkSigner);
24
- static withConfig(config: WalletConfig, signer?: SparkSigner): WalletConfigService;
25
- getCoordinatorAddress(): string;
26
- getConfig(): WalletConfig;
27
- getNetwork(): Network;
28
- getNetworkProto(): Network$1;
29
- }
30
-
31
- interface CleanUpPreimageShareRequest {
32
- paymentHash: Uint8Array;
33
- }
34
- declare const CleanUpPreimageShareRequest: MessageFns<CleanUpPreimageShareRequest>;
35
- interface MockServiceClient<CallOptionsExt = {}> {
36
- clean_up_preimage_share(request: DeepPartial<CleanUpPreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
37
- }
38
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
39
- type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
40
- $case: string;
41
- } ? {
42
- [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
43
- } & {
44
- $case: T["$case"];
45
- } : T extends {} ? {
46
- [K in keyof T]?: DeepPartial<T[K]>;
47
- } : Partial<T>;
48
- interface MessageFns<T> {
49
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
50
- decode(input: BinaryReader | Uint8Array, length?: number): T;
51
- fromJSON(object: any): T;
52
- toJSON(message: T): unknown;
53
- create(base?: DeepPartial<T>): T;
54
- fromPartial(object: DeepPartial<T>): T;
55
- }
56
-
57
- declare class ConnectionManager {
58
- private config;
59
- private clients;
60
- constructor(config: WalletConfigService);
61
- createClients(): Promise<void>;
62
- static createMockClient(address: string): MockServiceClient & {
63
- close: () => void;
64
- };
65
- private static createChannelWithTLS;
66
- createSparkClient(address: string, certPath?: string): Promise<SparkServiceClient & {
67
- close?: () => void;
68
- }>;
69
- private authenticate;
70
- private createSparkAuthnGrpcConnection;
71
- private createAuthMiddleWare;
72
- private createNodeMiddleware;
73
- private createBrowserMiddleware;
74
- private createGrpcClient;
75
- }
76
-
77
- export { ConnectionManager as C, type SigningOperator as S, WalletConfigService as W, type WalletConfig as a };