@buildonspark/issuer-sdk 0.1.35 → 0.1.36

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.
@@ -9,7 +9,7 @@ function hashFreezeTokensPayload(payload) {
9
9
  value: payload,
10
10
  expected: "valid freeze tokens payload"
11
11
  });
12
- let allHashes = [];
12
+ const allHashes = [];
13
13
  const versionHashObj = sha256.create();
14
14
  const versionBytes = new Uint8Array(4);
15
15
  new DataView(versionBytes.buffer).setUint32(0, payload.version, false);
@@ -93,101 +93,109 @@ var IssuerTokenTransactionService = class extends TokenTransactionService {
93
93
  constructor(config, connectionManager) {
94
94
  super(config, connectionManager);
95
95
  }
96
- async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
97
- return {
98
- version: 2,
99
- network: this.config.getNetworkProto(),
100
- tokenInputs: {
101
- $case: "mintInput",
102
- mintInput: {
103
- issuerPublicKey: issuerTokenPublicKey,
104
- tokenIdentifier: rawTokenIdentifierBytes
105
- }
106
- },
107
- tokenOutputs: [{
108
- ownerPublicKey: issuerTokenPublicKey,
109
- tokenIdentifier: rawTokenIdentifierBytes,
110
- tokenAmount: numberToBytesBE(tokenAmount, 16)
111
- }],
112
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
113
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
114
- expiryTime: void 0,
115
- invoiceAttachments: []
116
- };
117
- }
118
- async constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
119
- return {
120
- version: 3,
121
- tokenTransactionMetadata: {
96
+ constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
97
+ return new Promise((resolve) => {
98
+ resolve({
99
+ version: 2,
122
100
  network: this.config.getNetworkProto(),
123
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
124
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
125
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
101
+ tokenInputs: {
102
+ $case: "mintInput",
103
+ mintInput: {
104
+ issuerPublicKey: issuerTokenPublicKey,
105
+ tokenIdentifier: rawTokenIdentifierBytes
106
+ }
107
+ },
108
+ tokenOutputs: [{
109
+ ownerPublicKey: issuerTokenPublicKey,
110
+ tokenIdentifier: rawTokenIdentifierBytes,
111
+ tokenAmount: numberToBytesBE(tokenAmount, 16)
112
+ }],
113
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
114
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
115
+ expiryTime: void 0,
126
116
  invoiceAttachments: []
127
- },
128
- tokenInputs: {
129
- $case: "mintInput",
130
- mintInput: {
131
- issuerPublicKey: issuerTokenPublicKey,
132
- tokenIdentifier: rawTokenIdentifierBytes
133
- }
134
- },
135
- partialTokenOutputs: [{
136
- ownerPublicKey: issuerTokenPublicKey,
137
- tokenIdentifier: rawTokenIdentifierBytes,
138
- withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
139
- withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
140
- tokenAmount: numberToBytesBE(tokenAmount, 16)
141
- }]
142
- };
117
+ });
118
+ });
143
119
  }
144
- async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
145
- return {
146
- version: 2,
147
- network: this.config.getNetworkProto(),
148
- tokenInputs: {
149
- $case: "createInput",
150
- createInput: {
151
- issuerPublicKey: tokenPublicKey,
152
- tokenName,
153
- tokenTicker,
154
- decimals,
155
- maxSupply: numberToBytesBE(maxSupply, 16),
156
- isFreezable,
157
- extraMetadata
158
- }
159
- },
160
- tokenOutputs: [],
161
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
162
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
163
- expiryTime: void 0,
164
- invoiceAttachments: []
165
- };
120
+ constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
121
+ return new Promise((resolve) => {
122
+ resolve({
123
+ version: 3,
124
+ tokenTransactionMetadata: {
125
+ network: this.config.getNetworkProto(),
126
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
127
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
128
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
129
+ invoiceAttachments: []
130
+ },
131
+ tokenInputs: {
132
+ $case: "mintInput",
133
+ mintInput: {
134
+ issuerPublicKey: issuerTokenPublicKey,
135
+ tokenIdentifier: rawTokenIdentifierBytes
136
+ }
137
+ },
138
+ partialTokenOutputs: [{
139
+ ownerPublicKey: issuerTokenPublicKey,
140
+ tokenIdentifier: rawTokenIdentifierBytes,
141
+ withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
142
+ withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
143
+ tokenAmount: numberToBytesBE(tokenAmount, 16)
144
+ }]
145
+ });
146
+ });
166
147
  }
167
- async constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
168
- return {
169
- version: 3,
170
- tokenTransactionMetadata: {
148
+ constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
149
+ return new Promise((resolve) => {
150
+ resolve({
151
+ version: 2,
171
152
  network: this.config.getNetworkProto(),
172
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
173
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
174
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
153
+ tokenInputs: {
154
+ $case: "createInput",
155
+ createInput: {
156
+ issuerPublicKey: tokenPublicKey,
157
+ tokenName,
158
+ tokenTicker,
159
+ decimals,
160
+ maxSupply: numberToBytesBE(maxSupply, 16),
161
+ isFreezable,
162
+ extraMetadata
163
+ }
164
+ },
165
+ tokenOutputs: [],
166
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
167
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
168
+ expiryTime: void 0,
175
169
  invoiceAttachments: []
176
- },
177
- tokenInputs: {
178
- $case: "createInput",
179
- createInput: {
180
- issuerPublicKey: tokenPublicKey,
181
- tokenName,
182
- tokenTicker,
183
- decimals,
184
- maxSupply: numberToBytesBE(maxSupply, 16),
185
- isFreezable,
186
- extraMetadata
187
- }
188
- },
189
- partialTokenOutputs: []
190
- };
170
+ });
171
+ });
172
+ }
173
+ constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
174
+ return new Promise((resolve) => {
175
+ resolve({
176
+ version: 3,
177
+ tokenTransactionMetadata: {
178
+ network: this.config.getNetworkProto(),
179
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
180
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
181
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
182
+ invoiceAttachments: []
183
+ },
184
+ tokenInputs: {
185
+ $case: "createInput",
186
+ createInput: {
187
+ issuerPublicKey: tokenPublicKey,
188
+ tokenName,
189
+ tokenTicker,
190
+ decimals,
191
+ maxSupply: numberToBytesBE(maxSupply, 16),
192
+ isFreezable,
193
+ extraMetadata
194
+ }
195
+ },
196
+ partialTokenOutputs: []
197
+ });
198
+ });
191
199
  }
192
200
  };
193
201
 
@@ -576,8 +584,10 @@ var IssuerSparkWallet = class extends SparkWallet {
576
584
  * Retrieves the distribution information for the issuer's token.
577
585
  * @throws {SparkError} This feature is not yet supported
578
586
  */
579
- async getIssuerTokenDistribution() {
580
- throw new SparkError("Token distribution is not yet supported");
587
+ getIssuerTokenDistribution() {
588
+ return new Promise((_, reject) => {
589
+ reject(new SparkError("Token distribution is not yet supported"));
590
+ });
581
591
  }
582
592
  /**
583
593
  * This validates that the token belongs to this issuer.
@@ -11,7 +11,7 @@ function hashFreezeTokensPayload(payload) {
11
11
  value: payload,
12
12
  expected: "valid freeze tokens payload"
13
13
  });
14
- let allHashes = [];
14
+ const allHashes = [];
15
15
  const versionHashObj = _scure_btc_signer_utils.sha256.create();
16
16
  const versionBytes = new Uint8Array(4);
17
17
  new DataView(versionBytes.buffer).setUint32(0, payload.version, false);
@@ -137,101 +137,109 @@ var IssuerTokenTransactionService = class extends _buildonspark_spark_sdk.TokenT
137
137
  constructor(config, connectionManager) {
138
138
  super(config, connectionManager);
139
139
  }
140
- async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
141
- return {
142
- version: 2,
143
- network: this.config.getNetworkProto(),
144
- tokenInputs: {
145
- $case: "mintInput",
146
- mintInput: {
147
- issuerPublicKey: issuerTokenPublicKey,
148
- tokenIdentifier: rawTokenIdentifierBytes
149
- }
150
- },
151
- tokenOutputs: [{
152
- ownerPublicKey: issuerTokenPublicKey,
153
- tokenIdentifier: rawTokenIdentifierBytes,
154
- tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
155
- }],
156
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
157
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
158
- expiryTime: void 0,
159
- invoiceAttachments: []
160
- };
161
- }
162
- async constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
163
- return {
164
- version: 3,
165
- tokenTransactionMetadata: {
140
+ constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
141
+ return new Promise((resolve) => {
142
+ resolve({
143
+ version: 2,
166
144
  network: this.config.getNetworkProto(),
167
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
168
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
169
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
145
+ tokenInputs: {
146
+ $case: "mintInput",
147
+ mintInput: {
148
+ issuerPublicKey: issuerTokenPublicKey,
149
+ tokenIdentifier: rawTokenIdentifierBytes
150
+ }
151
+ },
152
+ tokenOutputs: [{
153
+ ownerPublicKey: issuerTokenPublicKey,
154
+ tokenIdentifier: rawTokenIdentifierBytes,
155
+ tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
156
+ }],
157
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
158
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
159
+ expiryTime: void 0,
170
160
  invoiceAttachments: []
171
- },
172
- tokenInputs: {
173
- $case: "mintInput",
174
- mintInput: {
175
- issuerPublicKey: issuerTokenPublicKey,
176
- tokenIdentifier: rawTokenIdentifierBytes
177
- }
178
- },
179
- partialTokenOutputs: [{
180
- ownerPublicKey: issuerTokenPublicKey,
181
- tokenIdentifier: rawTokenIdentifierBytes,
182
- withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
183
- withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
184
- tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
185
- }]
186
- };
161
+ });
162
+ });
187
163
  }
188
- async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
189
- return {
190
- version: 2,
191
- network: this.config.getNetworkProto(),
192
- tokenInputs: {
193
- $case: "createInput",
194
- createInput: {
195
- issuerPublicKey: tokenPublicKey,
196
- tokenName,
197
- tokenTicker,
198
- decimals,
199
- maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
200
- isFreezable,
201
- extraMetadata
202
- }
203
- },
204
- tokenOutputs: [],
205
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
206
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
207
- expiryTime: void 0,
208
- invoiceAttachments: []
209
- };
164
+ constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
165
+ return new Promise((resolve) => {
166
+ resolve({
167
+ version: 3,
168
+ tokenTransactionMetadata: {
169
+ network: this.config.getNetworkProto(),
170
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
171
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
172
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
173
+ invoiceAttachments: []
174
+ },
175
+ tokenInputs: {
176
+ $case: "mintInput",
177
+ mintInput: {
178
+ issuerPublicKey: issuerTokenPublicKey,
179
+ tokenIdentifier: rawTokenIdentifierBytes
180
+ }
181
+ },
182
+ partialTokenOutputs: [{
183
+ ownerPublicKey: issuerTokenPublicKey,
184
+ tokenIdentifier: rawTokenIdentifierBytes,
185
+ withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
186
+ withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
187
+ tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
188
+ }]
189
+ });
190
+ });
210
191
  }
211
- async constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
212
- return {
213
- version: 3,
214
- tokenTransactionMetadata: {
192
+ constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
193
+ return new Promise((resolve) => {
194
+ resolve({
195
+ version: 2,
215
196
  network: this.config.getNetworkProto(),
216
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
217
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
218
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
197
+ tokenInputs: {
198
+ $case: "createInput",
199
+ createInput: {
200
+ issuerPublicKey: tokenPublicKey,
201
+ tokenName,
202
+ tokenTicker,
203
+ decimals,
204
+ maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
205
+ isFreezable,
206
+ extraMetadata
207
+ }
208
+ },
209
+ tokenOutputs: [],
210
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
211
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
212
+ expiryTime: void 0,
219
213
  invoiceAttachments: []
220
- },
221
- tokenInputs: {
222
- $case: "createInput",
223
- createInput: {
224
- issuerPublicKey: tokenPublicKey,
225
- tokenName,
226
- tokenTicker,
227
- decimals,
228
- maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
229
- isFreezable,
230
- extraMetadata
231
- }
232
- },
233
- partialTokenOutputs: []
234
- };
214
+ });
215
+ });
216
+ }
217
+ constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
218
+ return new Promise((resolve) => {
219
+ resolve({
220
+ version: 3,
221
+ tokenTransactionMetadata: {
222
+ network: this.config.getNetworkProto(),
223
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
224
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
225
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
226
+ invoiceAttachments: []
227
+ },
228
+ tokenInputs: {
229
+ $case: "createInput",
230
+ createInput: {
231
+ issuerPublicKey: tokenPublicKey,
232
+ tokenName,
233
+ tokenTicker,
234
+ decimals,
235
+ maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
236
+ isFreezable,
237
+ extraMetadata
238
+ }
239
+ },
240
+ partialTokenOutputs: []
241
+ });
242
+ });
235
243
  }
236
244
  };
237
245
 
@@ -620,8 +628,10 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
620
628
  * Retrieves the distribution information for the issuer's token.
621
629
  * @throws {SparkError} This feature is not yet supported
622
630
  */
623
- async getIssuerTokenDistribution() {
624
- throw new _buildonspark_spark_sdk.SparkError("Token distribution is not yet supported");
631
+ getIssuerTokenDistribution() {
632
+ return new Promise((_, reject) => {
633
+ reject(new _buildonspark_spark_sdk.SparkError("Token distribution is not yet supported"));
634
+ });
625
635
  }
626
636
  /**
627
637
  * This validates that the token belongs to this issuer.
@@ -7,7 +7,8 @@ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark
7
7
  * Token metadata containing essential information about issuer's token.
8
8
  * This is the wallet's internal representation with JavaScript-friendly types.
9
9
  *
10
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
10
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human
11
+ * readable token identifier.
11
12
  *
12
13
  * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
13
14
  *
@@ -7,7 +7,8 @@ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark
7
7
  * Token metadata containing essential information about issuer's token.
8
8
  * This is the wallet's internal representation with JavaScript-friendly types.
9
9
  *
10
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
10
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human
11
+ * readable token identifier.
11
12
  *
12
13
  * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
13
14
  *