@buildonspark/spark-sdk 0.1.39 → 0.1.41
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/README.md +1 -1
- package/dist/{RequestLightningSendInput-39_zGri6.d.cts → RequestLightningSendInput-DXcLoiCe.d.cts} +10 -2
- package/dist/{RequestLightningSendInput-B4JdzclX.d.ts → RequestLightningSendInput-mXUWn_cp.d.ts} +10 -2
- package/dist/address/index.cjs +138 -6
- package/dist/address/index.d.cts +18 -6
- package/dist/address/index.d.ts +18 -6
- package/dist/address/index.js +5 -2
- package/dist/{chunk-FWQPAPXK.js → chunk-2ZXXLPG2.js} +1 -1
- package/dist/{chunk-S7KD6DDL.js → chunk-6YVPOQ2A.js} +41 -20
- package/dist/{chunk-ZUVYYR5T.js → chunk-7EFSUADA.js} +1 -0
- package/dist/{chunk-NS4UZRQ7.js → chunk-ABZA6R5S.js} +1 -1
- package/dist/{chunk-57XLH3ZR.js → chunk-ATEHMLKP.js} +23 -23
- package/dist/{chunk-VJTDG4BQ.js → chunk-HK6LPV6Z.js} +10 -1
- package/dist/{chunk-W3EC5XSA.js → chunk-J5W5Q2ZP.js} +337 -72
- package/dist/{chunk-TKYOYOYJ.js → chunk-KKSU7OZO.js} +653 -76
- package/dist/chunk-L3EHBOUX.js +0 -0
- package/dist/{chunk-C5LTJBI7.js → chunk-M6A4KFIG.js} +125 -226
- package/dist/{chunk-A74XSEW3.js → chunk-MIVX3GHD.js} +1 -1
- package/dist/{chunk-RGWBSZIO.js → chunk-ROKY5KS4.js} +23 -3
- package/dist/{chunk-LIP2K6KR.js → chunk-TM4TOEOX.js} +26 -8
- package/dist/{chunk-RAPBVYJY.js → chunk-UKT6OFLO.js} +125 -35
- package/dist/chunk-VA7MV4MZ.js +1073 -0
- package/dist/chunk-YEZDPUFY.js +840 -0
- package/dist/{chunk-DI7QXUQJ.js → chunk-ZXDE2XMU.js} +8 -5
- package/dist/graphql/objects/index.cjs +6 -3
- package/dist/graphql/objects/index.d.cts +6 -5
- package/dist/graphql/objects/index.d.ts +6 -5
- package/dist/graphql/objects/index.js +1 -1
- package/dist/{index-DEo_hdN3.d.cts → index-CFh4uWzi.d.cts} +60 -6
- package/dist/{index-BVY0yH_H.d.ts → index-OSDtPMmC.d.ts} +60 -6
- package/dist/index.cjs +3316 -954
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +48 -26
- package/dist/index.node.cjs +3316 -954
- package/dist/index.node.d.cts +9 -8
- package/dist/index.node.d.ts +9 -8
- package/dist/index.node.js +48 -26
- package/dist/native/index.cjs +3323 -961
- package/dist/native/index.d.cts +542 -260
- package/dist/native/index.d.ts +542 -260
- package/dist/native/index.js +3192 -838
- package/dist/{network-DobHpaV6.d.ts → network-BF2GYPye.d.ts} +9 -2
- package/dist/{network-GFGEHkS4.d.cts → network-BiwBmoOg.d.cts} +9 -2
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/lrc20.js +2 -2
- package/dist/proto/spark.cjs +125 -226
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +3 -5
- package/dist/proto/spark_token.cjs +1364 -0
- package/dist/proto/spark_token.d.cts +209 -0
- package/dist/proto/spark_token.d.ts +209 -0
- package/dist/proto/spark_token.js +32 -0
- package/dist/{sdk-types-BuVMn2rX.d.cts → sdk-types-CfhdFnsA.d.cts} +1 -1
- package/dist/{sdk-types-BeI6DM_M.d.ts → sdk-types-MnQrHolg.d.ts} +1 -1
- package/dist/services/config.cjs +64 -40
- package/dist/services/config.d.cts +6 -5
- package/dist/services/config.d.ts +6 -5
- package/dist/services/config.js +7 -7
- package/dist/services/connection.cjs +1108 -306
- package/dist/services/connection.d.cts +10 -5
- package/dist/services/connection.d.ts +10 -5
- package/dist/services/connection.js +3 -2
- package/dist/services/index.cjs +1702 -488
- package/dist/services/index.d.cts +6 -5
- package/dist/services/index.d.ts +6 -5
- package/dist/services/index.js +16 -14
- package/dist/services/lrc-connection.d.cts +5 -5
- package/dist/services/lrc-connection.d.ts +5 -5
- package/dist/services/lrc-connection.js +3 -3
- package/dist/services/token-transactions.cjs +637 -247
- package/dist/services/token-transactions.d.cts +19 -8
- package/dist/services/token-transactions.d.ts +19 -8
- package/dist/services/token-transactions.js +5 -4
- package/dist/services/wallet-config.cjs +1 -0
- package/dist/services/wallet-config.d.cts +6 -5
- package/dist/services/wallet-config.d.ts +6 -5
- package/dist/services/wallet-config.js +1 -1
- package/dist/signer/signer.cjs +122 -35
- package/dist/signer/signer.d.cts +4 -3
- package/dist/signer/signer.d.ts +4 -3
- package/dist/signer/signer.js +8 -4
- package/dist/{signer-C1t40Wus.d.cts → signer-BhLS7SYR.d.cts} +35 -14
- package/dist/{signer-DFGw9RRp.d.ts → signer-CylxIujU.d.ts} +35 -14
- package/dist/{spark-DXYE9gMM.d.ts → spark-DjR1b3TC.d.cts} +13 -21
- package/dist/{spark-DXYE9gMM.d.cts → spark-DjR1b3TC.d.ts} +13 -21
- package/dist/types/index.cjs +130 -227
- package/dist/types/index.d.cts +6 -5
- package/dist/types/index.d.ts +6 -5
- package/dist/types/index.js +3 -3
- package/dist/utils/index.cjs +1169 -3
- package/dist/utils/index.d.cts +66 -6
- package/dist/utils/index.d.ts +66 -6
- package/dist/utils/index.js +35 -14
- package/package.json +6 -2
- package/src/address/address.ts +41 -6
- package/src/graphql/client.ts +15 -0
- package/src/graphql/objects/Transfer.ts +7 -0
- package/src/graphql/queries/Transfer.ts +10 -0
- package/src/proto/spark.ts +215 -337
- package/src/proto/spark_token.ts +1407 -0
- package/src/services/config.ts +4 -0
- package/src/services/connection.ts +37 -1
- package/src/services/deposit.ts +23 -5
- package/src/services/token-transactions.ts +426 -75
- package/src/services/transfer.ts +182 -11
- package/src/services/tree-creation.ts +29 -14
- package/src/services/wallet-config.ts +2 -0
- package/src/signer/signer.ts +190 -48
- package/src/spark-wallet/spark-wallet.ts +510 -6
- package/src/tests/integration/transfer.test.ts +186 -214
- package/src/tests/integration/tree-creation.test.ts +5 -1
- package/src/tests/signer.test.ts +34 -0
- package/src/tests/transaction.test.ts +12 -0
- package/src/tests/xchain-address.test.ts +28 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/mempool.ts +26 -1
- package/src/utils/network.ts +15 -0
- package/src/utils/transaction.ts +51 -3
- package/src/utils/unilateral-exit.ts +729 -0
- package/src/utils/xchain-address.ts +36 -0
- package/dist/chunk-E5SL7XTO.js +0 -301
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @buildonspark/spark-sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add a method to fetch a single transfer
|
|
8
|
+
- Add a method to fetch transfers from the SSP
|
|
9
|
+
- Add TaprootOutputKeysGenerator in signer
|
|
10
|
+
|
|
11
|
+
## 0.1.40
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Improved support for unilateral exits
|
|
16
|
+
|
|
3
17
|
## 0.1.39
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# Welcome to Spark!
|
|
2
|
-
You can find our official documentation at https://docs.spark.money/wallet/introduction
|
|
2
|
+
You can find our official documentation at https://docs.spark.money/wallet/introduction
|
package/dist/{RequestLightningSendInput-39_zGri6.d.cts → RequestLightningSendInput-DXcLoiCe.d.cts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query } from '@lightsparkdev/core';
|
|
2
2
|
import { B as BitcoinNetwork } from './BitcoinNetwork-TnABML0T.cjs';
|
|
3
|
-
import { S as SparkSigner } from './signer-
|
|
3
|
+
import { S as SparkSigner } from './signer-BhLS7SYR.cjs';
|
|
4
4
|
|
|
5
5
|
/** This enum identifies the unit of currency associated with a CurrencyAmount. **/
|
|
6
6
|
declare enum CurrencyUnit {
|
|
@@ -287,6 +287,7 @@ declare class SspClient {
|
|
|
287
287
|
signature: string;
|
|
288
288
|
sspSignature: string;
|
|
289
289
|
}): Promise<ClaimStaticDepositOutput | null>;
|
|
290
|
+
getTransfer(id: string): Promise<Transfer | null>;
|
|
290
291
|
getChallenge(): Promise<GetChallengeOutput | null>;
|
|
291
292
|
verifyChallenge(signature: string, protectedChallenge: string): Promise<VerifyChallengeOutput | null>;
|
|
292
293
|
authenticate(): Promise<void>;
|
|
@@ -319,16 +320,23 @@ declare class Transfer {
|
|
|
319
320
|
/** The id of the transfer known at signing operators. If not set, the transfer hasn't been
|
|
320
321
|
* initialized. **/
|
|
321
322
|
readonly sparkId?: string | undefined;
|
|
323
|
+
/** The user request this transfer belongs to, if there is any **/
|
|
324
|
+
readonly userRequestId?: string | undefined;
|
|
322
325
|
constructor(
|
|
323
326
|
/** The total amount of the transfer. **/
|
|
324
327
|
totalAmount: CurrencyAmount,
|
|
325
328
|
/** The id of the transfer known at signing operators. If not set, the transfer hasn't been
|
|
326
329
|
* initialized. **/
|
|
327
|
-
sparkId?: string | undefined
|
|
330
|
+
sparkId?: string | undefined,
|
|
331
|
+
/** The user request this transfer belongs to, if there is any **/
|
|
332
|
+
userRequestId?: string | undefined);
|
|
328
333
|
getLeaves(client: SspClient, first?: number | undefined, after?: string | undefined): Promise<SparkTransferToLeavesConnection>;
|
|
329
334
|
toJson(): {
|
|
330
335
|
transfer_total_amount: any;
|
|
331
336
|
transfer_spark_id: string | undefined;
|
|
337
|
+
transfer_user_request: {
|
|
338
|
+
id: string | undefined;
|
|
339
|
+
};
|
|
332
340
|
};
|
|
333
341
|
}
|
|
334
342
|
|
package/dist/{RequestLightningSendInput-B4JdzclX.d.ts → RequestLightningSendInput-mXUWn_cp.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query } from '@lightsparkdev/core';
|
|
2
2
|
import { B as BitcoinNetwork } from './BitcoinNetwork-TnABML0T.js';
|
|
3
|
-
import { S as SparkSigner } from './signer-
|
|
3
|
+
import { S as SparkSigner } from './signer-CylxIujU.js';
|
|
4
4
|
|
|
5
5
|
/** This enum identifies the unit of currency associated with a CurrencyAmount. **/
|
|
6
6
|
declare enum CurrencyUnit {
|
|
@@ -287,6 +287,7 @@ declare class SspClient {
|
|
|
287
287
|
signature: string;
|
|
288
288
|
sspSignature: string;
|
|
289
289
|
}): Promise<ClaimStaticDepositOutput | null>;
|
|
290
|
+
getTransfer(id: string): Promise<Transfer | null>;
|
|
290
291
|
getChallenge(): Promise<GetChallengeOutput | null>;
|
|
291
292
|
verifyChallenge(signature: string, protectedChallenge: string): Promise<VerifyChallengeOutput | null>;
|
|
292
293
|
authenticate(): Promise<void>;
|
|
@@ -319,16 +320,23 @@ declare class Transfer {
|
|
|
319
320
|
/** The id of the transfer known at signing operators. If not set, the transfer hasn't been
|
|
320
321
|
* initialized. **/
|
|
321
322
|
readonly sparkId?: string | undefined;
|
|
323
|
+
/** The user request this transfer belongs to, if there is any **/
|
|
324
|
+
readonly userRequestId?: string | undefined;
|
|
322
325
|
constructor(
|
|
323
326
|
/** The total amount of the transfer. **/
|
|
324
327
|
totalAmount: CurrencyAmount,
|
|
325
328
|
/** The id of the transfer known at signing operators. If not set, the transfer hasn't been
|
|
326
329
|
* initialized. **/
|
|
327
|
-
sparkId?: string | undefined
|
|
330
|
+
sparkId?: string | undefined,
|
|
331
|
+
/** The user request this transfer belongs to, if there is any **/
|
|
332
|
+
userRequestId?: string | undefined);
|
|
328
333
|
getLeaves(client: SspClient, first?: number | undefined, after?: string | undefined): Promise<SparkTransferToLeavesConnection>;
|
|
329
334
|
toJson(): {
|
|
330
335
|
transfer_total_amount: any;
|
|
331
336
|
transfer_spark_id: string | undefined;
|
|
337
|
+
transfer_user_request: {
|
|
338
|
+
id: string | undefined;
|
|
339
|
+
};
|
|
332
340
|
};
|
|
333
341
|
}
|
|
334
342
|
|
package/dist/address/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var address_exports = {};
|
|
|
22
22
|
__export(address_exports, {
|
|
23
23
|
decodeSparkAddress: () => decodeSparkAddress,
|
|
24
24
|
encodeSparkAddress: () => encodeSparkAddress,
|
|
25
|
+
isValidPublicKey: () => isValidPublicKey,
|
|
25
26
|
isValidSparkAddress: () => isValidSparkAddress
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(address_exports);
|
|
@@ -59,13 +60,16 @@ var import_wire3 = require("@bufbuild/protobuf/wire");
|
|
|
59
60
|
|
|
60
61
|
// src/proto/spark.ts
|
|
61
62
|
function createBaseSparkAddress() {
|
|
62
|
-
return { identityPublicKey: new Uint8Array(0) };
|
|
63
|
+
return { identityPublicKey: new Uint8Array(0), paymentIntentFields: void 0 };
|
|
63
64
|
}
|
|
64
65
|
var SparkAddress = {
|
|
65
66
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
66
67
|
if (message.identityPublicKey.length !== 0) {
|
|
67
68
|
writer.uint32(10).bytes(message.identityPublicKey);
|
|
68
69
|
}
|
|
70
|
+
if (message.paymentIntentFields !== void 0) {
|
|
71
|
+
PaymentIntentFields.encode(message.paymentIntentFields, writer.uint32(18).fork()).join();
|
|
72
|
+
}
|
|
69
73
|
return writer;
|
|
70
74
|
},
|
|
71
75
|
decode(input, length) {
|
|
@@ -82,6 +86,13 @@ var SparkAddress = {
|
|
|
82
86
|
message.identityPublicKey = reader.bytes();
|
|
83
87
|
continue;
|
|
84
88
|
}
|
|
89
|
+
case 2: {
|
|
90
|
+
if (tag !== 18) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
message.paymentIntentFields = PaymentIntentFields.decode(reader, reader.uint32());
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
85
96
|
}
|
|
86
97
|
if ((tag & 7) === 4 || tag === 0) {
|
|
87
98
|
break;
|
|
@@ -92,7 +103,8 @@ var SparkAddress = {
|
|
|
92
103
|
},
|
|
93
104
|
fromJSON(object) {
|
|
94
105
|
return {
|
|
95
|
-
identityPublicKey: isSet(object.identityPublicKey) ? bytesFromBase64(object.identityPublicKey) : new Uint8Array(0)
|
|
106
|
+
identityPublicKey: isSet(object.identityPublicKey) ? bytesFromBase64(object.identityPublicKey) : new Uint8Array(0),
|
|
107
|
+
paymentIntentFields: isSet(object.paymentIntentFields) ? PaymentIntentFields.fromJSON(object.paymentIntentFields) : void 0
|
|
96
108
|
};
|
|
97
109
|
},
|
|
98
110
|
toJSON(message) {
|
|
@@ -100,6 +112,9 @@ var SparkAddress = {
|
|
|
100
112
|
if (message.identityPublicKey.length !== 0) {
|
|
101
113
|
obj.identityPublicKey = base64FromBytes(message.identityPublicKey);
|
|
102
114
|
}
|
|
115
|
+
if (message.paymentIntentFields !== void 0) {
|
|
116
|
+
obj.paymentIntentFields = PaymentIntentFields.toJSON(message.paymentIntentFields);
|
|
117
|
+
}
|
|
103
118
|
return obj;
|
|
104
119
|
},
|
|
105
120
|
create(base) {
|
|
@@ -108,6 +123,105 @@ var SparkAddress = {
|
|
|
108
123
|
fromPartial(object) {
|
|
109
124
|
const message = createBaseSparkAddress();
|
|
110
125
|
message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
|
|
126
|
+
message.paymentIntentFields = object.paymentIntentFields !== void 0 && object.paymentIntentFields !== null ? PaymentIntentFields.fromPartial(object.paymentIntentFields) : void 0;
|
|
127
|
+
return message;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
function createBasePaymentIntentFields() {
|
|
131
|
+
return { id: new Uint8Array(0), assetIdentifier: void 0, assetAmount: new Uint8Array(0), memo: void 0 };
|
|
132
|
+
}
|
|
133
|
+
var PaymentIntentFields = {
|
|
134
|
+
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
135
|
+
if (message.id.length !== 0) {
|
|
136
|
+
writer.uint32(10).bytes(message.id);
|
|
137
|
+
}
|
|
138
|
+
if (message.assetIdentifier !== void 0) {
|
|
139
|
+
writer.uint32(18).bytes(message.assetIdentifier);
|
|
140
|
+
}
|
|
141
|
+
if (message.assetAmount.length !== 0) {
|
|
142
|
+
writer.uint32(26).bytes(message.assetAmount);
|
|
143
|
+
}
|
|
144
|
+
if (message.memo !== void 0) {
|
|
145
|
+
writer.uint32(34).string(message.memo);
|
|
146
|
+
}
|
|
147
|
+
return writer;
|
|
148
|
+
},
|
|
149
|
+
decode(input, length) {
|
|
150
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
151
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
152
|
+
const message = createBasePaymentIntentFields();
|
|
153
|
+
while (reader.pos < end) {
|
|
154
|
+
const tag = reader.uint32();
|
|
155
|
+
switch (tag >>> 3) {
|
|
156
|
+
case 1: {
|
|
157
|
+
if (tag !== 10) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
message.id = reader.bytes();
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
case 2: {
|
|
164
|
+
if (tag !== 18) {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
message.assetIdentifier = reader.bytes();
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
case 3: {
|
|
171
|
+
if (tag !== 26) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
message.assetAmount = reader.bytes();
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
case 4: {
|
|
178
|
+
if (tag !== 34) {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
message.memo = reader.string();
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
reader.skip(tag & 7);
|
|
189
|
+
}
|
|
190
|
+
return message;
|
|
191
|
+
},
|
|
192
|
+
fromJSON(object) {
|
|
193
|
+
return {
|
|
194
|
+
id: isSet(object.id) ? bytesFromBase64(object.id) : new Uint8Array(0),
|
|
195
|
+
assetIdentifier: isSet(object.assetIdentifier) ? bytesFromBase64(object.assetIdentifier) : void 0,
|
|
196
|
+
assetAmount: isSet(object.assetAmount) ? bytesFromBase64(object.assetAmount) : new Uint8Array(0),
|
|
197
|
+
memo: isSet(object.memo) ? globalThis.String(object.memo) : void 0
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
toJSON(message) {
|
|
201
|
+
const obj = {};
|
|
202
|
+
if (message.id.length !== 0) {
|
|
203
|
+
obj.id = base64FromBytes(message.id);
|
|
204
|
+
}
|
|
205
|
+
if (message.assetIdentifier !== void 0) {
|
|
206
|
+
obj.assetIdentifier = base64FromBytes(message.assetIdentifier);
|
|
207
|
+
}
|
|
208
|
+
if (message.assetAmount.length !== 0) {
|
|
209
|
+
obj.assetAmount = base64FromBytes(message.assetAmount);
|
|
210
|
+
}
|
|
211
|
+
if (message.memo !== void 0) {
|
|
212
|
+
obj.memo = message.memo;
|
|
213
|
+
}
|
|
214
|
+
return obj;
|
|
215
|
+
},
|
|
216
|
+
create(base) {
|
|
217
|
+
return PaymentIntentFields.fromPartial(base ?? {});
|
|
218
|
+
},
|
|
219
|
+
fromPartial(object) {
|
|
220
|
+
const message = createBasePaymentIntentFields();
|
|
221
|
+
message.id = object.id ?? new Uint8Array(0);
|
|
222
|
+
message.assetIdentifier = object.assetIdentifier ?? void 0;
|
|
223
|
+
message.assetAmount = object.assetAmount ?? new Uint8Array(0);
|
|
224
|
+
message.memo = object.memo ?? void 0;
|
|
111
225
|
return message;
|
|
112
226
|
}
|
|
113
227
|
};
|
|
@@ -185,6 +299,8 @@ var ValidationError = class extends SparkSDKError {
|
|
|
185
299
|
};
|
|
186
300
|
|
|
187
301
|
// src/address/address.ts
|
|
302
|
+
var import_uuidv7 = require("uuidv7");
|
|
303
|
+
var import_utils2 = require("@noble/curves/abstract/utils");
|
|
188
304
|
var AddressNetwork = {
|
|
189
305
|
MAINNET: "sp",
|
|
190
306
|
TESTNET: "spt",
|
|
@@ -195,15 +311,20 @@ var AddressNetwork = {
|
|
|
195
311
|
function encodeSparkAddress(payload) {
|
|
196
312
|
try {
|
|
197
313
|
isValidPublicKey(payload.identityPublicKey);
|
|
314
|
+
let paymentIntentFields;
|
|
315
|
+
if (payload.paymentIntentFields) {
|
|
316
|
+
paymentIntentFields = payload.paymentIntentFields;
|
|
317
|
+
}
|
|
198
318
|
const sparkAddressProto = SparkAddress.create({
|
|
199
|
-
identityPublicKey: (0, import_utils.hexToBytes)(payload.identityPublicKey)
|
|
319
|
+
identityPublicKey: (0, import_utils.hexToBytes)(payload.identityPublicKey),
|
|
320
|
+
paymentIntentFields
|
|
200
321
|
});
|
|
201
322
|
const serializedPayload = SparkAddress.encode(sparkAddressProto).finish();
|
|
202
323
|
const words = import_base2.bech32m.toWords(serializedPayload);
|
|
203
324
|
return import_base2.bech32m.encode(
|
|
204
325
|
AddressNetwork[payload.network],
|
|
205
326
|
words,
|
|
206
|
-
|
|
327
|
+
500
|
|
207
328
|
);
|
|
208
329
|
} catch (error) {
|
|
209
330
|
throw new ValidationError(
|
|
@@ -218,7 +339,7 @@ function encodeSparkAddress(payload) {
|
|
|
218
339
|
}
|
|
219
340
|
function decodeSparkAddress(address, network) {
|
|
220
341
|
try {
|
|
221
|
-
const decoded = import_base2.bech32m.decode(address,
|
|
342
|
+
const decoded = import_base2.bech32m.decode(address, 500);
|
|
222
343
|
if (decoded.prefix !== AddressNetwork[network]) {
|
|
223
344
|
throw new ValidationError("Invalid Spark address prefix", {
|
|
224
345
|
field: "address",
|
|
@@ -229,7 +350,17 @@ function decodeSparkAddress(address, network) {
|
|
|
229
350
|
const payload = SparkAddress.decode(import_base2.bech32m.fromWords(decoded.words));
|
|
230
351
|
const publicKey = (0, import_utils.bytesToHex)(payload.identityPublicKey);
|
|
231
352
|
isValidPublicKey(publicKey);
|
|
232
|
-
|
|
353
|
+
const paymentIntentFields = payload.paymentIntentFields;
|
|
354
|
+
return {
|
|
355
|
+
identityPublicKey: publicKey,
|
|
356
|
+
network,
|
|
357
|
+
paymentIntentFields: paymentIntentFields && {
|
|
358
|
+
id: import_uuidv7.UUID.ofInner(paymentIntentFields.id).toString(),
|
|
359
|
+
assetIdentifier: paymentIntentFields.assetIdentifier ? (0, import_utils.bytesToHex)(paymentIntentFields.assetIdentifier) : void 0,
|
|
360
|
+
assetAmount: (0, import_utils2.bytesToNumberBE)(paymentIntentFields.assetAmount),
|
|
361
|
+
memo: paymentIntentFields.memo
|
|
362
|
+
}
|
|
363
|
+
};
|
|
233
364
|
} catch (error) {
|
|
234
365
|
if (error instanceof ValidationError) {
|
|
235
366
|
throw error;
|
|
@@ -291,5 +422,6 @@ function isValidPublicKey(publicKey) {
|
|
|
291
422
|
0 && (module.exports = {
|
|
292
423
|
decodeSparkAddress,
|
|
293
424
|
encodeSparkAddress,
|
|
425
|
+
isValidPublicKey,
|
|
294
426
|
isValidSparkAddress
|
|
295
427
|
});
|
package/dist/address/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PaymentIntentFields } from '../spark-DjR1b3TC.cjs';
|
|
2
|
+
import { a as NetworkType } from '../network-BiwBmoOg.cjs';
|
|
3
|
+
import '@bufbuild/protobuf/wire';
|
|
4
|
+
import 'nice-grpc-common';
|
|
2
5
|
import '@buildonspark/lrc20-sdk';
|
|
3
6
|
import '@scure/btc-signer';
|
|
4
7
|
import 'bitcoinjs-lib';
|
|
5
|
-
import '../spark-DXYE9gMM.cjs';
|
|
6
|
-
import '@bufbuild/protobuf/wire';
|
|
7
|
-
import 'nice-grpc-common';
|
|
8
8
|
import '../BitcoinNetwork-TnABML0T.cjs';
|
|
9
9
|
|
|
10
10
|
declare const AddressNetwork: Record<NetworkType, string>;
|
|
@@ -12,9 +12,21 @@ type SparkAddressFormat = `${(typeof AddressNetwork)[keyof typeof AddressNetwork
|
|
|
12
12
|
interface SparkAddressData {
|
|
13
13
|
identityPublicKey: string;
|
|
14
14
|
network: NetworkType;
|
|
15
|
+
paymentIntentFields?: PaymentIntentFields;
|
|
16
|
+
}
|
|
17
|
+
interface DecodedSparkAddressData {
|
|
18
|
+
identityPublicKey: string;
|
|
19
|
+
network: NetworkType;
|
|
20
|
+
paymentIntentFields?: {
|
|
21
|
+
id: string;
|
|
22
|
+
assetIdentifier?: string;
|
|
23
|
+
assetAmount: bigint;
|
|
24
|
+
memo?: string;
|
|
25
|
+
};
|
|
15
26
|
}
|
|
16
27
|
declare function encodeSparkAddress(payload: SparkAddressData): SparkAddressFormat;
|
|
17
|
-
declare function decodeSparkAddress(address: string, network: NetworkType):
|
|
28
|
+
declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
|
|
18
29
|
declare function isValidSparkAddress(address: string): boolean;
|
|
30
|
+
declare function isValidPublicKey(publicKey: string): void;
|
|
19
31
|
|
|
20
|
-
export { type SparkAddressData, type SparkAddressFormat, decodeSparkAddress, encodeSparkAddress, isValidSparkAddress };
|
|
32
|
+
export { type DecodedSparkAddressData, type SparkAddressData, type SparkAddressFormat, decodeSparkAddress, encodeSparkAddress, isValidPublicKey, isValidSparkAddress };
|
package/dist/address/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PaymentIntentFields } from '../spark-DjR1b3TC.js';
|
|
2
|
+
import { a as NetworkType } from '../network-BF2GYPye.js';
|
|
3
|
+
import '@bufbuild/protobuf/wire';
|
|
4
|
+
import 'nice-grpc-common';
|
|
2
5
|
import '@buildonspark/lrc20-sdk';
|
|
3
6
|
import '@scure/btc-signer';
|
|
4
7
|
import 'bitcoinjs-lib';
|
|
5
|
-
import '../spark-DXYE9gMM.js';
|
|
6
|
-
import '@bufbuild/protobuf/wire';
|
|
7
|
-
import 'nice-grpc-common';
|
|
8
8
|
import '../BitcoinNetwork-TnABML0T.js';
|
|
9
9
|
|
|
10
10
|
declare const AddressNetwork: Record<NetworkType, string>;
|
|
@@ -12,9 +12,21 @@ type SparkAddressFormat = `${(typeof AddressNetwork)[keyof typeof AddressNetwork
|
|
|
12
12
|
interface SparkAddressData {
|
|
13
13
|
identityPublicKey: string;
|
|
14
14
|
network: NetworkType;
|
|
15
|
+
paymentIntentFields?: PaymentIntentFields;
|
|
16
|
+
}
|
|
17
|
+
interface DecodedSparkAddressData {
|
|
18
|
+
identityPublicKey: string;
|
|
19
|
+
network: NetworkType;
|
|
20
|
+
paymentIntentFields?: {
|
|
21
|
+
id: string;
|
|
22
|
+
assetIdentifier?: string;
|
|
23
|
+
assetAmount: bigint;
|
|
24
|
+
memo?: string;
|
|
25
|
+
};
|
|
15
26
|
}
|
|
16
27
|
declare function encodeSparkAddress(payload: SparkAddressData): SparkAddressFormat;
|
|
17
|
-
declare function decodeSparkAddress(address: string, network: NetworkType):
|
|
28
|
+
declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
|
|
18
29
|
declare function isValidSparkAddress(address: string): boolean;
|
|
30
|
+
declare function isValidPublicKey(publicKey: string): void;
|
|
19
31
|
|
|
20
|
-
export { type SparkAddressData, type SparkAddressFormat, decodeSparkAddress, encodeSparkAddress, isValidSparkAddress };
|
|
32
|
+
export { type DecodedSparkAddressData, type SparkAddressData, type SparkAddressFormat, decodeSparkAddress, encodeSparkAddress, isValidPublicKey, isValidSparkAddress };
|
package/dist/address/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import "../chunk-L3EHBOUX.js";
|
|
1
2
|
import {
|
|
2
3
|
decodeSparkAddress,
|
|
3
4
|
encodeSparkAddress,
|
|
5
|
+
isValidPublicKey,
|
|
4
6
|
isValidSparkAddress
|
|
5
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-TM4TOEOX.js";
|
|
6
8
|
import "../chunk-VTUGIIWI.js";
|
|
7
|
-
import "../chunk-C5LTJBI7.js";
|
|
8
9
|
import "../chunk-TWF35O6M.js";
|
|
10
|
+
import "../chunk-M6A4KFIG.js";
|
|
9
11
|
import "../chunk-MVRQ5US7.js";
|
|
10
12
|
export {
|
|
11
13
|
decodeSparkAddress,
|
|
12
14
|
encodeSparkAddress,
|
|
15
|
+
isValidPublicKey,
|
|
13
16
|
isValidSparkAddress
|
|
14
17
|
};
|
|
@@ -219,9 +219,10 @@ var SparkTransferToLeavesConnectionFromJson = (obj) => {
|
|
|
219
219
|
|
|
220
220
|
// src/graphql/objects/Transfer.ts
|
|
221
221
|
var Transfer = class {
|
|
222
|
-
constructor(totalAmount, sparkId) {
|
|
222
|
+
constructor(totalAmount, sparkId, userRequestId) {
|
|
223
223
|
this.totalAmount = totalAmount;
|
|
224
224
|
this.sparkId = sparkId;
|
|
225
|
+
this.userRequestId = userRequestId;
|
|
225
226
|
autoBind(this);
|
|
226
227
|
}
|
|
227
228
|
async getLeaves(client, first = void 0, after = void 0) {
|
|
@@ -267,16 +268,34 @@ query FetchSparkTransferToLeavesConnection($entity_id: ID!, $first: Int, $after:
|
|
|
267
268
|
toJson() {
|
|
268
269
|
return {
|
|
269
270
|
transfer_total_amount: CurrencyAmountToJson(this.totalAmount),
|
|
270
|
-
transfer_spark_id: this.sparkId
|
|
271
|
+
transfer_spark_id: this.sparkId,
|
|
272
|
+
transfer_user_request: { id: this.userRequestId }
|
|
271
273
|
};
|
|
272
274
|
}
|
|
273
275
|
};
|
|
274
276
|
var TransferFromJson = (obj) => {
|
|
275
277
|
return new Transfer(
|
|
276
278
|
CurrencyAmountFromJson(obj["transfer_total_amount"]),
|
|
277
|
-
obj["transfer_spark_id"]
|
|
279
|
+
obj["transfer_spark_id"],
|
|
280
|
+
obj["transfer_user_request"]?.id ?? void 0
|
|
278
281
|
);
|
|
279
282
|
};
|
|
283
|
+
var FRAGMENT2 = `
|
|
284
|
+
fragment TransferFragment on Transfer {
|
|
285
|
+
__typename
|
|
286
|
+
transfer_total_amount: total_amount {
|
|
287
|
+
__typename
|
|
288
|
+
currency_amount_original_value: original_value
|
|
289
|
+
currency_amount_original_unit: original_unit
|
|
290
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
291
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
292
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
293
|
+
}
|
|
294
|
+
transfer_spark_id: spark_id
|
|
295
|
+
transfer_user_request: user_request {
|
|
296
|
+
id
|
|
297
|
+
}
|
|
298
|
+
}`;
|
|
280
299
|
var Transfer_default = Transfer;
|
|
281
300
|
|
|
282
301
|
// src/graphql/objects/CoopExitRequest.ts
|
|
@@ -299,7 +318,7 @@ var CoopExitRequestFromJson = (obj) => {
|
|
|
299
318
|
transfer: !!obj["coop_exit_request_transfer"] ? TransferFromJson(obj["coop_exit_request_transfer"]) : void 0
|
|
300
319
|
};
|
|
301
320
|
};
|
|
302
|
-
var
|
|
321
|
+
var FRAGMENT3 = `
|
|
303
322
|
fragment CoopExitRequestFragment on CoopExitRequest {
|
|
304
323
|
__typename
|
|
305
324
|
coop_exit_request_id: id
|
|
@@ -351,7 +370,7 @@ query GetCoopExitRequest($id: ID!) {
|
|
|
351
370
|
}
|
|
352
371
|
}
|
|
353
372
|
|
|
354
|
-
${
|
|
373
|
+
${FRAGMENT3}
|
|
355
374
|
`,
|
|
356
375
|
variables: { id },
|
|
357
376
|
constructObject: (data) => isObject2(data) && "entity" in data && isObject2(data.entity) ? CoopExitRequestFromJson(data.entity) : null
|
|
@@ -421,7 +440,7 @@ var LeavesSwapRequestFromJson = (obj) => {
|
|
|
421
440
|
expiresAt: obj["leaves_swap_request_expires_at"]
|
|
422
441
|
};
|
|
423
442
|
};
|
|
424
|
-
var
|
|
443
|
+
var FRAGMENT4 = `
|
|
425
444
|
fragment LeavesSwapRequestFragment on LeavesSwapRequest {
|
|
426
445
|
__typename
|
|
427
446
|
leaves_swap_request_id: id
|
|
@@ -496,7 +515,7 @@ query GetLeavesSwapRequest($id: ID!) {
|
|
|
496
515
|
}
|
|
497
516
|
}
|
|
498
517
|
|
|
499
|
-
${
|
|
518
|
+
${FRAGMENT4}
|
|
500
519
|
`,
|
|
501
520
|
variables: { id },
|
|
502
521
|
constructObject: (data) => isObject3(data) && "entity" in data && isObject3(data.entity) ? LeavesSwapRequestFromJson(data.entity) : null
|
|
@@ -550,7 +569,7 @@ var LightningReceiveRequestFromJson = (obj) => {
|
|
|
550
569
|
paymentPreimage: obj["lightning_receive_request_payment_preimage"]
|
|
551
570
|
};
|
|
552
571
|
};
|
|
553
|
-
var
|
|
572
|
+
var FRAGMENT5 = `
|
|
554
573
|
fragment LightningReceiveRequestFragment on LightningReceiveRequest {
|
|
555
574
|
__typename
|
|
556
575
|
lightning_receive_request_id: id
|
|
@@ -600,7 +619,7 @@ query GetLightningReceiveRequest($id: ID!) {
|
|
|
600
619
|
}
|
|
601
620
|
}
|
|
602
621
|
|
|
603
|
-
${
|
|
622
|
+
${FRAGMENT5}
|
|
604
623
|
`,
|
|
605
624
|
variables: { id },
|
|
606
625
|
constructObject: (data) => isObject4(data) && "entity" in data && isObject4(data.entity) ? LightningReceiveRequestFromJson(data.entity) : null
|
|
@@ -640,7 +659,7 @@ var LightningSendRequestFromJson = (obj) => {
|
|
|
640
659
|
paymentPreimage: obj["lightning_send_request_payment_preimage"]
|
|
641
660
|
};
|
|
642
661
|
};
|
|
643
|
-
var
|
|
662
|
+
var FRAGMENT6 = `
|
|
644
663
|
fragment LightningSendRequestFragment on LightningSendRequest {
|
|
645
664
|
__typename
|
|
646
665
|
lightning_send_request_id: id
|
|
@@ -683,7 +702,7 @@ query GetLightningSendRequest($id: ID!) {
|
|
|
683
702
|
}
|
|
684
703
|
}
|
|
685
704
|
|
|
686
|
-
${
|
|
705
|
+
${FRAGMENT6}
|
|
687
706
|
`,
|
|
688
707
|
variables: { id },
|
|
689
708
|
constructObject: (data) => isObject5(data) && "entity" in data && isObject5(data.entity) ? LightningSendRequestFromJson(data.entity) : null
|
|
@@ -815,7 +834,7 @@ var UserRequestFromJson = (obj) => {
|
|
|
815
834
|
`Couldn't find a concrete type for interface UserRequest corresponding to the typename=${obj["__typename"]}`
|
|
816
835
|
);
|
|
817
836
|
};
|
|
818
|
-
var
|
|
837
|
+
var FRAGMENT7 = `
|
|
819
838
|
fragment UserRequestFragment on UserRequest {
|
|
820
839
|
__typename
|
|
821
840
|
... on ClaimStaticDeposit {
|
|
@@ -1030,7 +1049,7 @@ query GetUserRequest($id: ID!) {
|
|
|
1030
1049
|
}
|
|
1031
1050
|
}
|
|
1032
1051
|
|
|
1033
|
-
${
|
|
1052
|
+
${FRAGMENT7}
|
|
1034
1053
|
`,
|
|
1035
1054
|
variables: { id },
|
|
1036
1055
|
constructObject: (data) => isObject6(data) && "entity" in data && isObject6(data.entity) ? UserRequestFromJson(data.entity) : null
|
|
@@ -1310,7 +1329,7 @@ query GetSparkWalletUser($id: ID!) {
|
|
|
1310
1329
|
}
|
|
1311
1330
|
}
|
|
1312
1331
|
|
|
1313
|
-
${
|
|
1332
|
+
${FRAGMENT8}
|
|
1314
1333
|
`,
|
|
1315
1334
|
variables: { id },
|
|
1316
1335
|
constructObject: (data) => isObject7(data) && "entity" in data && isObject7(data.entity) ? SparkWalletUserFromJson(data.entity) : null
|
|
@@ -1335,7 +1354,7 @@ var SparkWalletUserFromJson = (obj) => {
|
|
|
1335
1354
|
"SparkWalletUser"
|
|
1336
1355
|
);
|
|
1337
1356
|
};
|
|
1338
|
-
var
|
|
1357
|
+
var FRAGMENT8 = `
|
|
1339
1358
|
fragment SparkWalletUserFragment on SparkWalletUser {
|
|
1340
1359
|
__typename
|
|
1341
1360
|
spark_wallet_user_id: id
|
|
@@ -1349,25 +1368,27 @@ export {
|
|
|
1349
1368
|
CurrencyUnit_default,
|
|
1350
1369
|
CurrencyAmountFromJson,
|
|
1351
1370
|
SparkCoopExitRequestStatus_default,
|
|
1371
|
+
TransferFromJson,
|
|
1372
|
+
FRAGMENT2 as FRAGMENT,
|
|
1352
1373
|
Transfer_default,
|
|
1353
1374
|
CoopExitRequestFromJson,
|
|
1354
|
-
|
|
1375
|
+
FRAGMENT3 as FRAGMENT2,
|
|
1355
1376
|
getCoopExitRequestQuery,
|
|
1356
1377
|
SparkLeavesSwapRequestStatus_default,
|
|
1357
1378
|
LeavesSwapRequestFromJson,
|
|
1358
|
-
|
|
1379
|
+
FRAGMENT4 as FRAGMENT3,
|
|
1359
1380
|
getLeavesSwapRequestQuery,
|
|
1360
1381
|
LightningReceiveRequestStatus_default,
|
|
1361
1382
|
LightningReceiveRequestFromJson,
|
|
1362
|
-
|
|
1383
|
+
FRAGMENT5 as FRAGMENT4,
|
|
1363
1384
|
getLightningReceiveRequestQuery,
|
|
1364
1385
|
LightningSendRequestStatus_default,
|
|
1365
1386
|
LightningSendRequestFromJson,
|
|
1366
|
-
|
|
1387
|
+
FRAGMENT6 as FRAGMENT5,
|
|
1367
1388
|
getLightningSendRequestQuery,
|
|
1368
1389
|
ClaimStaticDepositRequestType_default,
|
|
1369
1390
|
ClaimStaticDepositStatus_default,
|
|
1370
|
-
|
|
1391
|
+
FRAGMENT7 as FRAGMENT6,
|
|
1371
1392
|
getUserRequestQuery,
|
|
1372
1393
|
getClaimStaticDepositQuery,
|
|
1373
1394
|
ExitSpeed_default,
|
|
@@ -129,6 +129,7 @@ var BASE_CONFIG = {
|
|
|
129
129
|
threshold: 2,
|
|
130
130
|
signingOperators: getLocalSigningOperators(),
|
|
131
131
|
tokenSignatures: "SCHNORR",
|
|
132
|
+
tokenTransactionVersion: "V0",
|
|
132
133
|
electrsUrl: getElectrsUrl("LOCAL"),
|
|
133
134
|
expectedWithdrawBondSats: 1e4,
|
|
134
135
|
expectedWithdrawRelativeBlockLocktime: 1e3,
|