@buildonspark/spark-sdk 0.1.44 → 0.1.45

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 (143) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{RequestLightningSendInput-RGel43ks.d.ts → RequestLightningSendInput-DEPd_fPO.d.ts} +1 -1
  3. package/dist/{RequestLightningSendInput-BxbCtwpV.d.cts → RequestLightningSendInput-Du0z7Om7.d.cts} +1 -1
  4. package/dist/address/index.cjs +2 -2
  5. package/dist/address/index.d.cts +2 -2
  6. package/dist/address/index.d.ts +2 -2
  7. package/dist/address/index.js +2 -2
  8. package/dist/{chunk-XX4RRWOX.js → chunk-5FUB65LX.js} +5 -7
  9. package/dist/{chunk-DAXGVPVM.js → chunk-6264CGDM.js} +4 -4
  10. package/dist/{chunk-UBT6EDVJ.js → chunk-7V6N75CC.js} +1 -1
  11. package/dist/{chunk-4Q2ZDYYU.js → chunk-BGGEVUJK.js} +1157 -208
  12. package/dist/{chunk-CIZNCBKE.js → chunk-C2S227QR.js} +648 -45
  13. package/dist/{chunk-NBCNYDWJ.js → chunk-GZ5IPPJ2.js} +2 -2
  14. package/dist/{chunk-6AFUC5M2.js → chunk-HWJWKEIU.js} +8 -2
  15. package/dist/{chunk-A2ZLMH6I.js → chunk-J2IE4Z7Y.js} +231 -299
  16. package/dist/{chunk-KEKGSH7B.js → chunk-KMUMFYFX.js} +3 -3
  17. package/dist/chunk-LHRD2WT6.js +2374 -0
  18. package/dist/{chunk-SQKXGAIR.js → chunk-NTFKFRQ2.js} +1 -1
  19. package/dist/{chunk-K4BJARWM.js → chunk-OBFKIEMP.js} +1 -1
  20. package/dist/{chunk-WPTRVD2V.js → chunk-PQN3C2MF.js} +15 -15
  21. package/dist/{chunk-EKFD62HN.js → chunk-R5PXJZQS.js} +1 -0
  22. package/dist/{chunk-HTMXTJRK.js → chunk-YUPMXTCJ.js} +4 -4
  23. package/dist/graphql/objects/index.d.cts +5 -4
  24. package/dist/graphql/objects/index.d.ts +5 -4
  25. package/dist/index-B2AwKW5J.d.cts +214 -0
  26. package/dist/index-CJDi1HWc.d.ts +214 -0
  27. package/dist/index.cjs +4025 -1314
  28. package/dist/index.d.cts +764 -19
  29. package/dist/index.d.ts +764 -19
  30. package/dist/index.js +16 -20
  31. package/dist/index.node.cjs +4025 -1318
  32. package/dist/index.node.d.cts +10 -8
  33. package/dist/index.node.d.ts +10 -8
  34. package/dist/index.node.js +16 -24
  35. package/dist/native/index.cjs +4026 -1315
  36. package/dist/native/index.d.cts +281 -85
  37. package/dist/native/index.d.ts +281 -85
  38. package/dist/native/index.js +4017 -1306
  39. package/dist/{network-CroCOQ0B.d.ts → network-BTJl-Sul.d.ts} +1 -1
  40. package/dist/{network-CfxLnaot.d.cts → network-CqgsdUF2.d.cts} +1 -1
  41. package/dist/proto/lrc20.cjs +222 -19
  42. package/dist/proto/lrc20.d.cts +1 -1
  43. package/dist/proto/lrc20.d.ts +1 -1
  44. package/dist/proto/lrc20.js +2 -2
  45. package/dist/proto/spark.cjs +1154 -205
  46. package/dist/proto/spark.d.cts +1 -1
  47. package/dist/proto/spark.d.ts +1 -1
  48. package/dist/proto/spark.js +3 -1
  49. package/dist/proto/spark_token.cjs +1377 -58
  50. package/dist/proto/spark_token.d.cts +153 -15
  51. package/dist/proto/spark_token.d.ts +153 -15
  52. package/dist/proto/spark_token.js +40 -4
  53. package/dist/{sdk-types-BeCBoozO.d.cts → sdk-types-B0SwjolI.d.cts} +1 -1
  54. package/dist/{sdk-types-CTbTdDbE.d.ts → sdk-types-Cc4l4kb1.d.ts} +1 -1
  55. package/dist/services/config.cjs +1 -1
  56. package/dist/services/config.d.cts +5 -4
  57. package/dist/services/config.d.ts +5 -4
  58. package/dist/services/config.js +6 -6
  59. package/dist/services/connection.cjs +2438 -262
  60. package/dist/services/connection.d.cts +5 -4
  61. package/dist/services/connection.d.ts +5 -4
  62. package/dist/services/connection.js +4 -4
  63. package/dist/services/index.cjs +5936 -3153
  64. package/dist/services/index.d.cts +7 -6
  65. package/dist/services/index.d.ts +7 -6
  66. package/dist/services/index.js +15 -13
  67. package/dist/services/lrc-connection.cjs +223 -20
  68. package/dist/services/lrc-connection.d.cts +5 -4
  69. package/dist/services/lrc-connection.d.ts +5 -4
  70. package/dist/services/lrc-connection.js +4 -4
  71. package/dist/services/token-transactions.cjs +840 -236
  72. package/dist/services/token-transactions.d.cts +25 -7
  73. package/dist/services/token-transactions.d.ts +25 -7
  74. package/dist/services/token-transactions.js +5 -4
  75. package/dist/services/wallet-config.cjs +2 -0
  76. package/dist/services/wallet-config.d.cts +7 -5
  77. package/dist/services/wallet-config.d.ts +7 -5
  78. package/dist/services/wallet-config.js +3 -1
  79. package/dist/signer/signer.cjs +1 -1
  80. package/dist/signer/signer.d.cts +3 -2
  81. package/dist/signer/signer.d.ts +3 -2
  82. package/dist/signer/signer.js +2 -2
  83. package/dist/{signer-D7vfYik9.d.ts → signer-BocS_J6B.d.ts} +2 -6
  84. package/dist/{signer-DaY8c60s.d.cts → signer-DKS0AJkw.d.cts} +2 -6
  85. package/dist/{spark-C4ZrsgjC.d.cts → spark-dM7EYXYQ.d.cts} +93 -15
  86. package/dist/{spark-C4ZrsgjC.d.ts → spark-dM7EYXYQ.d.ts} +93 -15
  87. package/dist/spark_bindings/native/index.cjs +183 -0
  88. package/dist/spark_bindings/native/index.d.cts +14 -0
  89. package/dist/spark_bindings/native/index.d.ts +14 -0
  90. package/dist/spark_bindings/native/index.js +141 -0
  91. package/dist/spark_bindings/wasm/index.cjs +1093 -0
  92. package/dist/spark_bindings/wasm/index.d.cts +47 -0
  93. package/dist/spark_bindings/wasm/index.d.ts +47 -0
  94. package/dist/{chunk-K4C4W5FC.js → spark_bindings/wasm/index.js} +7 -6
  95. package/dist/types/index.cjs +1156 -208
  96. package/dist/types/index.d.cts +5 -4
  97. package/dist/types/index.d.ts +5 -4
  98. package/dist/types/index.js +2 -2
  99. package/dist/types-C-Rp0Oo7.d.cts +46 -0
  100. package/dist/types-C-Rp0Oo7.d.ts +46 -0
  101. package/dist/utils/index.cjs +64 -12
  102. package/dist/utils/index.d.cts +14 -134
  103. package/dist/utils/index.d.ts +14 -134
  104. package/dist/utils/index.js +7 -7
  105. package/package.json +21 -1
  106. package/src/index.node.ts +0 -1
  107. package/src/index.ts +0 -1
  108. package/src/native/index.ts +1 -2
  109. package/src/proto/common.ts +5 -5
  110. package/src/proto/google/protobuf/descriptor.ts +34 -34
  111. package/src/proto/google/protobuf/duration.ts +2 -2
  112. package/src/proto/google/protobuf/empty.ts +2 -2
  113. package/src/proto/google/protobuf/timestamp.ts +2 -2
  114. package/src/proto/mock.ts +4 -4
  115. package/src/proto/spark.ts +1452 -185
  116. package/src/proto/spark_authn.ts +7 -7
  117. package/src/proto/spark_token.ts +1668 -105
  118. package/src/proto/validate/validate.ts +24 -24
  119. package/src/services/bolt11-spark.ts +62 -187
  120. package/src/services/coop-exit.ts +3 -0
  121. package/src/services/lrc20.ts +1 -1
  122. package/src/services/token-transactions.ts +197 -9
  123. package/src/services/transfer.ts +22 -0
  124. package/src/services/tree-creation.ts +13 -0
  125. package/src/services/wallet-config.ts +1 -1
  126. package/src/spark-wallet/spark-wallet.node.ts +0 -4
  127. package/src/spark-wallet/spark-wallet.ts +76 -108
  128. package/src/spark-wallet/types.ts +39 -3
  129. package/src/tests/bolt11-spark.test.ts +7 -15
  130. package/src/tests/integration/ssp/coop-exit.test.ts +7 -7
  131. package/src/tests/integration/swap.test.ts +453 -433
  132. package/src/tests/integration/transfer.test.ts +261 -248
  133. package/src/tests/token-identifier.test.ts +54 -0
  134. package/src/tests/tokens.test.ts +218 -23
  135. package/src/utils/token-hashing.ts +320 -44
  136. package/src/utils/token-identifier.ts +88 -0
  137. package/src/utils/token-transaction-validation.ts +350 -5
  138. package/src/utils/token-transactions.ts +12 -8
  139. package/src/utils/transaction.ts +0 -6
  140. package/dist/chunk-B3AMIGJG.js +0 -1073
  141. package/dist/index-CZmDdSts.d.cts +0 -829
  142. package/dist/index-ClIRO_3y.d.ts +0 -829
  143. package/dist/wasm-7OWFHDMS.js +0 -21
@@ -0,0 +1,2374 @@
1
+ import {
2
+ SigningKeyshare,
3
+ Timestamp,
4
+ networkFromJSON,
5
+ networkToJSON
6
+ } from "./chunk-BGGEVUJK.js";
7
+
8
+ // src/proto/spark_token.ts
9
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
10
+ var protobufPackage = "spark_token";
11
+ var TokenTransactionType = /* @__PURE__ */ ((TokenTransactionType2) => {
12
+ TokenTransactionType2[TokenTransactionType2["TOKEN_TRANSACTION_TYPE_UNSPECIFIED"] = 0] = "TOKEN_TRANSACTION_TYPE_UNSPECIFIED";
13
+ TokenTransactionType2[TokenTransactionType2["TOKEN_TRANSACTION_TYPE_CREATE"] = 1] = "TOKEN_TRANSACTION_TYPE_CREATE";
14
+ TokenTransactionType2[TokenTransactionType2["TOKEN_TRANSACTION_TYPE_MINT"] = 2] = "TOKEN_TRANSACTION_TYPE_MINT";
15
+ TokenTransactionType2[TokenTransactionType2["TOKEN_TRANSACTION_TYPE_TRANSFER"] = 3] = "TOKEN_TRANSACTION_TYPE_TRANSFER";
16
+ TokenTransactionType2[TokenTransactionType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
17
+ return TokenTransactionType2;
18
+ })(TokenTransactionType || {});
19
+ function tokenTransactionTypeFromJSON(object) {
20
+ switch (object) {
21
+ case 0:
22
+ case "TOKEN_TRANSACTION_TYPE_UNSPECIFIED":
23
+ return 0 /* TOKEN_TRANSACTION_TYPE_UNSPECIFIED */;
24
+ case 1:
25
+ case "TOKEN_TRANSACTION_TYPE_CREATE":
26
+ return 1 /* TOKEN_TRANSACTION_TYPE_CREATE */;
27
+ case 2:
28
+ case "TOKEN_TRANSACTION_TYPE_MINT":
29
+ return 2 /* TOKEN_TRANSACTION_TYPE_MINT */;
30
+ case 3:
31
+ case "TOKEN_TRANSACTION_TYPE_TRANSFER":
32
+ return 3 /* TOKEN_TRANSACTION_TYPE_TRANSFER */;
33
+ case -1:
34
+ case "UNRECOGNIZED":
35
+ default:
36
+ return -1 /* UNRECOGNIZED */;
37
+ }
38
+ }
39
+ function tokenTransactionTypeToJSON(object) {
40
+ switch (object) {
41
+ case 0 /* TOKEN_TRANSACTION_TYPE_UNSPECIFIED */:
42
+ return "TOKEN_TRANSACTION_TYPE_UNSPECIFIED";
43
+ case 1 /* TOKEN_TRANSACTION_TYPE_CREATE */:
44
+ return "TOKEN_TRANSACTION_TYPE_CREATE";
45
+ case 2 /* TOKEN_TRANSACTION_TYPE_MINT */:
46
+ return "TOKEN_TRANSACTION_TYPE_MINT";
47
+ case 3 /* TOKEN_TRANSACTION_TYPE_TRANSFER */:
48
+ return "TOKEN_TRANSACTION_TYPE_TRANSFER";
49
+ case -1 /* UNRECOGNIZED */:
50
+ default:
51
+ return "UNRECOGNIZED";
52
+ }
53
+ }
54
+ var TokenTransactionStatus = /* @__PURE__ */ ((TokenTransactionStatus2) => {
55
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_STARTED"] = 0] = "TOKEN_TRANSACTION_STARTED";
56
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_SIGNED"] = 1] = "TOKEN_TRANSACTION_SIGNED";
57
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_REVEALED"] = 5] = "TOKEN_TRANSACTION_REVEALED";
58
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_FINALIZED"] = 2] = "TOKEN_TRANSACTION_FINALIZED";
59
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_STARTED_CANCELLED"] = 3] = "TOKEN_TRANSACTION_STARTED_CANCELLED";
60
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_SIGNED_CANCELLED"] = 4] = "TOKEN_TRANSACTION_SIGNED_CANCELLED";
61
+ TokenTransactionStatus2[TokenTransactionStatus2["TOKEN_TRANSACTION_UNKNOWN"] = 10] = "TOKEN_TRANSACTION_UNKNOWN";
62
+ TokenTransactionStatus2[TokenTransactionStatus2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
63
+ return TokenTransactionStatus2;
64
+ })(TokenTransactionStatus || {});
65
+ function tokenTransactionStatusFromJSON(object) {
66
+ switch (object) {
67
+ case 0:
68
+ case "TOKEN_TRANSACTION_STARTED":
69
+ return 0 /* TOKEN_TRANSACTION_STARTED */;
70
+ case 1:
71
+ case "TOKEN_TRANSACTION_SIGNED":
72
+ return 1 /* TOKEN_TRANSACTION_SIGNED */;
73
+ case 5:
74
+ case "TOKEN_TRANSACTION_REVEALED":
75
+ return 5 /* TOKEN_TRANSACTION_REVEALED */;
76
+ case 2:
77
+ case "TOKEN_TRANSACTION_FINALIZED":
78
+ return 2 /* TOKEN_TRANSACTION_FINALIZED */;
79
+ case 3:
80
+ case "TOKEN_TRANSACTION_STARTED_CANCELLED":
81
+ return 3 /* TOKEN_TRANSACTION_STARTED_CANCELLED */;
82
+ case 4:
83
+ case "TOKEN_TRANSACTION_SIGNED_CANCELLED":
84
+ return 4 /* TOKEN_TRANSACTION_SIGNED_CANCELLED */;
85
+ case 10:
86
+ case "TOKEN_TRANSACTION_UNKNOWN":
87
+ return 10 /* TOKEN_TRANSACTION_UNKNOWN */;
88
+ case -1:
89
+ case "UNRECOGNIZED":
90
+ default:
91
+ return -1 /* UNRECOGNIZED */;
92
+ }
93
+ }
94
+ function tokenTransactionStatusToJSON(object) {
95
+ switch (object) {
96
+ case 0 /* TOKEN_TRANSACTION_STARTED */:
97
+ return "TOKEN_TRANSACTION_STARTED";
98
+ case 1 /* TOKEN_TRANSACTION_SIGNED */:
99
+ return "TOKEN_TRANSACTION_SIGNED";
100
+ case 5 /* TOKEN_TRANSACTION_REVEALED */:
101
+ return "TOKEN_TRANSACTION_REVEALED";
102
+ case 2 /* TOKEN_TRANSACTION_FINALIZED */:
103
+ return "TOKEN_TRANSACTION_FINALIZED";
104
+ case 3 /* TOKEN_TRANSACTION_STARTED_CANCELLED */:
105
+ return "TOKEN_TRANSACTION_STARTED_CANCELLED";
106
+ case 4 /* TOKEN_TRANSACTION_SIGNED_CANCELLED */:
107
+ return "TOKEN_TRANSACTION_SIGNED_CANCELLED";
108
+ case 10 /* TOKEN_TRANSACTION_UNKNOWN */:
109
+ return "TOKEN_TRANSACTION_UNKNOWN";
110
+ case -1 /* UNRECOGNIZED */:
111
+ default:
112
+ return "UNRECOGNIZED";
113
+ }
114
+ }
115
+ function createBaseTokenOutputToSpend() {
116
+ return { prevTokenTransactionHash: new Uint8Array(0), prevTokenTransactionVout: 0 };
117
+ }
118
+ var TokenOutputToSpend = {
119
+ encode(message, writer = new BinaryWriter()) {
120
+ if (message.prevTokenTransactionHash.length !== 0) {
121
+ writer.uint32(10).bytes(message.prevTokenTransactionHash);
122
+ }
123
+ if (message.prevTokenTransactionVout !== 0) {
124
+ writer.uint32(16).uint32(message.prevTokenTransactionVout);
125
+ }
126
+ return writer;
127
+ },
128
+ decode(input, length) {
129
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
130
+ const end = length === void 0 ? reader.len : reader.pos + length;
131
+ const message = createBaseTokenOutputToSpend();
132
+ while (reader.pos < end) {
133
+ const tag = reader.uint32();
134
+ switch (tag >>> 3) {
135
+ case 1: {
136
+ if (tag !== 10) {
137
+ break;
138
+ }
139
+ message.prevTokenTransactionHash = reader.bytes();
140
+ continue;
141
+ }
142
+ case 2: {
143
+ if (tag !== 16) {
144
+ break;
145
+ }
146
+ message.prevTokenTransactionVout = reader.uint32();
147
+ continue;
148
+ }
149
+ }
150
+ if ((tag & 7) === 4 || tag === 0) {
151
+ break;
152
+ }
153
+ reader.skip(tag & 7);
154
+ }
155
+ return message;
156
+ },
157
+ fromJSON(object) {
158
+ return {
159
+ prevTokenTransactionHash: isSet(object.prevTokenTransactionHash) ? bytesFromBase64(object.prevTokenTransactionHash) : new Uint8Array(0),
160
+ prevTokenTransactionVout: isSet(object.prevTokenTransactionVout) ? globalThis.Number(object.prevTokenTransactionVout) : 0
161
+ };
162
+ },
163
+ toJSON(message) {
164
+ const obj = {};
165
+ if (message.prevTokenTransactionHash.length !== 0) {
166
+ obj.prevTokenTransactionHash = base64FromBytes(message.prevTokenTransactionHash);
167
+ }
168
+ if (message.prevTokenTransactionVout !== 0) {
169
+ obj.prevTokenTransactionVout = Math.round(message.prevTokenTransactionVout);
170
+ }
171
+ return obj;
172
+ },
173
+ create(base) {
174
+ return TokenOutputToSpend.fromPartial(base ?? {});
175
+ },
176
+ fromPartial(object) {
177
+ const message = createBaseTokenOutputToSpend();
178
+ message.prevTokenTransactionHash = object.prevTokenTransactionHash ?? new Uint8Array(0);
179
+ message.prevTokenTransactionVout = object.prevTokenTransactionVout ?? 0;
180
+ return message;
181
+ }
182
+ };
183
+ function createBaseTokenTransferInput() {
184
+ return { outputsToSpend: [] };
185
+ }
186
+ var TokenTransferInput = {
187
+ encode(message, writer = new BinaryWriter()) {
188
+ for (const v of message.outputsToSpend) {
189
+ TokenOutputToSpend.encode(v, writer.uint32(10).fork()).join();
190
+ }
191
+ return writer;
192
+ },
193
+ decode(input, length) {
194
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
195
+ const end = length === void 0 ? reader.len : reader.pos + length;
196
+ const message = createBaseTokenTransferInput();
197
+ while (reader.pos < end) {
198
+ const tag = reader.uint32();
199
+ switch (tag >>> 3) {
200
+ case 1: {
201
+ if (tag !== 10) {
202
+ break;
203
+ }
204
+ message.outputsToSpend.push(TokenOutputToSpend.decode(reader, reader.uint32()));
205
+ continue;
206
+ }
207
+ }
208
+ if ((tag & 7) === 4 || tag === 0) {
209
+ break;
210
+ }
211
+ reader.skip(tag & 7);
212
+ }
213
+ return message;
214
+ },
215
+ fromJSON(object) {
216
+ return {
217
+ outputsToSpend: globalThis.Array.isArray(object?.outputsToSpend) ? object.outputsToSpend.map((e) => TokenOutputToSpend.fromJSON(e)) : []
218
+ };
219
+ },
220
+ toJSON(message) {
221
+ const obj = {};
222
+ if (message.outputsToSpend?.length) {
223
+ obj.outputsToSpend = message.outputsToSpend.map((e) => TokenOutputToSpend.toJSON(e));
224
+ }
225
+ return obj;
226
+ },
227
+ create(base) {
228
+ return TokenTransferInput.fromPartial(base ?? {});
229
+ },
230
+ fromPartial(object) {
231
+ const message = createBaseTokenTransferInput();
232
+ message.outputsToSpend = object.outputsToSpend?.map((e) => TokenOutputToSpend.fromPartial(e)) || [];
233
+ return message;
234
+ }
235
+ };
236
+ function createBaseTokenMintInput() {
237
+ return { issuerPublicKey: new Uint8Array(0), tokenIdentifier: void 0 };
238
+ }
239
+ var TokenMintInput = {
240
+ encode(message, writer = new BinaryWriter()) {
241
+ if (message.issuerPublicKey.length !== 0) {
242
+ writer.uint32(10).bytes(message.issuerPublicKey);
243
+ }
244
+ if (message.tokenIdentifier !== void 0) {
245
+ writer.uint32(18).bytes(message.tokenIdentifier);
246
+ }
247
+ return writer;
248
+ },
249
+ decode(input, length) {
250
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
251
+ const end = length === void 0 ? reader.len : reader.pos + length;
252
+ const message = createBaseTokenMintInput();
253
+ while (reader.pos < end) {
254
+ const tag = reader.uint32();
255
+ switch (tag >>> 3) {
256
+ case 1: {
257
+ if (tag !== 10) {
258
+ break;
259
+ }
260
+ message.issuerPublicKey = reader.bytes();
261
+ continue;
262
+ }
263
+ case 2: {
264
+ if (tag !== 18) {
265
+ break;
266
+ }
267
+ message.tokenIdentifier = reader.bytes();
268
+ continue;
269
+ }
270
+ }
271
+ if ((tag & 7) === 4 || tag === 0) {
272
+ break;
273
+ }
274
+ reader.skip(tag & 7);
275
+ }
276
+ return message;
277
+ },
278
+ fromJSON(object) {
279
+ return {
280
+ issuerPublicKey: isSet(object.issuerPublicKey) ? bytesFromBase64(object.issuerPublicKey) : new Uint8Array(0),
281
+ tokenIdentifier: isSet(object.tokenIdentifier) ? bytesFromBase64(object.tokenIdentifier) : void 0
282
+ };
283
+ },
284
+ toJSON(message) {
285
+ const obj = {};
286
+ if (message.issuerPublicKey.length !== 0) {
287
+ obj.issuerPublicKey = base64FromBytes(message.issuerPublicKey);
288
+ }
289
+ if (message.tokenIdentifier !== void 0) {
290
+ obj.tokenIdentifier = base64FromBytes(message.tokenIdentifier);
291
+ }
292
+ return obj;
293
+ },
294
+ create(base) {
295
+ return TokenMintInput.fromPartial(base ?? {});
296
+ },
297
+ fromPartial(object) {
298
+ const message = createBaseTokenMintInput();
299
+ message.issuerPublicKey = object.issuerPublicKey ?? new Uint8Array(0);
300
+ message.tokenIdentifier = object.tokenIdentifier ?? void 0;
301
+ return message;
302
+ }
303
+ };
304
+ function createBaseTokenCreateInput() {
305
+ return {
306
+ issuerPublicKey: new Uint8Array(0),
307
+ tokenName: "",
308
+ tokenTicker: "",
309
+ decimals: 0,
310
+ maxSupply: new Uint8Array(0),
311
+ isFreezable: false,
312
+ creationEntityPublicKey: void 0
313
+ };
314
+ }
315
+ var TokenCreateInput = {
316
+ encode(message, writer = new BinaryWriter()) {
317
+ if (message.issuerPublicKey.length !== 0) {
318
+ writer.uint32(10).bytes(message.issuerPublicKey);
319
+ }
320
+ if (message.tokenName !== "") {
321
+ writer.uint32(18).string(message.tokenName);
322
+ }
323
+ if (message.tokenTicker !== "") {
324
+ writer.uint32(26).string(message.tokenTicker);
325
+ }
326
+ if (message.decimals !== 0) {
327
+ writer.uint32(32).uint32(message.decimals);
328
+ }
329
+ if (message.maxSupply.length !== 0) {
330
+ writer.uint32(42).bytes(message.maxSupply);
331
+ }
332
+ if (message.isFreezable !== false) {
333
+ writer.uint32(48).bool(message.isFreezable);
334
+ }
335
+ if (message.creationEntityPublicKey !== void 0) {
336
+ writer.uint32(58).bytes(message.creationEntityPublicKey);
337
+ }
338
+ return writer;
339
+ },
340
+ decode(input, length) {
341
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
342
+ const end = length === void 0 ? reader.len : reader.pos + length;
343
+ const message = createBaseTokenCreateInput();
344
+ while (reader.pos < end) {
345
+ const tag = reader.uint32();
346
+ switch (tag >>> 3) {
347
+ case 1: {
348
+ if (tag !== 10) {
349
+ break;
350
+ }
351
+ message.issuerPublicKey = reader.bytes();
352
+ continue;
353
+ }
354
+ case 2: {
355
+ if (tag !== 18) {
356
+ break;
357
+ }
358
+ message.tokenName = reader.string();
359
+ continue;
360
+ }
361
+ case 3: {
362
+ if (tag !== 26) {
363
+ break;
364
+ }
365
+ message.tokenTicker = reader.string();
366
+ continue;
367
+ }
368
+ case 4: {
369
+ if (tag !== 32) {
370
+ break;
371
+ }
372
+ message.decimals = reader.uint32();
373
+ continue;
374
+ }
375
+ case 5: {
376
+ if (tag !== 42) {
377
+ break;
378
+ }
379
+ message.maxSupply = reader.bytes();
380
+ continue;
381
+ }
382
+ case 6: {
383
+ if (tag !== 48) {
384
+ break;
385
+ }
386
+ message.isFreezable = reader.bool();
387
+ continue;
388
+ }
389
+ case 7: {
390
+ if (tag !== 58) {
391
+ break;
392
+ }
393
+ message.creationEntityPublicKey = reader.bytes();
394
+ continue;
395
+ }
396
+ }
397
+ if ((tag & 7) === 4 || tag === 0) {
398
+ break;
399
+ }
400
+ reader.skip(tag & 7);
401
+ }
402
+ return message;
403
+ },
404
+ fromJSON(object) {
405
+ return {
406
+ issuerPublicKey: isSet(object.issuerPublicKey) ? bytesFromBase64(object.issuerPublicKey) : new Uint8Array(0),
407
+ tokenName: isSet(object.tokenName) ? globalThis.String(object.tokenName) : "",
408
+ tokenTicker: isSet(object.tokenTicker) ? globalThis.String(object.tokenTicker) : "",
409
+ decimals: isSet(object.decimals) ? globalThis.Number(object.decimals) : 0,
410
+ maxSupply: isSet(object.maxSupply) ? bytesFromBase64(object.maxSupply) : new Uint8Array(0),
411
+ isFreezable: isSet(object.isFreezable) ? globalThis.Boolean(object.isFreezable) : false,
412
+ creationEntityPublicKey: isSet(object.creationEntityPublicKey) ? bytesFromBase64(object.creationEntityPublicKey) : void 0
413
+ };
414
+ },
415
+ toJSON(message) {
416
+ const obj = {};
417
+ if (message.issuerPublicKey.length !== 0) {
418
+ obj.issuerPublicKey = base64FromBytes(message.issuerPublicKey);
419
+ }
420
+ if (message.tokenName !== "") {
421
+ obj.tokenName = message.tokenName;
422
+ }
423
+ if (message.tokenTicker !== "") {
424
+ obj.tokenTicker = message.tokenTicker;
425
+ }
426
+ if (message.decimals !== 0) {
427
+ obj.decimals = Math.round(message.decimals);
428
+ }
429
+ if (message.maxSupply.length !== 0) {
430
+ obj.maxSupply = base64FromBytes(message.maxSupply);
431
+ }
432
+ if (message.isFreezable !== false) {
433
+ obj.isFreezable = message.isFreezable;
434
+ }
435
+ if (message.creationEntityPublicKey !== void 0) {
436
+ obj.creationEntityPublicKey = base64FromBytes(message.creationEntityPublicKey);
437
+ }
438
+ return obj;
439
+ },
440
+ create(base) {
441
+ return TokenCreateInput.fromPartial(base ?? {});
442
+ },
443
+ fromPartial(object) {
444
+ const message = createBaseTokenCreateInput();
445
+ message.issuerPublicKey = object.issuerPublicKey ?? new Uint8Array(0);
446
+ message.tokenName = object.tokenName ?? "";
447
+ message.tokenTicker = object.tokenTicker ?? "";
448
+ message.decimals = object.decimals ?? 0;
449
+ message.maxSupply = object.maxSupply ?? new Uint8Array(0);
450
+ message.isFreezable = object.isFreezable ?? false;
451
+ message.creationEntityPublicKey = object.creationEntityPublicKey ?? void 0;
452
+ return message;
453
+ }
454
+ };
455
+ function createBaseTokenOutput() {
456
+ return {
457
+ id: void 0,
458
+ ownerPublicKey: new Uint8Array(0),
459
+ revocationCommitment: void 0,
460
+ withdrawBondSats: void 0,
461
+ withdrawRelativeBlockLocktime: void 0,
462
+ tokenPublicKey: void 0,
463
+ tokenIdentifier: void 0,
464
+ tokenAmount: new Uint8Array(0)
465
+ };
466
+ }
467
+ var TokenOutput = {
468
+ encode(message, writer = new BinaryWriter()) {
469
+ if (message.id !== void 0) {
470
+ writer.uint32(10).string(message.id);
471
+ }
472
+ if (message.ownerPublicKey.length !== 0) {
473
+ writer.uint32(18).bytes(message.ownerPublicKey);
474
+ }
475
+ if (message.revocationCommitment !== void 0) {
476
+ writer.uint32(26).bytes(message.revocationCommitment);
477
+ }
478
+ if (message.withdrawBondSats !== void 0) {
479
+ writer.uint32(32).uint64(message.withdrawBondSats);
480
+ }
481
+ if (message.withdrawRelativeBlockLocktime !== void 0) {
482
+ writer.uint32(40).uint64(message.withdrawRelativeBlockLocktime);
483
+ }
484
+ if (message.tokenPublicKey !== void 0) {
485
+ writer.uint32(50).bytes(message.tokenPublicKey);
486
+ }
487
+ if (message.tokenIdentifier !== void 0) {
488
+ writer.uint32(66).bytes(message.tokenIdentifier);
489
+ }
490
+ if (message.tokenAmount.length !== 0) {
491
+ writer.uint32(58).bytes(message.tokenAmount);
492
+ }
493
+ return writer;
494
+ },
495
+ decode(input, length) {
496
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
497
+ const end = length === void 0 ? reader.len : reader.pos + length;
498
+ const message = createBaseTokenOutput();
499
+ while (reader.pos < end) {
500
+ const tag = reader.uint32();
501
+ switch (tag >>> 3) {
502
+ case 1: {
503
+ if (tag !== 10) {
504
+ break;
505
+ }
506
+ message.id = reader.string();
507
+ continue;
508
+ }
509
+ case 2: {
510
+ if (tag !== 18) {
511
+ break;
512
+ }
513
+ message.ownerPublicKey = reader.bytes();
514
+ continue;
515
+ }
516
+ case 3: {
517
+ if (tag !== 26) {
518
+ break;
519
+ }
520
+ message.revocationCommitment = reader.bytes();
521
+ continue;
522
+ }
523
+ case 4: {
524
+ if (tag !== 32) {
525
+ break;
526
+ }
527
+ message.withdrawBondSats = longToNumber(reader.uint64());
528
+ continue;
529
+ }
530
+ case 5: {
531
+ if (tag !== 40) {
532
+ break;
533
+ }
534
+ message.withdrawRelativeBlockLocktime = longToNumber(reader.uint64());
535
+ continue;
536
+ }
537
+ case 6: {
538
+ if (tag !== 50) {
539
+ break;
540
+ }
541
+ message.tokenPublicKey = reader.bytes();
542
+ continue;
543
+ }
544
+ case 8: {
545
+ if (tag !== 66) {
546
+ break;
547
+ }
548
+ message.tokenIdentifier = reader.bytes();
549
+ continue;
550
+ }
551
+ case 7: {
552
+ if (tag !== 58) {
553
+ break;
554
+ }
555
+ message.tokenAmount = reader.bytes();
556
+ continue;
557
+ }
558
+ }
559
+ if ((tag & 7) === 4 || tag === 0) {
560
+ break;
561
+ }
562
+ reader.skip(tag & 7);
563
+ }
564
+ return message;
565
+ },
566
+ fromJSON(object) {
567
+ return {
568
+ id: isSet(object.id) ? globalThis.String(object.id) : void 0,
569
+ ownerPublicKey: isSet(object.ownerPublicKey) ? bytesFromBase64(object.ownerPublicKey) : new Uint8Array(0),
570
+ revocationCommitment: isSet(object.revocationCommitment) ? bytesFromBase64(object.revocationCommitment) : void 0,
571
+ withdrawBondSats: isSet(object.withdrawBondSats) ? globalThis.Number(object.withdrawBondSats) : void 0,
572
+ withdrawRelativeBlockLocktime: isSet(object.withdrawRelativeBlockLocktime) ? globalThis.Number(object.withdrawRelativeBlockLocktime) : void 0,
573
+ tokenPublicKey: isSet(object.tokenPublicKey) ? bytesFromBase64(object.tokenPublicKey) : void 0,
574
+ tokenIdentifier: isSet(object.tokenIdentifier) ? bytesFromBase64(object.tokenIdentifier) : void 0,
575
+ tokenAmount: isSet(object.tokenAmount) ? bytesFromBase64(object.tokenAmount) : new Uint8Array(0)
576
+ };
577
+ },
578
+ toJSON(message) {
579
+ const obj = {};
580
+ if (message.id !== void 0) {
581
+ obj.id = message.id;
582
+ }
583
+ if (message.ownerPublicKey.length !== 0) {
584
+ obj.ownerPublicKey = base64FromBytes(message.ownerPublicKey);
585
+ }
586
+ if (message.revocationCommitment !== void 0) {
587
+ obj.revocationCommitment = base64FromBytes(message.revocationCommitment);
588
+ }
589
+ if (message.withdrawBondSats !== void 0) {
590
+ obj.withdrawBondSats = Math.round(message.withdrawBondSats);
591
+ }
592
+ if (message.withdrawRelativeBlockLocktime !== void 0) {
593
+ obj.withdrawRelativeBlockLocktime = Math.round(message.withdrawRelativeBlockLocktime);
594
+ }
595
+ if (message.tokenPublicKey !== void 0) {
596
+ obj.tokenPublicKey = base64FromBytes(message.tokenPublicKey);
597
+ }
598
+ if (message.tokenIdentifier !== void 0) {
599
+ obj.tokenIdentifier = base64FromBytes(message.tokenIdentifier);
600
+ }
601
+ if (message.tokenAmount.length !== 0) {
602
+ obj.tokenAmount = base64FromBytes(message.tokenAmount);
603
+ }
604
+ return obj;
605
+ },
606
+ create(base) {
607
+ return TokenOutput.fromPartial(base ?? {});
608
+ },
609
+ fromPartial(object) {
610
+ const message = createBaseTokenOutput();
611
+ message.id = object.id ?? void 0;
612
+ message.ownerPublicKey = object.ownerPublicKey ?? new Uint8Array(0);
613
+ message.revocationCommitment = object.revocationCommitment ?? void 0;
614
+ message.withdrawBondSats = object.withdrawBondSats ?? void 0;
615
+ message.withdrawRelativeBlockLocktime = object.withdrawRelativeBlockLocktime ?? void 0;
616
+ message.tokenPublicKey = object.tokenPublicKey ?? void 0;
617
+ message.tokenIdentifier = object.tokenIdentifier ?? void 0;
618
+ message.tokenAmount = object.tokenAmount ?? new Uint8Array(0);
619
+ return message;
620
+ }
621
+ };
622
+ function createBaseTokenTransaction() {
623
+ return {
624
+ version: 0,
625
+ tokenInputs: void 0,
626
+ tokenOutputs: [],
627
+ sparkOperatorIdentityPublicKeys: [],
628
+ expiryTime: void 0,
629
+ network: 0,
630
+ clientCreatedTimestamp: void 0
631
+ };
632
+ }
633
+ var TokenTransaction = {
634
+ encode(message, writer = new BinaryWriter()) {
635
+ if (message.version !== 0) {
636
+ writer.uint32(8).uint32(message.version);
637
+ }
638
+ switch (message.tokenInputs?.$case) {
639
+ case "mintInput":
640
+ TokenMintInput.encode(message.tokenInputs.mintInput, writer.uint32(18).fork()).join();
641
+ break;
642
+ case "transferInput":
643
+ TokenTransferInput.encode(message.tokenInputs.transferInput, writer.uint32(26).fork()).join();
644
+ break;
645
+ case "createInput":
646
+ TokenCreateInput.encode(message.tokenInputs.createInput, writer.uint32(66).fork()).join();
647
+ break;
648
+ }
649
+ for (const v of message.tokenOutputs) {
650
+ TokenOutput.encode(v, writer.uint32(34).fork()).join();
651
+ }
652
+ for (const v of message.sparkOperatorIdentityPublicKeys) {
653
+ writer.uint32(42).bytes(v);
654
+ }
655
+ if (message.expiryTime !== void 0) {
656
+ Timestamp.encode(toTimestamp(message.expiryTime), writer.uint32(50).fork()).join();
657
+ }
658
+ if (message.network !== 0) {
659
+ writer.uint32(56).int32(message.network);
660
+ }
661
+ if (message.clientCreatedTimestamp !== void 0) {
662
+ Timestamp.encode(toTimestamp(message.clientCreatedTimestamp), writer.uint32(74).fork()).join();
663
+ }
664
+ return writer;
665
+ },
666
+ decode(input, length) {
667
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
668
+ const end = length === void 0 ? reader.len : reader.pos + length;
669
+ const message = createBaseTokenTransaction();
670
+ while (reader.pos < end) {
671
+ const tag = reader.uint32();
672
+ switch (tag >>> 3) {
673
+ case 1: {
674
+ if (tag !== 8) {
675
+ break;
676
+ }
677
+ message.version = reader.uint32();
678
+ continue;
679
+ }
680
+ case 2: {
681
+ if (tag !== 18) {
682
+ break;
683
+ }
684
+ message.tokenInputs = { $case: "mintInput", mintInput: TokenMintInput.decode(reader, reader.uint32()) };
685
+ continue;
686
+ }
687
+ case 3: {
688
+ if (tag !== 26) {
689
+ break;
690
+ }
691
+ message.tokenInputs = {
692
+ $case: "transferInput",
693
+ transferInput: TokenTransferInput.decode(reader, reader.uint32())
694
+ };
695
+ continue;
696
+ }
697
+ case 8: {
698
+ if (tag !== 66) {
699
+ break;
700
+ }
701
+ message.tokenInputs = { $case: "createInput", createInput: TokenCreateInput.decode(reader, reader.uint32()) };
702
+ continue;
703
+ }
704
+ case 4: {
705
+ if (tag !== 34) {
706
+ break;
707
+ }
708
+ message.tokenOutputs.push(TokenOutput.decode(reader, reader.uint32()));
709
+ continue;
710
+ }
711
+ case 5: {
712
+ if (tag !== 42) {
713
+ break;
714
+ }
715
+ message.sparkOperatorIdentityPublicKeys.push(reader.bytes());
716
+ continue;
717
+ }
718
+ case 6: {
719
+ if (tag !== 50) {
720
+ break;
721
+ }
722
+ message.expiryTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
723
+ continue;
724
+ }
725
+ case 7: {
726
+ if (tag !== 56) {
727
+ break;
728
+ }
729
+ message.network = reader.int32();
730
+ continue;
731
+ }
732
+ case 9: {
733
+ if (tag !== 74) {
734
+ break;
735
+ }
736
+ message.clientCreatedTimestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
737
+ continue;
738
+ }
739
+ }
740
+ if ((tag & 7) === 4 || tag === 0) {
741
+ break;
742
+ }
743
+ reader.skip(tag & 7);
744
+ }
745
+ return message;
746
+ },
747
+ fromJSON(object) {
748
+ return {
749
+ version: isSet(object.version) ? globalThis.Number(object.version) : 0,
750
+ tokenInputs: isSet(object.mintInput) ? { $case: "mintInput", mintInput: TokenMintInput.fromJSON(object.mintInput) } : isSet(object.transferInput) ? { $case: "transferInput", transferInput: TokenTransferInput.fromJSON(object.transferInput) } : isSet(object.createInput) ? { $case: "createInput", createInput: TokenCreateInput.fromJSON(object.createInput) } : void 0,
751
+ tokenOutputs: globalThis.Array.isArray(object?.tokenOutputs) ? object.tokenOutputs.map((e) => TokenOutput.fromJSON(e)) : [],
752
+ sparkOperatorIdentityPublicKeys: globalThis.Array.isArray(object?.sparkOperatorIdentityPublicKeys) ? object.sparkOperatorIdentityPublicKeys.map((e) => bytesFromBase64(e)) : [],
753
+ expiryTime: isSet(object.expiryTime) ? fromJsonTimestamp(object.expiryTime) : void 0,
754
+ network: isSet(object.network) ? networkFromJSON(object.network) : 0,
755
+ clientCreatedTimestamp: isSet(object.clientCreatedTimestamp) ? fromJsonTimestamp(object.clientCreatedTimestamp) : void 0
756
+ };
757
+ },
758
+ toJSON(message) {
759
+ const obj = {};
760
+ if (message.version !== 0) {
761
+ obj.version = Math.round(message.version);
762
+ }
763
+ if (message.tokenInputs?.$case === "mintInput") {
764
+ obj.mintInput = TokenMintInput.toJSON(message.tokenInputs.mintInput);
765
+ } else if (message.tokenInputs?.$case === "transferInput") {
766
+ obj.transferInput = TokenTransferInput.toJSON(message.tokenInputs.transferInput);
767
+ } else if (message.tokenInputs?.$case === "createInput") {
768
+ obj.createInput = TokenCreateInput.toJSON(message.tokenInputs.createInput);
769
+ }
770
+ if (message.tokenOutputs?.length) {
771
+ obj.tokenOutputs = message.tokenOutputs.map((e) => TokenOutput.toJSON(e));
772
+ }
773
+ if (message.sparkOperatorIdentityPublicKeys?.length) {
774
+ obj.sparkOperatorIdentityPublicKeys = message.sparkOperatorIdentityPublicKeys.map((e) => base64FromBytes(e));
775
+ }
776
+ if (message.expiryTime !== void 0) {
777
+ obj.expiryTime = message.expiryTime.toISOString();
778
+ }
779
+ if (message.network !== 0) {
780
+ obj.network = networkToJSON(message.network);
781
+ }
782
+ if (message.clientCreatedTimestamp !== void 0) {
783
+ obj.clientCreatedTimestamp = message.clientCreatedTimestamp.toISOString();
784
+ }
785
+ return obj;
786
+ },
787
+ create(base) {
788
+ return TokenTransaction.fromPartial(base ?? {});
789
+ },
790
+ fromPartial(object) {
791
+ const message = createBaseTokenTransaction();
792
+ message.version = object.version ?? 0;
793
+ switch (object.tokenInputs?.$case) {
794
+ case "mintInput": {
795
+ if (object.tokenInputs?.mintInput !== void 0 && object.tokenInputs?.mintInput !== null) {
796
+ message.tokenInputs = {
797
+ $case: "mintInput",
798
+ mintInput: TokenMintInput.fromPartial(object.tokenInputs.mintInput)
799
+ };
800
+ }
801
+ break;
802
+ }
803
+ case "transferInput": {
804
+ if (object.tokenInputs?.transferInput !== void 0 && object.tokenInputs?.transferInput !== null) {
805
+ message.tokenInputs = {
806
+ $case: "transferInput",
807
+ transferInput: TokenTransferInput.fromPartial(object.tokenInputs.transferInput)
808
+ };
809
+ }
810
+ break;
811
+ }
812
+ case "createInput": {
813
+ if (object.tokenInputs?.createInput !== void 0 && object.tokenInputs?.createInput !== null) {
814
+ message.tokenInputs = {
815
+ $case: "createInput",
816
+ createInput: TokenCreateInput.fromPartial(object.tokenInputs.createInput)
817
+ };
818
+ }
819
+ break;
820
+ }
821
+ }
822
+ message.tokenOutputs = object.tokenOutputs?.map((e) => TokenOutput.fromPartial(e)) || [];
823
+ message.sparkOperatorIdentityPublicKeys = object.sparkOperatorIdentityPublicKeys?.map((e) => e) || [];
824
+ message.expiryTime = object.expiryTime ?? void 0;
825
+ message.network = object.network ?? 0;
826
+ message.clientCreatedTimestamp = object.clientCreatedTimestamp ?? void 0;
827
+ return message;
828
+ }
829
+ };
830
+ function createBaseSignatureWithIndex() {
831
+ return { signature: new Uint8Array(0), inputIndex: 0 };
832
+ }
833
+ var SignatureWithIndex = {
834
+ encode(message, writer = new BinaryWriter()) {
835
+ if (message.signature.length !== 0) {
836
+ writer.uint32(10).bytes(message.signature);
837
+ }
838
+ if (message.inputIndex !== 0) {
839
+ writer.uint32(16).uint32(message.inputIndex);
840
+ }
841
+ return writer;
842
+ },
843
+ decode(input, length) {
844
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
845
+ const end = length === void 0 ? reader.len : reader.pos + length;
846
+ const message = createBaseSignatureWithIndex();
847
+ while (reader.pos < end) {
848
+ const tag = reader.uint32();
849
+ switch (tag >>> 3) {
850
+ case 1: {
851
+ if (tag !== 10) {
852
+ break;
853
+ }
854
+ message.signature = reader.bytes();
855
+ continue;
856
+ }
857
+ case 2: {
858
+ if (tag !== 16) {
859
+ break;
860
+ }
861
+ message.inputIndex = reader.uint32();
862
+ continue;
863
+ }
864
+ }
865
+ if ((tag & 7) === 4 || tag === 0) {
866
+ break;
867
+ }
868
+ reader.skip(tag & 7);
869
+ }
870
+ return message;
871
+ },
872
+ fromJSON(object) {
873
+ return {
874
+ signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),
875
+ inputIndex: isSet(object.inputIndex) ? globalThis.Number(object.inputIndex) : 0
876
+ };
877
+ },
878
+ toJSON(message) {
879
+ const obj = {};
880
+ if (message.signature.length !== 0) {
881
+ obj.signature = base64FromBytes(message.signature);
882
+ }
883
+ if (message.inputIndex !== 0) {
884
+ obj.inputIndex = Math.round(message.inputIndex);
885
+ }
886
+ return obj;
887
+ },
888
+ create(base) {
889
+ return SignatureWithIndex.fromPartial(base ?? {});
890
+ },
891
+ fromPartial(object) {
892
+ const message = createBaseSignatureWithIndex();
893
+ message.signature = object.signature ?? new Uint8Array(0);
894
+ message.inputIndex = object.inputIndex ?? 0;
895
+ return message;
896
+ }
897
+ };
898
+ function createBaseInputTtxoSignaturesPerOperator() {
899
+ return { ttxoSignatures: [], operatorIdentityPublicKey: new Uint8Array(0) };
900
+ }
901
+ var InputTtxoSignaturesPerOperator = {
902
+ encode(message, writer = new BinaryWriter()) {
903
+ for (const v of message.ttxoSignatures) {
904
+ SignatureWithIndex.encode(v, writer.uint32(10).fork()).join();
905
+ }
906
+ if (message.operatorIdentityPublicKey.length !== 0) {
907
+ writer.uint32(18).bytes(message.operatorIdentityPublicKey);
908
+ }
909
+ return writer;
910
+ },
911
+ decode(input, length) {
912
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
913
+ const end = length === void 0 ? reader.len : reader.pos + length;
914
+ const message = createBaseInputTtxoSignaturesPerOperator();
915
+ while (reader.pos < end) {
916
+ const tag = reader.uint32();
917
+ switch (tag >>> 3) {
918
+ case 1: {
919
+ if (tag !== 10) {
920
+ break;
921
+ }
922
+ message.ttxoSignatures.push(SignatureWithIndex.decode(reader, reader.uint32()));
923
+ continue;
924
+ }
925
+ case 2: {
926
+ if (tag !== 18) {
927
+ break;
928
+ }
929
+ message.operatorIdentityPublicKey = reader.bytes();
930
+ continue;
931
+ }
932
+ }
933
+ if ((tag & 7) === 4 || tag === 0) {
934
+ break;
935
+ }
936
+ reader.skip(tag & 7);
937
+ }
938
+ return message;
939
+ },
940
+ fromJSON(object) {
941
+ return {
942
+ ttxoSignatures: globalThis.Array.isArray(object?.ttxoSignatures) ? object.ttxoSignatures.map((e) => SignatureWithIndex.fromJSON(e)) : [],
943
+ operatorIdentityPublicKey: isSet(object.operatorIdentityPublicKey) ? bytesFromBase64(object.operatorIdentityPublicKey) : new Uint8Array(0)
944
+ };
945
+ },
946
+ toJSON(message) {
947
+ const obj = {};
948
+ if (message.ttxoSignatures?.length) {
949
+ obj.ttxoSignatures = message.ttxoSignatures.map((e) => SignatureWithIndex.toJSON(e));
950
+ }
951
+ if (message.operatorIdentityPublicKey.length !== 0) {
952
+ obj.operatorIdentityPublicKey = base64FromBytes(message.operatorIdentityPublicKey);
953
+ }
954
+ return obj;
955
+ },
956
+ create(base) {
957
+ return InputTtxoSignaturesPerOperator.fromPartial(base ?? {});
958
+ },
959
+ fromPartial(object) {
960
+ const message = createBaseInputTtxoSignaturesPerOperator();
961
+ message.ttxoSignatures = object.ttxoSignatures?.map((e) => SignatureWithIndex.fromPartial(e)) || [];
962
+ message.operatorIdentityPublicKey = object.operatorIdentityPublicKey ?? new Uint8Array(0);
963
+ return message;
964
+ }
965
+ };
966
+ function createBaseStartTransactionRequest() {
967
+ return {
968
+ identityPublicKey: new Uint8Array(0),
969
+ partialTokenTransaction: void 0,
970
+ partialTokenTransactionOwnerSignatures: [],
971
+ validityDurationSeconds: 0
972
+ };
973
+ }
974
+ var StartTransactionRequest = {
975
+ encode(message, writer = new BinaryWriter()) {
976
+ if (message.identityPublicKey.length !== 0) {
977
+ writer.uint32(10).bytes(message.identityPublicKey);
978
+ }
979
+ if (message.partialTokenTransaction !== void 0) {
980
+ TokenTransaction.encode(message.partialTokenTransaction, writer.uint32(18).fork()).join();
981
+ }
982
+ for (const v of message.partialTokenTransactionOwnerSignatures) {
983
+ SignatureWithIndex.encode(v, writer.uint32(26).fork()).join();
984
+ }
985
+ if (message.validityDurationSeconds !== 0) {
986
+ writer.uint32(32).uint64(message.validityDurationSeconds);
987
+ }
988
+ return writer;
989
+ },
990
+ decode(input, length) {
991
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
992
+ const end = length === void 0 ? reader.len : reader.pos + length;
993
+ const message = createBaseStartTransactionRequest();
994
+ while (reader.pos < end) {
995
+ const tag = reader.uint32();
996
+ switch (tag >>> 3) {
997
+ case 1: {
998
+ if (tag !== 10) {
999
+ break;
1000
+ }
1001
+ message.identityPublicKey = reader.bytes();
1002
+ continue;
1003
+ }
1004
+ case 2: {
1005
+ if (tag !== 18) {
1006
+ break;
1007
+ }
1008
+ message.partialTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
1009
+ continue;
1010
+ }
1011
+ case 3: {
1012
+ if (tag !== 26) {
1013
+ break;
1014
+ }
1015
+ message.partialTokenTransactionOwnerSignatures.push(SignatureWithIndex.decode(reader, reader.uint32()));
1016
+ continue;
1017
+ }
1018
+ case 4: {
1019
+ if (tag !== 32) {
1020
+ break;
1021
+ }
1022
+ message.validityDurationSeconds = longToNumber(reader.uint64());
1023
+ continue;
1024
+ }
1025
+ }
1026
+ if ((tag & 7) === 4 || tag === 0) {
1027
+ break;
1028
+ }
1029
+ reader.skip(tag & 7);
1030
+ }
1031
+ return message;
1032
+ },
1033
+ fromJSON(object) {
1034
+ return {
1035
+ identityPublicKey: isSet(object.identityPublicKey) ? bytesFromBase64(object.identityPublicKey) : new Uint8Array(0),
1036
+ partialTokenTransaction: isSet(object.partialTokenTransaction) ? TokenTransaction.fromJSON(object.partialTokenTransaction) : void 0,
1037
+ partialTokenTransactionOwnerSignatures: globalThis.Array.isArray(object?.partialTokenTransactionOwnerSignatures) ? object.partialTokenTransactionOwnerSignatures.map((e) => SignatureWithIndex.fromJSON(e)) : [],
1038
+ validityDurationSeconds: isSet(object.validityDurationSeconds) ? globalThis.Number(object.validityDurationSeconds) : 0
1039
+ };
1040
+ },
1041
+ toJSON(message) {
1042
+ const obj = {};
1043
+ if (message.identityPublicKey.length !== 0) {
1044
+ obj.identityPublicKey = base64FromBytes(message.identityPublicKey);
1045
+ }
1046
+ if (message.partialTokenTransaction !== void 0) {
1047
+ obj.partialTokenTransaction = TokenTransaction.toJSON(message.partialTokenTransaction);
1048
+ }
1049
+ if (message.partialTokenTransactionOwnerSignatures?.length) {
1050
+ obj.partialTokenTransactionOwnerSignatures = message.partialTokenTransactionOwnerSignatures.map(
1051
+ (e) => SignatureWithIndex.toJSON(e)
1052
+ );
1053
+ }
1054
+ if (message.validityDurationSeconds !== 0) {
1055
+ obj.validityDurationSeconds = Math.round(message.validityDurationSeconds);
1056
+ }
1057
+ return obj;
1058
+ },
1059
+ create(base) {
1060
+ return StartTransactionRequest.fromPartial(base ?? {});
1061
+ },
1062
+ fromPartial(object) {
1063
+ const message = createBaseStartTransactionRequest();
1064
+ message.identityPublicKey = object.identityPublicKey ?? new Uint8Array(0);
1065
+ message.partialTokenTransaction = object.partialTokenTransaction !== void 0 && object.partialTokenTransaction !== null ? TokenTransaction.fromPartial(object.partialTokenTransaction) : void 0;
1066
+ message.partialTokenTransactionOwnerSignatures = object.partialTokenTransactionOwnerSignatures?.map((e) => SignatureWithIndex.fromPartial(e)) || [];
1067
+ message.validityDurationSeconds = object.validityDurationSeconds ?? 0;
1068
+ return message;
1069
+ }
1070
+ };
1071
+ function createBaseStartTransactionResponse() {
1072
+ return { finalTokenTransaction: void 0, keyshareInfo: void 0 };
1073
+ }
1074
+ var StartTransactionResponse = {
1075
+ encode(message, writer = new BinaryWriter()) {
1076
+ if (message.finalTokenTransaction !== void 0) {
1077
+ TokenTransaction.encode(message.finalTokenTransaction, writer.uint32(10).fork()).join();
1078
+ }
1079
+ if (message.keyshareInfo !== void 0) {
1080
+ SigningKeyshare.encode(message.keyshareInfo, writer.uint32(18).fork()).join();
1081
+ }
1082
+ return writer;
1083
+ },
1084
+ decode(input, length) {
1085
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1086
+ const end = length === void 0 ? reader.len : reader.pos + length;
1087
+ const message = createBaseStartTransactionResponse();
1088
+ while (reader.pos < end) {
1089
+ const tag = reader.uint32();
1090
+ switch (tag >>> 3) {
1091
+ case 1: {
1092
+ if (tag !== 10) {
1093
+ break;
1094
+ }
1095
+ message.finalTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
1096
+ continue;
1097
+ }
1098
+ case 2: {
1099
+ if (tag !== 18) {
1100
+ break;
1101
+ }
1102
+ message.keyshareInfo = SigningKeyshare.decode(reader, reader.uint32());
1103
+ continue;
1104
+ }
1105
+ }
1106
+ if ((tag & 7) === 4 || tag === 0) {
1107
+ break;
1108
+ }
1109
+ reader.skip(tag & 7);
1110
+ }
1111
+ return message;
1112
+ },
1113
+ fromJSON(object) {
1114
+ return {
1115
+ finalTokenTransaction: isSet(object.finalTokenTransaction) ? TokenTransaction.fromJSON(object.finalTokenTransaction) : void 0,
1116
+ keyshareInfo: isSet(object.keyshareInfo) ? SigningKeyshare.fromJSON(object.keyshareInfo) : void 0
1117
+ };
1118
+ },
1119
+ toJSON(message) {
1120
+ const obj = {};
1121
+ if (message.finalTokenTransaction !== void 0) {
1122
+ obj.finalTokenTransaction = TokenTransaction.toJSON(message.finalTokenTransaction);
1123
+ }
1124
+ if (message.keyshareInfo !== void 0) {
1125
+ obj.keyshareInfo = SigningKeyshare.toJSON(message.keyshareInfo);
1126
+ }
1127
+ return obj;
1128
+ },
1129
+ create(base) {
1130
+ return StartTransactionResponse.fromPartial(base ?? {});
1131
+ },
1132
+ fromPartial(object) {
1133
+ const message = createBaseStartTransactionResponse();
1134
+ message.finalTokenTransaction = object.finalTokenTransaction !== void 0 && object.finalTokenTransaction !== null ? TokenTransaction.fromPartial(object.finalTokenTransaction) : void 0;
1135
+ message.keyshareInfo = object.keyshareInfo !== void 0 && object.keyshareInfo !== null ? SigningKeyshare.fromPartial(object.keyshareInfo) : void 0;
1136
+ return message;
1137
+ }
1138
+ };
1139
+ function createBaseCommitTransactionRequest() {
1140
+ return {
1141
+ finalTokenTransaction: void 0,
1142
+ finalTokenTransactionHash: new Uint8Array(0),
1143
+ inputTtxoSignaturesPerOperator: [],
1144
+ ownerIdentityPublicKey: new Uint8Array(0)
1145
+ };
1146
+ }
1147
+ var CommitTransactionRequest = {
1148
+ encode(message, writer = new BinaryWriter()) {
1149
+ if (message.finalTokenTransaction !== void 0) {
1150
+ TokenTransaction.encode(message.finalTokenTransaction, writer.uint32(10).fork()).join();
1151
+ }
1152
+ if (message.finalTokenTransactionHash.length !== 0) {
1153
+ writer.uint32(18).bytes(message.finalTokenTransactionHash);
1154
+ }
1155
+ for (const v of message.inputTtxoSignaturesPerOperator) {
1156
+ InputTtxoSignaturesPerOperator.encode(v, writer.uint32(26).fork()).join();
1157
+ }
1158
+ if (message.ownerIdentityPublicKey.length !== 0) {
1159
+ writer.uint32(34).bytes(message.ownerIdentityPublicKey);
1160
+ }
1161
+ return writer;
1162
+ },
1163
+ decode(input, length) {
1164
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1165
+ const end = length === void 0 ? reader.len : reader.pos + length;
1166
+ const message = createBaseCommitTransactionRequest();
1167
+ while (reader.pos < end) {
1168
+ const tag = reader.uint32();
1169
+ switch (tag >>> 3) {
1170
+ case 1: {
1171
+ if (tag !== 10) {
1172
+ break;
1173
+ }
1174
+ message.finalTokenTransaction = TokenTransaction.decode(reader, reader.uint32());
1175
+ continue;
1176
+ }
1177
+ case 2: {
1178
+ if (tag !== 18) {
1179
+ break;
1180
+ }
1181
+ message.finalTokenTransactionHash = reader.bytes();
1182
+ continue;
1183
+ }
1184
+ case 3: {
1185
+ if (tag !== 26) {
1186
+ break;
1187
+ }
1188
+ message.inputTtxoSignaturesPerOperator.push(InputTtxoSignaturesPerOperator.decode(reader, reader.uint32()));
1189
+ continue;
1190
+ }
1191
+ case 4: {
1192
+ if (tag !== 34) {
1193
+ break;
1194
+ }
1195
+ message.ownerIdentityPublicKey = reader.bytes();
1196
+ continue;
1197
+ }
1198
+ }
1199
+ if ((tag & 7) === 4 || tag === 0) {
1200
+ break;
1201
+ }
1202
+ reader.skip(tag & 7);
1203
+ }
1204
+ return message;
1205
+ },
1206
+ fromJSON(object) {
1207
+ return {
1208
+ finalTokenTransaction: isSet(object.finalTokenTransaction) ? TokenTransaction.fromJSON(object.finalTokenTransaction) : void 0,
1209
+ finalTokenTransactionHash: isSet(object.finalTokenTransactionHash) ? bytesFromBase64(object.finalTokenTransactionHash) : new Uint8Array(0),
1210
+ inputTtxoSignaturesPerOperator: globalThis.Array.isArray(object?.inputTtxoSignaturesPerOperator) ? object.inputTtxoSignaturesPerOperator.map((e) => InputTtxoSignaturesPerOperator.fromJSON(e)) : [],
1211
+ ownerIdentityPublicKey: isSet(object.ownerIdentityPublicKey) ? bytesFromBase64(object.ownerIdentityPublicKey) : new Uint8Array(0)
1212
+ };
1213
+ },
1214
+ toJSON(message) {
1215
+ const obj = {};
1216
+ if (message.finalTokenTransaction !== void 0) {
1217
+ obj.finalTokenTransaction = TokenTransaction.toJSON(message.finalTokenTransaction);
1218
+ }
1219
+ if (message.finalTokenTransactionHash.length !== 0) {
1220
+ obj.finalTokenTransactionHash = base64FromBytes(message.finalTokenTransactionHash);
1221
+ }
1222
+ if (message.inputTtxoSignaturesPerOperator?.length) {
1223
+ obj.inputTtxoSignaturesPerOperator = message.inputTtxoSignaturesPerOperator.map(
1224
+ (e) => InputTtxoSignaturesPerOperator.toJSON(e)
1225
+ );
1226
+ }
1227
+ if (message.ownerIdentityPublicKey.length !== 0) {
1228
+ obj.ownerIdentityPublicKey = base64FromBytes(message.ownerIdentityPublicKey);
1229
+ }
1230
+ return obj;
1231
+ },
1232
+ create(base) {
1233
+ return CommitTransactionRequest.fromPartial(base ?? {});
1234
+ },
1235
+ fromPartial(object) {
1236
+ const message = createBaseCommitTransactionRequest();
1237
+ message.finalTokenTransaction = object.finalTokenTransaction !== void 0 && object.finalTokenTransaction !== null ? TokenTransaction.fromPartial(object.finalTokenTransaction) : void 0;
1238
+ message.finalTokenTransactionHash = object.finalTokenTransactionHash ?? new Uint8Array(0);
1239
+ message.inputTtxoSignaturesPerOperator = object.inputTtxoSignaturesPerOperator?.map((e) => InputTtxoSignaturesPerOperator.fromPartial(e)) || [];
1240
+ message.ownerIdentityPublicKey = object.ownerIdentityPublicKey ?? new Uint8Array(0);
1241
+ return message;
1242
+ }
1243
+ };
1244
+ function createBaseCommitTransactionResponse() {
1245
+ return {};
1246
+ }
1247
+ var CommitTransactionResponse = {
1248
+ encode(_, writer = new BinaryWriter()) {
1249
+ return writer;
1250
+ },
1251
+ decode(input, length) {
1252
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1253
+ const end = length === void 0 ? reader.len : reader.pos + length;
1254
+ const message = createBaseCommitTransactionResponse();
1255
+ while (reader.pos < end) {
1256
+ const tag = reader.uint32();
1257
+ switch (tag >>> 3) {
1258
+ }
1259
+ if ((tag & 7) === 4 || tag === 0) {
1260
+ break;
1261
+ }
1262
+ reader.skip(tag & 7);
1263
+ }
1264
+ return message;
1265
+ },
1266
+ fromJSON(_) {
1267
+ return {};
1268
+ },
1269
+ toJSON(_) {
1270
+ const obj = {};
1271
+ return obj;
1272
+ },
1273
+ create(base) {
1274
+ return CommitTransactionResponse.fromPartial(base ?? {});
1275
+ },
1276
+ fromPartial(_) {
1277
+ const message = createBaseCommitTransactionResponse();
1278
+ return message;
1279
+ }
1280
+ };
1281
+ function createBaseQueryTokenMetadataRequest() {
1282
+ return { tokenIdentifiers: [], issuerPublicKeys: [] };
1283
+ }
1284
+ var QueryTokenMetadataRequest = {
1285
+ encode(message, writer = new BinaryWriter()) {
1286
+ for (const v of message.tokenIdentifiers) {
1287
+ writer.uint32(10).bytes(v);
1288
+ }
1289
+ for (const v of message.issuerPublicKeys) {
1290
+ writer.uint32(18).bytes(v);
1291
+ }
1292
+ return writer;
1293
+ },
1294
+ decode(input, length) {
1295
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1296
+ const end = length === void 0 ? reader.len : reader.pos + length;
1297
+ const message = createBaseQueryTokenMetadataRequest();
1298
+ while (reader.pos < end) {
1299
+ const tag = reader.uint32();
1300
+ switch (tag >>> 3) {
1301
+ case 1: {
1302
+ if (tag !== 10) {
1303
+ break;
1304
+ }
1305
+ message.tokenIdentifiers.push(reader.bytes());
1306
+ continue;
1307
+ }
1308
+ case 2: {
1309
+ if (tag !== 18) {
1310
+ break;
1311
+ }
1312
+ message.issuerPublicKeys.push(reader.bytes());
1313
+ continue;
1314
+ }
1315
+ }
1316
+ if ((tag & 7) === 4 || tag === 0) {
1317
+ break;
1318
+ }
1319
+ reader.skip(tag & 7);
1320
+ }
1321
+ return message;
1322
+ },
1323
+ fromJSON(object) {
1324
+ return {
1325
+ tokenIdentifiers: globalThis.Array.isArray(object?.tokenIdentifiers) ? object.tokenIdentifiers.map((e) => bytesFromBase64(e)) : [],
1326
+ issuerPublicKeys: globalThis.Array.isArray(object?.issuerPublicKeys) ? object.issuerPublicKeys.map((e) => bytesFromBase64(e)) : []
1327
+ };
1328
+ },
1329
+ toJSON(message) {
1330
+ const obj = {};
1331
+ if (message.tokenIdentifiers?.length) {
1332
+ obj.tokenIdentifiers = message.tokenIdentifiers.map((e) => base64FromBytes(e));
1333
+ }
1334
+ if (message.issuerPublicKeys?.length) {
1335
+ obj.issuerPublicKeys = message.issuerPublicKeys.map((e) => base64FromBytes(e));
1336
+ }
1337
+ return obj;
1338
+ },
1339
+ create(base) {
1340
+ return QueryTokenMetadataRequest.fromPartial(base ?? {});
1341
+ },
1342
+ fromPartial(object) {
1343
+ const message = createBaseQueryTokenMetadataRequest();
1344
+ message.tokenIdentifiers = object.tokenIdentifiers?.map((e) => e) || [];
1345
+ message.issuerPublicKeys = object.issuerPublicKeys?.map((e) => e) || [];
1346
+ return message;
1347
+ }
1348
+ };
1349
+ function createBaseTokenMetadata() {
1350
+ return {
1351
+ issuerPublicKey: new Uint8Array(0),
1352
+ tokenName: "",
1353
+ tokenTicker: "",
1354
+ decimals: 0,
1355
+ maxSupply: new Uint8Array(0),
1356
+ isFreezable: false,
1357
+ creationEntityPublicKey: void 0,
1358
+ tokenIdentifier: new Uint8Array(0)
1359
+ };
1360
+ }
1361
+ var TokenMetadata = {
1362
+ encode(message, writer = new BinaryWriter()) {
1363
+ if (message.issuerPublicKey.length !== 0) {
1364
+ writer.uint32(10).bytes(message.issuerPublicKey);
1365
+ }
1366
+ if (message.tokenName !== "") {
1367
+ writer.uint32(18).string(message.tokenName);
1368
+ }
1369
+ if (message.tokenTicker !== "") {
1370
+ writer.uint32(26).string(message.tokenTicker);
1371
+ }
1372
+ if (message.decimals !== 0) {
1373
+ writer.uint32(32).uint32(message.decimals);
1374
+ }
1375
+ if (message.maxSupply.length !== 0) {
1376
+ writer.uint32(42).bytes(message.maxSupply);
1377
+ }
1378
+ if (message.isFreezable !== false) {
1379
+ writer.uint32(48).bool(message.isFreezable);
1380
+ }
1381
+ if (message.creationEntityPublicKey !== void 0) {
1382
+ writer.uint32(58).bytes(message.creationEntityPublicKey);
1383
+ }
1384
+ if (message.tokenIdentifier.length !== 0) {
1385
+ writer.uint32(66).bytes(message.tokenIdentifier);
1386
+ }
1387
+ return writer;
1388
+ },
1389
+ decode(input, length) {
1390
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1391
+ const end = length === void 0 ? reader.len : reader.pos + length;
1392
+ const message = createBaseTokenMetadata();
1393
+ while (reader.pos < end) {
1394
+ const tag = reader.uint32();
1395
+ switch (tag >>> 3) {
1396
+ case 1: {
1397
+ if (tag !== 10) {
1398
+ break;
1399
+ }
1400
+ message.issuerPublicKey = reader.bytes();
1401
+ continue;
1402
+ }
1403
+ case 2: {
1404
+ if (tag !== 18) {
1405
+ break;
1406
+ }
1407
+ message.tokenName = reader.string();
1408
+ continue;
1409
+ }
1410
+ case 3: {
1411
+ if (tag !== 26) {
1412
+ break;
1413
+ }
1414
+ message.tokenTicker = reader.string();
1415
+ continue;
1416
+ }
1417
+ case 4: {
1418
+ if (tag !== 32) {
1419
+ break;
1420
+ }
1421
+ message.decimals = reader.uint32();
1422
+ continue;
1423
+ }
1424
+ case 5: {
1425
+ if (tag !== 42) {
1426
+ break;
1427
+ }
1428
+ message.maxSupply = reader.bytes();
1429
+ continue;
1430
+ }
1431
+ case 6: {
1432
+ if (tag !== 48) {
1433
+ break;
1434
+ }
1435
+ message.isFreezable = reader.bool();
1436
+ continue;
1437
+ }
1438
+ case 7: {
1439
+ if (tag !== 58) {
1440
+ break;
1441
+ }
1442
+ message.creationEntityPublicKey = reader.bytes();
1443
+ continue;
1444
+ }
1445
+ case 8: {
1446
+ if (tag !== 66) {
1447
+ break;
1448
+ }
1449
+ message.tokenIdentifier = reader.bytes();
1450
+ continue;
1451
+ }
1452
+ }
1453
+ if ((tag & 7) === 4 || tag === 0) {
1454
+ break;
1455
+ }
1456
+ reader.skip(tag & 7);
1457
+ }
1458
+ return message;
1459
+ },
1460
+ fromJSON(object) {
1461
+ return {
1462
+ issuerPublicKey: isSet(object.issuerPublicKey) ? bytesFromBase64(object.issuerPublicKey) : new Uint8Array(0),
1463
+ tokenName: isSet(object.tokenName) ? globalThis.String(object.tokenName) : "",
1464
+ tokenTicker: isSet(object.tokenTicker) ? globalThis.String(object.tokenTicker) : "",
1465
+ decimals: isSet(object.decimals) ? globalThis.Number(object.decimals) : 0,
1466
+ maxSupply: isSet(object.maxSupply) ? bytesFromBase64(object.maxSupply) : new Uint8Array(0),
1467
+ isFreezable: isSet(object.isFreezable) ? globalThis.Boolean(object.isFreezable) : false,
1468
+ creationEntityPublicKey: isSet(object.creationEntityPublicKey) ? bytesFromBase64(object.creationEntityPublicKey) : void 0,
1469
+ tokenIdentifier: isSet(object.tokenIdentifier) ? bytesFromBase64(object.tokenIdentifier) : new Uint8Array(0)
1470
+ };
1471
+ },
1472
+ toJSON(message) {
1473
+ const obj = {};
1474
+ if (message.issuerPublicKey.length !== 0) {
1475
+ obj.issuerPublicKey = base64FromBytes(message.issuerPublicKey);
1476
+ }
1477
+ if (message.tokenName !== "") {
1478
+ obj.tokenName = message.tokenName;
1479
+ }
1480
+ if (message.tokenTicker !== "") {
1481
+ obj.tokenTicker = message.tokenTicker;
1482
+ }
1483
+ if (message.decimals !== 0) {
1484
+ obj.decimals = Math.round(message.decimals);
1485
+ }
1486
+ if (message.maxSupply.length !== 0) {
1487
+ obj.maxSupply = base64FromBytes(message.maxSupply);
1488
+ }
1489
+ if (message.isFreezable !== false) {
1490
+ obj.isFreezable = message.isFreezable;
1491
+ }
1492
+ if (message.creationEntityPublicKey !== void 0) {
1493
+ obj.creationEntityPublicKey = base64FromBytes(message.creationEntityPublicKey);
1494
+ }
1495
+ if (message.tokenIdentifier.length !== 0) {
1496
+ obj.tokenIdentifier = base64FromBytes(message.tokenIdentifier);
1497
+ }
1498
+ return obj;
1499
+ },
1500
+ create(base) {
1501
+ return TokenMetadata.fromPartial(base ?? {});
1502
+ },
1503
+ fromPartial(object) {
1504
+ const message = createBaseTokenMetadata();
1505
+ message.issuerPublicKey = object.issuerPublicKey ?? new Uint8Array(0);
1506
+ message.tokenName = object.tokenName ?? "";
1507
+ message.tokenTicker = object.tokenTicker ?? "";
1508
+ message.decimals = object.decimals ?? 0;
1509
+ message.maxSupply = object.maxSupply ?? new Uint8Array(0);
1510
+ message.isFreezable = object.isFreezable ?? false;
1511
+ message.creationEntityPublicKey = object.creationEntityPublicKey ?? void 0;
1512
+ message.tokenIdentifier = object.tokenIdentifier ?? new Uint8Array(0);
1513
+ return message;
1514
+ }
1515
+ };
1516
+ function createBaseQueryTokenMetadataResponse() {
1517
+ return { tokenMetadata: [] };
1518
+ }
1519
+ var QueryTokenMetadataResponse = {
1520
+ encode(message, writer = new BinaryWriter()) {
1521
+ for (const v of message.tokenMetadata) {
1522
+ TokenMetadata.encode(v, writer.uint32(10).fork()).join();
1523
+ }
1524
+ return writer;
1525
+ },
1526
+ decode(input, length) {
1527
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1528
+ const end = length === void 0 ? reader.len : reader.pos + length;
1529
+ const message = createBaseQueryTokenMetadataResponse();
1530
+ while (reader.pos < end) {
1531
+ const tag = reader.uint32();
1532
+ switch (tag >>> 3) {
1533
+ case 1: {
1534
+ if (tag !== 10) {
1535
+ break;
1536
+ }
1537
+ message.tokenMetadata.push(TokenMetadata.decode(reader, reader.uint32()));
1538
+ continue;
1539
+ }
1540
+ }
1541
+ if ((tag & 7) === 4 || tag === 0) {
1542
+ break;
1543
+ }
1544
+ reader.skip(tag & 7);
1545
+ }
1546
+ return message;
1547
+ },
1548
+ fromJSON(object) {
1549
+ return {
1550
+ tokenMetadata: globalThis.Array.isArray(object?.tokenMetadata) ? object.tokenMetadata.map((e) => TokenMetadata.fromJSON(e)) : []
1551
+ };
1552
+ },
1553
+ toJSON(message) {
1554
+ const obj = {};
1555
+ if (message.tokenMetadata?.length) {
1556
+ obj.tokenMetadata = message.tokenMetadata.map((e) => TokenMetadata.toJSON(e));
1557
+ }
1558
+ return obj;
1559
+ },
1560
+ create(base) {
1561
+ return QueryTokenMetadataResponse.fromPartial(base ?? {});
1562
+ },
1563
+ fromPartial(object) {
1564
+ const message = createBaseQueryTokenMetadataResponse();
1565
+ message.tokenMetadata = object.tokenMetadata?.map((e) => TokenMetadata.fromPartial(e)) || [];
1566
+ return message;
1567
+ }
1568
+ };
1569
+ function createBaseQueryTokenOutputsRequest() {
1570
+ return { ownerPublicKeys: [], issuerPublicKeys: [], tokenIdentifiers: [], network: 0 };
1571
+ }
1572
+ var QueryTokenOutputsRequest = {
1573
+ encode(message, writer = new BinaryWriter()) {
1574
+ for (const v of message.ownerPublicKeys) {
1575
+ writer.uint32(10).bytes(v);
1576
+ }
1577
+ for (const v of message.issuerPublicKeys) {
1578
+ writer.uint32(18).bytes(v);
1579
+ }
1580
+ for (const v of message.tokenIdentifiers) {
1581
+ writer.uint32(34).bytes(v);
1582
+ }
1583
+ if (message.network !== 0) {
1584
+ writer.uint32(24).int32(message.network);
1585
+ }
1586
+ return writer;
1587
+ },
1588
+ decode(input, length) {
1589
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1590
+ const end = length === void 0 ? reader.len : reader.pos + length;
1591
+ const message = createBaseQueryTokenOutputsRequest();
1592
+ while (reader.pos < end) {
1593
+ const tag = reader.uint32();
1594
+ switch (tag >>> 3) {
1595
+ case 1: {
1596
+ if (tag !== 10) {
1597
+ break;
1598
+ }
1599
+ message.ownerPublicKeys.push(reader.bytes());
1600
+ continue;
1601
+ }
1602
+ case 2: {
1603
+ if (tag !== 18) {
1604
+ break;
1605
+ }
1606
+ message.issuerPublicKeys.push(reader.bytes());
1607
+ continue;
1608
+ }
1609
+ case 4: {
1610
+ if (tag !== 34) {
1611
+ break;
1612
+ }
1613
+ message.tokenIdentifiers.push(reader.bytes());
1614
+ continue;
1615
+ }
1616
+ case 3: {
1617
+ if (tag !== 24) {
1618
+ break;
1619
+ }
1620
+ message.network = reader.int32();
1621
+ continue;
1622
+ }
1623
+ }
1624
+ if ((tag & 7) === 4 || tag === 0) {
1625
+ break;
1626
+ }
1627
+ reader.skip(tag & 7);
1628
+ }
1629
+ return message;
1630
+ },
1631
+ fromJSON(object) {
1632
+ return {
1633
+ ownerPublicKeys: globalThis.Array.isArray(object?.ownerPublicKeys) ? object.ownerPublicKeys.map((e) => bytesFromBase64(e)) : [],
1634
+ issuerPublicKeys: globalThis.Array.isArray(object?.issuerPublicKeys) ? object.issuerPublicKeys.map((e) => bytesFromBase64(e)) : [],
1635
+ tokenIdentifiers: globalThis.Array.isArray(object?.tokenIdentifiers) ? object.tokenIdentifiers.map((e) => bytesFromBase64(e)) : [],
1636
+ network: isSet(object.network) ? networkFromJSON(object.network) : 0
1637
+ };
1638
+ },
1639
+ toJSON(message) {
1640
+ const obj = {};
1641
+ if (message.ownerPublicKeys?.length) {
1642
+ obj.ownerPublicKeys = message.ownerPublicKeys.map((e) => base64FromBytes(e));
1643
+ }
1644
+ if (message.issuerPublicKeys?.length) {
1645
+ obj.issuerPublicKeys = message.issuerPublicKeys.map((e) => base64FromBytes(e));
1646
+ }
1647
+ if (message.tokenIdentifiers?.length) {
1648
+ obj.tokenIdentifiers = message.tokenIdentifiers.map((e) => base64FromBytes(e));
1649
+ }
1650
+ if (message.network !== 0) {
1651
+ obj.network = networkToJSON(message.network);
1652
+ }
1653
+ return obj;
1654
+ },
1655
+ create(base) {
1656
+ return QueryTokenOutputsRequest.fromPartial(base ?? {});
1657
+ },
1658
+ fromPartial(object) {
1659
+ const message = createBaseQueryTokenOutputsRequest();
1660
+ message.ownerPublicKeys = object.ownerPublicKeys?.map((e) => e) || [];
1661
+ message.issuerPublicKeys = object.issuerPublicKeys?.map((e) => e) || [];
1662
+ message.tokenIdentifiers = object.tokenIdentifiers?.map((e) => e) || [];
1663
+ message.network = object.network ?? 0;
1664
+ return message;
1665
+ }
1666
+ };
1667
+ function createBaseQueryTokenTransactionsRequest() {
1668
+ return {
1669
+ outputIds: [],
1670
+ ownerPublicKeys: [],
1671
+ issuerPublicKeys: [],
1672
+ tokenIdentifiers: [],
1673
+ tokenTransactionHashes: [],
1674
+ limit: 0,
1675
+ offset: 0
1676
+ };
1677
+ }
1678
+ var QueryTokenTransactionsRequest = {
1679
+ encode(message, writer = new BinaryWriter()) {
1680
+ for (const v of message.outputIds) {
1681
+ writer.uint32(10).string(v);
1682
+ }
1683
+ for (const v of message.ownerPublicKeys) {
1684
+ writer.uint32(18).bytes(v);
1685
+ }
1686
+ for (const v of message.issuerPublicKeys) {
1687
+ writer.uint32(26).bytes(v);
1688
+ }
1689
+ for (const v of message.tokenIdentifiers) {
1690
+ writer.uint32(58).bytes(v);
1691
+ }
1692
+ for (const v of message.tokenTransactionHashes) {
1693
+ writer.uint32(34).bytes(v);
1694
+ }
1695
+ if (message.limit !== 0) {
1696
+ writer.uint32(40).int64(message.limit);
1697
+ }
1698
+ if (message.offset !== 0) {
1699
+ writer.uint32(48).int64(message.offset);
1700
+ }
1701
+ return writer;
1702
+ },
1703
+ decode(input, length) {
1704
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1705
+ const end = length === void 0 ? reader.len : reader.pos + length;
1706
+ const message = createBaseQueryTokenTransactionsRequest();
1707
+ while (reader.pos < end) {
1708
+ const tag = reader.uint32();
1709
+ switch (tag >>> 3) {
1710
+ case 1: {
1711
+ if (tag !== 10) {
1712
+ break;
1713
+ }
1714
+ message.outputIds.push(reader.string());
1715
+ continue;
1716
+ }
1717
+ case 2: {
1718
+ if (tag !== 18) {
1719
+ break;
1720
+ }
1721
+ message.ownerPublicKeys.push(reader.bytes());
1722
+ continue;
1723
+ }
1724
+ case 3: {
1725
+ if (tag !== 26) {
1726
+ break;
1727
+ }
1728
+ message.issuerPublicKeys.push(reader.bytes());
1729
+ continue;
1730
+ }
1731
+ case 7: {
1732
+ if (tag !== 58) {
1733
+ break;
1734
+ }
1735
+ message.tokenIdentifiers.push(reader.bytes());
1736
+ continue;
1737
+ }
1738
+ case 4: {
1739
+ if (tag !== 34) {
1740
+ break;
1741
+ }
1742
+ message.tokenTransactionHashes.push(reader.bytes());
1743
+ continue;
1744
+ }
1745
+ case 5: {
1746
+ if (tag !== 40) {
1747
+ break;
1748
+ }
1749
+ message.limit = longToNumber(reader.int64());
1750
+ continue;
1751
+ }
1752
+ case 6: {
1753
+ if (tag !== 48) {
1754
+ break;
1755
+ }
1756
+ message.offset = longToNumber(reader.int64());
1757
+ continue;
1758
+ }
1759
+ }
1760
+ if ((tag & 7) === 4 || tag === 0) {
1761
+ break;
1762
+ }
1763
+ reader.skip(tag & 7);
1764
+ }
1765
+ return message;
1766
+ },
1767
+ fromJSON(object) {
1768
+ return {
1769
+ outputIds: globalThis.Array.isArray(object?.outputIds) ? object.outputIds.map((e) => globalThis.String(e)) : [],
1770
+ ownerPublicKeys: globalThis.Array.isArray(object?.ownerPublicKeys) ? object.ownerPublicKeys.map((e) => bytesFromBase64(e)) : [],
1771
+ issuerPublicKeys: globalThis.Array.isArray(object?.issuerPublicKeys) ? object.issuerPublicKeys.map((e) => bytesFromBase64(e)) : [],
1772
+ tokenIdentifiers: globalThis.Array.isArray(object?.tokenIdentifiers) ? object.tokenIdentifiers.map((e) => bytesFromBase64(e)) : [],
1773
+ tokenTransactionHashes: globalThis.Array.isArray(object?.tokenTransactionHashes) ? object.tokenTransactionHashes.map((e) => bytesFromBase64(e)) : [],
1774
+ limit: isSet(object.limit) ? globalThis.Number(object.limit) : 0,
1775
+ offset: isSet(object.offset) ? globalThis.Number(object.offset) : 0
1776
+ };
1777
+ },
1778
+ toJSON(message) {
1779
+ const obj = {};
1780
+ if (message.outputIds?.length) {
1781
+ obj.outputIds = message.outputIds;
1782
+ }
1783
+ if (message.ownerPublicKeys?.length) {
1784
+ obj.ownerPublicKeys = message.ownerPublicKeys.map((e) => base64FromBytes(e));
1785
+ }
1786
+ if (message.issuerPublicKeys?.length) {
1787
+ obj.issuerPublicKeys = message.issuerPublicKeys.map((e) => base64FromBytes(e));
1788
+ }
1789
+ if (message.tokenIdentifiers?.length) {
1790
+ obj.tokenIdentifiers = message.tokenIdentifiers.map((e) => base64FromBytes(e));
1791
+ }
1792
+ if (message.tokenTransactionHashes?.length) {
1793
+ obj.tokenTransactionHashes = message.tokenTransactionHashes.map((e) => base64FromBytes(e));
1794
+ }
1795
+ if (message.limit !== 0) {
1796
+ obj.limit = Math.round(message.limit);
1797
+ }
1798
+ if (message.offset !== 0) {
1799
+ obj.offset = Math.round(message.offset);
1800
+ }
1801
+ return obj;
1802
+ },
1803
+ create(base) {
1804
+ return QueryTokenTransactionsRequest.fromPartial(base ?? {});
1805
+ },
1806
+ fromPartial(object) {
1807
+ const message = createBaseQueryTokenTransactionsRequest();
1808
+ message.outputIds = object.outputIds?.map((e) => e) || [];
1809
+ message.ownerPublicKeys = object.ownerPublicKeys?.map((e) => e) || [];
1810
+ message.issuerPublicKeys = object.issuerPublicKeys?.map((e) => e) || [];
1811
+ message.tokenIdentifiers = object.tokenIdentifiers?.map((e) => e) || [];
1812
+ message.tokenTransactionHashes = object.tokenTransactionHashes?.map((e) => e) || [];
1813
+ message.limit = object.limit ?? 0;
1814
+ message.offset = object.offset ?? 0;
1815
+ return message;
1816
+ }
1817
+ };
1818
+ function createBaseQueryTokenTransactionsResponse() {
1819
+ return { tokenTransactionsWithStatus: [], offset: 0 };
1820
+ }
1821
+ var QueryTokenTransactionsResponse = {
1822
+ encode(message, writer = new BinaryWriter()) {
1823
+ for (const v of message.tokenTransactionsWithStatus) {
1824
+ TokenTransactionWithStatus.encode(v, writer.uint32(10).fork()).join();
1825
+ }
1826
+ if (message.offset !== 0) {
1827
+ writer.uint32(16).int64(message.offset);
1828
+ }
1829
+ return writer;
1830
+ },
1831
+ decode(input, length) {
1832
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1833
+ const end = length === void 0 ? reader.len : reader.pos + length;
1834
+ const message = createBaseQueryTokenTransactionsResponse();
1835
+ while (reader.pos < end) {
1836
+ const tag = reader.uint32();
1837
+ switch (tag >>> 3) {
1838
+ case 1: {
1839
+ if (tag !== 10) {
1840
+ break;
1841
+ }
1842
+ message.tokenTransactionsWithStatus.push(TokenTransactionWithStatus.decode(reader, reader.uint32()));
1843
+ continue;
1844
+ }
1845
+ case 2: {
1846
+ if (tag !== 16) {
1847
+ break;
1848
+ }
1849
+ message.offset = longToNumber(reader.int64());
1850
+ continue;
1851
+ }
1852
+ }
1853
+ if ((tag & 7) === 4 || tag === 0) {
1854
+ break;
1855
+ }
1856
+ reader.skip(tag & 7);
1857
+ }
1858
+ return message;
1859
+ },
1860
+ fromJSON(object) {
1861
+ return {
1862
+ tokenTransactionsWithStatus: globalThis.Array.isArray(object?.tokenTransactionsWithStatus) ? object.tokenTransactionsWithStatus.map((e) => TokenTransactionWithStatus.fromJSON(e)) : [],
1863
+ offset: isSet(object.offset) ? globalThis.Number(object.offset) : 0
1864
+ };
1865
+ },
1866
+ toJSON(message) {
1867
+ const obj = {};
1868
+ if (message.tokenTransactionsWithStatus?.length) {
1869
+ obj.tokenTransactionsWithStatus = message.tokenTransactionsWithStatus.map(
1870
+ (e) => TokenTransactionWithStatus.toJSON(e)
1871
+ );
1872
+ }
1873
+ if (message.offset !== 0) {
1874
+ obj.offset = Math.round(message.offset);
1875
+ }
1876
+ return obj;
1877
+ },
1878
+ create(base) {
1879
+ return QueryTokenTransactionsResponse.fromPartial(base ?? {});
1880
+ },
1881
+ fromPartial(object) {
1882
+ const message = createBaseQueryTokenTransactionsResponse();
1883
+ message.tokenTransactionsWithStatus = object.tokenTransactionsWithStatus?.map((e) => TokenTransactionWithStatus.fromPartial(e)) || [];
1884
+ message.offset = object.offset ?? 0;
1885
+ return message;
1886
+ }
1887
+ };
1888
+ function createBaseOutputWithPreviousTransactionData() {
1889
+ return { output: void 0, previousTransactionHash: new Uint8Array(0), previousTransactionVout: 0 };
1890
+ }
1891
+ var OutputWithPreviousTransactionData = {
1892
+ encode(message, writer = new BinaryWriter()) {
1893
+ if (message.output !== void 0) {
1894
+ TokenOutput.encode(message.output, writer.uint32(10).fork()).join();
1895
+ }
1896
+ if (message.previousTransactionHash.length !== 0) {
1897
+ writer.uint32(18).bytes(message.previousTransactionHash);
1898
+ }
1899
+ if (message.previousTransactionVout !== 0) {
1900
+ writer.uint32(24).uint32(message.previousTransactionVout);
1901
+ }
1902
+ return writer;
1903
+ },
1904
+ decode(input, length) {
1905
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1906
+ const end = length === void 0 ? reader.len : reader.pos + length;
1907
+ const message = createBaseOutputWithPreviousTransactionData();
1908
+ while (reader.pos < end) {
1909
+ const tag = reader.uint32();
1910
+ switch (tag >>> 3) {
1911
+ case 1: {
1912
+ if (tag !== 10) {
1913
+ break;
1914
+ }
1915
+ message.output = TokenOutput.decode(reader, reader.uint32());
1916
+ continue;
1917
+ }
1918
+ case 2: {
1919
+ if (tag !== 18) {
1920
+ break;
1921
+ }
1922
+ message.previousTransactionHash = reader.bytes();
1923
+ continue;
1924
+ }
1925
+ case 3: {
1926
+ if (tag !== 24) {
1927
+ break;
1928
+ }
1929
+ message.previousTransactionVout = reader.uint32();
1930
+ continue;
1931
+ }
1932
+ }
1933
+ if ((tag & 7) === 4 || tag === 0) {
1934
+ break;
1935
+ }
1936
+ reader.skip(tag & 7);
1937
+ }
1938
+ return message;
1939
+ },
1940
+ fromJSON(object) {
1941
+ return {
1942
+ output: isSet(object.output) ? TokenOutput.fromJSON(object.output) : void 0,
1943
+ previousTransactionHash: isSet(object.previousTransactionHash) ? bytesFromBase64(object.previousTransactionHash) : new Uint8Array(0),
1944
+ previousTransactionVout: isSet(object.previousTransactionVout) ? globalThis.Number(object.previousTransactionVout) : 0
1945
+ };
1946
+ },
1947
+ toJSON(message) {
1948
+ const obj = {};
1949
+ if (message.output !== void 0) {
1950
+ obj.output = TokenOutput.toJSON(message.output);
1951
+ }
1952
+ if (message.previousTransactionHash.length !== 0) {
1953
+ obj.previousTransactionHash = base64FromBytes(message.previousTransactionHash);
1954
+ }
1955
+ if (message.previousTransactionVout !== 0) {
1956
+ obj.previousTransactionVout = Math.round(message.previousTransactionVout);
1957
+ }
1958
+ return obj;
1959
+ },
1960
+ create(base) {
1961
+ return OutputWithPreviousTransactionData.fromPartial(base ?? {});
1962
+ },
1963
+ fromPartial(object) {
1964
+ const message = createBaseOutputWithPreviousTransactionData();
1965
+ message.output = object.output !== void 0 && object.output !== null ? TokenOutput.fromPartial(object.output) : void 0;
1966
+ message.previousTransactionHash = object.previousTransactionHash ?? new Uint8Array(0);
1967
+ message.previousTransactionVout = object.previousTransactionVout ?? 0;
1968
+ return message;
1969
+ }
1970
+ };
1971
+ function createBaseQueryTokenOutputsResponse() {
1972
+ return { outputsWithPreviousTransactionData: [] };
1973
+ }
1974
+ var QueryTokenOutputsResponse = {
1975
+ encode(message, writer = new BinaryWriter()) {
1976
+ for (const v of message.outputsWithPreviousTransactionData) {
1977
+ OutputWithPreviousTransactionData.encode(v, writer.uint32(10).fork()).join();
1978
+ }
1979
+ return writer;
1980
+ },
1981
+ decode(input, length) {
1982
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1983
+ const end = length === void 0 ? reader.len : reader.pos + length;
1984
+ const message = createBaseQueryTokenOutputsResponse();
1985
+ while (reader.pos < end) {
1986
+ const tag = reader.uint32();
1987
+ switch (tag >>> 3) {
1988
+ case 1: {
1989
+ if (tag !== 10) {
1990
+ break;
1991
+ }
1992
+ message.outputsWithPreviousTransactionData.push(
1993
+ OutputWithPreviousTransactionData.decode(reader, reader.uint32())
1994
+ );
1995
+ continue;
1996
+ }
1997
+ }
1998
+ if ((tag & 7) === 4 || tag === 0) {
1999
+ break;
2000
+ }
2001
+ reader.skip(tag & 7);
2002
+ }
2003
+ return message;
2004
+ },
2005
+ fromJSON(object) {
2006
+ return {
2007
+ outputsWithPreviousTransactionData: globalThis.Array.isArray(object?.outputsWithPreviousTransactionData) ? object.outputsWithPreviousTransactionData.map((e) => OutputWithPreviousTransactionData.fromJSON(e)) : []
2008
+ };
2009
+ },
2010
+ toJSON(message) {
2011
+ const obj = {};
2012
+ if (message.outputsWithPreviousTransactionData?.length) {
2013
+ obj.outputsWithPreviousTransactionData = message.outputsWithPreviousTransactionData.map(
2014
+ (e) => OutputWithPreviousTransactionData.toJSON(e)
2015
+ );
2016
+ }
2017
+ return obj;
2018
+ },
2019
+ create(base) {
2020
+ return QueryTokenOutputsResponse.fromPartial(base ?? {});
2021
+ },
2022
+ fromPartial(object) {
2023
+ const message = createBaseQueryTokenOutputsResponse();
2024
+ message.outputsWithPreviousTransactionData = object.outputsWithPreviousTransactionData?.map((e) => OutputWithPreviousTransactionData.fromPartial(e)) || [];
2025
+ return message;
2026
+ }
2027
+ };
2028
+ function createBaseSpentTokenOutputMetadata() {
2029
+ return { outputId: "", revocationSecret: new Uint8Array(0) };
2030
+ }
2031
+ var SpentTokenOutputMetadata = {
2032
+ encode(message, writer = new BinaryWriter()) {
2033
+ if (message.outputId !== "") {
2034
+ writer.uint32(10).string(message.outputId);
2035
+ }
2036
+ if (message.revocationSecret.length !== 0) {
2037
+ writer.uint32(18).bytes(message.revocationSecret);
2038
+ }
2039
+ return writer;
2040
+ },
2041
+ decode(input, length) {
2042
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2043
+ const end = length === void 0 ? reader.len : reader.pos + length;
2044
+ const message = createBaseSpentTokenOutputMetadata();
2045
+ while (reader.pos < end) {
2046
+ const tag = reader.uint32();
2047
+ switch (tag >>> 3) {
2048
+ case 1: {
2049
+ if (tag !== 10) {
2050
+ break;
2051
+ }
2052
+ message.outputId = reader.string();
2053
+ continue;
2054
+ }
2055
+ case 2: {
2056
+ if (tag !== 18) {
2057
+ break;
2058
+ }
2059
+ message.revocationSecret = reader.bytes();
2060
+ continue;
2061
+ }
2062
+ }
2063
+ if ((tag & 7) === 4 || tag === 0) {
2064
+ break;
2065
+ }
2066
+ reader.skip(tag & 7);
2067
+ }
2068
+ return message;
2069
+ },
2070
+ fromJSON(object) {
2071
+ return {
2072
+ outputId: isSet(object.outputId) ? globalThis.String(object.outputId) : "",
2073
+ revocationSecret: isSet(object.revocationSecret) ? bytesFromBase64(object.revocationSecret) : new Uint8Array(0)
2074
+ };
2075
+ },
2076
+ toJSON(message) {
2077
+ const obj = {};
2078
+ if (message.outputId !== "") {
2079
+ obj.outputId = message.outputId;
2080
+ }
2081
+ if (message.revocationSecret.length !== 0) {
2082
+ obj.revocationSecret = base64FromBytes(message.revocationSecret);
2083
+ }
2084
+ return obj;
2085
+ },
2086
+ create(base) {
2087
+ return SpentTokenOutputMetadata.fromPartial(base ?? {});
2088
+ },
2089
+ fromPartial(object) {
2090
+ const message = createBaseSpentTokenOutputMetadata();
2091
+ message.outputId = object.outputId ?? "";
2092
+ message.revocationSecret = object.revocationSecret ?? new Uint8Array(0);
2093
+ return message;
2094
+ }
2095
+ };
2096
+ function createBaseTokenTransactionConfirmationMetadata() {
2097
+ return { spentTokenOutputsMetadata: [] };
2098
+ }
2099
+ var TokenTransactionConfirmationMetadata = {
2100
+ encode(message, writer = new BinaryWriter()) {
2101
+ for (const v of message.spentTokenOutputsMetadata) {
2102
+ SpentTokenOutputMetadata.encode(v, writer.uint32(10).fork()).join();
2103
+ }
2104
+ return writer;
2105
+ },
2106
+ decode(input, length) {
2107
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2108
+ const end = length === void 0 ? reader.len : reader.pos + length;
2109
+ const message = createBaseTokenTransactionConfirmationMetadata();
2110
+ while (reader.pos < end) {
2111
+ const tag = reader.uint32();
2112
+ switch (tag >>> 3) {
2113
+ case 1: {
2114
+ if (tag !== 10) {
2115
+ break;
2116
+ }
2117
+ message.spentTokenOutputsMetadata.push(SpentTokenOutputMetadata.decode(reader, reader.uint32()));
2118
+ continue;
2119
+ }
2120
+ }
2121
+ if ((tag & 7) === 4 || tag === 0) {
2122
+ break;
2123
+ }
2124
+ reader.skip(tag & 7);
2125
+ }
2126
+ return message;
2127
+ },
2128
+ fromJSON(object) {
2129
+ return {
2130
+ spentTokenOutputsMetadata: globalThis.Array.isArray(object?.spentTokenOutputsMetadata) ? object.spentTokenOutputsMetadata.map((e) => SpentTokenOutputMetadata.fromJSON(e)) : []
2131
+ };
2132
+ },
2133
+ toJSON(message) {
2134
+ const obj = {};
2135
+ if (message.spentTokenOutputsMetadata?.length) {
2136
+ obj.spentTokenOutputsMetadata = message.spentTokenOutputsMetadata.map((e) => SpentTokenOutputMetadata.toJSON(e));
2137
+ }
2138
+ return obj;
2139
+ },
2140
+ create(base) {
2141
+ return TokenTransactionConfirmationMetadata.fromPartial(base ?? {});
2142
+ },
2143
+ fromPartial(object) {
2144
+ const message = createBaseTokenTransactionConfirmationMetadata();
2145
+ message.spentTokenOutputsMetadata = object.spentTokenOutputsMetadata?.map((e) => SpentTokenOutputMetadata.fromPartial(e)) || [];
2146
+ return message;
2147
+ }
2148
+ };
2149
+ function createBaseTokenTransactionWithStatus() {
2150
+ return { tokenTransaction: void 0, status: 0, confirmationMetadata: void 0 };
2151
+ }
2152
+ var TokenTransactionWithStatus = {
2153
+ encode(message, writer = new BinaryWriter()) {
2154
+ if (message.tokenTransaction !== void 0) {
2155
+ TokenTransaction.encode(message.tokenTransaction, writer.uint32(10).fork()).join();
2156
+ }
2157
+ if (message.status !== 0) {
2158
+ writer.uint32(16).int32(message.status);
2159
+ }
2160
+ if (message.confirmationMetadata !== void 0) {
2161
+ TokenTransactionConfirmationMetadata.encode(message.confirmationMetadata, writer.uint32(26).fork()).join();
2162
+ }
2163
+ return writer;
2164
+ },
2165
+ decode(input, length) {
2166
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2167
+ const end = length === void 0 ? reader.len : reader.pos + length;
2168
+ const message = createBaseTokenTransactionWithStatus();
2169
+ while (reader.pos < end) {
2170
+ const tag = reader.uint32();
2171
+ switch (tag >>> 3) {
2172
+ case 1: {
2173
+ if (tag !== 10) {
2174
+ break;
2175
+ }
2176
+ message.tokenTransaction = TokenTransaction.decode(reader, reader.uint32());
2177
+ continue;
2178
+ }
2179
+ case 2: {
2180
+ if (tag !== 16) {
2181
+ break;
2182
+ }
2183
+ message.status = reader.int32();
2184
+ continue;
2185
+ }
2186
+ case 3: {
2187
+ if (tag !== 26) {
2188
+ break;
2189
+ }
2190
+ message.confirmationMetadata = TokenTransactionConfirmationMetadata.decode(reader, reader.uint32());
2191
+ continue;
2192
+ }
2193
+ }
2194
+ if ((tag & 7) === 4 || tag === 0) {
2195
+ break;
2196
+ }
2197
+ reader.skip(tag & 7);
2198
+ }
2199
+ return message;
2200
+ },
2201
+ fromJSON(object) {
2202
+ return {
2203
+ tokenTransaction: isSet(object.tokenTransaction) ? TokenTransaction.fromJSON(object.tokenTransaction) : void 0,
2204
+ status: isSet(object.status) ? tokenTransactionStatusFromJSON(object.status) : 0,
2205
+ confirmationMetadata: isSet(object.confirmationMetadata) ? TokenTransactionConfirmationMetadata.fromJSON(object.confirmationMetadata) : void 0
2206
+ };
2207
+ },
2208
+ toJSON(message) {
2209
+ const obj = {};
2210
+ if (message.tokenTransaction !== void 0) {
2211
+ obj.tokenTransaction = TokenTransaction.toJSON(message.tokenTransaction);
2212
+ }
2213
+ if (message.status !== 0) {
2214
+ obj.status = tokenTransactionStatusToJSON(message.status);
2215
+ }
2216
+ if (message.confirmationMetadata !== void 0) {
2217
+ obj.confirmationMetadata = TokenTransactionConfirmationMetadata.toJSON(message.confirmationMetadata);
2218
+ }
2219
+ return obj;
2220
+ },
2221
+ create(base) {
2222
+ return TokenTransactionWithStatus.fromPartial(base ?? {});
2223
+ },
2224
+ fromPartial(object) {
2225
+ const message = createBaseTokenTransactionWithStatus();
2226
+ message.tokenTransaction = object.tokenTransaction !== void 0 && object.tokenTransaction !== null ? TokenTransaction.fromPartial(object.tokenTransaction) : void 0;
2227
+ message.status = object.status ?? 0;
2228
+ message.confirmationMetadata = object.confirmationMetadata !== void 0 && object.confirmationMetadata !== null ? TokenTransactionConfirmationMetadata.fromPartial(object.confirmationMetadata) : void 0;
2229
+ return message;
2230
+ }
2231
+ };
2232
+ var SparkTokenServiceDefinition = {
2233
+ name: "SparkTokenService",
2234
+ fullName: "spark_token.SparkTokenService",
2235
+ methods: {
2236
+ /**
2237
+ * Start process to create final token transaction with all inputs required
2238
+ * from user and SOs (including revocation secret commitment)
2239
+ */
2240
+ start_transaction: {
2241
+ name: "start_transaction",
2242
+ requestType: StartTransactionRequest,
2243
+ requestStream: false,
2244
+ responseType: StartTransactionResponse,
2245
+ responseStream: false,
2246
+ options: {}
2247
+ },
2248
+ /**
2249
+ * Complete the transaction and commit it with all SOs. This will be
2250
+ * coordinated by one SO.
2251
+ */
2252
+ commit_transaction: {
2253
+ name: "commit_transaction",
2254
+ requestType: CommitTransactionRequest,
2255
+ requestStream: false,
2256
+ responseType: CommitTransactionResponse,
2257
+ responseStream: false,
2258
+ options: {}
2259
+ },
2260
+ query_token_metadata: {
2261
+ name: "query_token_metadata",
2262
+ requestType: QueryTokenMetadataRequest,
2263
+ requestStream: false,
2264
+ responseType: QueryTokenMetadataResponse,
2265
+ responseStream: false,
2266
+ options: {}
2267
+ },
2268
+ query_token_transactions: {
2269
+ name: "query_token_transactions",
2270
+ requestType: QueryTokenTransactionsRequest,
2271
+ requestStream: false,
2272
+ responseType: QueryTokenTransactionsResponse,
2273
+ responseStream: false,
2274
+ options: {}
2275
+ },
2276
+ query_token_outputs: {
2277
+ name: "query_token_outputs",
2278
+ requestType: QueryTokenOutputsRequest,
2279
+ requestStream: false,
2280
+ responseType: QueryTokenOutputsResponse,
2281
+ responseStream: false,
2282
+ options: {}
2283
+ }
2284
+ }
2285
+ };
2286
+ function bytesFromBase64(b64) {
2287
+ if (globalThis.Buffer) {
2288
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2289
+ } else {
2290
+ const bin = globalThis.atob(b64);
2291
+ const arr = new Uint8Array(bin.length);
2292
+ for (let i = 0; i < bin.length; ++i) {
2293
+ arr[i] = bin.charCodeAt(i);
2294
+ }
2295
+ return arr;
2296
+ }
2297
+ }
2298
+ function base64FromBytes(arr) {
2299
+ if (globalThis.Buffer) {
2300
+ return globalThis.Buffer.from(arr).toString("base64");
2301
+ } else {
2302
+ const bin = [];
2303
+ arr.forEach((byte) => {
2304
+ bin.push(globalThis.String.fromCharCode(byte));
2305
+ });
2306
+ return globalThis.btoa(bin.join(""));
2307
+ }
2308
+ }
2309
+ function toTimestamp(date) {
2310
+ const seconds = Math.trunc(date.getTime() / 1e3);
2311
+ const nanos = date.getTime() % 1e3 * 1e6;
2312
+ return { seconds, nanos };
2313
+ }
2314
+ function fromTimestamp(t) {
2315
+ let millis = (t.seconds || 0) * 1e3;
2316
+ millis += (t.nanos || 0) / 1e6;
2317
+ return new globalThis.Date(millis);
2318
+ }
2319
+ function fromJsonTimestamp(o) {
2320
+ if (o instanceof globalThis.Date) {
2321
+ return o;
2322
+ } else if (typeof o === "string") {
2323
+ return new globalThis.Date(o);
2324
+ } else {
2325
+ return fromTimestamp(Timestamp.fromJSON(o));
2326
+ }
2327
+ }
2328
+ function longToNumber(int64) {
2329
+ const num = globalThis.Number(int64.toString());
2330
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
2331
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
2332
+ }
2333
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
2334
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
2335
+ }
2336
+ return num;
2337
+ }
2338
+ function isSet(value) {
2339
+ return value !== null && value !== void 0;
2340
+ }
2341
+
2342
+ export {
2343
+ protobufPackage,
2344
+ TokenTransactionType,
2345
+ tokenTransactionTypeFromJSON,
2346
+ tokenTransactionTypeToJSON,
2347
+ TokenTransactionStatus,
2348
+ tokenTransactionStatusFromJSON,
2349
+ tokenTransactionStatusToJSON,
2350
+ TokenOutputToSpend,
2351
+ TokenTransferInput,
2352
+ TokenMintInput,
2353
+ TokenCreateInput,
2354
+ TokenOutput,
2355
+ TokenTransaction,
2356
+ SignatureWithIndex,
2357
+ InputTtxoSignaturesPerOperator,
2358
+ StartTransactionRequest,
2359
+ StartTransactionResponse,
2360
+ CommitTransactionRequest,
2361
+ CommitTransactionResponse,
2362
+ QueryTokenMetadataRequest,
2363
+ TokenMetadata,
2364
+ QueryTokenMetadataResponse,
2365
+ QueryTokenOutputsRequest,
2366
+ QueryTokenTransactionsRequest,
2367
+ QueryTokenTransactionsResponse,
2368
+ OutputWithPreviousTransactionData,
2369
+ QueryTokenOutputsResponse,
2370
+ SpentTokenOutputMetadata,
2371
+ TokenTransactionConfirmationMetadata,
2372
+ TokenTransactionWithStatus,
2373
+ SparkTokenServiceDefinition
2374
+ };