@buildonspark/spark-sdk 0.1.46 → 0.1.47
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/CHANGELOG.md +14 -0
- package/dist/{chunk-I54FARY2.js → chunk-EAP3U3CW.js} +14 -14
- package/dist/chunk-GWFQ7EBA.js +3773 -0
- package/dist/{chunk-JB64OQES.js → chunk-NNX4OK44.js} +3488 -935
- package/dist/{RequestLightningSendInput-CN6BNg_g.d.ts → client-CvpTRpcw.d.cts} +422 -212
- package/dist/{RequestLightningSendInput-2cSh_In4.d.cts → client-D7KgLN44.d.ts} +422 -212
- package/dist/graphql/objects/index.d.cts +5 -9
- package/dist/graphql/objects/index.d.ts +5 -9
- package/dist/graphql/objects/index.js +1 -1
- package/dist/index.cjs +20460 -23376
- package/dist/index.d.cts +15 -769
- package/dist/index.d.ts +15 -769
- package/dist/index.js +83 -73
- package/dist/index.node.cjs +21994 -25018
- package/dist/index.node.d.cts +312 -34
- package/dist/index.node.d.ts +312 -34
- package/dist/index.node.js +84 -178
- package/dist/native/index.cjs +17112 -20106
- package/dist/native/index.d.cts +974 -1138
- package/dist/native/index.d.ts +974 -1138
- package/dist/native/index.js +10604 -13592
- package/dist/proto/lrc20.d.cts +2 -2
- package/dist/proto/lrc20.d.ts +2 -2
- package/dist/proto/lrc20.js +3098 -46
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/{sdk-types-CKBsylfW.d.ts → sdk-types-BGCeea0G.d.ts} +1 -1
- package/dist/{sdk-types-Ct8xmN7l.d.cts → sdk-types-XUeQMLFP.d.cts} +1 -1
- package/dist/{spark-DbzGfse6.d.cts → spark-BbUrbvZz.d.cts} +1 -1
- package/dist/{spark-DbzGfse6.d.ts → spark-BbUrbvZz.d.ts} +1 -1
- package/dist/spark-wallet-BAFPpPtY.d.cts +923 -0
- package/dist/spark-wallet-CJkQW8pK.d.ts +923 -0
- package/dist/spark_bindings/native/index.d.cts +1 -1
- package/dist/spark_bindings/native/index.d.ts +1 -1
- package/dist/spark_bindings/wasm/index.d.cts +1 -1
- package/dist/spark_bindings/wasm/index.d.ts +1 -1
- package/dist/{services/index.cjs → tests/test-utils.cjs} +2511 -4379
- package/dist/tests/test-utils.d.cts +79 -0
- package/dist/tests/test-utils.d.ts +79 -0
- package/dist/tests/test-utils.js +85 -0
- package/dist/types/index.d.cts +5 -9
- package/dist/types/index.d.ts +5 -9
- package/dist/types/index.js +5 -5
- package/dist/{types-C-Rp0Oo7.d.cts → types-BADxR3bm.d.cts} +1 -1
- package/dist/{types-C-Rp0Oo7.d.ts → types-BADxR3bm.d.ts} +1 -1
- package/package.json +6 -34
- package/src/graphql/client.ts +59 -20
- package/src/index.node.ts +28 -2
- package/src/index.ts +31 -1
- package/src/native/index.ts +16 -2
- package/src/services/config.ts +4 -6
- package/src/services/connection.ts +131 -64
- package/src/services/lightning.ts +1 -2
- package/src/services/token-transactions.ts +7 -7
- package/src/services/transfer.ts +1 -1
- package/src/services/tree-creation.ts +1 -1
- package/src/services/wallet-config.ts +17 -9
- package/src/signer/signer.react-native.ts +2 -5
- package/src/signer/signer.ts +138 -64
- package/src/signer/types.ts +52 -0
- package/src/spark-wallet/spark-wallet.ts +79 -36
- package/src/spark-wallet/types.ts +4 -4
- package/src/tests/integration/coop-exit.test.ts +2 -1
- package/src/tests/integration/lightning.test.ts +2 -2
- package/src/tests/integration/swap.test.ts +1 -1
- package/src/tests/integration/transfer.test.ts +5 -5
- package/src/tests/integration/tree-creation.test.ts +1 -1
- package/src/tests/integration/wallet.test.ts +1 -0
- package/src/tests/isHermeticTest.ts +3 -24
- package/src/tests/{test-util.ts → test-utils.ts} +3 -7
- package/src/tests/wrapWithOtelSpan.test.ts +1 -1
- package/src/{address → utils}/address.ts +1 -1
- package/src/utils/crypto.ts +19 -9
- package/src/utils/index.ts +2 -0
- package/src/utils/network.ts +17 -0
- package/src/utils/secret-sharing.ts +1 -2
- package/src/utils/signing.ts +1 -1
- package/src/utils/token-transactions.ts +3 -3
- package/src/utils/unilateral-exit.ts +32 -0
- package/src/utils/xchain-address.ts +1 -1
- package/dist/BitcoinNetwork-TnABML0T.d.cts +0 -18
- package/dist/BitcoinNetwork-TnABML0T.d.ts +0 -18
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.cts +0 -10
- package/dist/LightningSendFeeEstimateInput-BgOhEAI-.d.ts +0 -10
- package/dist/address/index.cjs +0 -458
- package/dist/address/index.d.cts +0 -32
- package/dist/address/index.d.ts +0 -32
- package/dist/address/index.js +0 -17
- package/dist/chunk-4EMV7HHW.js +0 -277
- package/dist/chunk-C2S227QR.js +0 -2336
- package/dist/chunk-DXR2PXJU.js +0 -1122
- package/dist/chunk-GSI4OLXZ.js +0 -117
- package/dist/chunk-HHNQ3ZHC.js +0 -170
- package/dist/chunk-HSCLBJEL.js +0 -113
- package/dist/chunk-HWJWKEIU.js +0 -75
- package/dist/chunk-KMUMFYFX.js +0 -137
- package/dist/chunk-L3EHBOUX.js +0 -0
- package/dist/chunk-N5VZVCGJ.js +0 -622
- package/dist/chunk-NSJF5F5O.js +0 -325
- package/dist/chunk-NTFKFRQ2.js +0 -3146
- package/dist/chunk-OFCJFZ4I.js +0 -24
- package/dist/chunk-QNNSEJ4P.js +0 -232
- package/dist/chunk-UXDODSDT.js +0 -838
- package/dist/chunk-VTUGIIWI.js +0 -0
- package/dist/chunk-Z5HIAYFT.js +0 -84
- package/dist/index-CKL5DodV.d.cts +0 -214
- package/dist/index-COm59SPw.d.ts +0 -214
- package/dist/network-Css46DAz.d.cts +0 -46
- package/dist/network-hynb7iTZ.d.ts +0 -46
- package/dist/services/config.cjs +0 -2354
- package/dist/services/config.d.cts +0 -42
- package/dist/services/config.d.ts +0 -42
- package/dist/services/config.js +0 -17
- package/dist/services/connection.cjs +0 -17691
- package/dist/services/connection.d.cts +0 -95
- package/dist/services/connection.d.ts +0 -95
- package/dist/services/connection.js +0 -11
- package/dist/services/index.d.cts +0 -21
- package/dist/services/index.d.ts +0 -21
- package/dist/services/index.js +0 -58
- package/dist/services/lrc-connection.cjs +0 -4713
- package/dist/services/lrc-connection.d.cts +0 -34
- package/dist/services/lrc-connection.d.ts +0 -34
- package/dist/services/lrc-connection.js +0 -11
- package/dist/services/token-transactions.cjs +0 -2877
- package/dist/services/token-transactions.d.cts +0 -75
- package/dist/services/token-transactions.d.ts +0 -75
- package/dist/services/token-transactions.js +0 -15
- package/dist/services/wallet-config.cjs +0 -340
- package/dist/services/wallet-config.d.cts +0 -56
- package/dist/services/wallet-config.d.ts +0 -56
- package/dist/services/wallet-config.js +0 -33
- package/dist/signer/signer.cjs +0 -2004
- package/dist/signer/signer.d.cts +0 -10
- package/dist/signer/signer.d.ts +0 -10
- package/dist/signer/signer.js +0 -24
- package/dist/signer-BP6F__oR.d.cts +0 -187
- package/dist/signer-BVZJXcq7.d.ts +0 -187
- package/dist/utils/index.cjs +0 -2947
- package/dist/utils/index.d.cts +0 -18
- package/dist/utils/index.d.ts +0 -18
- package/dist/utils/index.js +0 -157
- package/src/address/index.ts +0 -1
- package/src/services/lrc-connection.ts +0 -215
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Q as QueryTransfersResponse, f as Transfer, d as TreeNode } from '../spark-BbUrbvZz.cjs';
|
|
2
|
+
import { S as SparkWallet$1, I as InitWalletResponse, C as ConfigOptions, a as SparkWalletProps } from '../spark-wallet-BAFPpPtY.cjs';
|
|
3
|
+
import { K as SparkSigner } from '../client-CvpTRpcw.cjs';
|
|
4
|
+
import { Transaction } from '@scure/btc-signer';
|
|
5
|
+
import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';
|
|
6
|
+
import '@bufbuild/protobuf/wire';
|
|
7
|
+
import 'nice-grpc-common';
|
|
8
|
+
import '@buildonspark/lrc20-sdk';
|
|
9
|
+
import 'bitcoinjs-lib';
|
|
10
|
+
import 'nice-grpc';
|
|
11
|
+
import 'nice-grpc-web';
|
|
12
|
+
import '../proto/spark_token.cjs';
|
|
13
|
+
import 'eventemitter3';
|
|
14
|
+
import '../sdk-types-XUeQMLFP.cjs';
|
|
15
|
+
import '@lightsparkdev/core';
|
|
16
|
+
import '@scure/bip32';
|
|
17
|
+
import '../types-BADxR3bm.cjs';
|
|
18
|
+
|
|
19
|
+
declare class SparkWallet extends SparkWallet$1 {
|
|
20
|
+
private tracer;
|
|
21
|
+
protected wrapWithOtelSpan<T>(name: string, fn: (...args: any[]) => Promise<T>): (...args: any[]) => Promise<T>;
|
|
22
|
+
protected initializeTracer(tracerName: string): Promise<void>;
|
|
23
|
+
private wrapSparkWalletWithTracing;
|
|
24
|
+
protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ISparkWalletTesting extends SparkWallet {
|
|
28
|
+
getSigner(): SparkSigner;
|
|
29
|
+
queryPendingTransfers(): Promise<QueryTransfersResponse>;
|
|
30
|
+
verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
|
|
31
|
+
}
|
|
32
|
+
declare class SparkWalletTesting extends SparkWallet implements ISparkWalletTesting {
|
|
33
|
+
private disableEvents;
|
|
34
|
+
constructor(options?: ConfigOptions, signer?: SparkSigner, disableEvents?: boolean);
|
|
35
|
+
static initialize(props: SparkWalletProps, disableEvents?: boolean): Promise<{
|
|
36
|
+
wallet: SparkWalletTesting;
|
|
37
|
+
mnemonic: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
protected setupBackgroundStream(): Promise<void>;
|
|
40
|
+
getSigner(): SparkSigner;
|
|
41
|
+
queryPendingTransfers(): Promise<QueryTransfersResponse>;
|
|
42
|
+
verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type FaucetCoin = {
|
|
46
|
+
key: Uint8Array;
|
|
47
|
+
outpoint: TransactionInput;
|
|
48
|
+
txout: TransactionOutput;
|
|
49
|
+
};
|
|
50
|
+
declare class BitcoinFaucet {
|
|
51
|
+
private url;
|
|
52
|
+
private username;
|
|
53
|
+
private password;
|
|
54
|
+
private coins;
|
|
55
|
+
private static instance;
|
|
56
|
+
private miningAddress;
|
|
57
|
+
private lock;
|
|
58
|
+
private constructor();
|
|
59
|
+
static getInstance(url?: string, username?: string, password?: string): BitcoinFaucet;
|
|
60
|
+
private withLock;
|
|
61
|
+
fund(): Promise<FaucetCoin>;
|
|
62
|
+
private refill;
|
|
63
|
+
sendFaucetCoinToP2WPKHAddress(pubKey: Uint8Array): Promise<void>;
|
|
64
|
+
signFaucetCoin(unsignedTx: Transaction, fundingTxOut: TransactionOutput, key: Uint8Array): Promise<Transaction>;
|
|
65
|
+
mineBlocks(numBlocks: number): Promise<any>;
|
|
66
|
+
private call;
|
|
67
|
+
generateToAddress(numBlocks: number, address: string): Promise<any>;
|
|
68
|
+
getBlock(blockHash: string): Promise<any>;
|
|
69
|
+
broadcastTx(txHex: string): Promise<any>;
|
|
70
|
+
getNewAddress(): Promise<string>;
|
|
71
|
+
sendToAddress(address: string, amount: bigint): Promise<Transaction>;
|
|
72
|
+
getRawTransaction(txid: string): Promise<any>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare function getTestWalletConfig(): ConfigOptions;
|
|
76
|
+
declare function getTestWalletConfigWithIdentityKey(identityPrivateKey: Uint8Array): ConfigOptions;
|
|
77
|
+
declare function createNewTree(wallet: SparkWalletTesting, pubKey: Uint8Array, faucet: BitcoinFaucet, amountSats?: bigint): Promise<TreeNode>;
|
|
78
|
+
|
|
79
|
+
export { BitcoinFaucet, createNewTree, getTestWalletConfig, getTestWalletConfigWithIdentityKey };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Q as QueryTransfersResponse, f as Transfer, d as TreeNode } from '../spark-BbUrbvZz.js';
|
|
2
|
+
import { S as SparkWallet$1, I as InitWalletResponse, C as ConfigOptions, a as SparkWalletProps } from '../spark-wallet-CJkQW8pK.js';
|
|
3
|
+
import { K as SparkSigner } from '../client-D7KgLN44.js';
|
|
4
|
+
import { Transaction } from '@scure/btc-signer';
|
|
5
|
+
import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';
|
|
6
|
+
import '@bufbuild/protobuf/wire';
|
|
7
|
+
import 'nice-grpc-common';
|
|
8
|
+
import '@buildonspark/lrc20-sdk';
|
|
9
|
+
import 'bitcoinjs-lib';
|
|
10
|
+
import 'nice-grpc';
|
|
11
|
+
import 'nice-grpc-web';
|
|
12
|
+
import '../proto/spark_token.js';
|
|
13
|
+
import 'eventemitter3';
|
|
14
|
+
import '../sdk-types-BGCeea0G.js';
|
|
15
|
+
import '@lightsparkdev/core';
|
|
16
|
+
import '@scure/bip32';
|
|
17
|
+
import '../types-BADxR3bm.js';
|
|
18
|
+
|
|
19
|
+
declare class SparkWallet extends SparkWallet$1 {
|
|
20
|
+
private tracer;
|
|
21
|
+
protected wrapWithOtelSpan<T>(name: string, fn: (...args: any[]) => Promise<T>): (...args: any[]) => Promise<T>;
|
|
22
|
+
protected initializeTracer(tracerName: string): Promise<void>;
|
|
23
|
+
private wrapSparkWalletWithTracing;
|
|
24
|
+
protected initWallet(mnemonicOrSeed?: Uint8Array | string, accountNumber?: number): Promise<InitWalletResponse | undefined>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ISparkWalletTesting extends SparkWallet {
|
|
28
|
+
getSigner(): SparkSigner;
|
|
29
|
+
queryPendingTransfers(): Promise<QueryTransfersResponse>;
|
|
30
|
+
verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
|
|
31
|
+
}
|
|
32
|
+
declare class SparkWalletTesting extends SparkWallet implements ISparkWalletTesting {
|
|
33
|
+
private disableEvents;
|
|
34
|
+
constructor(options?: ConfigOptions, signer?: SparkSigner, disableEvents?: boolean);
|
|
35
|
+
static initialize(props: SparkWalletProps, disableEvents?: boolean): Promise<{
|
|
36
|
+
wallet: SparkWalletTesting;
|
|
37
|
+
mnemonic: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
protected setupBackgroundStream(): Promise<void>;
|
|
40
|
+
getSigner(): SparkSigner;
|
|
41
|
+
queryPendingTransfers(): Promise<QueryTransfersResponse>;
|
|
42
|
+
verifyPendingTransfer(transfer: Transfer): Promise<Map<string, Uint8Array>>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type FaucetCoin = {
|
|
46
|
+
key: Uint8Array;
|
|
47
|
+
outpoint: TransactionInput;
|
|
48
|
+
txout: TransactionOutput;
|
|
49
|
+
};
|
|
50
|
+
declare class BitcoinFaucet {
|
|
51
|
+
private url;
|
|
52
|
+
private username;
|
|
53
|
+
private password;
|
|
54
|
+
private coins;
|
|
55
|
+
private static instance;
|
|
56
|
+
private miningAddress;
|
|
57
|
+
private lock;
|
|
58
|
+
private constructor();
|
|
59
|
+
static getInstance(url?: string, username?: string, password?: string): BitcoinFaucet;
|
|
60
|
+
private withLock;
|
|
61
|
+
fund(): Promise<FaucetCoin>;
|
|
62
|
+
private refill;
|
|
63
|
+
sendFaucetCoinToP2WPKHAddress(pubKey: Uint8Array): Promise<void>;
|
|
64
|
+
signFaucetCoin(unsignedTx: Transaction, fundingTxOut: TransactionOutput, key: Uint8Array): Promise<Transaction>;
|
|
65
|
+
mineBlocks(numBlocks: number): Promise<any>;
|
|
66
|
+
private call;
|
|
67
|
+
generateToAddress(numBlocks: number, address: string): Promise<any>;
|
|
68
|
+
getBlock(blockHash: string): Promise<any>;
|
|
69
|
+
broadcastTx(txHex: string): Promise<any>;
|
|
70
|
+
getNewAddress(): Promise<string>;
|
|
71
|
+
sendToAddress(address: string, amount: bigint): Promise<Transaction>;
|
|
72
|
+
getRawTransaction(txid: string): Promise<any>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare function getTestWalletConfig(): ConfigOptions;
|
|
76
|
+
declare function getTestWalletConfigWithIdentityKey(identityPrivateKey: Uint8Array): ConfigOptions;
|
|
77
|
+
declare function createNewTree(wallet: SparkWalletTesting, pubKey: Uint8Array, faucet: BitcoinFaucet, amountSats?: bigint): Promise<TreeNode>;
|
|
78
|
+
|
|
79
|
+
export { BitcoinFaucet, createNewTree, getTestWalletConfig, getTestWalletConfigWithIdentityKey };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BitcoinFaucet,
|
|
3
|
+
ConnectionManager,
|
|
4
|
+
DepositService,
|
|
5
|
+
RPCError,
|
|
6
|
+
WalletConfig,
|
|
7
|
+
WalletConfigService,
|
|
8
|
+
getNetwork,
|
|
9
|
+
getP2TRAddressFromPublicKey
|
|
10
|
+
} from "../chunk-GWFQ7EBA.js";
|
|
11
|
+
import "../chunk-LHRD2WT6.js";
|
|
12
|
+
import "../chunk-BGGEVUJK.js";
|
|
13
|
+
import "../chunk-HMLOC6TE.js";
|
|
14
|
+
import "../chunk-MVRQ5US7.js";
|
|
15
|
+
|
|
16
|
+
// src/tests/test-utils.ts
|
|
17
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
18
|
+
import { Address, OutScript, Transaction } from "@scure/btc-signer";
|
|
19
|
+
import { uuidv7 } from "uuidv7";
|
|
20
|
+
function getTestWalletConfig() {
|
|
21
|
+
const identityPrivateKey = secp256k1.utils.randomPrivateKey();
|
|
22
|
+
return getTestWalletConfigWithIdentityKey(identityPrivateKey);
|
|
23
|
+
}
|
|
24
|
+
function getTestWalletConfigWithIdentityKey(identityPrivateKey) {
|
|
25
|
+
return {
|
|
26
|
+
...WalletConfig.LOCAL,
|
|
27
|
+
identityPrivateKey
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function createNewTree(wallet, pubKey, faucet, amountSats = 100000n) {
|
|
31
|
+
const faucetCoin = await faucet.fund();
|
|
32
|
+
const configService = new WalletConfigService(
|
|
33
|
+
{
|
|
34
|
+
network: "LOCAL"
|
|
35
|
+
},
|
|
36
|
+
wallet.getSigner()
|
|
37
|
+
);
|
|
38
|
+
const connectionManager = new ConnectionManager(configService);
|
|
39
|
+
const depositService = new DepositService(configService, connectionManager);
|
|
40
|
+
const leafId = uuidv7();
|
|
41
|
+
const depositResp = await depositService.generateDepositAddress({
|
|
42
|
+
signingPubkey: pubKey,
|
|
43
|
+
leafId
|
|
44
|
+
});
|
|
45
|
+
if (!depositResp.depositAddress) {
|
|
46
|
+
throw new RPCError("Deposit address not found", {
|
|
47
|
+
method: "generateDepositAddress",
|
|
48
|
+
params: { signingPubkey: pubKey, leafId }
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const depositTx = new Transaction();
|
|
52
|
+
depositTx.addInput(faucetCoin.outpoint);
|
|
53
|
+
const addr = Address(getNetwork(4 /* LOCAL */)).decode(
|
|
54
|
+
depositResp.depositAddress.address
|
|
55
|
+
);
|
|
56
|
+
const script = OutScript.encode(addr);
|
|
57
|
+
depositTx.addOutput({ script, amount: amountSats });
|
|
58
|
+
const treeResp = await depositService.createTreeRoot({
|
|
59
|
+
signingPubKey: pubKey,
|
|
60
|
+
verifyingKey: depositResp.depositAddress.verifyingKey,
|
|
61
|
+
depositTx,
|
|
62
|
+
vout: 0
|
|
63
|
+
});
|
|
64
|
+
const signedDepositTx = await faucet.signFaucetCoin(
|
|
65
|
+
depositTx,
|
|
66
|
+
faucetCoin.txout,
|
|
67
|
+
faucetCoin.key
|
|
68
|
+
);
|
|
69
|
+
await faucet.broadcastTx(signedDepositTx.hex);
|
|
70
|
+
const randomKey = secp256k1.utils.randomPrivateKey();
|
|
71
|
+
const randomPubKey = secp256k1.getPublicKey(randomKey);
|
|
72
|
+
const randomAddress = getP2TRAddressFromPublicKey(
|
|
73
|
+
randomPubKey,
|
|
74
|
+
4 /* LOCAL */
|
|
75
|
+
);
|
|
76
|
+
await faucet.generateToAddress(1, randomAddress);
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
78
|
+
return treeResp.nodes[0];
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
BitcoinFaucet,
|
|
82
|
+
createNewTree,
|
|
83
|
+
getTestWalletConfig,
|
|
84
|
+
getTestWalletConfigWithIdentityKey
|
|
85
|
+
};
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
export { B as BitcoinNetwork } from '../
|
|
1
|
+
export { B as BitcoinNetwork, C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, k as CurrencyAmount, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateInput, t as LightningSendFeeEstimateOutput, v as LightningSendRequest, w as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, x as RequestLeavesSwapInput, y as RequestLightningReceiveInput, z as RequestLightningSendInput, S as SparkCoopExitRequestStatus, A as SparkLeavesSwapRequestStatus, D as SparkTransferToLeavesConnection, F as StaticDepositQuoteInput, H as StaticDepositQuoteOutput, J as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, u as getLightningSendRequestQuery } from '../client-CvpTRpcw.cjs';
|
|
2
2
|
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, CoopExitFeeQuoteOutput, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getUserRequestQuery } from '../graphql/objects/index.cjs';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { c as CommonProto, s as SparkProto } from '../spark-DbzGfse6.cjs';
|
|
6
|
-
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-Ct8xmN7l.cjs';
|
|
3
|
+
export { c as CommonProto, s as SparkProto } from '../spark-BbUrbvZz.cjs';
|
|
4
|
+
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-XUeQMLFP.cjs';
|
|
7
5
|
import '@lightsparkdev/core';
|
|
8
|
-
import '../signer-BP6F__oR.cjs';
|
|
9
|
-
import '@scure/bip32';
|
|
10
|
-
import '../types-C-Rp0Oo7.cjs';
|
|
11
6
|
import '@buildonspark/lrc20-sdk';
|
|
12
7
|
import '@scure/btc-signer';
|
|
13
8
|
import 'bitcoinjs-lib';
|
|
14
|
-
import '@
|
|
9
|
+
import '@scure/bip32';
|
|
10
|
+
import '../types-BADxR3bm.cjs';
|
|
15
11
|
import '@bufbuild/protobuf/wire';
|
|
16
12
|
import 'nice-grpc-common';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
export { B as BitcoinNetwork } from '../
|
|
1
|
+
export { B as BitcoinNetwork, C as ClaimStaticDepositOutput, a as CompleteCoopExitInput, b as CompleteLeavesSwapInput, c as CoopExitFeeEstimate, d as CoopExitFeeEstimatesInput, e as CoopExitFeeEstimatesOutput, f as CoopExitFeeQuote, h as CoopExitFeeQuoteInput, i as CoopExitRequest, k as CurrencyAmount, l as CurrencyUnit, E as ExitSpeed, G as GetChallengeOutput, I as Invoice, L as Leaf, m as LeavesSwapFeeEstimateOutput, o as LeavesSwapRequest, q as LightningReceiveRequest, r as LightningReceiveRequestStatus, s as LightningSendFeeEstimateInput, t as LightningSendFeeEstimateOutput, v as LightningSendRequest, w as LightningSendRequestStatus, P as PageInfo, R as RequestCoopExitInput, x as RequestLeavesSwapInput, y as RequestLightningReceiveInput, z as RequestLightningSendInput, S as SparkCoopExitRequestStatus, A as SparkLeavesSwapRequestStatus, D as SparkTransferToLeavesConnection, F as StaticDepositQuoteInput, H as StaticDepositQuoteOutput, J as SwapLeaf, T as Transfer, U as UserLeafInput, V as VerifyChallengeOutput, g as getCoopExitFeeQuoteQuery, j as getCoopExitRequestQuery, n as getLeavesSwapRequestQuery, p as getLightningReceiveRequestQuery, u as getLightningSendRequestQuery } from '../client-D7KgLN44.js';
|
|
2
2
|
export { ClaimStaticDeposit, ClaimStaticDepositInput, ClaimStaticDepositRequestType, ClaimStaticDepositStatus, CompleteCoopExitOutput, CompleteLeavesSwapOutput, CompleteSeedReleaseInput, CompleteSeedReleaseOutput, Connection, CoopExitFeeQuoteOutput, Entity, GetChallengeInput, LeavesSwapFeeEstimateInput, NotifyReceiverTransferInput, Provider, RequestCoopExitOutput, RequestLeavesSwapOutput, RequestLightningReceiveOutput, RequestLightningSendOutput, SparkUserRequestStatus, SparkUserRequestType, SparkWalletUser, SparkWalletUserToUserRequestsConnection, StartSeedReleaseInput, UserRequest, VerifyChallengeInput, WalletUserIdentityPublicKeyInput, WalletUserIdentityPublicKeyOutput, getClaimStaticDepositQuery, getUserRequestQuery } from '../graphql/objects/index.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { c as CommonProto, s as SparkProto } from '../spark-DbzGfse6.js';
|
|
6
|
-
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-CKBsylfW.js';
|
|
3
|
+
export { c as CommonProto, s as SparkProto } from '../spark-BbUrbvZz.js';
|
|
4
|
+
export { T as TransferDirection, W as WalletLeaf, a as WalletTransfer, b as WalletTransferLeaf, c as mapTransferLeafToWalletTransferLeaf, d as mapTransferToWalletTransfer, m as mapTreeNodeToWalletLeaf } from '../sdk-types-BGCeea0G.js';
|
|
7
5
|
import '@lightsparkdev/core';
|
|
8
|
-
import '../signer-BVZJXcq7.js';
|
|
9
|
-
import '@scure/bip32';
|
|
10
|
-
import '../types-C-Rp0Oo7.js';
|
|
11
6
|
import '@buildonspark/lrc20-sdk';
|
|
12
7
|
import '@scure/btc-signer';
|
|
13
8
|
import 'bitcoinjs-lib';
|
|
14
|
-
import '@
|
|
9
|
+
import '@scure/bip32';
|
|
10
|
+
import '../types-BADxR3bm.js';
|
|
15
11
|
import '@bufbuild/protobuf/wire';
|
|
16
12
|
import 'nice-grpc-common';
|
package/dist/types/index.js
CHANGED
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
mapTransferToWalletTransfer,
|
|
5
5
|
mapTreeNodeToWalletLeaf
|
|
6
6
|
} from "../chunk-OBFKIEMP.js";
|
|
7
|
+
import {
|
|
8
|
+
common_exports,
|
|
9
|
+
spark_exports
|
|
10
|
+
} from "../chunk-BGGEVUJK.js";
|
|
7
11
|
import {
|
|
8
12
|
ClaimStaticDepositRequestType_default,
|
|
9
13
|
ClaimStaticDepositStatus_default,
|
|
@@ -23,14 +27,10 @@ import {
|
|
|
23
27
|
getLightningReceiveRequestQuery,
|
|
24
28
|
getLightningSendRequestQuery,
|
|
25
29
|
getUserRequestQuery
|
|
26
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-EAP3U3CW.js";
|
|
27
31
|
import {
|
|
28
32
|
BitcoinNetwork_default
|
|
29
33
|
} from "../chunk-HMLOC6TE.js";
|
|
30
|
-
import {
|
|
31
|
-
common_exports,
|
|
32
|
-
spark_exports
|
|
33
|
-
} from "../chunk-BGGEVUJK.js";
|
|
34
34
|
import "../chunk-MVRQ5US7.js";
|
|
35
35
|
export {
|
|
36
36
|
BitcoinNetwork_default as BitcoinNetwork,
|
|
@@ -43,4 +43,4 @@ type AggregateFrostParams = {
|
|
|
43
43
|
adaptorPubKey?: Uint8Array;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
export type { AggregateFrostParams as A, DummyTx as D,
|
|
46
|
+
export type { AggregateFrostParams as A, DummyTx as D, IKeyPackage as I, SignFrostParams as S, ISigningNonce as a, ISigningCommitment as b };
|
|
@@ -43,4 +43,4 @@ type AggregateFrostParams = {
|
|
|
43
43
|
adaptorPubKey?: Uint8Array;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
export type { AggregateFrostParams as A, DummyTx as D,
|
|
46
|
+
export type { AggregateFrostParams as A, DummyTx as D, IKeyPackage as I, SignFrostParams as S, ISigningNonce as a, ISigningCommitment as b };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buildonspark/spark-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,37 +41,13 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"./signer": {
|
|
45
|
-
"import": "./dist/signer/signer.js",
|
|
46
|
-
"require": "./dist/signer/signer.cjs"
|
|
47
|
-
},
|
|
48
|
-
"./services/wallet-config": {
|
|
49
|
-
"import": "./dist/services/wallet-config.js",
|
|
50
|
-
"require": "./dist/services/wallet-config.cjs"
|
|
51
|
-
},
|
|
52
|
-
"./utils": {
|
|
53
|
-
"import": "./dist/utils/index.js",
|
|
54
|
-
"require": "./dist/utils/index.cjs"
|
|
55
|
-
},
|
|
56
|
-
"./token-transactions": {
|
|
57
|
-
"import": "./dist/services/token-transactions.js",
|
|
58
|
-
"require": "./dist/services/token-transactions.cjs"
|
|
59
|
-
},
|
|
60
44
|
"./types": {
|
|
61
45
|
"import": "./dist/types/index.js",
|
|
62
46
|
"require": "./dist/types/index.cjs"
|
|
63
47
|
},
|
|
64
|
-
"./
|
|
65
|
-
"import": "./dist/
|
|
66
|
-
"require": "./dist/
|
|
67
|
-
},
|
|
68
|
-
"./lrc-connection": {
|
|
69
|
-
"import": "./dist/services/lrc-connection.js",
|
|
70
|
-
"require": "./dist/services/lrc-connection.cjs"
|
|
71
|
-
},
|
|
72
|
-
"./connection": {
|
|
73
|
-
"import": "./dist/services/connection.js",
|
|
74
|
-
"require": "./dist/services/connection.cjs"
|
|
48
|
+
"./test-utils": {
|
|
49
|
+
"import": "./dist/tests/test-utils.js",
|
|
50
|
+
"require": "./dist/tests/test-utils.cjs"
|
|
75
51
|
},
|
|
76
52
|
"./proto/spark": {
|
|
77
53
|
"import": "./dist/proto/spark.js",
|
|
@@ -85,10 +61,6 @@
|
|
|
85
61
|
"import": "./dist/proto/lrc20.js",
|
|
86
62
|
"require": "./dist/proto/lrc20.cjs"
|
|
87
63
|
},
|
|
88
|
-
"./address": {
|
|
89
|
-
"import": "./dist/address/index.js",
|
|
90
|
-
"require": "./dist/address/index.cjs"
|
|
91
|
-
},
|
|
92
64
|
"./native": {
|
|
93
65
|
"import": "./dist/native/index.js",
|
|
94
66
|
"require": "./dist/native/index.cjs"
|
|
@@ -129,8 +101,8 @@
|
|
|
129
101
|
"postversion": "yarn build",
|
|
130
102
|
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --detectOpenHandles --forceExit",
|
|
131
103
|
"test": "yarn test-cmd src/tests/*.test.ts",
|
|
132
|
-
"test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
|
|
133
|
-
"test:integration:ssp": "yarn test-cmd src/tests/integration/ssp/*.test.ts",
|
|
104
|
+
"test:integration": "HERMETIC_TEST=true yarn test-cmd src/tests/integration/*.test.ts",
|
|
105
|
+
"test:integration:ssp": "HERMETIC_TEST=true yarn test-cmd src/tests/integration/ssp/*.test.ts",
|
|
134
106
|
"types:watch": "tsc-absolute --watch",
|
|
135
107
|
"types": "tsc",
|
|
136
108
|
"patch-wasm": "node ./wasm/patch-wasm.mjs",
|
package/src/graphql/client.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
NodeKeyCache,
|
|
6
6
|
Query,
|
|
7
7
|
Requester,
|
|
8
|
+
isError,
|
|
8
9
|
} from "@lightsparkdev/core";
|
|
9
10
|
import { sha256 } from "@noble/hashes/sha2";
|
|
10
11
|
import { AuthenticationError, NetworkError } from "../errors/index.js";
|
|
@@ -91,6 +92,7 @@ export default class SspClient {
|
|
|
91
92
|
|
|
92
93
|
private readonly signer: SparkSigner;
|
|
93
94
|
private readonly authProvider: SparkAuthProvider;
|
|
95
|
+
private authPromise?: Promise<void>;
|
|
94
96
|
|
|
95
97
|
constructor(
|
|
96
98
|
config: HasSspClientOptions & {
|
|
@@ -525,30 +527,67 @@ export default class SspClient {
|
|
|
525
527
|
}
|
|
526
528
|
|
|
527
529
|
async authenticate() {
|
|
528
|
-
this.
|
|
529
|
-
|
|
530
|
-
const challenge = await this.getChallenge();
|
|
531
|
-
if (!challenge) {
|
|
532
|
-
throw new Error("Failed to get challenge");
|
|
530
|
+
if (this.authPromise) {
|
|
531
|
+
return this.authPromise;
|
|
533
532
|
}
|
|
534
533
|
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
);
|
|
534
|
+
const promise = (async (): Promise<void> => {
|
|
535
|
+
const MAX_ATTEMPTS = 3;
|
|
536
|
+
let lastErr: Error | undefined;
|
|
539
537
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
throw new Error("Failed to verify challenge");
|
|
546
|
-
}
|
|
538
|
+
/* React Native can cause some outgoing requests to be paused which can result
|
|
539
|
+
in challenges expiring, so we'll retry any authentication failures: */
|
|
540
|
+
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
|
|
541
|
+
try {
|
|
542
|
+
this.authProvider.removeAuth();
|
|
547
543
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
544
|
+
const challenge = await this.getChallenge();
|
|
545
|
+
if (!challenge) {
|
|
546
|
+
throw new Error("Failed to get challenge");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const challengeBytes = Buffer.from(
|
|
550
|
+
challenge.protectedChallenge,
|
|
551
|
+
"base64",
|
|
552
|
+
);
|
|
553
|
+
const signature = await this.signer.signMessageWithIdentityKey(
|
|
554
|
+
sha256(challengeBytes),
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
const verifyChallenge = await this.verifyChallenge(
|
|
558
|
+
Buffer.from(signature).toString("base64"),
|
|
559
|
+
challenge.protectedChallenge,
|
|
560
|
+
);
|
|
561
|
+
if (!verifyChallenge) {
|
|
562
|
+
throw new Error("Failed to verify challenge");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
this.authProvider.setAuth(
|
|
566
|
+
verifyChallenge.sessionToken,
|
|
567
|
+
new Date(verifyChallenge.validUntil),
|
|
568
|
+
);
|
|
569
|
+
return;
|
|
570
|
+
} catch (err: unknown) {
|
|
571
|
+
if (
|
|
572
|
+
isError(err) &&
|
|
573
|
+
err.message.toLowerCase().includes("challenge expired")
|
|
574
|
+
) {
|
|
575
|
+
lastErr = err;
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
throw err;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
throw lastErr ?? new Error("Failed to authenticate after retries");
|
|
583
|
+
})();
|
|
584
|
+
|
|
585
|
+
this.authPromise = promise;
|
|
586
|
+
try {
|
|
587
|
+
return await promise;
|
|
588
|
+
} finally {
|
|
589
|
+
this.authPromise = undefined;
|
|
590
|
+
}
|
|
552
591
|
}
|
|
553
592
|
|
|
554
593
|
async getCoopExitFeeQuote({
|
package/src/index.node.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
+
/* Root Node.js entrypoint */
|
|
2
|
+
|
|
3
|
+
import { setCrypto } from "./utils/crypto.js";
|
|
4
|
+
import nodeCrypto from "crypto";
|
|
5
|
+
|
|
6
|
+
const cryptoImpl =
|
|
7
|
+
typeof global !== "undefined" && global.crypto ? global.crypto : nodeCrypto;
|
|
8
|
+
|
|
9
|
+
setCrypto(cryptoImpl);
|
|
10
|
+
|
|
1
11
|
export * from "./errors/index.js";
|
|
2
|
-
export * from "./spark-wallet/spark-wallet.node.js";
|
|
3
|
-
export * from "./spark-wallet/types.js";
|
|
4
12
|
export * from "./utils/index.js";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
DefaultSparkSigner,
|
|
16
|
+
TaprootSparkSigner,
|
|
17
|
+
TaprootOutputKeysGenerator,
|
|
18
|
+
type SparkSigner,
|
|
19
|
+
type TokenSigner,
|
|
20
|
+
} from "./signer/signer.js";
|
|
21
|
+
export * from "./signer/types.js";
|
|
22
|
+
|
|
23
|
+
export { SparkWallet } from "./spark-wallet/spark-wallet.js";
|
|
24
|
+
export * from "./spark-wallet/types.js";
|
|
25
|
+
|
|
26
|
+
export { WalletConfig } from "./services/wallet-config.js";
|
|
27
|
+
export { TokenTransactionService } from "./services/token-transactions.js";
|
|
28
|
+
export { type ConnectionManager } from "./services/connection.js";
|
|
29
|
+
export { type WalletConfigService } from "./services/config.js";
|
|
30
|
+
export { type ConfigOptions } from "./services/wallet-config.js";
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/* Root web/default entrypoint. For Node.js see index.node.ts */
|
|
2
|
+
|
|
3
|
+
import { setCrypto } from "./utils/crypto.js";
|
|
4
|
+
|
|
5
|
+
const cryptoImpl =
|
|
6
|
+
typeof window !== "undefined" && window.crypto
|
|
7
|
+
? window.crypto
|
|
8
|
+
: typeof global !== "undefined" && global.crypto
|
|
9
|
+
? global.crypto
|
|
10
|
+
: null;
|
|
11
|
+
|
|
12
|
+
setCrypto(cryptoImpl);
|
|
13
|
+
|
|
1
14
|
export * from "./errors/index.js";
|
|
2
|
-
export * from "./spark-wallet/spark-wallet.js";
|
|
3
15
|
export * from "./utils/index.js";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
DefaultSparkSigner,
|
|
19
|
+
TaprootSparkSigner,
|
|
20
|
+
TaprootOutputKeysGenerator,
|
|
21
|
+
type SparkSigner,
|
|
22
|
+
type TokenSigner,
|
|
23
|
+
} from "./signer/signer.js";
|
|
24
|
+
export * from "./signer/types.js";
|
|
25
|
+
|
|
26
|
+
export { SparkWallet } from "./spark-wallet/spark-wallet.js";
|
|
27
|
+
export * from "./spark-wallet/types.js";
|
|
28
|
+
|
|
29
|
+
export { WalletConfig } from "./services/wallet-config.js";
|
|
30
|
+
export { TokenTransactionService } from "./services/token-transactions.js";
|
|
31
|
+
export { type ConnectionManager } from "./services/connection.js";
|
|
32
|
+
export { type WalletConfigService } from "./services/config.js";
|
|
33
|
+
export { type ConfigOptions } from "./services/wallet-config.js";
|
package/src/native/index.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
/* Root React Native entrypoint */
|
|
2
|
+
|
|
3
|
+
import { setCrypto, SparkCrypto } from "../utils/crypto.js";
|
|
4
|
+
|
|
5
|
+
setCrypto(globalThis.crypto);
|
|
6
|
+
|
|
1
7
|
export * from "../errors/index.js";
|
|
8
|
+
export * from "../utils/index.js";
|
|
9
|
+
|
|
2
10
|
export { ReactNativeSparkSigner } from "../signer/signer.react-native.js";
|
|
3
11
|
/* Enable some consumers to use named import DefaultSparkSigner regardless of module, see LIG-7662 */
|
|
4
12
|
export { ReactNativeSparkSigner as DefaultSparkSigner } from "../signer/signer.react-native.js";
|
|
13
|
+
|
|
5
14
|
export { SparkWallet } from "../spark-wallet/spark-wallet.js";
|
|
6
|
-
export * from "../
|
|
7
|
-
|
|
15
|
+
export * from "../spark-wallet/types.js";
|
|
16
|
+
|
|
17
|
+
export { WalletConfig } from "../services/wallet-config.js";
|
|
18
|
+
export { TokenTransactionService } from "../services/token-transactions.js";
|
|
19
|
+
export { type ConnectionManager } from "../services/connection.js";
|
|
20
|
+
export { type WalletConfigService } from "../services/config.js";
|
|
21
|
+
export { type ConfigOptions } from "../services/wallet-config.js";
|
package/src/services/config.ts
CHANGED
|
@@ -8,9 +8,7 @@ import { DefaultSparkSigner, SparkSigner } from "../signer/signer.js";
|
|
|
8
8
|
import { Network, NetworkToProto, NetworkType } from "../utils/network.js";
|
|
9
9
|
import {
|
|
10
10
|
ConfigOptions,
|
|
11
|
-
|
|
12
|
-
MAINNET_WALLET_CONFIG,
|
|
13
|
-
REGTEST_WALLET_CONFIG,
|
|
11
|
+
WalletConfig,
|
|
14
12
|
SigningOperator,
|
|
15
13
|
} from "./wallet-config.js";
|
|
16
14
|
import { ConfigurationError } from "../errors/types.js";
|
|
@@ -39,11 +37,11 @@ export class WalletConfigService
|
|
|
39
37
|
private getDefaultConfig(network: Network): Required<ConfigOptions> {
|
|
40
38
|
switch (network) {
|
|
41
39
|
case Network.MAINNET:
|
|
42
|
-
return
|
|
40
|
+
return WalletConfig.MAINNET;
|
|
43
41
|
case Network.REGTEST:
|
|
44
|
-
return
|
|
42
|
+
return WalletConfig.REGTEST;
|
|
45
43
|
default:
|
|
46
|
-
return
|
|
44
|
+
return WalletConfig.LOCAL;
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
|