@onekeyfe/cardano-coin-selection-asmjs 1.1.9 → 1.1.10-alpha.0

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.
@@ -210,7 +210,8 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
210
210
  for (let i = 0; i < certificates.len(); i++) {
211
211
  const cert = certificates.get(i);
212
212
  const certificate = {};
213
- if (cert.kind() === 0) {
213
+ const certKind = cert.kind();
214
+ if (certKind === 0) {
214
215
  const credential = (_a = cert.as_stake_registration()) === null || _a === void 0 ? void 0 : _a.stake_credential();
215
216
  certificate.type = CardanoCertificateType.STAKE_REGISTRATION;
216
217
  if ((credential === null || credential === void 0 ? void 0 : credential.kind()) === 0) {
@@ -221,7 +222,7 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
221
222
  certificate.scriptHash = scriptHash;
222
223
  }
223
224
  }
224
- else if (cert.kind() === 1) {
225
+ else if (certKind === 1) {
225
226
  const credential = cert.as_stake_deregistration().stake_credential();
226
227
  certificate.type = CardanoCertificateType.STAKE_DEREGISTRATION;
227
228
  if (credential.kind() === 0) {
@@ -232,7 +233,7 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
232
233
  certificate.scriptHash = scriptHash;
233
234
  }
234
235
  }
235
- else if (cert.kind() === 2) {
236
+ else if (certKind === 2) {
236
237
  const delegation = cert.as_stake_delegation();
237
238
  const credential = delegation.stake_credential();
238
239
  const poolKeyHashHex = Buffer.from(delegation.pool_keyhash().to_bytes()).toString('hex');
@@ -246,7 +247,7 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
246
247
  }
247
248
  certificate.pool = poolKeyHashHex;
248
249
  }
249
- else if (cert.kind() === 3) {
250
+ else if (certKind === 3) {
250
251
  const params = cert.as_pool_registration().pool_params();
251
252
  certificate.type = CardanoCertificateType.STAKE_POOL_REGISTRATION;
252
253
  const owners = params.pool_owners();
@@ -329,6 +330,12 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
329
330
  metadata,
330
331
  };
331
332
  }
333
+ else {
334
+ // Skip unsupported certificate types (kind 4, 5, 6, etc.)
335
+ // Don't push empty certificate objects
336
+ console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
337
+ continue;
338
+ }
332
339
  onekeyCertificates.push(certificate);
333
340
  }
334
341
  }
@@ -184,7 +184,8 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
184
184
  for (let i = 0; i < certificates.len(); i++) {
185
185
  const cert = certificates.get(i);
186
186
  const certificate = {};
187
- if (cert.kind() === 0) {
187
+ const certKind = cert.kind();
188
+ if (certKind === 0) {
188
189
  const credential = (_a = cert.as_stake_registration()) === null || _a === void 0 ? void 0 : _a.stake_credential();
189
190
  certificate.type = CardanoCertificateType.STAKE_REGISTRATION;
190
191
  if ((credential === null || credential === void 0 ? void 0 : credential.kind()) === 0) {
@@ -195,7 +196,7 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
195
196
  certificate.scriptHash = scriptHash;
196
197
  }
197
198
  }
198
- else if (cert.kind() === 1) {
199
+ else if (certKind === 1) {
199
200
  const credential = cert.as_stake_deregistration().stake_credential();
200
201
  certificate.type = CardanoCertificateType.STAKE_DEREGISTRATION;
201
202
  if (credential.kind() === 0) {
@@ -206,7 +207,7 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
206
207
  certificate.scriptHash = scriptHash;
207
208
  }
208
209
  }
209
- else if (cert.kind() === 2) {
210
+ else if (certKind === 2) {
210
211
  const delegation = cert.as_stake_delegation();
211
212
  const credential = delegation.stake_credential();
212
213
  const poolKeyHashHex = Buffer.from(delegation.pool_keyhash().to_bytes()).toString('hex');
@@ -220,7 +221,7 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
220
221
  }
221
222
  certificate.pool = poolKeyHashHex;
222
223
  }
223
- else if (cert.kind() === 3) {
224
+ else if (certKind === 3) {
224
225
  const params = cert.as_pool_registration().pool_params();
225
226
  certificate.type = CardanoCertificateType.STAKE_POOL_REGISTRATION;
226
227
  const owners = params.pool_owners();
@@ -303,6 +304,12 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
303
304
  metadata,
304
305
  };
305
306
  }
307
+ else {
308
+ // Skip unsupported certificate types (kind 4, 5, 6, etc.)
309
+ // Don't push empty certificate objects
310
+ console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
311
+ continue;
312
+ }
306
313
  onekeyCertificates.push(certificate);
307
314
  }
308
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/cardano-coin-selection-asmjs",
3
- "version": "1.1.9",
3
+ "version": "1.1.10-alpha.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "coin selection"