@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @buildonspark/issuer-sdk
2
2
 
3
+ ## 0.1.36
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - Updated dependencies [d4ef15a]
9
+ - @buildonspark/spark-sdk@0.8.0
10
+
3
11
  ## 0.1.35
4
12
 
5
13
  ### Patch Changes
@@ -6,7 +6,8 @@ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark
6
6
  * Token metadata containing essential information about issuer's token.
7
7
  * This is the wallet's internal representation with JavaScript-friendly types.
8
8
  *
9
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
9
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human
10
+ * readable token identifier.
10
11
  *
11
12
  * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
12
13
  *
@@ -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.
@@ -10,7 +10,7 @@ function hashFreezeTokensPayload(payload) {
10
10
  value: payload,
11
11
  expected: "valid freeze tokens payload"
12
12
  });
13
- let allHashes = [];
13
+ const allHashes = [];
14
14
  const versionHashObj = _scure_btc_signer_utils.sha256.create();
15
15
  const versionBytes = new Uint8Array(4);
16
16
  new DataView(versionBytes.buffer).setUint32(0, payload.version, false);
@@ -94,101 +94,109 @@ var IssuerTokenTransactionService = class extends _buildonspark_spark_sdk.TokenT
94
94
  constructor(config, connectionManager) {
95
95
  super(config, connectionManager);
96
96
  }
97
- async constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
98
- return {
99
- version: 2,
100
- network: this.config.getNetworkProto(),
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: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
112
- }],
113
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
114
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
115
- expiryTime: void 0,
116
- invoiceAttachments: []
117
- };
118
- }
119
- async constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
120
- return {
121
- version: 3,
122
- tokenTransactionMetadata: {
97
+ constructMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
98
+ return new Promise((resolve) => {
99
+ resolve({
100
+ version: 2,
123
101
  network: this.config.getNetworkProto(),
124
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
125
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
126
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
102
+ tokenInputs: {
103
+ $case: "mintInput",
104
+ mintInput: {
105
+ issuerPublicKey: issuerTokenPublicKey,
106
+ tokenIdentifier: rawTokenIdentifierBytes
107
+ }
108
+ },
109
+ tokenOutputs: [{
110
+ ownerPublicKey: issuerTokenPublicKey,
111
+ tokenIdentifier: rawTokenIdentifierBytes,
112
+ tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
113
+ }],
114
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
115
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
116
+ expiryTime: void 0,
127
117
  invoiceAttachments: []
128
- },
129
- tokenInputs: {
130
- $case: "mintInput",
131
- mintInput: {
132
- issuerPublicKey: issuerTokenPublicKey,
133
- tokenIdentifier: rawTokenIdentifierBytes
134
- }
135
- },
136
- partialTokenOutputs: [{
137
- ownerPublicKey: issuerTokenPublicKey,
138
- tokenIdentifier: rawTokenIdentifierBytes,
139
- withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
140
- withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
141
- tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
142
- }]
143
- };
118
+ });
119
+ });
144
120
  }
145
- async constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
146
- return {
147
- version: 2,
148
- network: this.config.getNetworkProto(),
149
- tokenInputs: {
150
- $case: "createInput",
151
- createInput: {
152
- issuerPublicKey: tokenPublicKey,
153
- tokenName,
154
- tokenTicker,
155
- decimals,
156
- maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
157
- isFreezable,
158
- extraMetadata
159
- }
160
- },
161
- tokenOutputs: [],
162
- clientCreatedTimestamp: /* @__PURE__ */ new Date(),
163
- sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
164
- expiryTime: void 0,
165
- invoiceAttachments: []
166
- };
121
+ constructPartialMintTokenTransaction(rawTokenIdentifierBytes, issuerTokenPublicKey, tokenAmount) {
122
+ return new Promise((resolve) => {
123
+ resolve({
124
+ version: 3,
125
+ tokenTransactionMetadata: {
126
+ network: this.config.getNetworkProto(),
127
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
128
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
129
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
130
+ invoiceAttachments: []
131
+ },
132
+ tokenInputs: {
133
+ $case: "mintInput",
134
+ mintInput: {
135
+ issuerPublicKey: issuerTokenPublicKey,
136
+ tokenIdentifier: rawTokenIdentifierBytes
137
+ }
138
+ },
139
+ partialTokenOutputs: [{
140
+ ownerPublicKey: issuerTokenPublicKey,
141
+ tokenIdentifier: rawTokenIdentifierBytes,
142
+ withdrawBondSats: this.config.getExpectedWithdrawBondSats(),
143
+ withdrawRelativeBlockLocktime: this.config.getExpectedWithdrawRelativeBlockLocktime(),
144
+ tokenAmount: (0, _noble_curves_utils.numberToBytesBE)(tokenAmount, 16)
145
+ }]
146
+ });
147
+ });
167
148
  }
168
- async constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
169
- return {
170
- version: 3,
171
- tokenTransactionMetadata: {
149
+ constructCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
150
+ return new Promise((resolve) => {
151
+ resolve({
152
+ version: 2,
172
153
  network: this.config.getNetworkProto(),
173
- sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
174
- validityDurationSeconds: await this.config.getTokenValidityDurationSeconds(),
175
- clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
154
+ tokenInputs: {
155
+ $case: "createInput",
156
+ createInput: {
157
+ issuerPublicKey: tokenPublicKey,
158
+ tokenName,
159
+ tokenTicker,
160
+ decimals,
161
+ maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
162
+ isFreezable,
163
+ extraMetadata
164
+ }
165
+ },
166
+ tokenOutputs: [],
167
+ clientCreatedTimestamp: /* @__PURE__ */ new Date(),
168
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys(),
169
+ expiryTime: void 0,
176
170
  invoiceAttachments: []
177
- },
178
- tokenInputs: {
179
- $case: "createInput",
180
- createInput: {
181
- issuerPublicKey: tokenPublicKey,
182
- tokenName,
183
- tokenTicker,
184
- decimals,
185
- maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
186
- isFreezable,
187
- extraMetadata
188
- }
189
- },
190
- partialTokenOutputs: []
191
- };
171
+ });
172
+ });
173
+ }
174
+ constructPartialCreateTokenTransaction(tokenPublicKey, tokenName, tokenTicker, decimals, maxSupply, isFreezable, extraMetadata) {
175
+ return new Promise((resolve) => {
176
+ resolve({
177
+ version: 3,
178
+ tokenTransactionMetadata: {
179
+ network: this.config.getNetworkProto(),
180
+ sparkOperatorIdentityPublicKeys: this.collectOperatorIdentityPublicKeys(),
181
+ validityDurationSeconds: this.config.getTokenValidityDurationSeconds(),
182
+ clientCreatedTimestamp: this.connectionManager.getCurrentServerTime(),
183
+ invoiceAttachments: []
184
+ },
185
+ tokenInputs: {
186
+ $case: "createInput",
187
+ createInput: {
188
+ issuerPublicKey: tokenPublicKey,
189
+ tokenName,
190
+ tokenTicker,
191
+ decimals,
192
+ maxSupply: (0, _noble_curves_utils.numberToBytesBE)(maxSupply, 16),
193
+ isFreezable,
194
+ extraMetadata
195
+ }
196
+ },
197
+ partialTokenOutputs: []
198
+ });
199
+ });
192
200
  }
193
201
  };
194
202
 
@@ -577,8 +585,10 @@ var IssuerSparkWallet = class extends _buildonspark_spark_sdk.SparkWallet {
577
585
  * Retrieves the distribution information for the issuer's token.
578
586
  * @throws {SparkError} This feature is not yet supported
579
587
  */
580
- async getIssuerTokenDistribution() {
581
- throw new _buildonspark_spark_sdk.SparkError("Token distribution is not yet supported");
588
+ getIssuerTokenDistribution() {
589
+ return new Promise((_, reject) => {
590
+ reject(new _buildonspark_spark_sdk.SparkError("Token distribution is not yet supported"));
591
+ });
582
592
  }
583
593
  /**
584
594
  * This validates that the token belongs to this issuer.
@@ -6,7 +6,8 @@ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark
6
6
  * Token metadata containing essential information about issuer's token.
7
7
  * This is the wallet's internal representation with JavaScript-friendly types.
8
8
  *
9
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
9
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human
10
+ * readable token identifier.
10
11
  *
11
12
  * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
12
13
  *
@@ -6,7 +6,8 @@ import { OutputWithPreviousTransactionData, TokenOutputRef } from "@buildonspark
6
6
  * Token metadata containing essential information about issuer's token.
7
7
  * This is the wallet's internal representation with JavaScript-friendly types.
8
8
  *
9
- * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human readable token identifier.
9
+ * rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the human
10
+ * readable token identifier.
10
11
  *
11
12
  * tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
12
13
  *