@buildonspark/spark-sdk 0.1.45 → 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 +22 -0
- package/dist/{chunk-I54FARY2.js → chunk-EAP3U3CW.js} +14 -14
- package/dist/chunk-GWFQ7EBA.js +3773 -0
- package/dist/{chunk-J2IE4Z7Y.js → chunk-NNX4OK44.js} +3487 -934
- package/dist/{RequestLightningSendInput-Du0z7Om7.d.cts → client-CvpTRpcw.d.cts} +422 -212
- package/dist/{RequestLightningSendInput-DEPd_fPO.d.ts → 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 +20461 -23377
- package/dist/index.d.cts +15 -769
- package/dist/index.d.ts +15 -769
- package/dist/index.js +81 -71
- 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 +82 -176
- package/dist/native/index.cjs +22847 -25841
- 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-Cc4l4kb1.d.ts → sdk-types-BGCeea0G.d.ts} +1 -1
- package/dist/{sdk-types-B0SwjolI.d.cts → sdk-types-XUeQMLFP.d.cts} +1 -1
- package/dist/{spark-dM7EYXYQ.d.cts → spark-BbUrbvZz.d.cts} +1 -1
- package/dist/{spark-dM7EYXYQ.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} +2512 -4380
- 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 +7 -35
- 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 +18 -10
- 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-5FUB65LX.js +0 -838
- package/dist/chunk-6264CGDM.js +0 -113
- package/dist/chunk-7V6N75CC.js +0 -24
- package/dist/chunk-C2S227QR.js +0 -2336
- package/dist/chunk-GSI4OLXZ.js +0 -117
- package/dist/chunk-GZ5IPPJ2.js +0 -170
- package/dist/chunk-HWJWKEIU.js +0 -75
- package/dist/chunk-KMUMFYFX.js +0 -137
- package/dist/chunk-L3EHBOUX.js +0 -0
- package/dist/chunk-NSJF5F5O.js +0 -325
- package/dist/chunk-NTFKFRQ2.js +0 -3146
- package/dist/chunk-PQN3C2MF.js +0 -1122
- package/dist/chunk-QNNSEJ4P.js +0 -232
- package/dist/chunk-R5PXJZQS.js +0 -277
- package/dist/chunk-VTUGIIWI.js +0 -0
- package/dist/chunk-YUPMXTCJ.js +0 -622
- package/dist/chunk-Z5HIAYFT.js +0 -84
- package/dist/index-B2AwKW5J.d.cts +0 -214
- package/dist/index-CJDi1HWc.d.ts +0 -214
- package/dist/network-BTJl-Sul.d.ts +0 -46
- package/dist/network-CqgsdUF2.d.cts +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-BocS_J6B.d.ts +0 -187
- package/dist/signer-DKS0AJkw.d.cts +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
package/dist/chunk-QNNSEJ4P.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ValidationError
|
|
3
|
-
} from "./chunk-GSI4OLXZ.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/secret-sharing.ts
|
|
6
|
-
import { bytesToHex, equalBytes } from "@noble/curves/abstract/utils";
|
|
7
|
-
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
8
|
-
|
|
9
|
-
// src/utils/crypto.ts
|
|
10
|
-
import nodeCrypto from "crypto";
|
|
11
|
-
var getCrypto = () => {
|
|
12
|
-
let cryptoImpl = typeof window !== "undefined" ? window.crypto : typeof global !== "undefined" && global.crypto ? global.crypto : nodeCrypto;
|
|
13
|
-
return cryptoImpl;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/utils/secret-sharing.ts
|
|
17
|
-
var crypto = getCrypto();
|
|
18
|
-
function getRandomBigInt(max) {
|
|
19
|
-
const byteLength = max.toString(2).length + 7 >> 3;
|
|
20
|
-
const maxBigInt = max;
|
|
21
|
-
const mask = (1n << BigInt(max.toString(2).length)) - 1n;
|
|
22
|
-
while (true) {
|
|
23
|
-
const randBytes = crypto.getRandomValues(new Uint8Array(byteLength + 1));
|
|
24
|
-
const randValue = BigInt("0x" + bytesToHex(randBytes)) & mask;
|
|
25
|
-
if (randValue < maxBigInt) {
|
|
26
|
-
return randValue;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function modInverse(a, m) {
|
|
31
|
-
a = (a % m + m) % m;
|
|
32
|
-
let [old_r, r] = [a, m];
|
|
33
|
-
let [old_s, s] = [1n, 0n];
|
|
34
|
-
let [old_t, t] = [0n, 1n];
|
|
35
|
-
while (r !== 0n) {
|
|
36
|
-
const quotient = old_r / r;
|
|
37
|
-
[old_r, r] = [r, old_r - quotient * r];
|
|
38
|
-
[old_s, s] = [s, old_s - quotient * s];
|
|
39
|
-
[old_t, t] = [t, old_t - quotient * t];
|
|
40
|
-
}
|
|
41
|
-
if (old_r !== 1n) {
|
|
42
|
-
throw new ValidationError("Modular inverse does not exist", {
|
|
43
|
-
field: "modInverse",
|
|
44
|
-
value: `a: ${a}, m: ${m}`,
|
|
45
|
-
expected: "a and m must be coprime"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return (old_s % m + m) % m;
|
|
49
|
-
}
|
|
50
|
-
function evaluatePolynomial(polynomial, x) {
|
|
51
|
-
let result = 0n;
|
|
52
|
-
for (let i = 0; i < polynomial.coefficients.length; i++) {
|
|
53
|
-
const coeff = polynomial.coefficients[i];
|
|
54
|
-
if (!coeff) {
|
|
55
|
-
throw new ValidationError("Coefficient is undefined", {
|
|
56
|
-
field: "coefficient",
|
|
57
|
-
value: "undefined",
|
|
58
|
-
expected: "A valid bigint coefficient"
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const xPow = x ** BigInt(i) % polynomial.fieldModulus;
|
|
62
|
-
result = (result + xPow * coeff) % polynomial.fieldModulus;
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
function fieldDiv(numerator, denominator, fieldModulus) {
|
|
67
|
-
if (denominator === 0n) {
|
|
68
|
-
throw new ValidationError("Division by zero", {
|
|
69
|
-
field: "denominator",
|
|
70
|
-
value: "0",
|
|
71
|
-
expected: "Non-zero value"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const inverse = modInverse(denominator, fieldModulus);
|
|
75
|
-
return numerator * inverse % fieldModulus;
|
|
76
|
-
}
|
|
77
|
-
function computerLagrangeCoefficients(index, points) {
|
|
78
|
-
let numerator = 1n;
|
|
79
|
-
let denominator = 1n;
|
|
80
|
-
let fieldModulus = points[0]?.fieldModulus;
|
|
81
|
-
if (!fieldModulus) {
|
|
82
|
-
throw new ValidationError("Field modulus is undefined", {
|
|
83
|
-
field: "fieldModulus",
|
|
84
|
-
value: "undefined",
|
|
85
|
-
expected: "A valid field modulus"
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
for (const point of points) {
|
|
89
|
-
if (point.index === index) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
numerator = numerator * point.index;
|
|
93
|
-
const value = point.index - index;
|
|
94
|
-
denominator = denominator * value;
|
|
95
|
-
}
|
|
96
|
-
return fieldDiv(numerator, denominator, fieldModulus);
|
|
97
|
-
}
|
|
98
|
-
function generatePolynomialForSecretSharing(fieldModulus, secret, degree) {
|
|
99
|
-
const coefficients = new Array(degree);
|
|
100
|
-
const proofs = new Array(degree);
|
|
101
|
-
coefficients[0] = secret;
|
|
102
|
-
proofs[0] = secp256k1.ProjectivePoint.fromPrivateKey(secret).toRawBytes(true);
|
|
103
|
-
for (let i = 1; i < degree; i++) {
|
|
104
|
-
const coefficient = getRandomBigInt(fieldModulus);
|
|
105
|
-
coefficients[i] = coefficient;
|
|
106
|
-
proofs[i] = secp256k1.ProjectivePoint.fromPrivateKey(coefficient).toRawBytes(true);
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
fieldModulus,
|
|
110
|
-
coefficients,
|
|
111
|
-
proofs
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function splitSecret(fieldModulus, secret, threshold, numberOfShares) {
|
|
115
|
-
const polynomial = generatePolynomialForSecretSharing(
|
|
116
|
-
fieldModulus,
|
|
117
|
-
secret,
|
|
118
|
-
threshold
|
|
119
|
-
);
|
|
120
|
-
const shares = [];
|
|
121
|
-
for (let i = 1; i <= numberOfShares; i++) {
|
|
122
|
-
const share = evaluatePolynomial(polynomial, BigInt(i));
|
|
123
|
-
shares.push({
|
|
124
|
-
fieldModulus,
|
|
125
|
-
threshold,
|
|
126
|
-
index: BigInt(i),
|
|
127
|
-
share
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return shares;
|
|
131
|
-
}
|
|
132
|
-
function splitSecretWithProofs(secret, fieldModulus, threshold, numberOfShares) {
|
|
133
|
-
const polynomial = generatePolynomialForSecretSharing(
|
|
134
|
-
fieldModulus,
|
|
135
|
-
secret,
|
|
136
|
-
threshold
|
|
137
|
-
);
|
|
138
|
-
const shares = [];
|
|
139
|
-
for (let i = 1; i <= numberOfShares; i++) {
|
|
140
|
-
const share = evaluatePolynomial(polynomial, BigInt(i));
|
|
141
|
-
shares.push({
|
|
142
|
-
fieldModulus,
|
|
143
|
-
threshold,
|
|
144
|
-
index: BigInt(i),
|
|
145
|
-
share,
|
|
146
|
-
proofs: polynomial.proofs
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return shares;
|
|
150
|
-
}
|
|
151
|
-
function recoverSecret(shares) {
|
|
152
|
-
if (shares.length === 0) return 0n;
|
|
153
|
-
const threshold = shares[0]?.threshold;
|
|
154
|
-
const fieldModulus = shares[0]?.fieldModulus;
|
|
155
|
-
if (!threshold || !fieldModulus) {
|
|
156
|
-
throw new ValidationError("Shares are not valid", {
|
|
157
|
-
field: "shares",
|
|
158
|
-
value: "Missing threshold or fieldModulus",
|
|
159
|
-
expected: "Valid shares with threshold and fieldModulus"
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (shares.length < threshold) {
|
|
163
|
-
throw new ValidationError("Not enough shares to recover secret", {
|
|
164
|
-
field: "shares",
|
|
165
|
-
value: shares.length,
|
|
166
|
-
expected: `At least ${threshold} shares`
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
let result = 0n;
|
|
170
|
-
for (const share of shares) {
|
|
171
|
-
const coeff = computerLagrangeCoefficients(share.index, shares);
|
|
172
|
-
const item = share.share * coeff % fieldModulus;
|
|
173
|
-
result = (result + item) % fieldModulus;
|
|
174
|
-
}
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
function validateShare(share) {
|
|
178
|
-
const targetPubkey = secp256k1.ProjectivePoint.fromPrivateKey(
|
|
179
|
-
share.share
|
|
180
|
-
).toRawBytes(true);
|
|
181
|
-
let resultPubkey = share.proofs[0];
|
|
182
|
-
if (!resultPubkey) {
|
|
183
|
-
throw new ValidationError("Result pubkey is not valid", {
|
|
184
|
-
field: "resultPubkey",
|
|
185
|
-
value: "null",
|
|
186
|
-
expected: "Valid public key bytes"
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
for (let i = 1; i < share.proofs.length; i++) {
|
|
190
|
-
const pubkey = share.proofs[i];
|
|
191
|
-
if (!pubkey) {
|
|
192
|
-
throw new ValidationError("Pubkey is not valid", {
|
|
193
|
-
field: "pubkey",
|
|
194
|
-
value: "null",
|
|
195
|
-
expected: "Valid public key bytes"
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
const value = share.index ** BigInt(i) % share.fieldModulus;
|
|
199
|
-
const scaledPoint = secp256k1.ProjectivePoint.fromHex(pubkey).multiply(value);
|
|
200
|
-
resultPubkey = secp256k1.ProjectivePoint.fromHex(resultPubkey).add(scaledPoint).toRawBytes(true);
|
|
201
|
-
}
|
|
202
|
-
if (!equalBytes(resultPubkey, targetPubkey)) {
|
|
203
|
-
throw new ValidationError("Share is not valid", {
|
|
204
|
-
field: "share",
|
|
205
|
-
value: "Invalid proof",
|
|
206
|
-
expected: "Valid share with matching proofs"
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function bigIntToPrivateKey(value) {
|
|
211
|
-
const hex = value.toString(16).padStart(64, "0");
|
|
212
|
-
const bytes = new Uint8Array(32);
|
|
213
|
-
for (let i = 0; i < 32; i++) {
|
|
214
|
-
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
215
|
-
}
|
|
216
|
-
return bytes;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export {
|
|
220
|
-
getCrypto,
|
|
221
|
-
getRandomBigInt,
|
|
222
|
-
modInverse,
|
|
223
|
-
evaluatePolynomial,
|
|
224
|
-
fieldDiv,
|
|
225
|
-
computerLagrangeCoefficients,
|
|
226
|
-
generatePolynomialForSecretSharing,
|
|
227
|
-
splitSecret,
|
|
228
|
-
splitSecretWithProofs,
|
|
229
|
-
recoverSecret,
|
|
230
|
-
validateShare,
|
|
231
|
-
bigIntToPrivateKey
|
|
232
|
-
};
|
package/dist/chunk-R5PXJZQS.js
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
// src/tests/isHermeticTest.ts
|
|
2
|
-
import { isNode } from "@lightsparkdev/core";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
function isHermeticTest() {
|
|
5
|
-
if (isNode) {
|
|
6
|
-
return (fs?.existsSync?.("/tmp/spark_hermetic") ?? false) || process.env.HERMETIC_TEST === "true";
|
|
7
|
-
}
|
|
8
|
-
return typeof process !== "undefined" && process.env?.HERMETIC_TEST === "true" || false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// src/services/wallet-config.ts
|
|
12
|
-
var SSP_IDENTITY_PUBLIC_KEYS = {
|
|
13
|
-
LOCAL: "028c094a432d46a0ac95349d792c2e3730bd60c29188db716f56a99e39b95338b4",
|
|
14
|
-
REGTEST: {
|
|
15
|
-
PROD: "022bf283544b16c0622daecb79422007d167eca6ce9f0c98c0c49833b1f7170bfe"
|
|
16
|
-
},
|
|
17
|
-
MAINNET: {
|
|
18
|
-
PROD: "023e33e2920326f64ea31058d44777442d97d7d5cbfcf54e3060bc1695e5261c93"
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var URL_CONFIG = {
|
|
22
|
-
LOCAL: {
|
|
23
|
-
SSP: "http://127.0.0.1:5000",
|
|
24
|
-
ELECTRS: "http://127.0.0.1:30000",
|
|
25
|
-
LRC20: "http://127.0.0.1:18530",
|
|
26
|
-
LRC20_NODE: "http://127.0.0.1:18332"
|
|
27
|
-
},
|
|
28
|
-
REGTEST: {
|
|
29
|
-
PROD: {
|
|
30
|
-
SSP: "https://api.lightspark.com",
|
|
31
|
-
ELECTRS: "https://regtest-mempool.us-west-2.sparkinfra.net/api",
|
|
32
|
-
LRC20: "https://regtest.lrc20.lightspark.com:443",
|
|
33
|
-
LRC20_NODE: "https://regtest.lrc20.lightspark.com"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
MAINNET: {
|
|
37
|
-
PROD: {
|
|
38
|
-
SSP: "https://api.lightspark.com",
|
|
39
|
-
ELECTRS: "https://mempool.space/api",
|
|
40
|
-
LRC20: "https://mainnet.lrc20.lightspark.com:443",
|
|
41
|
-
LRC20_NODE: "https://mainnet.lrc20.lightspark.com"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var ELECTRS_CREDENTIALS = {
|
|
46
|
-
username: "spark-sdk",
|
|
47
|
-
password: "mCMk1JqlBNtetUNy"
|
|
48
|
-
};
|
|
49
|
-
function getElectrsUrl(network) {
|
|
50
|
-
switch (network) {
|
|
51
|
-
case "LOCAL":
|
|
52
|
-
return isHermeticTest() ? "http://mempool.minikube.local/api" : URL_CONFIG.LOCAL.ELECTRS;
|
|
53
|
-
case "REGTEST":
|
|
54
|
-
return URL_CONFIG.REGTEST.PROD.ELECTRS;
|
|
55
|
-
case "MAINNET":
|
|
56
|
-
return URL_CONFIG.MAINNET.PROD.ELECTRS;
|
|
57
|
-
default:
|
|
58
|
-
return URL_CONFIG.LOCAL.ELECTRS;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function getLrc20Url(network) {
|
|
62
|
-
switch (network) {
|
|
63
|
-
case "LOCAL":
|
|
64
|
-
return URL_CONFIG.LOCAL.LRC20;
|
|
65
|
-
case "REGTEST":
|
|
66
|
-
return URL_CONFIG.REGTEST.PROD.LRC20;
|
|
67
|
-
case "MAINNET":
|
|
68
|
-
return URL_CONFIG.MAINNET.PROD.LRC20;
|
|
69
|
-
default:
|
|
70
|
-
return URL_CONFIG.LOCAL.LRC20;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function getLrc20NodeUrl(network) {
|
|
74
|
-
switch (network) {
|
|
75
|
-
case "LOCAL":
|
|
76
|
-
return URL_CONFIG.LOCAL.LRC20_NODE;
|
|
77
|
-
case "REGTEST":
|
|
78
|
-
return URL_CONFIG.REGTEST.PROD.LRC20_NODE;
|
|
79
|
-
case "MAINNET":
|
|
80
|
-
return URL_CONFIG.MAINNET.PROD.LRC20_NODE;
|
|
81
|
-
default:
|
|
82
|
-
return URL_CONFIG.LOCAL.LRC20_NODE;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function getSspIdentityPublicKey(network) {
|
|
86
|
-
switch (network) {
|
|
87
|
-
case "LOCAL":
|
|
88
|
-
return SSP_IDENTITY_PUBLIC_KEYS.LOCAL;
|
|
89
|
-
case "REGTEST":
|
|
90
|
-
return SSP_IDENTITY_PUBLIC_KEYS.REGTEST.PROD;
|
|
91
|
-
case "MAINNET":
|
|
92
|
-
return SSP_IDENTITY_PUBLIC_KEYS.MAINNET.PROD;
|
|
93
|
-
default:
|
|
94
|
-
return SSP_IDENTITY_PUBLIC_KEYS.LOCAL;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function getSspUrl(network) {
|
|
98
|
-
switch (network) {
|
|
99
|
-
case "LOCAL":
|
|
100
|
-
return isHermeticTest() ? "http://app.minikube.local" : URL_CONFIG.LOCAL.SSP;
|
|
101
|
-
case "REGTEST":
|
|
102
|
-
return URL_CONFIG.REGTEST.PROD.SSP;
|
|
103
|
-
case "MAINNET":
|
|
104
|
-
return URL_CONFIG.MAINNET.PROD.SSP;
|
|
105
|
-
default:
|
|
106
|
-
return URL_CONFIG.LOCAL.SSP;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function getSspSchemaEndpoint(network) {
|
|
110
|
-
switch (network) {
|
|
111
|
-
case "LOCAL":
|
|
112
|
-
return "graphql/spark/rc";
|
|
113
|
-
}
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
var PROD_PUBKEYS = [
|
|
117
|
-
"03dfbdff4b6332c220f8fa2ba8ed496c698ceada563fa01b67d9983bfc5c95e763",
|
|
118
|
-
"03e625e9768651c9be268e287245cc33f96a68ce9141b0b4769205db027ee8ed77",
|
|
119
|
-
"022eda13465a59205413086130a65dc0ed1b8f8e51937043161f8be0c369b1a410"
|
|
120
|
-
];
|
|
121
|
-
function getLocalFrostSignerAddress() {
|
|
122
|
-
return isHermeticTest() ? "localhost:9999" : "unix:///tmp/frost_0.sock";
|
|
123
|
-
}
|
|
124
|
-
var BASE_CONFIG = {
|
|
125
|
-
network: "LOCAL",
|
|
126
|
-
lrc20Address: getLrc20Url("LOCAL"),
|
|
127
|
-
coodinatorIdentifier: "0000000000000000000000000000000000000000000000000000000000000001",
|
|
128
|
-
frostSignerAddress: getLocalFrostSignerAddress(),
|
|
129
|
-
threshold: 2,
|
|
130
|
-
signingOperators: getLocalSigningOperators(),
|
|
131
|
-
tokenSignatures: "SCHNORR",
|
|
132
|
-
tokenTransactionVersion: "V0",
|
|
133
|
-
tokenValidityDurationSeconds: 180,
|
|
134
|
-
electrsUrl: getElectrsUrl("LOCAL"),
|
|
135
|
-
expectedWithdrawBondSats: 1e4,
|
|
136
|
-
expectedWithdrawRelativeBlockLocktime: 1e3,
|
|
137
|
-
lrc20ApiConfig: {
|
|
138
|
-
electrsUrl: getElectrsUrl("LOCAL"),
|
|
139
|
-
lrc20NodeUrl: getLrc20NodeUrl("LOCAL"),
|
|
140
|
-
electrsCredentials: ELECTRS_CREDENTIALS
|
|
141
|
-
},
|
|
142
|
-
sspClientOptions: {
|
|
143
|
-
baseUrl: getSspUrl("LOCAL"),
|
|
144
|
-
identityPublicKey: getSspIdentityPublicKey("LOCAL"),
|
|
145
|
-
schemaEndpoint: getSspSchemaEndpoint("LOCAL")
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var LOCAL_WALLET_CONFIG = {
|
|
149
|
-
...BASE_CONFIG,
|
|
150
|
-
threshold: 3
|
|
151
|
-
};
|
|
152
|
-
var LOCAL_WALLET_CONFIG_SCHNORR = {
|
|
153
|
-
...LOCAL_WALLET_CONFIG,
|
|
154
|
-
threshold: 3
|
|
155
|
-
// 3 for issuance tests.
|
|
156
|
-
};
|
|
157
|
-
var LOCAL_WALLET_CONFIG_ECDSA = {
|
|
158
|
-
...LOCAL_WALLET_CONFIG,
|
|
159
|
-
tokenSignatures: "ECDSA",
|
|
160
|
-
threshold: 3
|
|
161
|
-
// 3 for issuance tests.
|
|
162
|
-
};
|
|
163
|
-
var REGTEST_WALLET_CONFIG = {
|
|
164
|
-
...BASE_CONFIG,
|
|
165
|
-
network: "REGTEST",
|
|
166
|
-
lrc20Address: getLrc20Url("REGTEST"),
|
|
167
|
-
signingOperators: getSigningOperators(),
|
|
168
|
-
electrsUrl: getElectrsUrl("REGTEST"),
|
|
169
|
-
lrc20ApiConfig: {
|
|
170
|
-
electrsUrl: getElectrsUrl("REGTEST"),
|
|
171
|
-
lrc20NodeUrl: getLrc20NodeUrl("REGTEST"),
|
|
172
|
-
electrsCredentials: ELECTRS_CREDENTIALS
|
|
173
|
-
},
|
|
174
|
-
expectedWithdrawBondSats: 1e4,
|
|
175
|
-
expectedWithdrawRelativeBlockLocktime: 1e3,
|
|
176
|
-
sspClientOptions: {
|
|
177
|
-
baseUrl: getSspUrl("REGTEST"),
|
|
178
|
-
identityPublicKey: getSspIdentityPublicKey("REGTEST")
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var MAINNET_WALLET_CONFIG = {
|
|
182
|
-
...BASE_CONFIG,
|
|
183
|
-
network: "MAINNET",
|
|
184
|
-
lrc20Address: getLrc20Url("MAINNET"),
|
|
185
|
-
signingOperators: getSigningOperators(),
|
|
186
|
-
electrsUrl: getElectrsUrl("MAINNET"),
|
|
187
|
-
lrc20ApiConfig: {
|
|
188
|
-
electrsUrl: getElectrsUrl("MAINNET"),
|
|
189
|
-
lrc20NodeUrl: getLrc20NodeUrl("MAINNET")
|
|
190
|
-
},
|
|
191
|
-
expectedWithdrawBondSats: 1e4,
|
|
192
|
-
expectedWithdrawRelativeBlockLocktime: 1e3,
|
|
193
|
-
sspClientOptions: {
|
|
194
|
-
baseUrl: getSspUrl("MAINNET"),
|
|
195
|
-
identityPublicKey: getSspIdentityPublicKey("MAINNET")
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
function getSigningOperators() {
|
|
199
|
-
return {
|
|
200
|
-
"0000000000000000000000000000000000000000000000000000000000000001": {
|
|
201
|
-
id: 0,
|
|
202
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000001",
|
|
203
|
-
address: "https://0.spark.lightspark.com",
|
|
204
|
-
identityPublicKey: PROD_PUBKEYS[0]
|
|
205
|
-
},
|
|
206
|
-
"0000000000000000000000000000000000000000000000000000000000000002": {
|
|
207
|
-
id: 1,
|
|
208
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000002",
|
|
209
|
-
address: "https://1.spark.lightspark.com",
|
|
210
|
-
identityPublicKey: PROD_PUBKEYS[1]
|
|
211
|
-
},
|
|
212
|
-
"0000000000000000000000000000000000000000000000000000000000000003": {
|
|
213
|
-
id: 2,
|
|
214
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000003",
|
|
215
|
-
address: "https://2.spark.flashnet.xyz",
|
|
216
|
-
identityPublicKey: PROD_PUBKEYS[2]
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function getLocalSigningOperators() {
|
|
221
|
-
const pubkeys = [
|
|
222
|
-
"0322ca18fc489ae25418a0e768273c2c61cabb823edfb14feb891e9bec62016510",
|
|
223
|
-
"0341727a6c41b168f07eb50865ab8c397a53c7eef628ac1020956b705e43b6cb27",
|
|
224
|
-
"0305ab8d485cc752394de4981f8a5ae004f2becfea6f432c9a59d5022d8764f0a6",
|
|
225
|
-
"0352aef4d49439dedd798ac4aef1e7ebef95f569545b647a25338398c1247ffdea",
|
|
226
|
-
"02c05c88cc8fc181b1ba30006df6a4b0597de6490e24514fbdd0266d2b9cd3d0ba"
|
|
227
|
-
];
|
|
228
|
-
return {
|
|
229
|
-
"0000000000000000000000000000000000000000000000000000000000000001": {
|
|
230
|
-
id: 0,
|
|
231
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000001",
|
|
232
|
-
address: "https://localhost:8535",
|
|
233
|
-
identityPublicKey: pubkeys[0]
|
|
234
|
-
},
|
|
235
|
-
"0000000000000000000000000000000000000000000000000000000000000002": {
|
|
236
|
-
id: 1,
|
|
237
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000002",
|
|
238
|
-
address: "https://localhost:8536",
|
|
239
|
-
identityPublicKey: pubkeys[1]
|
|
240
|
-
},
|
|
241
|
-
"0000000000000000000000000000000000000000000000000000000000000003": {
|
|
242
|
-
id: 2,
|
|
243
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000003",
|
|
244
|
-
address: "https://localhost:8537",
|
|
245
|
-
identityPublicKey: pubkeys[2]
|
|
246
|
-
},
|
|
247
|
-
"0000000000000000000000000000000000000000000000000000000000000004": {
|
|
248
|
-
id: 3,
|
|
249
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000004",
|
|
250
|
-
address: "https://localhost:8538",
|
|
251
|
-
identityPublicKey: pubkeys[3]
|
|
252
|
-
},
|
|
253
|
-
"0000000000000000000000000000000000000000000000000000000000000005": {
|
|
254
|
-
id: 4,
|
|
255
|
-
identifier: "0000000000000000000000000000000000000000000000000000000000000005",
|
|
256
|
-
address: "https://localhost:8539",
|
|
257
|
-
identityPublicKey: pubkeys[4]
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export {
|
|
263
|
-
ELECTRS_CREDENTIALS,
|
|
264
|
-
getElectrsUrl,
|
|
265
|
-
getLrc20Url,
|
|
266
|
-
getLrc20NodeUrl,
|
|
267
|
-
getSspIdentityPublicKey,
|
|
268
|
-
getSspUrl,
|
|
269
|
-
getSspSchemaEndpoint,
|
|
270
|
-
BASE_CONFIG,
|
|
271
|
-
LOCAL_WALLET_CONFIG,
|
|
272
|
-
LOCAL_WALLET_CONFIG_SCHNORR,
|
|
273
|
-
LOCAL_WALLET_CONFIG_ECDSA,
|
|
274
|
-
REGTEST_WALLET_CONFIG,
|
|
275
|
-
MAINNET_WALLET_CONFIG,
|
|
276
|
-
getLocalSigningOperators
|
|
277
|
-
};
|
package/dist/chunk-VTUGIIWI.js
DELETED
|
File without changes
|