@buildonspark/spark-sdk 0.2.4 → 0.2.6
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 +22 -0
- package/dist/{chunk-3SEOTO43.js → chunk-3SPMJMUX.js} +3 -2
- package/dist/chunk-AVI5E5VT.js +66 -0
- package/dist/{chunk-WAQKYSDI.js → chunk-CQY5ML2A.js} +3 -2
- package/dist/{chunk-W4ZRBSWM.js → chunk-GUZ3WCB4.js} +466 -167
- package/dist/{client-KhNkrXz4.d.cts → client-CusuvuCe.d.cts} +199 -104
- package/dist/{client-BF4cn8F4.d.ts → client-Dn4Ld8pD.d.ts} +199 -104
- package/dist/debug.cjs +662 -336
- package/dist/debug.d.cts +9 -7
- package/dist/debug.d.ts +9 -7
- package/dist/debug.js +3 -3
- package/dist/graphql/objects/index.d.cts +6 -51
- package/dist/graphql/objects/index.d.ts +6 -51
- package/dist/graphql/objects/index.js +1 -1
- package/dist/index.cjs +713 -327
- package/dist/index.d.cts +19 -188
- package/dist/index.d.ts +19 -188
- package/dist/index.js +15 -8
- package/dist/index.node.cjs +638 -352
- package/dist/index.node.d.cts +7 -7
- package/dist/index.node.d.ts +7 -7
- package/dist/index.node.js +59 -100
- package/dist/native/index.cjs +655 -325
- package/dist/native/index.d.cts +253 -164
- package/dist/native/index.d.ts +253 -164
- package/dist/native/index.js +505 -172
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- 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/{spark-B_7nZx6T.d.cts → spark-Cj4brrP5.d.cts} +1 -1
- package/dist/{spark-B_7nZx6T.d.ts → spark-Cj4brrP5.d.ts} +1 -1
- package/dist/{spark-wallet-C1Tr_VKI.d.ts → spark-wallet-B6YthxDI.d.ts} +61 -26
- package/dist/{spark-wallet-DG3x2obf.d.cts → spark-wallet-BbOf2P2l.d.cts} +61 -26
- package/dist/spark-wallet.node-BBk1sGS2.d.cts +12 -0
- package/dist/spark-wallet.node-Bffethig.d.ts +12 -0
- package/dist/tests/test-utils.cjs +86 -54
- package/dist/tests/test-utils.d.cts +24 -24
- package/dist/tests/test-utils.d.ts +24 -24
- package/dist/tests/test-utils.js +4 -4
- package/dist/token-transactions-0_5XMWjs.d.ts +184 -0
- package/dist/token-transactions-CD-Adb5y.d.cts +184 -0
- package/dist/types/index.cjs +3 -2
- package/dist/types/index.d.cts +3 -4
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.js +2 -2
- package/dist/{xchain-address-HBr6isnc.d.cts → xchain-address-BnKZ0-dY.d.cts} +6 -5
- package/dist/{xchain-address-BHu6CpZC.d.ts → xchain-address-Di3lu4Wy.d.ts} +6 -5
- package/package.json +7 -2
- package/src/graphql/client.ts +49 -8
- package/src/graphql/objects/SparkWalletUser.ts +1 -1
- package/src/graphql/queries/Transfers.ts +15 -0
- package/src/index.node.ts +5 -1
- package/src/index.ts +4 -1
- package/src/services/config.ts +13 -2
- package/src/services/token-transactions.ts +22 -8
- package/src/services/wallet-config.ts +22 -13
- package/src/spark-wallet/spark-wallet.browser.ts +72 -0
- package/src/spark-wallet/spark-wallet.node.ts +60 -118
- package/src/spark-wallet/spark-wallet.ts +400 -156
- package/src/tests/integration/ssp/coop-exit-validation.test.ts +233 -0
- package/src/tests/integration/ssp/coop-exit.test.ts +112 -93
- package/src/tests/integration/ssp/static-deposit-validation.test.ts +145 -0
- package/src/tests/integration/ssp/static_deposit.test.ts +453 -64
- package/src/tests/integration/ssp/transfers.test.ts +102 -0
- package/src/tests/integration/static_deposit.test.ts +92 -0
- package/src/tests/integration/transfer.test.ts +1 -1
- package/src/tests/utils/regtest-test-faucet.ts +8 -0
- package/src/tests/utils/spark-testing-wallet.ts +42 -0
- package/src/tests/utils/test-faucet.ts +6 -2
- package/src/types/sdk-types.ts +15 -0
- package/src/utils/bitcoin.ts +13 -0
- package/src/utils/token-identifier.ts +47 -4
- package/src/utils/token-transactions.ts +13 -9
- package/dist/chunk-TVUMSHWA.js +0 -7
- package/dist/sdk-types-CB9HrW5O.d.cts +0 -44
- package/dist/sdk-types-CkRNraXT.d.ts +0 -44
- package/dist/spark-wallet.node-CGxoeCpH.d.ts +0 -13
- package/dist/spark-wallet.node-CN9LoB_O.d.cts +0 -13
- package/src/graphql/queries/Transfer.ts +0 -10
package/dist/index.node.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { AuthenticationError, ConfigurationError, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenTransactionService, ValidationError } from './
|
|
2
|
-
export { B as Bech32mTokenIdentifier, n as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager,
|
|
3
|
-
export {
|
|
4
|
-
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-
|
|
5
|
-
export { S as SparkWallet } from './spark-wallet.node-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-CD-Adb5y.cjs';
|
|
2
|
+
export { B as Bech32mTokenIdentifier, n as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, s as CreateLightningInvoiceParams, D as DecodedSparkAddressData, t as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, k as LRC_WALLET_NETWORK_TYPE, N as Network, h as NetworkToProto, g as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, y as SparkWalletEvents, x as SparkWalletProps, u as TokenBalanceMap, w as TokenMetadataMap, v as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, q as decodeBech32mTokenIdentifier, d as decodeSparkAddress, o as encodeBech32mTokenIdentifier, e as encodeSparkAddress, j as getNetwork, l as getNetworkFromAddress, r as getNetworkFromBech32mTokenIdentifier, m as getNetworkFromString, f as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-BbOf2P2l.cjs';
|
|
3
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, a5 as LeafInfo, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './xchain-address-BnKZ0-dY.cjs';
|
|
4
|
+
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-CusuvuCe.cjs';
|
|
5
|
+
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-BBk1sGS2.cjs';
|
|
6
6
|
export { TokenSigner } from '@buildonspark/lrc20-sdk';
|
|
7
7
|
export { MultisigReceiptInput } from '@buildonspark/lrc20-sdk/lrc/types';
|
|
8
|
-
import './spark-
|
|
8
|
+
import './spark-Cj4brrP5.cjs';
|
|
9
9
|
import '@bufbuild/protobuf/wire';
|
|
10
10
|
import 'nice-grpc-common';
|
|
11
11
|
import './proto/spark_token.cjs';
|
|
@@ -13,8 +13,8 @@ import '@scure/btc-signer';
|
|
|
13
13
|
import 'bitcoinjs-lib';
|
|
14
14
|
import 'nice-grpc';
|
|
15
15
|
import 'nice-grpc-web';
|
|
16
|
+
import '@opentelemetry/sdk-trace-base';
|
|
16
17
|
import 'eventemitter3';
|
|
17
|
-
import './sdk-types-CB9HrW5O.cjs';
|
|
18
18
|
import '@scure/btc-signer/psbt';
|
|
19
19
|
import '@lightsparkdev/core';
|
|
20
20
|
import '@scure/bip32';
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { AuthenticationError, ConfigurationError, InternalValidationError, NetworkError, NotImplementedError, RPCError, SparkSDKError, TokenTransactionService, ValidationError } from './
|
|
2
|
-
export { B as Bech32mTokenIdentifier, n as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager,
|
|
3
|
-
export {
|
|
4
|
-
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-
|
|
5
|
-
export { S as SparkWallet } from './spark-wallet.node-
|
|
1
|
+
export { A as AuthenticationError, C as ConfigurationError, I as InternalValidationError, N as NetworkError, a as NotImplementedError, R as RPCError, S as SparkSDKError, T as TokenTransactionService, V as ValidationError } from './token-transactions-0_5XMWjs.js';
|
|
2
|
+
export { B as Bech32mTokenIdentifier, n as Bech32mTokenIdentifierData, b as ConfigOptions, C as ConnectionManager, s as CreateLightningInvoiceParams, D as DecodedSparkAddressData, t as DepositParams, I as InitWalletResponse, L as LRC_WALLET_NETWORK, k as LRC_WALLET_NETWORK_TYPE, N as Network, h as NetworkToProto, g as NetworkType, P as PayLightningInvoiceParams, R as RawTokenIdentifierHex, c as SparkAddressData, S as SparkAddressFormat, y as SparkWalletEvents, x as SparkWalletProps, u as TokenBalanceMap, w as TokenMetadataMap, v as TokenOutputsMap, T as TransferParams, U as UserTokenMetadata, a as WalletConfig, W as WalletConfigService, q as decodeBech32mTokenIdentifier, d as decodeSparkAddress, o as encodeBech32mTokenIdentifier, e as encodeSparkAddress, j as getNetwork, l as getNetworkFromAddress, r as getNetworkFromBech32mTokenIdentifier, m as getNetworkFromString, f as isValidPublicKey, i as isValidSparkAddress, p as protoToNetwork } from './spark-wallet-B6YthxDI.js';
|
|
3
|
+
export { ab as BroadcastConfig, ac as BroadcastResult, Q as DEFAULT_FEE_SATS, M as DIRECT_TIMELOCK_OFFSET, a9 as FeeBumpTxChain, a8 as FeeBumpTxPackage, a7 as FeeRate, O as INITIAL_DIRECT_SEQUENCE, N as INITIAL_SEQUENCE, a5 as LeafInfo, P as TEST_UNILATERAL_DIRECT_SEQUENCE, T as TEST_UNILATERAL_SEQUENCE, aa as TxChain, a6 as Utxo, q as addPrivateKeys, o as addPublicKeys, b as applyAdaptorToSignature, p as applyAdditiveTweakToPublicKey, J as checkIfSelectedOutputsAreAvailable, a1 as checkIfValidSequence, z as collectResponses, c as computeTaprootKeyNoScript, ag as constructFeeBumpTx, af as constructUnilateralExitFeeBumpPackages, ae as constructUnilateralExitTxs, _ as createConnectorRefundTransactions, X as createLeafNodeTx, V as createNodeTx, W as createNodeTxs, Y as createRefundTx, Z as createRefundTxs, S as createRootTx, F as createSigningCommitment, B as createSigningNonce, U as createSplitTx, H as decodeBytesToSigningCommitment, E as decodeBytesToSigningNonce, a2 as doesLeafNeedRefresh, G as encodeSigningCommitmentToBytes, D as encodeSigningNonceToBytes, K as filterTokenBalanceForTokenIdentifier, a as generateAdaptorFromSignature, g as generateSignatureFromExistingAdaptor, $ as getCurrentTimelock, a4 as getEphemeralAnchorOutput, w as getLatestDepositTxId, a3 as getNextTransactionSequence, f as getP2TRAddressFromPkScript, e as getP2TRAddressFromPublicKey, d as getP2TRScriptFromPublicKey, h as getP2WPKHAddressFromPublicKey, A as getRandomSigningNonce, k as getSigHashFromTx, C as getSigningCommitmentFromNonce, ah as getSparkAddressFromTaproot, a0 as getTransactionSequence, L as getTransferPackageSigningPayload, n as getTxEstimatedVbytesSizeByNumberOfInputsOutputs, j as getTxFromRawTxBytes, i as getTxFromRawTxHex, l as getTxId, m as getTxIdNoReverse, ad as isEphemeralAnchorOutput, x as isTxBroadcast, u as lastKeyWithTarget, R as maybeApplyFee, y as proofOfPossessionMessageHashForDepositAddress, r as subtractPrivateKeys, s as subtractPublicKeys, I as sumAvailableTokens, t as sumOfPrivateKeys, v as validateOutboundAdaptorSignature } from './xchain-address-Di3lu4Wy.js';
|
|
4
|
+
export { A as AggregateFrostParams, D as DefaultSparkSigner, p as DerivedHDKey, l as KeyDerivation, K as KeyDerivationType, q as KeyPair, n as SignFrostParams, k as SigningCommitment, i as SigningCommitmentWithOptionalNonce, j as SigningNonce, S as SparkSigner, o as SplitSecretWithProofsParams, T as TaprootOutputKeysGenerator, a as TaprootSparkSigner, U as UnsafeStatelessSparkSigner, V as VerifiableSecretShare, h as bigIntToPrivateKey, c as computerLagrangeCoefficients, e as evaluatePolynomial, f as fieldDiv, b as generatePolynomialForSecretSharing, g as getRandomBigInt, m as modInverse, r as recoverSecret, s as splitSecret, d as splitSecretWithProofs, v as validateShare } from './client-Dn4Ld8pD.js';
|
|
5
|
+
export { S as SparkWallet, i as initializeTracerEnv } from './spark-wallet.node-Bffethig.js';
|
|
6
6
|
export { TokenSigner } from '@buildonspark/lrc20-sdk';
|
|
7
7
|
export { MultisigReceiptInput } from '@buildonspark/lrc20-sdk/lrc/types';
|
|
8
|
-
import './spark-
|
|
8
|
+
import './spark-Cj4brrP5.js';
|
|
9
9
|
import '@bufbuild/protobuf/wire';
|
|
10
10
|
import 'nice-grpc-common';
|
|
11
11
|
import './proto/spark_token.js';
|
|
@@ -13,8 +13,8 @@ import '@scure/btc-signer';
|
|
|
13
13
|
import 'bitcoinjs-lib';
|
|
14
14
|
import 'nice-grpc';
|
|
15
15
|
import 'nice-grpc-web';
|
|
16
|
+
import '@opentelemetry/sdk-trace-base';
|
|
16
17
|
import 'eventemitter3';
|
|
17
|
-
import './sdk-types-CkRNraXT.js';
|
|
18
18
|
import '@scure/btc-signer/psbt';
|
|
19
19
|
import '@lightsparkdev/core';
|
|
20
20
|
import '@scure/bip32';
|
package/dist/index.node.js
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
encodeSparkAddress,
|
|
62
62
|
evaluatePolynomial,
|
|
63
63
|
fieldDiv,
|
|
64
|
-
|
|
64
|
+
filterTokenBalanceForTokenIdentifier,
|
|
65
65
|
generateAdaptorFromSignature,
|
|
66
66
|
generatePolynomialForSecretSharing,
|
|
67
67
|
generateSignatureFromExistingAdaptor,
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
getLatestDepositTxId,
|
|
71
71
|
getNetwork,
|
|
72
72
|
getNetworkFromAddress,
|
|
73
|
+
getNetworkFromBech32mTokenIdentifier,
|
|
73
74
|
getNetworkFromString,
|
|
74
75
|
getNextTransactionSequence,
|
|
75
76
|
getP2TRAddressFromPkScript,
|
|
@@ -83,6 +84,7 @@ import {
|
|
|
83
84
|
getSparkAddressFromTaproot,
|
|
84
85
|
getTransactionSequence,
|
|
85
86
|
getTransferPackageSigningPayload,
|
|
87
|
+
getTxEstimatedVbytesSizeByNumberOfInputsOutputs,
|
|
86
88
|
getTxFromRawTxBytes,
|
|
87
89
|
getTxFromRawTxHex,
|
|
88
90
|
getTxId,
|
|
@@ -106,10 +108,10 @@ import {
|
|
|
106
108
|
sumOfPrivateKeys,
|
|
107
109
|
validateOutboundAdaptorSignature,
|
|
108
110
|
validateShare
|
|
109
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-GUZ3WCB4.js";
|
|
110
112
|
import "./chunk-G4MSZ6DE.js";
|
|
111
|
-
import "./chunk-
|
|
112
|
-
import "./chunk-
|
|
113
|
+
import "./chunk-3SPMJMUX.js";
|
|
114
|
+
import "./chunk-CQY5ML2A.js";
|
|
113
115
|
import "./chunk-AAZWSPUK.js";
|
|
114
116
|
import "./chunk-MVRQ5US7.js";
|
|
115
117
|
|
|
@@ -117,104 +119,58 @@ import "./chunk-MVRQ5US7.js";
|
|
|
117
119
|
import nodeCrypto from "crypto";
|
|
118
120
|
|
|
119
121
|
// src/spark-wallet/spark-wallet.node.ts
|
|
120
|
-
import {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
throw error;
|
|
140
|
-
} finally {
|
|
141
|
-
span.end();
|
|
142
|
-
}
|
|
143
|
-
});
|
|
122
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
123
|
+
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
|
|
124
|
+
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
125
|
+
import { registerInstrumentations } from "@opentelemetry/instrumentation";
|
|
126
|
+
import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici";
|
|
127
|
+
var SparkWalletNodeJS = class _SparkWalletNodeJS extends SparkWallet {
|
|
128
|
+
static async initialize({
|
|
129
|
+
mnemonicOrSeed,
|
|
130
|
+
accountNumber,
|
|
131
|
+
signer,
|
|
132
|
+
options
|
|
133
|
+
}) {
|
|
134
|
+
const wallet = new _SparkWalletNodeJS(options, signer);
|
|
135
|
+
wallet.initializeTracer(wallet);
|
|
136
|
+
const initResponse = await wallet.initWallet(mnemonicOrSeed, accountNumber);
|
|
137
|
+
return {
|
|
138
|
+
wallet,
|
|
139
|
+
...initResponse
|
|
144
140
|
};
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
trace.setGlobalTracerProvider(new BasicTracerProvider());
|
|
152
|
-
propagation.setGlobalPropagator(new W3CTraceContextPropagator());
|
|
153
|
-
context.setGlobalContextManager(new AsyncLocalStorageContextManager());
|
|
154
|
-
this.tracer = trace.getTracer(tracerName);
|
|
155
|
-
}
|
|
156
|
-
getTraceName(methodName) {
|
|
157
|
-
return `SparkWallet.${methodName}`;
|
|
158
|
-
}
|
|
159
|
-
wrapPublicMethodsWithOtelSpan(methodName) {
|
|
160
|
-
const original = this[methodName];
|
|
161
|
-
if (typeof original !== "function") {
|
|
162
|
-
throw new Error(`Method ${methodName} is not a function on SparkWallet.`);
|
|
163
|
-
}
|
|
164
|
-
const wrapped = this.wrapWithOtelSpan(
|
|
165
|
-
this.getTraceName(methodName),
|
|
166
|
-
original.bind(this)
|
|
167
|
-
);
|
|
168
|
-
this[methodName] = wrapped;
|
|
169
|
-
}
|
|
170
|
-
wrapSparkWalletWithTracing() {
|
|
171
|
-
const methods = [
|
|
172
|
-
"getLeaves",
|
|
173
|
-
"getIdentityPublicKey",
|
|
174
|
-
"getSparkAddress",
|
|
175
|
-
"createSparkPaymentIntent",
|
|
176
|
-
"getSwapFeeEstimate",
|
|
177
|
-
"getTransfers",
|
|
178
|
-
"getBalance",
|
|
179
|
-
"getSingleUseDepositAddress",
|
|
180
|
-
"getStaticDepositAddress",
|
|
181
|
-
"queryStaticDepositAddresses",
|
|
182
|
-
"getClaimStaticDepositQuote",
|
|
183
|
-
"claimStaticDeposit",
|
|
184
|
-
"refundStaticDeposit",
|
|
185
|
-
"getUnusedDepositAddresses",
|
|
186
|
-
"claimDeposit",
|
|
187
|
-
"advancedDeposit",
|
|
188
|
-
"transfer",
|
|
189
|
-
"createLightningInvoice",
|
|
190
|
-
"payLightningInvoice",
|
|
191
|
-
"getLightningSendFeeEstimate",
|
|
192
|
-
"withdraw",
|
|
193
|
-
"getWithdrawalFeeQuote",
|
|
194
|
-
"getTransferFromSsp",
|
|
195
|
-
"getTransfer",
|
|
196
|
-
"transferTokens",
|
|
197
|
-
"batchTransferTokens",
|
|
198
|
-
"queryTokenTransactions",
|
|
199
|
-
"getLightningReceiveRequest",
|
|
200
|
-
"getLightningSendRequest",
|
|
201
|
-
"getCoopExitRequest",
|
|
202
|
-
"checkTimelock",
|
|
203
|
-
"testOnly_expireTimelock"
|
|
204
|
-
];
|
|
205
|
-
methods.forEach((m) => this.wrapPublicMethodsWithOtelSpan(m));
|
|
206
|
-
this.initWallet = this.wrapWithOtelSpan(
|
|
207
|
-
this.getTraceName("initWallet"),
|
|
208
|
-
this.initWallet.bind(this)
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
async initWallet(mnemonicOrSeed, accountNumber) {
|
|
212
|
-
const res = super.initWallet(mnemonicOrSeed, accountNumber);
|
|
213
|
-
await this.initializeTracer(this.tracerId);
|
|
214
|
-
this.wrapSparkWalletWithTracing();
|
|
215
|
-
return res;
|
|
142
|
+
initializeTracerEnv({
|
|
143
|
+
spanProcessors,
|
|
144
|
+
traceUrls
|
|
145
|
+
}) {
|
|
146
|
+
initializeTracerEnvNodeJS({ spanProcessors, traceUrls });
|
|
216
147
|
}
|
|
217
148
|
};
|
|
149
|
+
function initializeTracerEnvNodeJS({
|
|
150
|
+
spanProcessors,
|
|
151
|
+
traceUrls
|
|
152
|
+
}) {
|
|
153
|
+
const provider = new NodeTracerProvider({ spanProcessors });
|
|
154
|
+
provider.register({
|
|
155
|
+
contextManager: new AsyncLocalStorageContextManager(),
|
|
156
|
+
propagator: new W3CTraceContextPropagator()
|
|
157
|
+
});
|
|
158
|
+
registerInstrumentations({
|
|
159
|
+
instrumentations: [
|
|
160
|
+
new UndiciInstrumentation({
|
|
161
|
+
ignoreRequestHook: (request) => {
|
|
162
|
+
try {
|
|
163
|
+
return !traceUrls.some(
|
|
164
|
+
(prefix) => request.origin.startsWith(prefix)
|
|
165
|
+
);
|
|
166
|
+
} catch {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
218
174
|
|
|
219
175
|
// src/index.node.ts
|
|
220
176
|
var cryptoImpl = typeof global !== "undefined" && global.crypto ? global.crypto : nodeCrypto;
|
|
@@ -238,7 +194,7 @@ export {
|
|
|
238
194
|
NotImplementedError,
|
|
239
195
|
RPCError,
|
|
240
196
|
SparkSDKError,
|
|
241
|
-
|
|
197
|
+
SparkWalletNodeJS as SparkWallet,
|
|
242
198
|
TEST_UNILATERAL_DIRECT_SEQUENCE,
|
|
243
199
|
TEST_UNILATERAL_SEQUENCE,
|
|
244
200
|
TaprootOutputKeysGenerator,
|
|
@@ -281,7 +237,7 @@ export {
|
|
|
281
237
|
encodeSparkAddress,
|
|
282
238
|
evaluatePolynomial,
|
|
283
239
|
fieldDiv,
|
|
284
|
-
|
|
240
|
+
filterTokenBalanceForTokenIdentifier,
|
|
285
241
|
generateAdaptorFromSignature,
|
|
286
242
|
generatePolynomialForSecretSharing,
|
|
287
243
|
generateSignatureFromExistingAdaptor,
|
|
@@ -290,6 +246,7 @@ export {
|
|
|
290
246
|
getLatestDepositTxId,
|
|
291
247
|
getNetwork,
|
|
292
248
|
getNetworkFromAddress,
|
|
249
|
+
getNetworkFromBech32mTokenIdentifier,
|
|
293
250
|
getNetworkFromString,
|
|
294
251
|
getNextTransactionSequence,
|
|
295
252
|
getP2TRAddressFromPkScript,
|
|
@@ -303,10 +260,12 @@ export {
|
|
|
303
260
|
getSparkAddressFromTaproot,
|
|
304
261
|
getTransactionSequence,
|
|
305
262
|
getTransferPackageSigningPayload,
|
|
263
|
+
getTxEstimatedVbytesSizeByNumberOfInputsOutputs,
|
|
306
264
|
getTxFromRawTxBytes,
|
|
307
265
|
getTxFromRawTxHex,
|
|
308
266
|
getTxId,
|
|
309
267
|
getTxIdNoReverse,
|
|
268
|
+
initializeTracerEnvNodeJS as initializeTracerEnv,
|
|
310
269
|
isEphemeralAnchorOutput,
|
|
311
270
|
isTxBroadcast,
|
|
312
271
|
isValidPublicKey,
|