@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.
Files changed (125) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/dist/{RequestLightningSendInput-39_zGri6.d.cts → RequestLightningSendInput-DXcLoiCe.d.cts} +10 -2
  4. package/dist/{RequestLightningSendInput-B4JdzclX.d.ts → RequestLightningSendInput-mXUWn_cp.d.ts} +10 -2
  5. package/dist/address/index.cjs +138 -6
  6. package/dist/address/index.d.cts +18 -6
  7. package/dist/address/index.d.ts +18 -6
  8. package/dist/address/index.js +5 -2
  9. package/dist/{chunk-FWQPAPXK.js → chunk-2ZXXLPG2.js} +1 -1
  10. package/dist/{chunk-S7KD6DDL.js → chunk-6YVPOQ2A.js} +41 -20
  11. package/dist/{chunk-ZUVYYR5T.js → chunk-7EFSUADA.js} +1 -0
  12. package/dist/{chunk-NS4UZRQ7.js → chunk-ABZA6R5S.js} +1 -1
  13. package/dist/{chunk-57XLH3ZR.js → chunk-ATEHMLKP.js} +23 -23
  14. package/dist/{chunk-VJTDG4BQ.js → chunk-HK6LPV6Z.js} +10 -1
  15. package/dist/{chunk-W3EC5XSA.js → chunk-J5W5Q2ZP.js} +337 -72
  16. package/dist/{chunk-TKYOYOYJ.js → chunk-KKSU7OZO.js} +653 -76
  17. package/dist/chunk-L3EHBOUX.js +0 -0
  18. package/dist/{chunk-C5LTJBI7.js → chunk-M6A4KFIG.js} +125 -226
  19. package/dist/{chunk-A74XSEW3.js → chunk-MIVX3GHD.js} +1 -1
  20. package/dist/{chunk-RGWBSZIO.js → chunk-ROKY5KS4.js} +23 -3
  21. package/dist/{chunk-LIP2K6KR.js → chunk-TM4TOEOX.js} +26 -8
  22. package/dist/{chunk-RAPBVYJY.js → chunk-UKT6OFLO.js} +125 -35
  23. package/dist/chunk-VA7MV4MZ.js +1073 -0
  24. package/dist/chunk-YEZDPUFY.js +840 -0
  25. package/dist/{chunk-DI7QXUQJ.js → chunk-ZXDE2XMU.js} +8 -5
  26. package/dist/graphql/objects/index.cjs +6 -3
  27. package/dist/graphql/objects/index.d.cts +6 -5
  28. package/dist/graphql/objects/index.d.ts +6 -5
  29. package/dist/graphql/objects/index.js +1 -1
  30. package/dist/{index-DEo_hdN3.d.cts → index-CFh4uWzi.d.cts} +60 -6
  31. package/dist/{index-BVY0yH_H.d.ts → index-OSDtPMmC.d.ts} +60 -6
  32. package/dist/index.cjs +3316 -954
  33. package/dist/index.d.cts +9 -8
  34. package/dist/index.d.ts +9 -8
  35. package/dist/index.js +48 -26
  36. package/dist/index.node.cjs +3316 -954
  37. package/dist/index.node.d.cts +9 -8
  38. package/dist/index.node.d.ts +9 -8
  39. package/dist/index.node.js +48 -26
  40. package/dist/native/index.cjs +3323 -961
  41. package/dist/native/index.d.cts +542 -260
  42. package/dist/native/index.d.ts +542 -260
  43. package/dist/native/index.js +3192 -838
  44. package/dist/{network-DobHpaV6.d.ts → network-BF2GYPye.d.ts} +9 -2
  45. package/dist/{network-GFGEHkS4.d.cts → network-BiwBmoOg.d.cts} +9 -2
  46. package/dist/proto/lrc20.d.cts +1 -1
  47. package/dist/proto/lrc20.d.ts +1 -1
  48. package/dist/proto/lrc20.js +2 -2
  49. package/dist/proto/spark.cjs +125 -226
  50. package/dist/proto/spark.d.cts +1 -1
  51. package/dist/proto/spark.d.ts +1 -1
  52. package/dist/proto/spark.js +3 -5
  53. package/dist/proto/spark_token.cjs +1364 -0
  54. package/dist/proto/spark_token.d.cts +209 -0
  55. package/dist/proto/spark_token.d.ts +209 -0
  56. package/dist/proto/spark_token.js +32 -0
  57. package/dist/{sdk-types-BuVMn2rX.d.cts → sdk-types-CfhdFnsA.d.cts} +1 -1
  58. package/dist/{sdk-types-BeI6DM_M.d.ts → sdk-types-MnQrHolg.d.ts} +1 -1
  59. package/dist/services/config.cjs +64 -40
  60. package/dist/services/config.d.cts +6 -5
  61. package/dist/services/config.d.ts +6 -5
  62. package/dist/services/config.js +7 -7
  63. package/dist/services/connection.cjs +1108 -306
  64. package/dist/services/connection.d.cts +10 -5
  65. package/dist/services/connection.d.ts +10 -5
  66. package/dist/services/connection.js +3 -2
  67. package/dist/services/index.cjs +1702 -488
  68. package/dist/services/index.d.cts +6 -5
  69. package/dist/services/index.d.ts +6 -5
  70. package/dist/services/index.js +16 -14
  71. package/dist/services/lrc-connection.d.cts +5 -5
  72. package/dist/services/lrc-connection.d.ts +5 -5
  73. package/dist/services/lrc-connection.js +3 -3
  74. package/dist/services/token-transactions.cjs +637 -247
  75. package/dist/services/token-transactions.d.cts +19 -8
  76. package/dist/services/token-transactions.d.ts +19 -8
  77. package/dist/services/token-transactions.js +5 -4
  78. package/dist/services/wallet-config.cjs +1 -0
  79. package/dist/services/wallet-config.d.cts +6 -5
  80. package/dist/services/wallet-config.d.ts +6 -5
  81. package/dist/services/wallet-config.js +1 -1
  82. package/dist/signer/signer.cjs +122 -35
  83. package/dist/signer/signer.d.cts +4 -3
  84. package/dist/signer/signer.d.ts +4 -3
  85. package/dist/signer/signer.js +8 -4
  86. package/dist/{signer-C1t40Wus.d.cts → signer-BhLS7SYR.d.cts} +35 -14
  87. package/dist/{signer-DFGw9RRp.d.ts → signer-CylxIujU.d.ts} +35 -14
  88. package/dist/{spark-DXYE9gMM.d.ts → spark-DjR1b3TC.d.cts} +13 -21
  89. package/dist/{spark-DXYE9gMM.d.cts → spark-DjR1b3TC.d.ts} +13 -21
  90. package/dist/types/index.cjs +130 -227
  91. package/dist/types/index.d.cts +6 -5
  92. package/dist/types/index.d.ts +6 -5
  93. package/dist/types/index.js +3 -3
  94. package/dist/utils/index.cjs +1169 -3
  95. package/dist/utils/index.d.cts +66 -6
  96. package/dist/utils/index.d.ts +66 -6
  97. package/dist/utils/index.js +35 -14
  98. package/package.json +6 -2
  99. package/src/address/address.ts +41 -6
  100. package/src/graphql/client.ts +15 -0
  101. package/src/graphql/objects/Transfer.ts +7 -0
  102. package/src/graphql/queries/Transfer.ts +10 -0
  103. package/src/proto/spark.ts +215 -337
  104. package/src/proto/spark_token.ts +1407 -0
  105. package/src/services/config.ts +4 -0
  106. package/src/services/connection.ts +37 -1
  107. package/src/services/deposit.ts +23 -5
  108. package/src/services/token-transactions.ts +426 -75
  109. package/src/services/transfer.ts +182 -11
  110. package/src/services/tree-creation.ts +29 -14
  111. package/src/services/wallet-config.ts +2 -0
  112. package/src/signer/signer.ts +190 -48
  113. package/src/spark-wallet/spark-wallet.ts +510 -6
  114. package/src/tests/integration/transfer.test.ts +186 -214
  115. package/src/tests/integration/tree-creation.test.ts +5 -1
  116. package/src/tests/signer.test.ts +34 -0
  117. package/src/tests/transaction.test.ts +12 -0
  118. package/src/tests/xchain-address.test.ts +28 -0
  119. package/src/utils/index.ts +2 -0
  120. package/src/utils/mempool.ts +26 -1
  121. package/src/utils/network.ts +15 -0
  122. package/src/utils/transaction.ts +51 -3
  123. package/src/utils/unilateral-exit.ts +729 -0
  124. package/src/utils/xchain-address.ts +36 -0
  125. package/dist/chunk-E5SL7XTO.js +0 -301
@@ -0,0 +1,1364 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/proto/spark_token.ts
21
+ var spark_token_exports = {};
22
+ __export(spark_token_exports, {
23
+ CommitTransactionRequest: () => CommitTransactionRequest,
24
+ CommitTransactionResponse: () => CommitTransactionResponse,
25
+ InputTtxoSignaturesPerOperator: () => InputTtxoSignaturesPerOperator,
26
+ SignatureWithIndex: () => SignatureWithIndex,
27
+ SparkTokenServiceDefinition: () => SparkTokenServiceDefinition,
28
+ StartTransactionRequest: () => StartTransactionRequest,
29
+ StartTransactionResponse: () => StartTransactionResponse,
30
+ TokenMintInput: () => TokenMintInput,
31
+ TokenOutput: () => TokenOutput,
32
+ TokenOutputToSpend: () => TokenOutputToSpend,
33
+ TokenTransaction: () => TokenTransaction,
34
+ TokenTransferInput: () => TokenTransferInput,
35
+ protobufPackage: () => protobufPackage
36
+ });
37
+ module.exports = __toCommonJS(spark_token_exports);
38
+
39
+ // buffer.js
40
+ var import_buffer = require("buffer");
41
+ if (typeof globalThis.Buffer === "undefined") {
42
+ globalThis.Buffer = import_buffer.Buffer;
43
+ }
44
+ if (typeof window !== "undefined") {
45
+ if (typeof window.global === "undefined") {
46
+ window.global = window;
47
+ }
48
+ if (typeof window.globalThis === "undefined") {
49
+ window.globalThis = window;
50
+ }
51
+ }
52
+
53
+ // src/proto/spark_token.ts
54
+ var import_wire5 = require("@bufbuild/protobuf/wire");
55
+
56
+ // src/proto/google/protobuf/timestamp.ts
57
+ var import_wire = require("@bufbuild/protobuf/wire");
58
+ function createBaseTimestamp() {
59
+ return { seconds: 0, nanos: 0 };
60
+ }
61
+ var Timestamp = {
62
+ encode(message, writer = new import_wire.BinaryWriter()) {
63
+ if (message.seconds !== 0) {
64
+ writer.uint32(8).int64(message.seconds);
65
+ }
66
+ if (message.nanos !== 0) {
67
+ writer.uint32(16).int32(message.nanos);
68
+ }
69
+ return writer;
70
+ },
71
+ decode(input, length) {
72
+ const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input);
73
+ let end = length === void 0 ? reader.len : reader.pos + length;
74
+ const message = createBaseTimestamp();
75
+ while (reader.pos < end) {
76
+ const tag = reader.uint32();
77
+ switch (tag >>> 3) {
78
+ case 1: {
79
+ if (tag !== 8) {
80
+ break;
81
+ }
82
+ message.seconds = longToNumber(reader.int64());
83
+ continue;
84
+ }
85
+ case 2: {
86
+ if (tag !== 16) {
87
+ break;
88
+ }
89
+ message.nanos = reader.int32();
90
+ continue;
91
+ }
92
+ }
93
+ if ((tag & 7) === 4 || tag === 0) {
94
+ break;
95
+ }
96
+ reader.skip(tag & 7);
97
+ }
98
+ return message;
99
+ },
100
+ fromJSON(object) {
101
+ return {
102
+ seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
103
+ nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
104
+ };
105
+ },
106
+ toJSON(message) {
107
+ const obj = {};
108
+ if (message.seconds !== 0) {
109
+ obj.seconds = Math.round(message.seconds);
110
+ }
111
+ if (message.nanos !== 0) {
112
+ obj.nanos = Math.round(message.nanos);
113
+ }
114
+ return obj;
115
+ },
116
+ create(base) {
117
+ return Timestamp.fromPartial(base ?? {});
118
+ },
119
+ fromPartial(object) {
120
+ const message = createBaseTimestamp();
121
+ message.seconds = object.seconds ?? 0;
122
+ message.nanos = object.nanos ?? 0;
123
+ return message;
124
+ }
125
+ };
126
+ function longToNumber(int64) {
127
+ const num = globalThis.Number(int64.toString());
128
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
129
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
130
+ }
131
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
132
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
133
+ }
134
+ return num;
135
+ }
136
+ function isSet(value) {
137
+ return value !== null && value !== void 0;
138
+ }
139
+
140
+ // src/proto/spark.ts
141
+ var import_wire4 = require("@bufbuild/protobuf/wire");
142
+
143
+ // src/proto/common.ts
144
+ var import_wire2 = require("@bufbuild/protobuf/wire");
145
+
146
+ // src/proto/google/protobuf/empty.ts
147
+ var import_wire3 = require("@bufbuild/protobuf/wire");
148
+
149
+ // src/proto/spark.ts
150
+ function networkFromJSON(object) {
151
+ switch (object) {
152
+ case 0:
153
+ case "UNSPECIFIED":
154
+ return 0 /* UNSPECIFIED */;
155
+ case 1:
156
+ case "MAINNET":
157
+ return 1 /* MAINNET */;
158
+ case 2:
159
+ case "REGTEST":
160
+ return 2 /* REGTEST */;
161
+ case 3:
162
+ case "TESTNET":
163
+ return 3 /* TESTNET */;
164
+ case 4:
165
+ case "SIGNET":
166
+ return 4 /* SIGNET */;
167
+ case -1:
168
+ case "UNRECOGNIZED":
169
+ default:
170
+ return -1 /* UNRECOGNIZED */;
171
+ }
172
+ }
173
+ function networkToJSON(object) {
174
+ switch (object) {
175
+ case 0 /* UNSPECIFIED */:
176
+ return "UNSPECIFIED";
177
+ case 1 /* MAINNET */:
178
+ return "MAINNET";
179
+ case 2 /* REGTEST */:
180
+ return "REGTEST";
181
+ case 3 /* TESTNET */:
182
+ return "TESTNET";
183
+ case 4 /* SIGNET */:
184
+ return "SIGNET";
185
+ case -1 /* UNRECOGNIZED */:
186
+ default:
187
+ return "UNRECOGNIZED";
188
+ }
189
+ }
190
+ function createBaseSigningKeyshare() {
191
+ return { ownerIdentifiers: [], threshold: 0, publicKey: new Uint8Array(0) };
192
+ }
193
+ var SigningKeyshare = {
194
+ encode(message, writer = new import_wire4.BinaryWriter()) {
195
+ for (const v of message.ownerIdentifiers) {
196
+ writer.uint32(10).string(v);
197
+ }
198
+ if (message.threshold !== 0) {
199
+ writer.uint32(16).uint32(message.threshold);
200
+ }
201
+ if (message.publicKey.length !== 0) {
202
+ writer.uint32(26).bytes(message.publicKey);
203
+ }
204
+ return writer;
205
+ },
206
+ decode(input, length) {
207
+ const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
208
+ let end = length === void 0 ? reader.len : reader.pos + length;
209
+ const message = createBaseSigningKeyshare();
210
+ while (reader.pos < end) {
211
+ const tag = reader.uint32();
212
+ switch (tag >>> 3) {
213
+ case 1: {
214
+ if (tag !== 10) {
215
+ break;
216
+ }
217
+ message.ownerIdentifiers.push(reader.string());
218
+ continue;
219
+ }
220
+ case 2: {
221
+ if (tag !== 16) {
222
+ break;
223
+ }
224
+ message.threshold = reader.uint32();
225
+ continue;
226
+ }
227
+ case 3: {
228
+ if (tag !== 26) {
229
+ break;
230
+ }
231
+ message.publicKey = reader.bytes();
232
+ continue;
233
+ }
234
+ }
235
+ if ((tag & 7) === 4 || tag === 0) {
236
+ break;
237
+ }
238
+ reader.skip(tag & 7);
239
+ }
240
+ return message;
241
+ },
242
+ fromJSON(object) {
243
+ return {
244
+ ownerIdentifiers: globalThis.Array.isArray(object?.ownerIdentifiers) ? object.ownerIdentifiers.map((e) => globalThis.String(e)) : [],
245
+ threshold: isSet2(object.threshold) ? globalThis.Number(object.threshold) : 0,
246
+ publicKey: isSet2(object.publicKey) ? bytesFromBase64(object.publicKey) : new Uint8Array(0)
247
+ };
248
+ },
249
+ toJSON(message) {
250
+ const obj = {};
251
+ if (message.ownerIdentifiers?.length) {
252
+ obj.ownerIdentifiers = message.ownerIdentifiers;
253
+ }
254
+ if (message.threshold !== 0) {
255
+ obj.threshold = Math.round(message.threshold);
256
+ }
257
+ if (message.publicKey.length !== 0) {
258
+ obj.publicKey = base64FromBytes(message.publicKey);
259
+ }
260
+ return obj;
261
+ },
262
+ create(base) {
263
+ return SigningKeyshare.fromPartial(base ?? {});
264
+ },
265
+ fromPartial(object) {
266
+ const message = createBaseSigningKeyshare();
267
+ message.ownerIdentifiers = object.ownerIdentifiers?.map((e) => e) || [];
268
+ message.threshold = object.threshold ?? 0;
269
+ message.publicKey = object.publicKey ?? new Uint8Array(0);
270
+ return message;
271
+ }
272
+ };
273
+ function bytesFromBase64(b64) {
274
+ if (globalThis.Buffer) {
275
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
276
+ } else {
277
+ const bin = globalThis.atob(b64);
278
+ const arr = new Uint8Array(bin.length);
279
+ for (let i = 0; i < bin.length; ++i) {
280
+ arr[i] = bin.charCodeAt(i);
281
+ }
282
+ return arr;
283
+ }
284
+ }
285
+ function base64FromBytes(arr) {
286
+ if (globalThis.Buffer) {
287
+ return globalThis.Buffer.from(arr).toString("base64");
288
+ } else {
289
+ const bin = [];
290
+ arr.forEach((byte) => {
291
+ bin.push(globalThis.String.fromCharCode(byte));
292
+ });
293
+ return globalThis.btoa(bin.join(""));
294
+ }
295
+ }
296
+ function isSet2(value) {
297
+ return value !== null && value !== void 0;
298
+ }
299
+
300
+ // src/proto/spark_token.ts
301
+ var protobufPackage = "spark_token";
302
+ function createBaseTokenOutputToSpend() {
303
+ return { prevTokenTransactionHash: new Uint8Array(0), prevTokenTransactionVout: 0 };
304
+ }
305
+ var TokenOutputToSpend = {
306
+ encode(message, writer = new import_wire5.BinaryWriter()) {
307
+ if (message.prevTokenTransactionHash.length !== 0) {
308
+ writer.uint32(10).bytes(message.prevTokenTransactionHash);
309
+ }
310
+ if (message.prevTokenTransactionVout !== 0) {
311
+ writer.uint32(16).uint32(message.prevTokenTransactionVout);
312
+ }
313
+ return writer;
314
+ },
315
+ decode(input, length) {
316
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
317
+ let end = length === void 0 ? reader.len : reader.pos + length;
318
+ const message = createBaseTokenOutputToSpend();
319
+ while (reader.pos < end) {
320
+ const tag = reader.uint32();
321
+ switch (tag >>> 3) {
322
+ case 1: {
323
+ if (tag !== 10) {
324
+ break;
325
+ }
326
+ message.prevTokenTransactionHash = reader.bytes();
327
+ continue;
328
+ }
329
+ case 2: {
330
+ if (tag !== 16) {
331
+ break;
332
+ }
333
+ message.prevTokenTransactionVout = reader.uint32();
334
+ continue;
335
+ }
336
+ }
337
+ if ((tag & 7) === 4 || tag === 0) {
338
+ break;
339
+ }
340
+ reader.skip(tag & 7);
341
+ }
342
+ return message;
343
+ },
344
+ fromJSON(object) {
345
+ return {
346
+ prevTokenTransactionHash: isSet3(object.prevTokenTransactionHash) ? bytesFromBase642(object.prevTokenTransactionHash) : new Uint8Array(0),
347
+ prevTokenTransactionVout: isSet3(object.prevTokenTransactionVout) ? globalThis.Number(object.prevTokenTransactionVout) : 0
348
+ };
349
+ },
350
+ toJSON(message) {
351
+ const obj = {};
352
+ if (message.prevTokenTransactionHash.length !== 0) {
353
+ obj.prevTokenTransactionHash = base64FromBytes2(message.prevTokenTransactionHash);
354
+ }
355
+ if (message.prevTokenTransactionVout !== 0) {
356
+ obj.prevTokenTransactionVout = Math.round(message.prevTokenTransactionVout);
357
+ }
358
+ return obj;
359
+ },
360
+ create(base) {
361
+ return TokenOutputToSpend.fromPartial(base ?? {});
362
+ },
363
+ fromPartial(object) {
364
+ const message = createBaseTokenOutputToSpend();
365
+ message.prevTokenTransactionHash = object.prevTokenTransactionHash ?? new Uint8Array(0);
366
+ message.prevTokenTransactionVout = object.prevTokenTransactionVout ?? 0;
367
+ return message;
368
+ }
369
+ };
370
+ function createBaseTokenTransferInput() {
371
+ return { outputsToSpend: [] };
372
+ }
373
+ var TokenTransferInput = {
374
+ encode(message, writer = new import_wire5.BinaryWriter()) {
375
+ for (const v of message.outputsToSpend) {
376
+ TokenOutputToSpend.encode(v, writer.uint32(10).fork()).join();
377
+ }
378
+ return writer;
379
+ },
380
+ decode(input, length) {
381
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
382
+ let end = length === void 0 ? reader.len : reader.pos + length;
383
+ const message = createBaseTokenTransferInput();
384
+ while (reader.pos < end) {
385
+ const tag = reader.uint32();
386
+ switch (tag >>> 3) {
387
+ case 1: {
388
+ if (tag !== 10) {
389
+ break;
390
+ }
391
+ message.outputsToSpend.push(TokenOutputToSpend.decode(reader, reader.uint32()));
392
+ continue;
393
+ }
394
+ }
395
+ if ((tag & 7) === 4 || tag === 0) {
396
+ break;
397
+ }
398
+ reader.skip(tag & 7);
399
+ }
400
+ return message;
401
+ },
402
+ fromJSON(object) {
403
+ return {
404
+ outputsToSpend: globalThis.Array.isArray(object?.outputsToSpend) ? object.outputsToSpend.map((e) => TokenOutputToSpend.fromJSON(e)) : []
405
+ };
406
+ },
407
+ toJSON(message) {
408
+ const obj = {};
409
+ if (message.outputsToSpend?.length) {
410
+ obj.outputsToSpend = message.outputsToSpend.map((e) => TokenOutputToSpend.toJSON(e));
411
+ }
412
+ return obj;
413
+ },
414
+ create(base) {
415
+ return TokenTransferInput.fromPartial(base ?? {});
416
+ },
417
+ fromPartial(object) {
418
+ const message = createBaseTokenTransferInput();
419
+ message.outputsToSpend = object.outputsToSpend?.map((e) => TokenOutputToSpend.fromPartial(e)) || [];
420
+ return message;
421
+ }
422
+ };
423
+ function createBaseTokenMintInput() {
424
+ return { issuerPublicKey: new Uint8Array(0), issuerProvidedTimestamp: 0 };
425
+ }
426
+ var TokenMintInput = {
427
+ encode(message, writer = new import_wire5.BinaryWriter()) {
428
+ if (message.issuerPublicKey.length !== 0) {
429
+ writer.uint32(10).bytes(message.issuerPublicKey);
430
+ }
431
+ if (message.issuerProvidedTimestamp !== 0) {
432
+ writer.uint32(16).uint64(message.issuerProvidedTimestamp);
433
+ }
434
+ return writer;
435
+ },
436
+ decode(input, length) {
437
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
438
+ let end = length === void 0 ? reader.len : reader.pos + length;
439
+ const message = createBaseTokenMintInput();
440
+ while (reader.pos < end) {
441
+ const tag = reader.uint32();
442
+ switch (tag >>> 3) {
443
+ case 1: {
444
+ if (tag !== 10) {
445
+ break;
446
+ }
447
+ message.issuerPublicKey = reader.bytes();
448
+ continue;
449
+ }
450
+ case 2: {
451
+ if (tag !== 16) {
452
+ break;
453
+ }
454
+ message.issuerProvidedTimestamp = longToNumber2(reader.uint64());
455
+ continue;
456
+ }
457
+ }
458
+ if ((tag & 7) === 4 || tag === 0) {
459
+ break;
460
+ }
461
+ reader.skip(tag & 7);
462
+ }
463
+ return message;
464
+ },
465
+ fromJSON(object) {
466
+ return {
467
+ issuerPublicKey: isSet3(object.issuerPublicKey) ? bytesFromBase642(object.issuerPublicKey) : new Uint8Array(0),
468
+ issuerProvidedTimestamp: isSet3(object.issuerProvidedTimestamp) ? globalThis.Number(object.issuerProvidedTimestamp) : 0
469
+ };
470
+ },
471
+ toJSON(message) {
472
+ const obj = {};
473
+ if (message.issuerPublicKey.length !== 0) {
474
+ obj.issuerPublicKey = base64FromBytes2(message.issuerPublicKey);
475
+ }
476
+ if (message.issuerProvidedTimestamp !== 0) {
477
+ obj.issuerProvidedTimestamp = Math.round(message.issuerProvidedTimestamp);
478
+ }
479
+ return obj;
480
+ },
481
+ create(base) {
482
+ return TokenMintInput.fromPartial(base ?? {});
483
+ },
484
+ fromPartial(object) {
485
+ const message = createBaseTokenMintInput();
486
+ message.issuerPublicKey = object.issuerPublicKey ?? new Uint8Array(0);
487
+ message.issuerProvidedTimestamp = object.issuerProvidedTimestamp ?? 0;
488
+ return message;
489
+ }
490
+ };
491
+ function createBaseTokenOutput() {
492
+ return {
493
+ id: void 0,
494
+ ownerPublicKey: new Uint8Array(0),
495
+ revocationCommitment: void 0,
496
+ withdrawBondSats: void 0,
497
+ withdrawRelativeBlockLocktime: void 0,
498
+ tokenPublicKey: new Uint8Array(0),
499
+ tokenAmount: new Uint8Array(0)
500
+ };
501
+ }
502
+ var TokenOutput = {
503
+ encode(message, writer = new import_wire5.BinaryWriter()) {
504
+ if (message.id !== void 0) {
505
+ writer.uint32(10).string(message.id);
506
+ }
507
+ if (message.ownerPublicKey.length !== 0) {
508
+ writer.uint32(18).bytes(message.ownerPublicKey);
509
+ }
510
+ if (message.revocationCommitment !== void 0) {
511
+ writer.uint32(26).bytes(message.revocationCommitment);
512
+ }
513
+ if (message.withdrawBondSats !== void 0) {
514
+ writer.uint32(32).uint64(message.withdrawBondSats);
515
+ }
516
+ if (message.withdrawRelativeBlockLocktime !== void 0) {
517
+ writer.uint32(40).uint64(message.withdrawRelativeBlockLocktime);
518
+ }
519
+ if (message.tokenPublicKey.length !== 0) {
520
+ writer.uint32(50).bytes(message.tokenPublicKey);
521
+ }
522
+ if (message.tokenAmount.length !== 0) {
523
+ writer.uint32(58).bytes(message.tokenAmount);
524
+ }
525
+ return writer;
526
+ },
527
+ decode(input, length) {
528
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
529
+ let end = length === void 0 ? reader.len : reader.pos + length;
530
+ const message = createBaseTokenOutput();
531
+ while (reader.pos < end) {
532
+ const tag = reader.uint32();
533
+ switch (tag >>> 3) {
534
+ case 1: {
535
+ if (tag !== 10) {
536
+ break;
537
+ }
538
+ message.id = reader.string();
539
+ continue;
540
+ }
541
+ case 2: {
542
+ if (tag !== 18) {
543
+ break;
544
+ }
545
+ message.ownerPublicKey = reader.bytes();
546
+ continue;
547
+ }
548
+ case 3: {
549
+ if (tag !== 26) {
550
+ break;
551
+ }
552
+ message.revocationCommitment = reader.bytes();
553
+ continue;
554
+ }
555
+ case 4: {
556
+ if (tag !== 32) {
557
+ break;
558
+ }
559
+ message.withdrawBondSats = longToNumber2(reader.uint64());
560
+ continue;
561
+ }
562
+ case 5: {
563
+ if (tag !== 40) {
564
+ break;
565
+ }
566
+ message.withdrawRelativeBlockLocktime = longToNumber2(reader.uint64());
567
+ continue;
568
+ }
569
+ case 6: {
570
+ if (tag !== 50) {
571
+ break;
572
+ }
573
+ message.tokenPublicKey = reader.bytes();
574
+ continue;
575
+ }
576
+ case 7: {
577
+ if (tag !== 58) {
578
+ break;
579
+ }
580
+ message.tokenAmount = reader.bytes();
581
+ continue;
582
+ }
583
+ }
584
+ if ((tag & 7) === 4 || tag === 0) {
585
+ break;
586
+ }
587
+ reader.skip(tag & 7);
588
+ }
589
+ return message;
590
+ },
591
+ fromJSON(object) {
592
+ return {
593
+ id: isSet3(object.id) ? globalThis.String(object.id) : void 0,
594
+ ownerPublicKey: isSet3(object.ownerPublicKey) ? bytesFromBase642(object.ownerPublicKey) : new Uint8Array(0),
595
+ revocationCommitment: isSet3(object.revocationCommitment) ? bytesFromBase642(object.revocationCommitment) : void 0,
596
+ withdrawBondSats: isSet3(object.withdrawBondSats) ? globalThis.Number(object.withdrawBondSats) : void 0,
597
+ withdrawRelativeBlockLocktime: isSet3(object.withdrawRelativeBlockLocktime) ? globalThis.Number(object.withdrawRelativeBlockLocktime) : void 0,
598
+ tokenPublicKey: isSet3(object.tokenPublicKey) ? bytesFromBase642(object.tokenPublicKey) : new Uint8Array(0),
599
+ tokenAmount: isSet3(object.tokenAmount) ? bytesFromBase642(object.tokenAmount) : new Uint8Array(0)
600
+ };
601
+ },
602
+ toJSON(message) {
603
+ const obj = {};
604
+ if (message.id !== void 0) {
605
+ obj.id = message.id;
606
+ }
607
+ if (message.ownerPublicKey.length !== 0) {
608
+ obj.ownerPublicKey = base64FromBytes2(message.ownerPublicKey);
609
+ }
610
+ if (message.revocationCommitment !== void 0) {
611
+ obj.revocationCommitment = base64FromBytes2(message.revocationCommitment);
612
+ }
613
+ if (message.withdrawBondSats !== void 0) {
614
+ obj.withdrawBondSats = Math.round(message.withdrawBondSats);
615
+ }
616
+ if (message.withdrawRelativeBlockLocktime !== void 0) {
617
+ obj.withdrawRelativeBlockLocktime = Math.round(message.withdrawRelativeBlockLocktime);
618
+ }
619
+ if (message.tokenPublicKey.length !== 0) {
620
+ obj.tokenPublicKey = base64FromBytes2(message.tokenPublicKey);
621
+ }
622
+ if (message.tokenAmount.length !== 0) {
623
+ obj.tokenAmount = base64FromBytes2(message.tokenAmount);
624
+ }
625
+ return obj;
626
+ },
627
+ create(base) {
628
+ return TokenOutput.fromPartial(base ?? {});
629
+ },
630
+ fromPartial(object) {
631
+ const message = createBaseTokenOutput();
632
+ message.id = object.id ?? void 0;
633
+ message.ownerPublicKey = object.ownerPublicKey ?? new Uint8Array(0);
634
+ message.revocationCommitment = object.revocationCommitment ?? void 0;
635
+ message.withdrawBondSats = object.withdrawBondSats ?? void 0;
636
+ message.withdrawRelativeBlockLocktime = object.withdrawRelativeBlockLocktime ?? void 0;
637
+ message.tokenPublicKey = object.tokenPublicKey ?? new Uint8Array(0);
638
+ message.tokenAmount = object.tokenAmount ?? new Uint8Array(0);
639
+ return message;
640
+ }
641
+ };
642
+ function createBaseTokenTransaction() {
643
+ return {
644
+ version: 0,
645
+ tokenInputs: void 0,
646
+ tokenOutputs: [],
647
+ sparkOperatorIdentityPublicKeys: [],
648
+ expiryTime: void 0,
649
+ network: 0
650
+ };
651
+ }
652
+ var TokenTransaction = {
653
+ encode(message, writer = new import_wire5.BinaryWriter()) {
654
+ if (message.version !== 0) {
655
+ writer.uint32(8).uint32(message.version);
656
+ }
657
+ switch (message.tokenInputs?.$case) {
658
+ case "mintInput":
659
+ TokenMintInput.encode(message.tokenInputs.mintInput, writer.uint32(18).fork()).join();
660
+ break;
661
+ case "transferInput":
662
+ TokenTransferInput.encode(message.tokenInputs.transferInput, writer.uint32(26).fork()).join();
663
+ break;
664
+ }
665
+ for (const v of message.tokenOutputs) {
666
+ TokenOutput.encode(v, writer.uint32(34).fork()).join();
667
+ }
668
+ for (const v of message.sparkOperatorIdentityPublicKeys) {
669
+ writer.uint32(42).bytes(v);
670
+ }
671
+ if (message.expiryTime !== void 0) {
672
+ Timestamp.encode(toTimestamp(message.expiryTime), writer.uint32(50).fork()).join();
673
+ }
674
+ if (message.network !== 0) {
675
+ writer.uint32(56).int32(message.network);
676
+ }
677
+ return writer;
678
+ },
679
+ decode(input, length) {
680
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
681
+ let end = length === void 0 ? reader.len : reader.pos + length;
682
+ const message = createBaseTokenTransaction();
683
+ while (reader.pos < end) {
684
+ const tag = reader.uint32();
685
+ switch (tag >>> 3) {
686
+ case 1: {
687
+ if (tag !== 8) {
688
+ break;
689
+ }
690
+ message.version = reader.uint32();
691
+ continue;
692
+ }
693
+ case 2: {
694
+ if (tag !== 18) {
695
+ break;
696
+ }
697
+ message.tokenInputs = { $case: "mintInput", mintInput: TokenMintInput.decode(reader, reader.uint32()) };
698
+ continue;
699
+ }
700
+ case 3: {
701
+ if (tag !== 26) {
702
+ break;
703
+ }
704
+ message.tokenInputs = {
705
+ $case: "transferInput",
706
+ transferInput: TokenTransferInput.decode(reader, reader.uint32())
707
+ };
708
+ continue;
709
+ }
710
+ case 4: {
711
+ if (tag !== 34) {
712
+ break;
713
+ }
714
+ message.tokenOutputs.push(TokenOutput.decode(reader, reader.uint32()));
715
+ continue;
716
+ }
717
+ case 5: {
718
+ if (tag !== 42) {
719
+ break;
720
+ }
721
+ message.sparkOperatorIdentityPublicKeys.push(reader.bytes());
722
+ continue;
723
+ }
724
+ case 6: {
725
+ if (tag !== 50) {
726
+ break;
727
+ }
728
+ message.expiryTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
729
+ continue;
730
+ }
731
+ case 7: {
732
+ if (tag !== 56) {
733
+ break;
734
+ }
735
+ message.network = reader.int32();
736
+ continue;
737
+ }
738
+ }
739
+ if ((tag & 7) === 4 || tag === 0) {
740
+ break;
741
+ }
742
+ reader.skip(tag & 7);
743
+ }
744
+ return message;
745
+ },
746
+ fromJSON(object) {
747
+ return {
748
+ version: isSet3(object.version) ? globalThis.Number(object.version) : 0,
749
+ tokenInputs: isSet3(object.mintInput) ? { $case: "mintInput", mintInput: TokenMintInput.fromJSON(object.mintInput) } : isSet3(object.transferInput) ? { $case: "transferInput", transferInput: TokenTransferInput.fromJSON(object.transferInput) } : void 0,
750
+ tokenOutputs: globalThis.Array.isArray(object?.tokenOutputs) ? object.tokenOutputs.map((e) => TokenOutput.fromJSON(e)) : [],
751
+ sparkOperatorIdentityPublicKeys: globalThis.Array.isArray(object?.sparkOperatorIdentityPublicKeys) ? object.sparkOperatorIdentityPublicKeys.map((e) => bytesFromBase642(e)) : [],
752
+ expiryTime: isSet3(object.expiryTime) ? fromJsonTimestamp(object.expiryTime) : void 0,
753
+ network: isSet3(object.network) ? networkFromJSON(object.network) : 0
754
+ };
755
+ },
756
+ toJSON(message) {
757
+ const obj = {};
758
+ if (message.version !== 0) {
759
+ obj.version = Math.round(message.version);
760
+ }
761
+ if (message.tokenInputs?.$case === "mintInput") {
762
+ obj.mintInput = TokenMintInput.toJSON(message.tokenInputs.mintInput);
763
+ } else if (message.tokenInputs?.$case === "transferInput") {
764
+ obj.transferInput = TokenTransferInput.toJSON(message.tokenInputs.transferInput);
765
+ }
766
+ if (message.tokenOutputs?.length) {
767
+ obj.tokenOutputs = message.tokenOutputs.map((e) => TokenOutput.toJSON(e));
768
+ }
769
+ if (message.sparkOperatorIdentityPublicKeys?.length) {
770
+ obj.sparkOperatorIdentityPublicKeys = message.sparkOperatorIdentityPublicKeys.map((e) => base64FromBytes2(e));
771
+ }
772
+ if (message.expiryTime !== void 0) {
773
+ obj.expiryTime = message.expiryTime.toISOString();
774
+ }
775
+ if (message.network !== 0) {
776
+ obj.network = networkToJSON(message.network);
777
+ }
778
+ return obj;
779
+ },
780
+ create(base) {
781
+ return TokenTransaction.fromPartial(base ?? {});
782
+ },
783
+ fromPartial(object) {
784
+ const message = createBaseTokenTransaction();
785
+ message.version = object.version ?? 0;
786
+ switch (object.tokenInputs?.$case) {
787
+ case "mintInput": {
788
+ if (object.tokenInputs?.mintInput !== void 0 && object.tokenInputs?.mintInput !== null) {
789
+ message.tokenInputs = {
790
+ $case: "mintInput",
791
+ mintInput: TokenMintInput.fromPartial(object.tokenInputs.mintInput)
792
+ };
793
+ }
794
+ break;
795
+ }
796
+ case "transferInput": {
797
+ if (object.tokenInputs?.transferInput !== void 0 && object.tokenInputs?.transferInput !== null) {
798
+ message.tokenInputs = {
799
+ $case: "transferInput",
800
+ transferInput: TokenTransferInput.fromPartial(object.tokenInputs.transferInput)
801
+ };
802
+ }
803
+ break;
804
+ }
805
+ }
806
+ message.tokenOutputs = object.tokenOutputs?.map((e) => TokenOutput.fromPartial(e)) || [];
807
+ message.sparkOperatorIdentityPublicKeys = object.sparkOperatorIdentityPublicKeys?.map((e) => e) || [];
808
+ message.expiryTime = object.expiryTime ?? void 0;
809
+ message.network = object.network ?? 0;
810
+ return message;
811
+ }
812
+ };
813
+ function createBaseSignatureWithIndex() {
814
+ return { signature: new Uint8Array(0), inputIndex: 0 };
815
+ }
816
+ var SignatureWithIndex = {
817
+ encode(message, writer = new import_wire5.BinaryWriter()) {
818
+ if (message.signature.length !== 0) {
819
+ writer.uint32(10).bytes(message.signature);
820
+ }
821
+ if (message.inputIndex !== 0) {
822
+ writer.uint32(16).uint32(message.inputIndex);
823
+ }
824
+ return writer;
825
+ },
826
+ decode(input, length) {
827
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
828
+ let end = length === void 0 ? reader.len : reader.pos + length;
829
+ const message = createBaseSignatureWithIndex();
830
+ while (reader.pos < end) {
831
+ const tag = reader.uint32();
832
+ switch (tag >>> 3) {
833
+ case 1: {
834
+ if (tag !== 10) {
835
+ break;
836
+ }
837
+ message.signature = reader.bytes();
838
+ continue;
839
+ }
840
+ case 2: {
841
+ if (tag !== 16) {
842
+ break;
843
+ }
844
+ message.inputIndex = reader.uint32();
845
+ continue;
846
+ }
847
+ }
848
+ if ((tag & 7) === 4 || tag === 0) {
849
+ break;
850
+ }
851
+ reader.skip(tag & 7);
852
+ }
853
+ return message;
854
+ },
855
+ fromJSON(object) {
856
+ return {
857
+ signature: isSet3(object.signature) ? bytesFromBase642(object.signature) : new Uint8Array(0),
858
+ inputIndex: isSet3(object.inputIndex) ? globalThis.Number(object.inputIndex) : 0
859
+ };
860
+ },
861
+ toJSON(message) {
862
+ const obj = {};
863
+ if (message.signature.length !== 0) {
864
+ obj.signature = base64FromBytes2(message.signature);
865
+ }
866
+ if (message.inputIndex !== 0) {
867
+ obj.inputIndex = Math.round(message.inputIndex);
868
+ }
869
+ return obj;
870
+ },
871
+ create(base) {
872
+ return SignatureWithIndex.fromPartial(base ?? {});
873
+ },
874
+ fromPartial(object) {
875
+ const message = createBaseSignatureWithIndex();
876
+ message.signature = object.signature ?? new Uint8Array(0);
877
+ message.inputIndex = object.inputIndex ?? 0;
878
+ return message;
879
+ }
880
+ };
881
+ function createBaseInputTtxoSignaturesPerOperator() {
882
+ return { ttxoSignatures: [], operatorIdentityPublicKey: new Uint8Array(0) };
883
+ }
884
+ var InputTtxoSignaturesPerOperator = {
885
+ encode(message, writer = new import_wire5.BinaryWriter()) {
886
+ for (const v of message.ttxoSignatures) {
887
+ SignatureWithIndex.encode(v, writer.uint32(10).fork()).join();
888
+ }
889
+ if (message.operatorIdentityPublicKey.length !== 0) {
890
+ writer.uint32(18).bytes(message.operatorIdentityPublicKey);
891
+ }
892
+ return writer;
893
+ },
894
+ decode(input, length) {
895
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
896
+ let end = length === void 0 ? reader.len : reader.pos + length;
897
+ const message = createBaseInputTtxoSignaturesPerOperator();
898
+ while (reader.pos < end) {
899
+ const tag = reader.uint32();
900
+ switch (tag >>> 3) {
901
+ case 1: {
902
+ if (tag !== 10) {
903
+ break;
904
+ }
905
+ message.ttxoSignatures.push(SignatureWithIndex.decode(reader, reader.uint32()));
906
+ continue;
907
+ }
908
+ case 2: {
909
+ if (tag !== 18) {
910
+ break;
911
+ }
912
+ message.operatorIdentityPublicKey = reader.bytes();
913
+ continue;
914
+ }
915
+ }
916
+ if ((tag & 7) === 4 || tag === 0) {
917
+ break;
918
+ }
919
+ reader.skip(tag & 7);
920
+ }
921
+ return message;
922
+ },
923
+ fromJSON(object) {
924
+ return {
925
+ ttxoSignatures: globalThis.Array.isArray(object?.ttxoSignatures) ? object.ttxoSignatures.map((e) => SignatureWithIndex.fromJSON(e)) : [],
926
+ operatorIdentityPublicKey: isSet3(object.operatorIdentityPublicKey) ? bytesFromBase642(object.operatorIdentityPublicKey) : new Uint8Array(0)
927
+ };
928
+ },
929
+ toJSON(message) {
930
+ const obj = {};
931
+ if (message.ttxoSignatures?.length) {
932
+ obj.ttxoSignatures = message.ttxoSignatures.map((e) => SignatureWithIndex.toJSON(e));
933
+ }
934
+ if (message.operatorIdentityPublicKey.length !== 0) {
935
+ obj.operatorIdentityPublicKey = base64FromBytes2(message.operatorIdentityPublicKey);
936
+ }
937
+ return obj;
938
+ },
939
+ create(base) {
940
+ return InputTtxoSignaturesPerOperator.fromPartial(base ?? {});
941
+ },
942
+ fromPartial(object) {
943
+ const message = createBaseInputTtxoSignaturesPerOperator();
944
+ message.ttxoSignatures = object.ttxoSignatures?.map((e) => SignatureWithIndex.fromPartial(e)) || [];
945
+ message.operatorIdentityPublicKey = object.operatorIdentityPublicKey ?? new Uint8Array(0);
946
+ return message;
947
+ }
948
+ };
949
+ function createBaseStartTransactionRequest() {
950
+ return {
951
+ identityPublicKey: new Uint8Array(0),
952
+ partialTokenTransaction: void 0,
953
+ partialTokenTransactionOwnerSignatures: [],
954
+ validityDurationSeconds: 0
955
+ };
956
+ }
957
+ var StartTransactionRequest = {
958
+ encode(message, writer = new import_wire5.BinaryWriter()) {
959
+ if (message.identityPublicKey.length !== 0) {
960
+ writer.uint32(10).bytes(message.identityPublicKey);
961
+ }
962
+ if (message.partialTokenTransaction !== void 0) {
963
+ TokenTransaction.encode(message.partialTokenTransaction, writer.uint32(18).fork()).join();
964
+ }
965
+ for (const v of message.partialTokenTransactionOwnerSignatures) {
966
+ SignatureWithIndex.encode(v, writer.uint32(26).fork()).join();
967
+ }
968
+ if (message.validityDurationSeconds !== 0) {
969
+ writer.uint32(32).uint64(message.validityDurationSeconds);
970
+ }
971
+ return writer;
972
+ },
973
+ decode(input, length) {
974
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
975
+ let end = length === void 0 ? reader.len : reader.pos + length;
976
+ const message = createBaseStartTransactionRequest();
977
+ while (reader.pos < end) {
978
+ const tag = reader.uint32();
979
+ switch (tag >>> 3) {
980
+ case 1: {
981
+ if (tag !== 10) {
982
+ break;
983
+ }
984
+ message.identityPublicKey = reader.bytes();
985
+ continue;
986
+ }
987
+ case 2: {
988
+ if (tag !== 18) {
989
+ break;
990
+ }
991
+ message.partialTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
992
+ continue;
993
+ }
994
+ case 3: {
995
+ if (tag !== 26) {
996
+ break;
997
+ }
998
+ message.partialTokenTransactionOwnerSignatures.push(SignatureWithIndex.decode(reader, reader.uint32()));
999
+ continue;
1000
+ }
1001
+ case 4: {
1002
+ if (tag !== 32) {
1003
+ break;
1004
+ }
1005
+ message.validityDurationSeconds = longToNumber2(reader.uint64());
1006
+ continue;
1007
+ }
1008
+ }
1009
+ if ((tag & 7) === 4 || tag === 0) {
1010
+ break;
1011
+ }
1012
+ reader.skip(tag & 7);
1013
+ }
1014
+ return message;
1015
+ },
1016
+ fromJSON(object) {
1017
+ return {
1018
+ identityPublicKey: isSet3(object.identityPublicKey) ? bytesFromBase642(object.identityPublicKey) : new Uint8Array(0),
1019
+ partialTokenTransaction: isSet3(object.partialTokenTransaction) ? TokenTransaction.fromJSON(object.partialTokenTransaction) : void 0,
1020
+ partialTokenTransactionOwnerSignatures: globalThis.Array.isArray(object?.partialTokenTransactionOwnerSignatures) ? object.partialTokenTransactionOwnerSignatures.map((e) => SignatureWithIndex.fromJSON(e)) : [],
1021
+ validityDurationSeconds: isSet3(object.validityDurationSeconds) ? globalThis.Number(object.validityDurationSeconds) : 0
1022
+ };
1023
+ },
1024
+ toJSON(message) {
1025
+ const obj = {};
1026
+ if (message.identityPublicKey.length !== 0) {
1027
+ obj.identityPublicKey = base64FromBytes2(message.identityPublicKey);
1028
+ }
1029
+ if (message.partialTokenTransaction !== void 0) {
1030
+ obj.partialTokenTransaction = TokenTransaction.toJSON(message.partialTokenTransaction);
1031
+ }
1032
+ if (message.partialTokenTransactionOwnerSignatures?.length) {
1033
+ obj.partialTokenTransactionOwnerSignatures = message.partialTokenTransactionOwnerSignatures.map(
1034
+ (e) => SignatureWithIndex.toJSON(e)
1035
+ );
1036
+ }
1037
+ if (message.validityDurationSeconds !== 0) {
1038
+ obj.validityDurationSeconds = Math.round(message.validityDurationSeconds);
1039
+ }
1040
+ return obj;
1041
+ },
1042
+ create(base) {
1043
+ return StartTransactionRequest.fromPartial(base ?? {});
1044
+ },
1045
+ fromPartial(object) {
1046
+ const message = createBaseStartTransactionRequest();
1047
+ message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
1048
+ message.partialTokenTransaction = object.partialTokenTransaction !== void 0 && object.partialTokenTransaction !== null ? TokenTransaction.fromPartial(object.partialTokenTransaction) : void 0;
1049
+ message.partialTokenTransactionOwnerSignatures = object.partialTokenTransactionOwnerSignatures?.map((e) => SignatureWithIndex.fromPartial(e)) || [];
1050
+ message.validityDurationSeconds = object.validityDurationSeconds ?? 0;
1051
+ return message;
1052
+ }
1053
+ };
1054
+ function createBaseStartTransactionResponse() {
1055
+ return { finalTokenTransaction: void 0, keyshareInfo: void 0 };
1056
+ }
1057
+ var StartTransactionResponse = {
1058
+ encode(message, writer = new import_wire5.BinaryWriter()) {
1059
+ if (message.finalTokenTransaction !== void 0) {
1060
+ TokenTransaction.encode(message.finalTokenTransaction, writer.uint32(10).fork()).join();
1061
+ }
1062
+ if (message.keyshareInfo !== void 0) {
1063
+ SigningKeyshare.encode(message.keyshareInfo, writer.uint32(18).fork()).join();
1064
+ }
1065
+ return writer;
1066
+ },
1067
+ decode(input, length) {
1068
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
1069
+ let end = length === void 0 ? reader.len : reader.pos + length;
1070
+ const message = createBaseStartTransactionResponse();
1071
+ while (reader.pos < end) {
1072
+ const tag = reader.uint32();
1073
+ switch (tag >>> 3) {
1074
+ case 1: {
1075
+ if (tag !== 10) {
1076
+ break;
1077
+ }
1078
+ message.finalTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
1079
+ continue;
1080
+ }
1081
+ case 2: {
1082
+ if (tag !== 18) {
1083
+ break;
1084
+ }
1085
+ message.keyshareInfo = SigningKeyshare.decode(reader, reader.uint32());
1086
+ continue;
1087
+ }
1088
+ }
1089
+ if ((tag & 7) === 4 || tag === 0) {
1090
+ break;
1091
+ }
1092
+ reader.skip(tag & 7);
1093
+ }
1094
+ return message;
1095
+ },
1096
+ fromJSON(object) {
1097
+ return {
1098
+ finalTokenTransaction: isSet3(object.finalTokenTransaction) ? TokenTransaction.fromJSON(object.finalTokenTransaction) : void 0,
1099
+ keyshareInfo: isSet3(object.keyshareInfo) ? SigningKeyshare.fromJSON(object.keyshareInfo) : void 0
1100
+ };
1101
+ },
1102
+ toJSON(message) {
1103
+ const obj = {};
1104
+ if (message.finalTokenTransaction !== void 0) {
1105
+ obj.finalTokenTransaction = TokenTransaction.toJSON(message.finalTokenTransaction);
1106
+ }
1107
+ if (message.keyshareInfo !== void 0) {
1108
+ obj.keyshareInfo = SigningKeyshare.toJSON(message.keyshareInfo);
1109
+ }
1110
+ return obj;
1111
+ },
1112
+ create(base) {
1113
+ return StartTransactionResponse.fromPartial(base ?? {});
1114
+ },
1115
+ fromPartial(object) {
1116
+ const message = createBaseStartTransactionResponse();
1117
+ message.finalTokenTransaction = object.finalTokenTransaction !== void 0 && object.finalTokenTransaction !== null ? TokenTransaction.fromPartial(object.finalTokenTransaction) : void 0;
1118
+ message.keyshareInfo = object.keyshareInfo !== void 0 && object.keyshareInfo !== null ? SigningKeyshare.fromPartial(object.keyshareInfo) : void 0;
1119
+ return message;
1120
+ }
1121
+ };
1122
+ function createBaseCommitTransactionRequest() {
1123
+ return {
1124
+ finalTokenTransaction: void 0,
1125
+ finalTokenTransactionHash: new Uint8Array(0),
1126
+ inputTtxoSignaturesPerOperator: [],
1127
+ ownerIdentityPublicKey: new Uint8Array(0)
1128
+ };
1129
+ }
1130
+ var CommitTransactionRequest = {
1131
+ encode(message, writer = new import_wire5.BinaryWriter()) {
1132
+ if (message.finalTokenTransaction !== void 0) {
1133
+ TokenTransaction.encode(message.finalTokenTransaction, writer.uint32(10).fork()).join();
1134
+ }
1135
+ if (message.finalTokenTransactionHash.length !== 0) {
1136
+ writer.uint32(18).bytes(message.finalTokenTransactionHash);
1137
+ }
1138
+ for (const v of message.inputTtxoSignaturesPerOperator) {
1139
+ InputTtxoSignaturesPerOperator.encode(v, writer.uint32(26).fork()).join();
1140
+ }
1141
+ if (message.ownerIdentityPublicKey.length !== 0) {
1142
+ writer.uint32(34).bytes(message.ownerIdentityPublicKey);
1143
+ }
1144
+ return writer;
1145
+ },
1146
+ decode(input, length) {
1147
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
1148
+ let end = length === void 0 ? reader.len : reader.pos + length;
1149
+ const message = createBaseCommitTransactionRequest();
1150
+ while (reader.pos < end) {
1151
+ const tag = reader.uint32();
1152
+ switch (tag >>> 3) {
1153
+ case 1: {
1154
+ if (tag !== 10) {
1155
+ break;
1156
+ }
1157
+ message.finalTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
1158
+ continue;
1159
+ }
1160
+ case 2: {
1161
+ if (tag !== 18) {
1162
+ break;
1163
+ }
1164
+ message.finalTokenTransactionHash = reader.bytes();
1165
+ continue;
1166
+ }
1167
+ case 3: {
1168
+ if (tag !== 26) {
1169
+ break;
1170
+ }
1171
+ message.inputTtxoSignaturesPerOperator.push(InputTtxoSignaturesPerOperator.decode(reader, reader.uint32()));
1172
+ continue;
1173
+ }
1174
+ case 4: {
1175
+ if (tag !== 34) {
1176
+ break;
1177
+ }
1178
+ message.ownerIdentityPublicKey = reader.bytes();
1179
+ continue;
1180
+ }
1181
+ }
1182
+ if ((tag & 7) === 4 || tag === 0) {
1183
+ break;
1184
+ }
1185
+ reader.skip(tag & 7);
1186
+ }
1187
+ return message;
1188
+ },
1189
+ fromJSON(object) {
1190
+ return {
1191
+ finalTokenTransaction: isSet3(object.finalTokenTransaction) ? TokenTransaction.fromJSON(object.finalTokenTransaction) : void 0,
1192
+ finalTokenTransactionHash: isSet3(object.finalTokenTransactionHash) ? bytesFromBase642(object.finalTokenTransactionHash) : new Uint8Array(0),
1193
+ inputTtxoSignaturesPerOperator: globalThis.Array.isArray(object?.inputTtxoSignaturesPerOperator) ? object.inputTtxoSignaturesPerOperator.map((e) => InputTtxoSignaturesPerOperator.fromJSON(e)) : [],
1194
+ ownerIdentityPublicKey: isSet3(object.ownerIdentityPublicKey) ? bytesFromBase642(object.ownerIdentityPublicKey) : new Uint8Array(0)
1195
+ };
1196
+ },
1197
+ toJSON(message) {
1198
+ const obj = {};
1199
+ if (message.finalTokenTransaction !== void 0) {
1200
+ obj.finalTokenTransaction = TokenTransaction.toJSON(message.finalTokenTransaction);
1201
+ }
1202
+ if (message.finalTokenTransactionHash.length !== 0) {
1203
+ obj.finalTokenTransactionHash = base64FromBytes2(message.finalTokenTransactionHash);
1204
+ }
1205
+ if (message.inputTtxoSignaturesPerOperator?.length) {
1206
+ obj.inputTtxoSignaturesPerOperator = message.inputTtxoSignaturesPerOperator.map(
1207
+ (e) => InputTtxoSignaturesPerOperator.toJSON(e)
1208
+ );
1209
+ }
1210
+ if (message.ownerIdentityPublicKey.length !== 0) {
1211
+ obj.ownerIdentityPublicKey = base64FromBytes2(message.ownerIdentityPublicKey);
1212
+ }
1213
+ return obj;
1214
+ },
1215
+ create(base) {
1216
+ return CommitTransactionRequest.fromPartial(base ?? {});
1217
+ },
1218
+ fromPartial(object) {
1219
+ const message = createBaseCommitTransactionRequest();
1220
+ message.finalTokenTransaction = object.finalTokenTransaction !== void 0 && object.finalTokenTransaction !== null ? TokenTransaction.fromPartial(object.finalTokenTransaction) : void 0;
1221
+ message.finalTokenTransactionHash = object.finalTokenTransactionHash ?? new Uint8Array(0);
1222
+ message.inputTtxoSignaturesPerOperator = object.inputTtxoSignaturesPerOperator?.map((e) => InputTtxoSignaturesPerOperator.fromPartial(e)) || [];
1223
+ message.ownerIdentityPublicKey = object.ownerIdentityPublicKey ?? new Uint8Array(0);
1224
+ return message;
1225
+ }
1226
+ };
1227
+ function createBaseCommitTransactionResponse() {
1228
+ return {};
1229
+ }
1230
+ var CommitTransactionResponse = {
1231
+ encode(_, writer = new import_wire5.BinaryWriter()) {
1232
+ return writer;
1233
+ },
1234
+ decode(input, length) {
1235
+ const reader = input instanceof import_wire5.BinaryReader ? input : new import_wire5.BinaryReader(input);
1236
+ let end = length === void 0 ? reader.len : reader.pos + length;
1237
+ const message = createBaseCommitTransactionResponse();
1238
+ while (reader.pos < end) {
1239
+ const tag = reader.uint32();
1240
+ switch (tag >>> 3) {
1241
+ }
1242
+ if ((tag & 7) === 4 || tag === 0) {
1243
+ break;
1244
+ }
1245
+ reader.skip(tag & 7);
1246
+ }
1247
+ return message;
1248
+ },
1249
+ fromJSON(_) {
1250
+ return {};
1251
+ },
1252
+ toJSON(_) {
1253
+ const obj = {};
1254
+ return obj;
1255
+ },
1256
+ create(base) {
1257
+ return CommitTransactionResponse.fromPartial(base ?? {});
1258
+ },
1259
+ fromPartial(_) {
1260
+ const message = createBaseCommitTransactionResponse();
1261
+ return message;
1262
+ }
1263
+ };
1264
+ var SparkTokenServiceDefinition = {
1265
+ name: "SparkTokenService",
1266
+ fullName: "spark_token.SparkTokenService",
1267
+ methods: {
1268
+ /**
1269
+ * Start process to create final token transaction with all inputs required
1270
+ * from user and SOs (including revocation secret commitment)
1271
+ */
1272
+ start_transaction: {
1273
+ name: "start_transaction",
1274
+ requestType: StartTransactionRequest,
1275
+ requestStream: false,
1276
+ responseType: StartTransactionResponse,
1277
+ responseStream: false,
1278
+ options: {}
1279
+ },
1280
+ /**
1281
+ * Complete the transaction and commit it with all SOs. This will be
1282
+ * coordinated by one SO.
1283
+ */
1284
+ commit_transaction: {
1285
+ name: "commit_transaction",
1286
+ requestType: CommitTransactionRequest,
1287
+ requestStream: false,
1288
+ responseType: CommitTransactionResponse,
1289
+ responseStream: false,
1290
+ options: {}
1291
+ }
1292
+ }
1293
+ };
1294
+ function bytesFromBase642(b64) {
1295
+ if (globalThis.Buffer) {
1296
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1297
+ } else {
1298
+ const bin = globalThis.atob(b64);
1299
+ const arr = new Uint8Array(bin.length);
1300
+ for (let i = 0; i < bin.length; ++i) {
1301
+ arr[i] = bin.charCodeAt(i);
1302
+ }
1303
+ return arr;
1304
+ }
1305
+ }
1306
+ function base64FromBytes2(arr) {
1307
+ if (globalThis.Buffer) {
1308
+ return globalThis.Buffer.from(arr).toString("base64");
1309
+ } else {
1310
+ const bin = [];
1311
+ arr.forEach((byte) => {
1312
+ bin.push(globalThis.String.fromCharCode(byte));
1313
+ });
1314
+ return globalThis.btoa(bin.join(""));
1315
+ }
1316
+ }
1317
+ function toTimestamp(date) {
1318
+ const seconds = Math.trunc(date.getTime() / 1e3);
1319
+ const nanos = date.getTime() % 1e3 * 1e6;
1320
+ return { seconds, nanos };
1321
+ }
1322
+ function fromTimestamp(t) {
1323
+ let millis = (t.seconds || 0) * 1e3;
1324
+ millis += (t.nanos || 0) / 1e6;
1325
+ return new globalThis.Date(millis);
1326
+ }
1327
+ function fromJsonTimestamp(o) {
1328
+ if (o instanceof globalThis.Date) {
1329
+ return o;
1330
+ } else if (typeof o === "string") {
1331
+ return new globalThis.Date(o);
1332
+ } else {
1333
+ return fromTimestamp(Timestamp.fromJSON(o));
1334
+ }
1335
+ }
1336
+ function longToNumber2(int64) {
1337
+ const num = globalThis.Number(int64.toString());
1338
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
1339
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
1340
+ }
1341
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
1342
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
1343
+ }
1344
+ return num;
1345
+ }
1346
+ function isSet3(value) {
1347
+ return value !== null && value !== void 0;
1348
+ }
1349
+ // Annotate the CommonJS export names for ESM import in node:
1350
+ 0 && (module.exports = {
1351
+ CommitTransactionRequest,
1352
+ CommitTransactionResponse,
1353
+ InputTtxoSignaturesPerOperator,
1354
+ SignatureWithIndex,
1355
+ SparkTokenServiceDefinition,
1356
+ StartTransactionRequest,
1357
+ StartTransactionResponse,
1358
+ TokenMintInput,
1359
+ TokenOutput,
1360
+ TokenOutputToSpend,
1361
+ TokenTransaction,
1362
+ TokenTransferInput,
1363
+ protobufPackage
1364
+ });