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

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.
@@ -22,7 +22,14 @@ export declare enum CardanoCertificateType {
22
22
  STAKE_REGISTRATION = 0,
23
23
  STAKE_DEREGISTRATION = 1,
24
24
  STAKE_DELEGATION = 2,
25
- STAKE_POOL_REGISTRATION = 3
25
+ STAKE_POOL_REGISTRATION = 3,
26
+ STAKE_REGISTRATION_CONWAY = 7,
27
+ STAKE_DEREGISTRATION_CONWAY = 8,
28
+ VOTE_DELEGATION = 9,
29
+ STAKE_AND_VOTE_DELEGATION = 10,
30
+ STAKE_REGISTRATION_AND_DELEGATION = 11,
31
+ VOTE_REGISTRATION_AND_DELEGATION = 12,
32
+ STAKE_VOTE_REGISTRATION_AND_DELEGATION = 13
26
33
  }
27
34
  export declare enum CardanoPoolRelayType {
28
35
  SINGLE_HOST_IP = 0,
@@ -53,6 +53,14 @@ var CardanoCertificateType;
53
53
  CardanoCertificateType[CardanoCertificateType["STAKE_DEREGISTRATION"] = 1] = "STAKE_DEREGISTRATION";
54
54
  CardanoCertificateType[CardanoCertificateType["STAKE_DELEGATION"] = 2] = "STAKE_DELEGATION";
55
55
  CardanoCertificateType[CardanoCertificateType["STAKE_POOL_REGISTRATION"] = 3] = "STAKE_POOL_REGISTRATION";
56
+ // Conway era
57
+ CardanoCertificateType[CardanoCertificateType["STAKE_REGISTRATION_CONWAY"] = 7] = "STAKE_REGISTRATION_CONWAY";
58
+ CardanoCertificateType[CardanoCertificateType["STAKE_DEREGISTRATION_CONWAY"] = 8] = "STAKE_DEREGISTRATION_CONWAY";
59
+ CardanoCertificateType[CardanoCertificateType["VOTE_DELEGATION"] = 9] = "VOTE_DELEGATION";
60
+ CardanoCertificateType[CardanoCertificateType["STAKE_AND_VOTE_DELEGATION"] = 10] = "STAKE_AND_VOTE_DELEGATION";
61
+ CardanoCertificateType[CardanoCertificateType["STAKE_REGISTRATION_AND_DELEGATION"] = 11] = "STAKE_REGISTRATION_AND_DELEGATION";
62
+ CardanoCertificateType[CardanoCertificateType["VOTE_REGISTRATION_AND_DELEGATION"] = 12] = "VOTE_REGISTRATION_AND_DELEGATION";
63
+ CardanoCertificateType[CardanoCertificateType["STAKE_VOTE_REGISTRATION_AND_DELEGATION"] = 13] = "STAKE_VOTE_REGISTRATION_AND_DELEGATION";
56
64
  })(CardanoCertificateType || (exports.CardanoCertificateType = CardanoCertificateType = {}));
57
65
  var CardanoPoolRelayType;
58
66
  (function (CardanoPoolRelayType) {
@@ -197,7 +205,7 @@ const outputsToOneKey = (outputs, changeAddress) => {
197
205
  * @param {Transaction} tx
198
206
  */
199
207
  const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
200
- var _a;
208
+ var _a, _b, _c, _d;
201
209
  const keys = generateKeys(initKeys, xpub);
202
210
  const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(rawTx, 'hex'));
203
211
  let signingMode = CardanoTxSigningMode.ORDINARY_TRANSACTION;
@@ -330,10 +338,52 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
330
338
  metadata,
331
339
  };
332
340
  }
341
+ else if (certKind === 9 || certKind === 15) {
342
+ // Conway era: Vote Delegation (kind 9 in CDDL, may appear as 15 in some lib versions)
343
+ // For hardware wallet signing, we need the stake key path
344
+ const voteDelegation = (_b = cert.as_vote_delegation) === null || _b === void 0 ? void 0 : _b.call(cert);
345
+ if (voteDelegation) {
346
+ const credential = voteDelegation.stake_credential();
347
+ certificate.type = CardanoCertificateType.VOTE_DELEGATION;
348
+ if (credential.kind() === 0) {
349
+ certificate.path = keys.stake.path;
350
+ }
351
+ else {
352
+ const scriptHash = Buffer.from(credential.to_scripthash().to_bytes()).toString('hex');
353
+ certificate.scriptHash = scriptHash;
354
+ }
355
+ // drep can be key hash, script hash, or abstain/no_confidence
356
+ const drep = voteDelegation.drep();
357
+ if ((_c = drep.to_key_hash) === null || _c === void 0 ? void 0 : _c.call(drep)) {
358
+ certificate.dRep = {
359
+ type: 0, // key hash
360
+ keyHash: Buffer.from(drep.to_key_hash().to_bytes()).toString('hex'),
361
+ };
362
+ }
363
+ else if ((_d = drep.to_script_hash) === null || _d === void 0 ? void 0 : _d.call(drep)) {
364
+ certificate.dRep = {
365
+ type: 1, // script hash
366
+ scriptHash: Buffer.from(drep.to_script_hash().to_bytes()).toString('hex'),
367
+ };
368
+ }
369
+ else {
370
+ // abstain or no_confidence
371
+ certificate.dRep = {
372
+ type: drep.kind(), // 2 = abstain, 3 = no_confidence
373
+ };
374
+ }
375
+ }
376
+ else {
377
+ // Fallback: just include stake path for signing
378
+ console.log(`[txToOneKey] Vote delegation cert kind ${certKind}, using stake path for signing`);
379
+ certificate.type = CardanoCertificateType.VOTE_DELEGATION;
380
+ certificate.path = keys.stake.path;
381
+ }
382
+ }
333
383
  else {
334
- // Skip unsupported certificate types (kind 4, 5, 6, etc.)
384
+ // Skip unsupported certificate types
335
385
  // Don't push empty certificate objects
336
- console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
386
+ console.log(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
337
387
  continue;
338
388
  }
339
389
  onekeyCertificates.push(certificate);
@@ -22,7 +22,14 @@ export declare enum CardanoCertificateType {
22
22
  STAKE_REGISTRATION = 0,
23
23
  STAKE_DEREGISTRATION = 1,
24
24
  STAKE_DELEGATION = 2,
25
- STAKE_POOL_REGISTRATION = 3
25
+ STAKE_POOL_REGISTRATION = 3,
26
+ STAKE_REGISTRATION_CONWAY = 7,
27
+ STAKE_DEREGISTRATION_CONWAY = 8,
28
+ VOTE_DELEGATION = 9,
29
+ STAKE_AND_VOTE_DELEGATION = 10,
30
+ STAKE_REGISTRATION_AND_DELEGATION = 11,
31
+ VOTE_REGISTRATION_AND_DELEGATION = 12,
32
+ STAKE_VOTE_REGISTRATION_AND_DELEGATION = 13
26
33
  }
27
34
  export declare enum CardanoPoolRelayType {
28
35
  SINGLE_HOST_IP = 0,
@@ -27,6 +27,14 @@ export var CardanoCertificateType;
27
27
  CardanoCertificateType[CardanoCertificateType["STAKE_DEREGISTRATION"] = 1] = "STAKE_DEREGISTRATION";
28
28
  CardanoCertificateType[CardanoCertificateType["STAKE_DELEGATION"] = 2] = "STAKE_DELEGATION";
29
29
  CardanoCertificateType[CardanoCertificateType["STAKE_POOL_REGISTRATION"] = 3] = "STAKE_POOL_REGISTRATION";
30
+ // Conway era
31
+ CardanoCertificateType[CardanoCertificateType["STAKE_REGISTRATION_CONWAY"] = 7] = "STAKE_REGISTRATION_CONWAY";
32
+ CardanoCertificateType[CardanoCertificateType["STAKE_DEREGISTRATION_CONWAY"] = 8] = "STAKE_DEREGISTRATION_CONWAY";
33
+ CardanoCertificateType[CardanoCertificateType["VOTE_DELEGATION"] = 9] = "VOTE_DELEGATION";
34
+ CardanoCertificateType[CardanoCertificateType["STAKE_AND_VOTE_DELEGATION"] = 10] = "STAKE_AND_VOTE_DELEGATION";
35
+ CardanoCertificateType[CardanoCertificateType["STAKE_REGISTRATION_AND_DELEGATION"] = 11] = "STAKE_REGISTRATION_AND_DELEGATION";
36
+ CardanoCertificateType[CardanoCertificateType["VOTE_REGISTRATION_AND_DELEGATION"] = 12] = "VOTE_REGISTRATION_AND_DELEGATION";
37
+ CardanoCertificateType[CardanoCertificateType["STAKE_VOTE_REGISTRATION_AND_DELEGATION"] = 13] = "STAKE_VOTE_REGISTRATION_AND_DELEGATION";
30
38
  })(CardanoCertificateType || (CardanoCertificateType = {}));
31
39
  export var CardanoPoolRelayType;
32
40
  (function (CardanoPoolRelayType) {
@@ -171,7 +179,7 @@ const outputsToOneKey = (outputs, changeAddress) => {
171
179
  * @param {Transaction} tx
172
180
  */
173
181
  export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
174
- var _a;
182
+ var _a, _b, _c, _d;
175
183
  const keys = generateKeys(initKeys, xpub);
176
184
  const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(rawTx, 'hex'));
177
185
  let signingMode = CardanoTxSigningMode.ORDINARY_TRANSACTION;
@@ -304,10 +312,52 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
304
312
  metadata,
305
313
  };
306
314
  }
315
+ else if (certKind === 9 || certKind === 15) {
316
+ // Conway era: Vote Delegation (kind 9 in CDDL, may appear as 15 in some lib versions)
317
+ // For hardware wallet signing, we need the stake key path
318
+ const voteDelegation = (_b = cert.as_vote_delegation) === null || _b === void 0 ? void 0 : _b.call(cert);
319
+ if (voteDelegation) {
320
+ const credential = voteDelegation.stake_credential();
321
+ certificate.type = CardanoCertificateType.VOTE_DELEGATION;
322
+ if (credential.kind() === 0) {
323
+ certificate.path = keys.stake.path;
324
+ }
325
+ else {
326
+ const scriptHash = Buffer.from(credential.to_scripthash().to_bytes()).toString('hex');
327
+ certificate.scriptHash = scriptHash;
328
+ }
329
+ // drep can be key hash, script hash, or abstain/no_confidence
330
+ const drep = voteDelegation.drep();
331
+ if ((_c = drep.to_key_hash) === null || _c === void 0 ? void 0 : _c.call(drep)) {
332
+ certificate.dRep = {
333
+ type: 0, // key hash
334
+ keyHash: Buffer.from(drep.to_key_hash().to_bytes()).toString('hex'),
335
+ };
336
+ }
337
+ else if ((_d = drep.to_script_hash) === null || _d === void 0 ? void 0 : _d.call(drep)) {
338
+ certificate.dRep = {
339
+ type: 1, // script hash
340
+ scriptHash: Buffer.from(drep.to_script_hash().to_bytes()).toString('hex'),
341
+ };
342
+ }
343
+ else {
344
+ // abstain or no_confidence
345
+ certificate.dRep = {
346
+ type: drep.kind(), // 2 = abstain, 3 = no_confidence
347
+ };
348
+ }
349
+ }
350
+ else {
351
+ // Fallback: just include stake path for signing
352
+ console.log(`[txToOneKey] Vote delegation cert kind ${certKind}, using stake path for signing`);
353
+ certificate.type = CardanoCertificateType.VOTE_DELEGATION;
354
+ certificate.path = keys.stake.path;
355
+ }
356
+ }
307
357
  else {
308
- // Skip unsupported certificate types (kind 4, 5, 6, etc.)
358
+ // Skip unsupported certificate types
309
359
  // Don't push empty certificate objects
310
- console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
360
+ console.log(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
311
361
  continue;
312
362
  }
313
363
  onekeyCertificates.push(certificate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/cardano-coin-selection-asmjs",
3
- "version": "1.1.10-alpha.0",
3
+ "version": "1.1.10-alpha.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "coin selection"