@buildonspark/spark-sdk 0.2.1 → 0.2.3
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 +13 -0
- package/dist/{chunk-TM6CHQXC.js → chunk-3SEOTO43.js} +1 -1
- package/dist/{chunk-2ENZX6LT.js → chunk-AAZWSPUK.js} +84 -8
- package/dist/{chunk-4JD4HIAN.js → chunk-G4MSZ6DE.js} +299 -1
- package/dist/{chunk-KFDVDUIS.js → chunk-PLLJIZC3.js} +138 -35
- package/dist/{chunk-N4JAOOIN.js → chunk-PTRXJS7Q.js} +1 -1
- package/dist/{client-DKbwpcnl.d.ts → client-CGTRS23n.d.ts} +21 -4
- package/dist/{client-Drs5Lapg.d.cts → client-CcYzmpmj.d.cts} +21 -4
- package/dist/debug.cjs +455 -40
- package/dist/debug.d.cts +5 -5
- package/dist/debug.d.ts +5 -5
- package/dist/debug.js +4 -4
- package/dist/graphql/objects/index.d.cts +2 -2
- package/dist/graphql/objects/index.d.ts +2 -2
- package/dist/index.cjs +515 -40
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -5
- package/dist/index.node.cjs +517 -44
- package/dist/index.node.d.cts +8 -6
- package/dist/index.node.d.ts +8 -6
- package/dist/index.node.js +6 -4
- package/dist/native/index.cjs +459 -43
- package/dist/native/index.d.cts +62 -15
- package/dist/native/index.d.ts +62 -15
- package/dist/native/index.js +459 -43
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/lrc20.js +1 -1
- package/dist/proto/spark.cjs +84 -8
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +1 -1
- package/dist/proto/spark_token.cjs +301 -0
- package/dist/proto/spark_token.d.cts +35 -2
- package/dist/proto/spark_token.d.ts +35 -2
- package/dist/proto/spark_token.js +8 -2
- package/dist/{sdk-types-DJ2ve9YY.d.cts → sdk-types-CB9HrW5O.d.cts} +1 -1
- package/dist/{sdk-types-DCIVdKUT.d.ts → sdk-types-CkRNraXT.d.ts} +1 -1
- package/dist/{spark-BUOx3U7Q.d.cts → spark-B_7nZx6T.d.cts} +112 -10
- package/dist/{spark-BUOx3U7Q.d.ts → spark-B_7nZx6T.d.ts} +112 -10
- package/dist/{spark-wallet-DbCjWOfP.d.ts → spark-wallet-CxcGPXRB.d.ts} +10 -6
- package/dist/{spark-wallet-BslnB-4H.d.cts → spark-wallet-DJJm19BP.d.cts} +10 -6
- package/dist/tests/test-utils.cjs +455 -17
- package/dist/tests/test-utils.d.cts +9 -5
- package/dist/tests/test-utils.d.ts +9 -5
- package/dist/tests/test-utils.js +13 -6
- package/dist/types/index.cjs +84 -8
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -2
- package/dist/{xchain-address-BIcYZU3K.d.ts → xchain-address-Bh9w1SeC.d.ts} +3 -3
- package/dist/{xchain-address-C3B-Jfk5.d.cts → xchain-address-SZ7dkVUE.d.cts} +3 -3
- package/package.json +1 -1
- package/src/index.node.ts +6 -6
- package/src/index.ts +5 -5
- package/src/proto/spark.ts +172 -16
- package/src/proto/spark_token.ts +369 -0
- package/src/services/connection.ts +3 -3
- package/src/services/coop-exit.ts +1 -1
- package/src/services/deposit.ts +2 -2
- package/src/services/signing.ts +1 -1
- package/src/services/token-transactions.ts +6 -2
- package/src/services/transfer.ts +25 -9
- package/src/services/tree-creation.ts +10 -7
- package/src/signer/signer.react-native.ts +4 -3
- package/src/signer/signer.ts +84 -6
- package/src/signer/types.ts +7 -1
- package/src/spark-wallet/spark-wallet.ts +56 -15
- package/src/tests/integration/coop-exit.test.ts +5 -3
- package/src/tests/integration/deposit.test.ts +20 -10
- package/src/tests/integration/lightning.test.ts +13 -7
- package/src/tests/integration/message-signing.test.ts +10 -7
- package/src/tests/integration/swap.test.ts +8 -4
- package/src/tests/integration/transfer.test.ts +25 -11
- package/src/tests/integration/wallet.test.ts +9 -4
- package/src/tests/test-utils.ts +10 -1
package/dist/native/index.cjs
CHANGED
|
@@ -15727,14 +15727,6 @@ var SparkServiceDefinition = {
|
|
|
15727
15727
|
responseStream: false,
|
|
15728
15728
|
options: {}
|
|
15729
15729
|
},
|
|
15730
|
-
create_tree_v2: {
|
|
15731
|
-
name: "create_tree_v2",
|
|
15732
|
-
requestType: CreateTreeRequest,
|
|
15733
|
-
requestStream: false,
|
|
15734
|
-
responseType: CreateTreeResponse,
|
|
15735
|
-
responseStream: false,
|
|
15736
|
-
options: {}
|
|
15737
|
-
},
|
|
15738
15730
|
get_signing_operator_list: {
|
|
15739
15731
|
name: "get_signing_operator_list",
|
|
15740
15732
|
requestType: Empty,
|
|
@@ -15901,6 +15893,90 @@ var SparkServiceDefinition = {
|
|
|
15901
15893
|
responseType: ExitSingleNodeTreesResponse,
|
|
15902
15894
|
responseStream: false,
|
|
15903
15895
|
options: {}
|
|
15896
|
+
},
|
|
15897
|
+
/**
|
|
15898
|
+
* The following endpoints enforce inclusion of Direct Transactions used
|
|
15899
|
+
* for unilateral exits
|
|
15900
|
+
*/
|
|
15901
|
+
create_tree_v2: {
|
|
15902
|
+
name: "create_tree_v2",
|
|
15903
|
+
requestType: CreateTreeRequest,
|
|
15904
|
+
requestStream: false,
|
|
15905
|
+
responseType: CreateTreeResponse,
|
|
15906
|
+
responseStream: false,
|
|
15907
|
+
options: {}
|
|
15908
|
+
},
|
|
15909
|
+
cooperative_exit_v2: {
|
|
15910
|
+
name: "cooperative_exit_v2",
|
|
15911
|
+
requestType: CooperativeExitRequest,
|
|
15912
|
+
requestStream: false,
|
|
15913
|
+
responseType: CooperativeExitResponse,
|
|
15914
|
+
responseStream: false,
|
|
15915
|
+
options: {}
|
|
15916
|
+
},
|
|
15917
|
+
extend_leaf_v2: {
|
|
15918
|
+
name: "extend_leaf_v2",
|
|
15919
|
+
requestType: ExtendLeafRequest,
|
|
15920
|
+
requestStream: false,
|
|
15921
|
+
responseType: ExtendLeafResponse,
|
|
15922
|
+
responseStream: false,
|
|
15923
|
+
options: {}
|
|
15924
|
+
},
|
|
15925
|
+
claim_transfer_sign_refunds_v2: {
|
|
15926
|
+
name: "claim_transfer_sign_refunds_v2",
|
|
15927
|
+
requestType: ClaimTransferSignRefundsRequest,
|
|
15928
|
+
requestStream: false,
|
|
15929
|
+
responseType: ClaimTransferSignRefundsResponse,
|
|
15930
|
+
responseStream: false,
|
|
15931
|
+
options: {}
|
|
15932
|
+
},
|
|
15933
|
+
finalize_node_signatures_v2: {
|
|
15934
|
+
name: "finalize_node_signatures_v2",
|
|
15935
|
+
requestType: FinalizeNodeSignaturesRequest,
|
|
15936
|
+
requestStream: false,
|
|
15937
|
+
responseType: FinalizeNodeSignaturesResponse,
|
|
15938
|
+
responseStream: false,
|
|
15939
|
+
options: {}
|
|
15940
|
+
},
|
|
15941
|
+
initiate_preimage_swap_v2: {
|
|
15942
|
+
name: "initiate_preimage_swap_v2",
|
|
15943
|
+
requestType: InitiatePreimageSwapRequest,
|
|
15944
|
+
requestStream: false,
|
|
15945
|
+
responseType: InitiatePreimageSwapResponse,
|
|
15946
|
+
responseStream: false,
|
|
15947
|
+
options: {}
|
|
15948
|
+
},
|
|
15949
|
+
start_leaf_swap_v2: {
|
|
15950
|
+
name: "start_leaf_swap_v2",
|
|
15951
|
+
requestType: StartTransferRequest,
|
|
15952
|
+
requestStream: false,
|
|
15953
|
+
responseType: StartTransferResponse,
|
|
15954
|
+
responseStream: false,
|
|
15955
|
+
options: {}
|
|
15956
|
+
},
|
|
15957
|
+
counter_leaf_swap_v2: {
|
|
15958
|
+
name: "counter_leaf_swap_v2",
|
|
15959
|
+
requestType: CounterLeafSwapRequest,
|
|
15960
|
+
requestStream: false,
|
|
15961
|
+
responseType: CounterLeafSwapResponse,
|
|
15962
|
+
responseStream: false,
|
|
15963
|
+
options: {}
|
|
15964
|
+
},
|
|
15965
|
+
start_transfer_v2: {
|
|
15966
|
+
name: "start_transfer_v2",
|
|
15967
|
+
requestType: StartTransferRequest,
|
|
15968
|
+
requestStream: false,
|
|
15969
|
+
responseType: StartTransferResponse,
|
|
15970
|
+
responseStream: false,
|
|
15971
|
+
options: {}
|
|
15972
|
+
},
|
|
15973
|
+
refresh_timelock_v2: {
|
|
15974
|
+
name: "refresh_timelock_v2",
|
|
15975
|
+
requestType: RefreshTimelockRequest,
|
|
15976
|
+
requestStream: false,
|
|
15977
|
+
responseType: RefreshTimelockResponse,
|
|
15978
|
+
responseStream: false,
|
|
15979
|
+
options: {}
|
|
15904
15980
|
}
|
|
15905
15981
|
}
|
|
15906
15982
|
};
|
|
@@ -18981,7 +19057,7 @@ init_buffer();
|
|
|
18981
19057
|
var import_core8 = require("@lightsparkdev/core");
|
|
18982
19058
|
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
18983
19059
|
var isBun = globalThis.Bun !== void 0;
|
|
18984
|
-
var packageVersion = true ? "0.2.
|
|
19060
|
+
var packageVersion = true ? "0.2.3" : "unknown";
|
|
18985
19061
|
var baseEnvStr = "unknown";
|
|
18986
19062
|
if (isBun) {
|
|
18987
19063
|
const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
|
|
@@ -19248,7 +19324,8 @@ var DefaultSparkSigner = class {
|
|
|
19248
19324
|
field: "privateKey"
|
|
19249
19325
|
});
|
|
19250
19326
|
}
|
|
19251
|
-
const
|
|
19327
|
+
const commitment = selfCommitment.commitment;
|
|
19328
|
+
const nonce = this.commitmentToNonceMap.get(commitment);
|
|
19252
19329
|
if (!nonce) {
|
|
19253
19330
|
throw new ValidationError("Nonce not found for commitment", {
|
|
19254
19331
|
field: "nonce"
|
|
@@ -19263,7 +19340,7 @@ var DefaultSparkSigner = class {
|
|
|
19263
19340
|
message,
|
|
19264
19341
|
keyPackage,
|
|
19265
19342
|
nonce,
|
|
19266
|
-
selfCommitment,
|
|
19343
|
+
selfCommitment: commitment,
|
|
19267
19344
|
statechainCommitments,
|
|
19268
19345
|
adaptorPubKey
|
|
19269
19346
|
});
|
|
@@ -19291,7 +19368,7 @@ var DefaultSparkSigner = class {
|
|
|
19291
19368
|
statechainPublicKeys,
|
|
19292
19369
|
verifyingKey,
|
|
19293
19370
|
statechainCommitments,
|
|
19294
|
-
selfCommitment,
|
|
19371
|
+
selfCommitment: selfCommitment.commitment,
|
|
19295
19372
|
selfPublicKey: publicKey,
|
|
19296
19373
|
selfSignature,
|
|
19297
19374
|
adaptorPubKey
|
|
@@ -19342,7 +19419,9 @@ var DefaultSparkSigner = class {
|
|
|
19342
19419
|
const nonce = getRandomSigningNonce();
|
|
19343
19420
|
const commitment = getSigningCommitmentFromNonce(nonce);
|
|
19344
19421
|
this.commitmentToNonceMap.set(commitment, nonce);
|
|
19345
|
-
return
|
|
19422
|
+
return {
|
|
19423
|
+
commitment
|
|
19424
|
+
};
|
|
19346
19425
|
}
|
|
19347
19426
|
async validateMessageWithIdentityKey(message, signature) {
|
|
19348
19427
|
if (!this.identityKey?.publicKey) {
|
|
@@ -19414,7 +19493,8 @@ var ReactNativeSparkSigner = class extends DefaultSparkSigner {
|
|
|
19414
19493
|
field: "privateKey"
|
|
19415
19494
|
});
|
|
19416
19495
|
}
|
|
19417
|
-
const
|
|
19496
|
+
const commitment = selfCommitment.commitment;
|
|
19497
|
+
const nonce = this.commitmentToNonceMap.get(commitment);
|
|
19418
19498
|
if (!nonce) {
|
|
19419
19499
|
throw new ValidationError("Nonce not found for commitment", {
|
|
19420
19500
|
field: "nonce"
|
|
@@ -19429,7 +19509,7 @@ var ReactNativeSparkSigner = class extends DefaultSparkSigner {
|
|
|
19429
19509
|
message,
|
|
19430
19510
|
keyPackage,
|
|
19431
19511
|
nonce,
|
|
19432
|
-
selfCommitment,
|
|
19512
|
+
selfCommitment: commitment,
|
|
19433
19513
|
statechainCommitments,
|
|
19434
19514
|
adaptorPubKey
|
|
19435
19515
|
});
|
|
@@ -19451,7 +19531,7 @@ var ReactNativeSparkSigner = class extends DefaultSparkSigner {
|
|
|
19451
19531
|
statechainPublicKeys,
|
|
19452
19532
|
verifyingKey,
|
|
19453
19533
|
statechainCommitments,
|
|
19454
|
-
selfCommitment,
|
|
19534
|
+
selfCommitment: selfCommitment.commitment,
|
|
19455
19535
|
selfPublicKey: publicKey,
|
|
19456
19536
|
selfSignature,
|
|
19457
19537
|
adaptorPubKey
|
|
@@ -23673,6 +23753,293 @@ var TokenTransactionWithStatus2 = {
|
|
|
23673
23753
|
return message;
|
|
23674
23754
|
}
|
|
23675
23755
|
};
|
|
23756
|
+
function createBaseFreezeTokensPayload2() {
|
|
23757
|
+
return {
|
|
23758
|
+
version: 0,
|
|
23759
|
+
ownerPublicKey: new Uint8Array(0),
|
|
23760
|
+
tokenPublicKey: void 0,
|
|
23761
|
+
tokenIdentifier: void 0,
|
|
23762
|
+
issuerProvidedTimestamp: 0,
|
|
23763
|
+
operatorIdentityPublicKey: new Uint8Array(0),
|
|
23764
|
+
shouldUnfreeze: false
|
|
23765
|
+
};
|
|
23766
|
+
}
|
|
23767
|
+
var FreezeTokensPayload2 = {
|
|
23768
|
+
encode(message, writer = new import_wire7.BinaryWriter()) {
|
|
23769
|
+
if (message.version !== 0) {
|
|
23770
|
+
writer.uint32(8).uint32(message.version);
|
|
23771
|
+
}
|
|
23772
|
+
if (message.ownerPublicKey.length !== 0) {
|
|
23773
|
+
writer.uint32(18).bytes(message.ownerPublicKey);
|
|
23774
|
+
}
|
|
23775
|
+
if (message.tokenPublicKey !== void 0) {
|
|
23776
|
+
writer.uint32(26).bytes(message.tokenPublicKey);
|
|
23777
|
+
}
|
|
23778
|
+
if (message.tokenIdentifier !== void 0) {
|
|
23779
|
+
writer.uint32(34).bytes(message.tokenIdentifier);
|
|
23780
|
+
}
|
|
23781
|
+
if (message.issuerProvidedTimestamp !== 0) {
|
|
23782
|
+
writer.uint32(40).uint64(message.issuerProvidedTimestamp);
|
|
23783
|
+
}
|
|
23784
|
+
if (message.operatorIdentityPublicKey.length !== 0) {
|
|
23785
|
+
writer.uint32(50).bytes(message.operatorIdentityPublicKey);
|
|
23786
|
+
}
|
|
23787
|
+
if (message.shouldUnfreeze !== false) {
|
|
23788
|
+
writer.uint32(56).bool(message.shouldUnfreeze);
|
|
23789
|
+
}
|
|
23790
|
+
return writer;
|
|
23791
|
+
},
|
|
23792
|
+
decode(input, length) {
|
|
23793
|
+
const reader = input instanceof import_wire7.BinaryReader ? input : new import_wire7.BinaryReader(input);
|
|
23794
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
23795
|
+
const message = createBaseFreezeTokensPayload2();
|
|
23796
|
+
while (reader.pos < end) {
|
|
23797
|
+
const tag = reader.uint32();
|
|
23798
|
+
switch (tag >>> 3) {
|
|
23799
|
+
case 1: {
|
|
23800
|
+
if (tag !== 8) {
|
|
23801
|
+
break;
|
|
23802
|
+
}
|
|
23803
|
+
message.version = reader.uint32();
|
|
23804
|
+
continue;
|
|
23805
|
+
}
|
|
23806
|
+
case 2: {
|
|
23807
|
+
if (tag !== 18) {
|
|
23808
|
+
break;
|
|
23809
|
+
}
|
|
23810
|
+
message.ownerPublicKey = reader.bytes();
|
|
23811
|
+
continue;
|
|
23812
|
+
}
|
|
23813
|
+
case 3: {
|
|
23814
|
+
if (tag !== 26) {
|
|
23815
|
+
break;
|
|
23816
|
+
}
|
|
23817
|
+
message.tokenPublicKey = reader.bytes();
|
|
23818
|
+
continue;
|
|
23819
|
+
}
|
|
23820
|
+
case 4: {
|
|
23821
|
+
if (tag !== 34) {
|
|
23822
|
+
break;
|
|
23823
|
+
}
|
|
23824
|
+
message.tokenIdentifier = reader.bytes();
|
|
23825
|
+
continue;
|
|
23826
|
+
}
|
|
23827
|
+
case 5: {
|
|
23828
|
+
if (tag !== 40) {
|
|
23829
|
+
break;
|
|
23830
|
+
}
|
|
23831
|
+
message.issuerProvidedTimestamp = longToNumber4(reader.uint64());
|
|
23832
|
+
continue;
|
|
23833
|
+
}
|
|
23834
|
+
case 6: {
|
|
23835
|
+
if (tag !== 50) {
|
|
23836
|
+
break;
|
|
23837
|
+
}
|
|
23838
|
+
message.operatorIdentityPublicKey = reader.bytes();
|
|
23839
|
+
continue;
|
|
23840
|
+
}
|
|
23841
|
+
case 7: {
|
|
23842
|
+
if (tag !== 56) {
|
|
23843
|
+
break;
|
|
23844
|
+
}
|
|
23845
|
+
message.shouldUnfreeze = reader.bool();
|
|
23846
|
+
continue;
|
|
23847
|
+
}
|
|
23848
|
+
}
|
|
23849
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
23850
|
+
break;
|
|
23851
|
+
}
|
|
23852
|
+
reader.skip(tag & 7);
|
|
23853
|
+
}
|
|
23854
|
+
return message;
|
|
23855
|
+
},
|
|
23856
|
+
fromJSON(object) {
|
|
23857
|
+
return {
|
|
23858
|
+
version: isSet6(object.version) ? globalThis.Number(object.version) : 0,
|
|
23859
|
+
ownerPublicKey: isSet6(object.ownerPublicKey) ? bytesFromBase645(object.ownerPublicKey) : new Uint8Array(0),
|
|
23860
|
+
tokenPublicKey: isSet6(object.tokenPublicKey) ? bytesFromBase645(object.tokenPublicKey) : void 0,
|
|
23861
|
+
tokenIdentifier: isSet6(object.tokenIdentifier) ? bytesFromBase645(object.tokenIdentifier) : void 0,
|
|
23862
|
+
issuerProvidedTimestamp: isSet6(object.issuerProvidedTimestamp) ? globalThis.Number(object.issuerProvidedTimestamp) : 0,
|
|
23863
|
+
operatorIdentityPublicKey: isSet6(object.operatorIdentityPublicKey) ? bytesFromBase645(object.operatorIdentityPublicKey) : new Uint8Array(0),
|
|
23864
|
+
shouldUnfreeze: isSet6(object.shouldUnfreeze) ? globalThis.Boolean(object.shouldUnfreeze) : false
|
|
23865
|
+
};
|
|
23866
|
+
},
|
|
23867
|
+
toJSON(message) {
|
|
23868
|
+
const obj = {};
|
|
23869
|
+
if (message.version !== 0) {
|
|
23870
|
+
obj.version = Math.round(message.version);
|
|
23871
|
+
}
|
|
23872
|
+
if (message.ownerPublicKey.length !== 0) {
|
|
23873
|
+
obj.ownerPublicKey = base64FromBytes5(message.ownerPublicKey);
|
|
23874
|
+
}
|
|
23875
|
+
if (message.tokenPublicKey !== void 0) {
|
|
23876
|
+
obj.tokenPublicKey = base64FromBytes5(message.tokenPublicKey);
|
|
23877
|
+
}
|
|
23878
|
+
if (message.tokenIdentifier !== void 0) {
|
|
23879
|
+
obj.tokenIdentifier = base64FromBytes5(message.tokenIdentifier);
|
|
23880
|
+
}
|
|
23881
|
+
if (message.issuerProvidedTimestamp !== 0) {
|
|
23882
|
+
obj.issuerProvidedTimestamp = Math.round(message.issuerProvidedTimestamp);
|
|
23883
|
+
}
|
|
23884
|
+
if (message.operatorIdentityPublicKey.length !== 0) {
|
|
23885
|
+
obj.operatorIdentityPublicKey = base64FromBytes5(message.operatorIdentityPublicKey);
|
|
23886
|
+
}
|
|
23887
|
+
if (message.shouldUnfreeze !== false) {
|
|
23888
|
+
obj.shouldUnfreeze = message.shouldUnfreeze;
|
|
23889
|
+
}
|
|
23890
|
+
return obj;
|
|
23891
|
+
},
|
|
23892
|
+
create(base) {
|
|
23893
|
+
return FreezeTokensPayload2.fromPartial(base ?? {});
|
|
23894
|
+
},
|
|
23895
|
+
fromPartial(object) {
|
|
23896
|
+
const message = createBaseFreezeTokensPayload2();
|
|
23897
|
+
message.version = object.version ?? 0;
|
|
23898
|
+
message.ownerPublicKey = object.ownerPublicKey ?? new Uint8Array(0);
|
|
23899
|
+
message.tokenPublicKey = object.tokenPublicKey ?? void 0;
|
|
23900
|
+
message.tokenIdentifier = object.tokenIdentifier ?? void 0;
|
|
23901
|
+
message.issuerProvidedTimestamp = object.issuerProvidedTimestamp ?? 0;
|
|
23902
|
+
message.operatorIdentityPublicKey = object.operatorIdentityPublicKey ?? new Uint8Array(0);
|
|
23903
|
+
message.shouldUnfreeze = object.shouldUnfreeze ?? false;
|
|
23904
|
+
return message;
|
|
23905
|
+
}
|
|
23906
|
+
};
|
|
23907
|
+
function createBaseFreezeTokensRequest2() {
|
|
23908
|
+
return { freezeTokensPayload: void 0, issuerSignature: new Uint8Array(0) };
|
|
23909
|
+
}
|
|
23910
|
+
var FreezeTokensRequest2 = {
|
|
23911
|
+
encode(message, writer = new import_wire7.BinaryWriter()) {
|
|
23912
|
+
if (message.freezeTokensPayload !== void 0) {
|
|
23913
|
+
FreezeTokensPayload2.encode(message.freezeTokensPayload, writer.uint32(10).fork()).join();
|
|
23914
|
+
}
|
|
23915
|
+
if (message.issuerSignature.length !== 0) {
|
|
23916
|
+
writer.uint32(18).bytes(message.issuerSignature);
|
|
23917
|
+
}
|
|
23918
|
+
return writer;
|
|
23919
|
+
},
|
|
23920
|
+
decode(input, length) {
|
|
23921
|
+
const reader = input instanceof import_wire7.BinaryReader ? input : new import_wire7.BinaryReader(input);
|
|
23922
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
23923
|
+
const message = createBaseFreezeTokensRequest2();
|
|
23924
|
+
while (reader.pos < end) {
|
|
23925
|
+
const tag = reader.uint32();
|
|
23926
|
+
switch (tag >>> 3) {
|
|
23927
|
+
case 1: {
|
|
23928
|
+
if (tag !== 10) {
|
|
23929
|
+
break;
|
|
23930
|
+
}
|
|
23931
|
+
message.freezeTokensPayload = FreezeTokensPayload2.decode(reader, reader.uint32());
|
|
23932
|
+
continue;
|
|
23933
|
+
}
|
|
23934
|
+
case 2: {
|
|
23935
|
+
if (tag !== 18) {
|
|
23936
|
+
break;
|
|
23937
|
+
}
|
|
23938
|
+
message.issuerSignature = reader.bytes();
|
|
23939
|
+
continue;
|
|
23940
|
+
}
|
|
23941
|
+
}
|
|
23942
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
23943
|
+
break;
|
|
23944
|
+
}
|
|
23945
|
+
reader.skip(tag & 7);
|
|
23946
|
+
}
|
|
23947
|
+
return message;
|
|
23948
|
+
},
|
|
23949
|
+
fromJSON(object) {
|
|
23950
|
+
return {
|
|
23951
|
+
freezeTokensPayload: isSet6(object.freezeTokensPayload) ? FreezeTokensPayload2.fromJSON(object.freezeTokensPayload) : void 0,
|
|
23952
|
+
issuerSignature: isSet6(object.issuerSignature) ? bytesFromBase645(object.issuerSignature) : new Uint8Array(0)
|
|
23953
|
+
};
|
|
23954
|
+
},
|
|
23955
|
+
toJSON(message) {
|
|
23956
|
+
const obj = {};
|
|
23957
|
+
if (message.freezeTokensPayload !== void 0) {
|
|
23958
|
+
obj.freezeTokensPayload = FreezeTokensPayload2.toJSON(message.freezeTokensPayload);
|
|
23959
|
+
}
|
|
23960
|
+
if (message.issuerSignature.length !== 0) {
|
|
23961
|
+
obj.issuerSignature = base64FromBytes5(message.issuerSignature);
|
|
23962
|
+
}
|
|
23963
|
+
return obj;
|
|
23964
|
+
},
|
|
23965
|
+
create(base) {
|
|
23966
|
+
return FreezeTokensRequest2.fromPartial(base ?? {});
|
|
23967
|
+
},
|
|
23968
|
+
fromPartial(object) {
|
|
23969
|
+
const message = createBaseFreezeTokensRequest2();
|
|
23970
|
+
message.freezeTokensPayload = object.freezeTokensPayload !== void 0 && object.freezeTokensPayload !== null ? FreezeTokensPayload2.fromPartial(object.freezeTokensPayload) : void 0;
|
|
23971
|
+
message.issuerSignature = object.issuerSignature ?? new Uint8Array(0);
|
|
23972
|
+
return message;
|
|
23973
|
+
}
|
|
23974
|
+
};
|
|
23975
|
+
function createBaseFreezeTokensResponse2() {
|
|
23976
|
+
return { impactedOutputIds: [], impactedTokenAmount: new Uint8Array(0) };
|
|
23977
|
+
}
|
|
23978
|
+
var FreezeTokensResponse2 = {
|
|
23979
|
+
encode(message, writer = new import_wire7.BinaryWriter()) {
|
|
23980
|
+
for (const v of message.impactedOutputIds) {
|
|
23981
|
+
writer.uint32(10).string(v);
|
|
23982
|
+
}
|
|
23983
|
+
if (message.impactedTokenAmount.length !== 0) {
|
|
23984
|
+
writer.uint32(18).bytes(message.impactedTokenAmount);
|
|
23985
|
+
}
|
|
23986
|
+
return writer;
|
|
23987
|
+
},
|
|
23988
|
+
decode(input, length) {
|
|
23989
|
+
const reader = input instanceof import_wire7.BinaryReader ? input : new import_wire7.BinaryReader(input);
|
|
23990
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
23991
|
+
const message = createBaseFreezeTokensResponse2();
|
|
23992
|
+
while (reader.pos < end) {
|
|
23993
|
+
const tag = reader.uint32();
|
|
23994
|
+
switch (tag >>> 3) {
|
|
23995
|
+
case 1: {
|
|
23996
|
+
if (tag !== 10) {
|
|
23997
|
+
break;
|
|
23998
|
+
}
|
|
23999
|
+
message.impactedOutputIds.push(reader.string());
|
|
24000
|
+
continue;
|
|
24001
|
+
}
|
|
24002
|
+
case 2: {
|
|
24003
|
+
if (tag !== 18) {
|
|
24004
|
+
break;
|
|
24005
|
+
}
|
|
24006
|
+
message.impactedTokenAmount = reader.bytes();
|
|
24007
|
+
continue;
|
|
24008
|
+
}
|
|
24009
|
+
}
|
|
24010
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
24011
|
+
break;
|
|
24012
|
+
}
|
|
24013
|
+
reader.skip(tag & 7);
|
|
24014
|
+
}
|
|
24015
|
+
return message;
|
|
24016
|
+
},
|
|
24017
|
+
fromJSON(object) {
|
|
24018
|
+
return {
|
|
24019
|
+
impactedOutputIds: globalThis.Array.isArray(object?.impactedOutputIds) ? object.impactedOutputIds.map((e) => globalThis.String(e)) : [],
|
|
24020
|
+
impactedTokenAmount: isSet6(object.impactedTokenAmount) ? bytesFromBase645(object.impactedTokenAmount) : new Uint8Array(0)
|
|
24021
|
+
};
|
|
24022
|
+
},
|
|
24023
|
+
toJSON(message) {
|
|
24024
|
+
const obj = {};
|
|
24025
|
+
if (message.impactedOutputIds?.length) {
|
|
24026
|
+
obj.impactedOutputIds = message.impactedOutputIds;
|
|
24027
|
+
}
|
|
24028
|
+
if (message.impactedTokenAmount.length !== 0) {
|
|
24029
|
+
obj.impactedTokenAmount = base64FromBytes5(message.impactedTokenAmount);
|
|
24030
|
+
}
|
|
24031
|
+
return obj;
|
|
24032
|
+
},
|
|
24033
|
+
create(base) {
|
|
24034
|
+
return FreezeTokensResponse2.fromPartial(base ?? {});
|
|
24035
|
+
},
|
|
24036
|
+
fromPartial(object) {
|
|
24037
|
+
const message = createBaseFreezeTokensResponse2();
|
|
24038
|
+
message.impactedOutputIds = object.impactedOutputIds?.map((e) => e) || [];
|
|
24039
|
+
message.impactedTokenAmount = object.impactedTokenAmount ?? new Uint8Array(0);
|
|
24040
|
+
return message;
|
|
24041
|
+
}
|
|
24042
|
+
};
|
|
23676
24043
|
var SparkTokenServiceDefinition = {
|
|
23677
24044
|
name: "SparkTokenService",
|
|
23678
24045
|
fullName: "spark_token.SparkTokenService",
|
|
@@ -23724,6 +24091,14 @@ var SparkTokenServiceDefinition = {
|
|
|
23724
24091
|
responseType: QueryTokenOutputsResponse2,
|
|
23725
24092
|
responseStream: false,
|
|
23726
24093
|
options: {}
|
|
24094
|
+
},
|
|
24095
|
+
freeze_tokens: {
|
|
24096
|
+
name: "freeze_tokens",
|
|
24097
|
+
requestType: FreezeTokensRequest2,
|
|
24098
|
+
requestStream: false,
|
|
24099
|
+
responseType: FreezeTokensResponse2,
|
|
24100
|
+
responseStream: false,
|
|
24101
|
+
options: {}
|
|
23727
24102
|
}
|
|
23728
24103
|
}
|
|
23729
24104
|
};
|
|
@@ -24182,6 +24557,13 @@ var DEFAULT_EXPIRY_TIME = 10 * 60 * 1e3;
|
|
|
24182
24557
|
function initialSequence() {
|
|
24183
24558
|
return 1 << 30 | INITIAL_TIME_LOCK;
|
|
24184
24559
|
}
|
|
24560
|
+
function getSigningJobProto(signingJob) {
|
|
24561
|
+
return {
|
|
24562
|
+
signingPublicKey: signingJob.signingPublicKey,
|
|
24563
|
+
rawTx: signingJob.rawTx,
|
|
24564
|
+
signingNonceCommitment: signingJob.signingNonceCommitment.commitment
|
|
24565
|
+
};
|
|
24566
|
+
}
|
|
24185
24567
|
var BaseTransferService = class {
|
|
24186
24568
|
config;
|
|
24187
24569
|
connectionManager;
|
|
@@ -24808,7 +25190,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
24808
25190
|
refundSigningData.keyDerivation
|
|
24809
25191
|
),
|
|
24810
25192
|
rawTx: refundTx.toBytes(),
|
|
24811
|
-
signingNonceCommitment: refundNonceCommitmentProto
|
|
25193
|
+
signingNonceCommitment: refundNonceCommitmentProto.commitment
|
|
24812
25194
|
},
|
|
24813
25195
|
// TODO: Add direct refund signature
|
|
24814
25196
|
directRefundTxSigningJob: void 0,
|
|
@@ -25120,7 +25502,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
25120
25502
|
const response = await sparkClient.refresh_timelock({
|
|
25121
25503
|
leafId: leaf.id,
|
|
25122
25504
|
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
25123
|
-
signingJobs
|
|
25505
|
+
signingJobs: signingJobs.map(getSigningJobProto)
|
|
25124
25506
|
});
|
|
25125
25507
|
if (signingJobs.length !== response.signingResults.length) {
|
|
25126
25508
|
throw Error(
|
|
@@ -25286,8 +25668,8 @@ var TransferService = class extends BaseTransferService {
|
|
|
25286
25668
|
const response = await sparkClient.extend_leaf({
|
|
25287
25669
|
leafId: node.id,
|
|
25288
25670
|
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
25289
|
-
nodeTxSigningJob: newNodeSigningJob,
|
|
25290
|
-
refundTxSigningJob: newRefundSigningJob
|
|
25671
|
+
nodeTxSigningJob: getSigningJobProto(newNodeSigningJob),
|
|
25672
|
+
refundTxSigningJob: getSigningJobProto(newRefundSigningJob)
|
|
25291
25673
|
});
|
|
25292
25674
|
if (!response.nodeTxSigningResult || !response.refundTxSigningResult) {
|
|
25293
25675
|
throw new Error("Signing result does not exist");
|
|
@@ -25395,7 +25777,7 @@ var TransferService = class extends BaseTransferService {
|
|
|
25395
25777
|
const response = await sparkClient.refresh_timelock({
|
|
25396
25778
|
leafId: node.id,
|
|
25397
25779
|
ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
|
|
25398
|
-
signingJobs: [refundSigningJob]
|
|
25780
|
+
signingJobs: [getSigningJobProto(refundSigningJob)]
|
|
25399
25781
|
});
|
|
25400
25782
|
if (response.signingResults.length !== 1) {
|
|
25401
25783
|
throw Error(
|
|
@@ -25547,7 +25929,7 @@ var CoopExitService = class extends BaseTransferService {
|
|
|
25547
25929
|
leaf.keyDerivation
|
|
25548
25930
|
),
|
|
25549
25931
|
rawTx: refundTx.toBytes(),
|
|
25550
|
-
signingNonceCommitment
|
|
25932
|
+
signingNonceCommitment: signingNonceCommitment.commitment
|
|
25551
25933
|
},
|
|
25552
25934
|
// TODO: Add direct refund signature
|
|
25553
25935
|
directRefundTxSigningJob: void 0,
|
|
@@ -25802,12 +26184,12 @@ var DepositService = class {
|
|
|
25802
26184
|
rootTxSigningJob: {
|
|
25803
26185
|
rawTx: rootTx.toBytes(),
|
|
25804
26186
|
signingPublicKey: signingPubKey,
|
|
25805
|
-
signingNonceCommitment: rootNonceCommitment
|
|
26187
|
+
signingNonceCommitment: rootNonceCommitment.commitment
|
|
25806
26188
|
},
|
|
25807
26189
|
refundTxSigningJob: {
|
|
25808
26190
|
rawTx: refundTx.toBytes(),
|
|
25809
26191
|
signingPublicKey: signingPubKey,
|
|
25810
|
-
signingNonceCommitment: refundNonceCommitment
|
|
26192
|
+
signingNonceCommitment: refundNonceCommitment.commitment
|
|
25811
26193
|
}
|
|
25812
26194
|
});
|
|
25813
26195
|
} catch (error) {
|
|
@@ -28430,7 +28812,9 @@ var TokenTransactionService = class {
|
|
|
28430
28812
|
issuerPublicKeys,
|
|
28431
28813
|
tokenTransactionHashes,
|
|
28432
28814
|
tokenIdentifiers,
|
|
28433
|
-
outputIds
|
|
28815
|
+
outputIds,
|
|
28816
|
+
pageSize,
|
|
28817
|
+
offset
|
|
28434
28818
|
} = params;
|
|
28435
28819
|
const tokenClient = await this.connectionManager.createSparkTokenClient(
|
|
28436
28820
|
this.config.getCoordinatorAddress()
|
|
@@ -28441,8 +28825,8 @@ var TokenTransactionService = class {
|
|
|
28441
28825
|
tokenIdentifiers: tokenIdentifiers?.map(import_utils19.hexToBytes),
|
|
28442
28826
|
tokenTransactionHashes: tokenTransactionHashes?.map(import_utils19.hexToBytes),
|
|
28443
28827
|
outputIds: outputIds || [],
|
|
28444
|
-
limit:
|
|
28445
|
-
offset
|
|
28828
|
+
limit: pageSize,
|
|
28829
|
+
offset
|
|
28446
28830
|
};
|
|
28447
28831
|
try {
|
|
28448
28832
|
const response = await tokenClient.query_token_transactions(queryParams);
|
|
@@ -28879,7 +29263,7 @@ var TreeCreationService = class {
|
|
|
28879
29263
|
const signingJob = {
|
|
28880
29264
|
signingPublicKey: node.signingPublicKey,
|
|
28881
29265
|
rawTx: tx.toBytes(),
|
|
28882
|
-
signingNonceCommitment
|
|
29266
|
+
signingNonceCommitment: signingNonceCommitment.commitment
|
|
28883
29267
|
};
|
|
28884
29268
|
internalCreationNode.nodeTxSigningCommitment = signingNonceCommitment;
|
|
28885
29269
|
internalCreationNode.nodeTxSigningJob = signingJob;
|
|
@@ -28908,7 +29292,7 @@ var TreeCreationService = class {
|
|
|
28908
29292
|
const childSigningJob = {
|
|
28909
29293
|
signingPublicKey: node.signingPublicKey,
|
|
28910
29294
|
rawTx: childTx.toBytes(),
|
|
28911
|
-
signingNonceCommitment: childSigningNonceCommitment
|
|
29295
|
+
signingNonceCommitment: childSigningNonceCommitment.commitment
|
|
28912
29296
|
};
|
|
28913
29297
|
childCreationNode.nodeTxSigningCommitment = childSigningNonceCommitment;
|
|
28914
29298
|
childCreationNode.nodeTxSigningJob = childSigningJob;
|
|
@@ -28935,7 +29319,7 @@ var TreeCreationService = class {
|
|
|
28935
29319
|
const refundSigningJob = {
|
|
28936
29320
|
signingPublicKey: node.signingPublicKey,
|
|
28937
29321
|
rawTx: refundTx.toBytes(),
|
|
28938
|
-
signingNonceCommitment: refundSigningNonceCommitment
|
|
29322
|
+
signingNonceCommitment: refundSigningNonceCommitment.commitment
|
|
28939
29323
|
};
|
|
28940
29324
|
childCreationNode.refundTxSigningCommitment = refundSigningNonceCommitment;
|
|
28941
29325
|
childCreationNode.refundTxSigningJob = refundSigningJob;
|
|
@@ -28970,7 +29354,7 @@ var TreeCreationService = class {
|
|
|
28970
29354
|
const rootNodeSigningJob = {
|
|
28971
29355
|
signingPublicKey: root.signingPublicKey,
|
|
28972
29356
|
rawTx: rootNodeTx.toBytes(),
|
|
28973
|
-
signingNonceCommitment: rootNodeSigningCommitment
|
|
29357
|
+
signingNonceCommitment: rootNodeSigningCommitment.commitment
|
|
28974
29358
|
};
|
|
28975
29359
|
const rootCreationNode = {
|
|
28976
29360
|
nodeTxSigningJob: rootNodeSigningJob,
|
|
@@ -29203,7 +29587,7 @@ var SigningService = class {
|
|
|
29203
29587
|
leaf.keyDerivation
|
|
29204
29588
|
),
|
|
29205
29589
|
rawTx: refundTx.toBytes(),
|
|
29206
|
-
signingNonceCommitment: signingCommitment,
|
|
29590
|
+
signingNonceCommitment: signingCommitment.commitment,
|
|
29207
29591
|
userSignature: signingResult,
|
|
29208
29592
|
signingCommitments: {
|
|
29209
29593
|
signingCommitments: signingNonceCommitments
|
|
@@ -29796,11 +30180,24 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
29796
30180
|
}
|
|
29797
30181
|
}
|
|
29798
30182
|
}
|
|
29799
|
-
const
|
|
29800
|
-
|
|
29801
|
-
|
|
29802
|
-
for (const [id, leaf] of
|
|
29803
|
-
if (
|
|
30183
|
+
const availableLeaves = Object.entries(leaves.nodes).filter(
|
|
30184
|
+
([_, node]) => node.status === "AVAILABLE"
|
|
30185
|
+
);
|
|
30186
|
+
for (const [id, leaf] of availableLeaves) {
|
|
30187
|
+
if (leaf.parentNodeId && leaf.status === "AVAILABLE" && this.verifyKey(
|
|
30188
|
+
await this.config.signer.getPublicKeyFromDerivation({
|
|
30189
|
+
type: "leaf" /* LEAF */,
|
|
30190
|
+
path: leaf.parentNodeId
|
|
30191
|
+
}),
|
|
30192
|
+
leaf.signingKeyshare?.publicKey ?? new Uint8Array(),
|
|
30193
|
+
leaf.verifyingPublicKey
|
|
30194
|
+
)) {
|
|
30195
|
+
this.transferLeavesToSelf([leaf], {
|
|
30196
|
+
type: "leaf" /* LEAF */,
|
|
30197
|
+
path: leaf.parentNodeId
|
|
30198
|
+
});
|
|
30199
|
+
leavesToIgnore.add(id);
|
|
30200
|
+
} else if (!this.verifyKey(
|
|
29804
30201
|
await this.config.signer.getPublicKeyFromDerivation({
|
|
29805
30202
|
type: "leaf" /* LEAF */,
|
|
29806
30203
|
path: leaf.id
|
|
@@ -29811,9 +30208,23 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
29811
30208
|
leavesToIgnore.add(id);
|
|
29812
30209
|
}
|
|
29813
30210
|
}
|
|
29814
|
-
return
|
|
29815
|
-
|
|
29816
|
-
|
|
30211
|
+
return availableLeaves.filter(([_, node]) => !leavesToIgnore.has(node.id)).map(([_, node]) => node);
|
|
30212
|
+
}
|
|
30213
|
+
async checkExtendLeaves(leaves) {
|
|
30214
|
+
await this.withLeaves(async () => {
|
|
30215
|
+
for (const leaf of leaves) {
|
|
30216
|
+
if (!leaf.parentNodeId && leaf.status === "AVAILABLE") {
|
|
30217
|
+
const res = await this.transferService.extendTimelock(leaf);
|
|
30218
|
+
await this.transferLeavesToSelf(res.nodes, {
|
|
30219
|
+
type: "leaf" /* LEAF */,
|
|
30220
|
+
path: leaf.id
|
|
30221
|
+
});
|
|
30222
|
+
}
|
|
30223
|
+
}
|
|
30224
|
+
});
|
|
30225
|
+
}
|
|
30226
|
+
verifyKey(pubkey1, pubkey2, verifyingKey) {
|
|
30227
|
+
return (0, import_utils24.equalBytes)(addPublicKeys(pubkey1, pubkey2), verifyingKey);
|
|
29817
30228
|
}
|
|
29818
30229
|
async selectLeaves(targetAmounts) {
|
|
29819
30230
|
if (targetAmounts.length === 0) {
|
|
@@ -29952,6 +30363,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
29952
30363
|
leaves = await this.checkRefreshTimelockNodes(leaves);
|
|
29953
30364
|
leaves = await this.checkExtendTimeLockNodes(leaves);
|
|
29954
30365
|
this.leaves = leaves;
|
|
30366
|
+
this.checkExtendLeaves(leaves);
|
|
29955
30367
|
this.optimizeLeaves().catch((e) => {
|
|
29956
30368
|
console.error("Failed to optimize leaves", e);
|
|
29957
30369
|
});
|
|
@@ -30651,7 +31063,7 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
30651
31063
|
const signingJob = {
|
|
30652
31064
|
rawTx: tx.toBytes(),
|
|
30653
31065
|
signingPublicKey: await this.config.signer.getStaticDepositSigningKey(0),
|
|
30654
|
-
signingNonceCommitment
|
|
31066
|
+
signingNonceCommitment: signingNonceCommitment.commitment
|
|
30655
31067
|
};
|
|
30656
31068
|
const message = await this.getStaticDepositSigningPayload(
|
|
30657
31069
|
depositTransactionId,
|
|
@@ -32112,14 +32524,18 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
|
|
|
32112
32524
|
issuerPublicKeys,
|
|
32113
32525
|
tokenTransactionHashes,
|
|
32114
32526
|
tokenIdentifiers,
|
|
32115
|
-
outputIds
|
|
32527
|
+
outputIds,
|
|
32528
|
+
pageSize = 100,
|
|
32529
|
+
offset = 0
|
|
32116
32530
|
}) {
|
|
32117
32531
|
return this.tokenTransactionService.queryTokenTransactions({
|
|
32118
32532
|
ownerPublicKeys,
|
|
32119
32533
|
issuerPublicKeys,
|
|
32120
32534
|
tokenTransactionHashes,
|
|
32121
32535
|
tokenIdentifiers,
|
|
32122
|
-
outputIds
|
|
32536
|
+
outputIds,
|
|
32537
|
+
pageSize,
|
|
32538
|
+
offset
|
|
32123
32539
|
});
|
|
32124
32540
|
}
|
|
32125
32541
|
async getTokenL1Address() {
|