@onekeyfe/cardano-coin-selection-asmjs 1.1.10-alpha.1 → 1.1.10-alpha.5
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.
|
@@ -23,13 +23,13 @@ export declare enum CardanoCertificateType {
|
|
|
23
23
|
STAKE_DEREGISTRATION = 1,
|
|
24
24
|
STAKE_DELEGATION = 2,
|
|
25
25
|
STAKE_POOL_REGISTRATION = 3,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
VOTE_DELEGATION = 9
|
|
27
|
+
}
|
|
28
|
+
export declare enum CardanoDRepType {
|
|
29
|
+
KEY_HASH = 0,
|
|
30
|
+
SCRIPT_HASH = 1,
|
|
31
|
+
ABSTAIN = 2,
|
|
32
|
+
NO_CONFIDENCE = 3
|
|
33
33
|
}
|
|
34
34
|
export declare enum CardanoPoolRelayType {
|
|
35
35
|
SINGLE_HOST_IP = 0,
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.txToOneKey = exports.CardanoPoolRelayType = exports.CardanoCertificateType = exports.CardanoTxSigningMode = exports.CardanoAddressType = void 0;
|
|
26
|
+
exports.txToOneKey = exports.CardanoPoolRelayType = exports.CardanoDRepType = exports.CardanoCertificateType = exports.CardanoTxSigningMode = exports.CardanoAddressType = void 0;
|
|
27
27
|
// @ts-nocheck
|
|
28
28
|
const CardanoWasm = __importStar(require("@emurgo/cardano-serialization-lib-asmjs"));
|
|
29
29
|
var CardanoAddressType;
|
|
@@ -53,15 +53,15 @@ 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
56
|
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";
|
|
64
57
|
})(CardanoCertificateType || (exports.CardanoCertificateType = CardanoCertificateType = {}));
|
|
58
|
+
var CardanoDRepType;
|
|
59
|
+
(function (CardanoDRepType) {
|
|
60
|
+
CardanoDRepType[CardanoDRepType["KEY_HASH"] = 0] = "KEY_HASH";
|
|
61
|
+
CardanoDRepType[CardanoDRepType["SCRIPT_HASH"] = 1] = "SCRIPT_HASH";
|
|
62
|
+
CardanoDRepType[CardanoDRepType["ABSTAIN"] = 2] = "ABSTAIN";
|
|
63
|
+
CardanoDRepType[CardanoDRepType["NO_CONFIDENCE"] = 3] = "NO_CONFIDENCE";
|
|
64
|
+
})(CardanoDRepType || (exports.CardanoDRepType = CardanoDRepType = {}));
|
|
65
65
|
var CardanoPoolRelayType;
|
|
66
66
|
(function (CardanoPoolRelayType) {
|
|
67
67
|
CardanoPoolRelayType[CardanoPoolRelayType["SINGLE_HOST_IP"] = 0] = "SINGLE_HOST_IP";
|
|
@@ -205,7 +205,7 @@ const outputsToOneKey = (outputs, changeAddress) => {
|
|
|
205
205
|
* @param {Transaction} tx
|
|
206
206
|
*/
|
|
207
207
|
const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
|
|
208
|
-
var _a, _b, _c
|
|
208
|
+
var _a, _b, _c;
|
|
209
209
|
const keys = generateKeys(initKeys, xpub);
|
|
210
210
|
const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(rawTx, 'hex'));
|
|
211
211
|
let signingMode = CardanoTxSigningMode.ORDINARY_TRANSACTION;
|
|
@@ -338,52 +338,39 @@ const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
|
|
|
338
338
|
metadata,
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
-
else if (certKind ===
|
|
342
|
-
//
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
certificate.
|
|
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
|
-
}
|
|
341
|
+
else if (certKind === 15) {
|
|
342
|
+
// VoteDelegation (CertificateKind.VoteDelegation = 15 in WASM lib)
|
|
343
|
+
const voteDelegation = cert.as_vote_delegation();
|
|
344
|
+
const credential = voteDelegation.stake_credential();
|
|
345
|
+
certificate.type = CardanoCertificateType.VOTE_DELEGATION;
|
|
346
|
+
if (credential.kind() === 0) {
|
|
347
|
+
certificate.path = keys.stake.path;
|
|
375
348
|
}
|
|
376
349
|
else {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
350
|
+
const scriptHash = Buffer.from(credential.to_scripthash().to_bytes()).toString('hex');
|
|
351
|
+
certificate.scriptHash = scriptHash;
|
|
352
|
+
}
|
|
353
|
+
// Parse DRep
|
|
354
|
+
const drep = voteDelegation.drep();
|
|
355
|
+
const drepKind = drep.kind();
|
|
356
|
+
// DRepKind: KeyHash = 0, ScriptHash = 1, AlwaysAbstain = 2, AlwaysNoConfidence = 3
|
|
357
|
+
certificate.dRep = {
|
|
358
|
+
type: drepKind,
|
|
359
|
+
};
|
|
360
|
+
if (drepKind === 0) {
|
|
361
|
+
// KEY_HASH
|
|
362
|
+
certificate.dRep.keyHash = (_b = drep.to_key_hash()) === null || _b === void 0 ? void 0 : _b.to_hex();
|
|
363
|
+
}
|
|
364
|
+
else if (drepKind === 1) {
|
|
365
|
+
// SCRIPT_HASH
|
|
366
|
+
certificate.dRep.scriptHash = (_c = drep.to_script_hash()) === null || _c === void 0 ? void 0 : _c.to_hex();
|
|
381
367
|
}
|
|
368
|
+
// ABSTAIN (2) and NO_CONFIDENCE (3) don't need additional fields
|
|
382
369
|
}
|
|
383
370
|
else {
|
|
384
|
-
// Skip unsupported certificate types
|
|
371
|
+
// Skip unsupported certificate types (kind 4, 5, 6, etc.)
|
|
385
372
|
// Don't push empty certificate objects
|
|
386
|
-
console.
|
|
373
|
+
console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
|
|
387
374
|
continue;
|
|
388
375
|
}
|
|
389
376
|
onekeyCertificates.push(certificate);
|
|
@@ -23,13 +23,13 @@ export declare enum CardanoCertificateType {
|
|
|
23
23
|
STAKE_DEREGISTRATION = 1,
|
|
24
24
|
STAKE_DELEGATION = 2,
|
|
25
25
|
STAKE_POOL_REGISTRATION = 3,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
VOTE_DELEGATION = 9
|
|
27
|
+
}
|
|
28
|
+
export declare enum CardanoDRepType {
|
|
29
|
+
KEY_HASH = 0,
|
|
30
|
+
SCRIPT_HASH = 1,
|
|
31
|
+
ABSTAIN = 2,
|
|
32
|
+
NO_CONFIDENCE = 3
|
|
33
33
|
}
|
|
34
34
|
export declare enum CardanoPoolRelayType {
|
|
35
35
|
SINGLE_HOST_IP = 0,
|
|
@@ -27,15 +27,15 @@ 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
30
|
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";
|
|
38
31
|
})(CardanoCertificateType || (CardanoCertificateType = {}));
|
|
32
|
+
export var CardanoDRepType;
|
|
33
|
+
(function (CardanoDRepType) {
|
|
34
|
+
CardanoDRepType[CardanoDRepType["KEY_HASH"] = 0] = "KEY_HASH";
|
|
35
|
+
CardanoDRepType[CardanoDRepType["SCRIPT_HASH"] = 1] = "SCRIPT_HASH";
|
|
36
|
+
CardanoDRepType[CardanoDRepType["ABSTAIN"] = 2] = "ABSTAIN";
|
|
37
|
+
CardanoDRepType[CardanoDRepType["NO_CONFIDENCE"] = 3] = "NO_CONFIDENCE";
|
|
38
|
+
})(CardanoDRepType || (CardanoDRepType = {}));
|
|
39
39
|
export var CardanoPoolRelayType;
|
|
40
40
|
(function (CardanoPoolRelayType) {
|
|
41
41
|
CardanoPoolRelayType[CardanoPoolRelayType["SINGLE_HOST_IP"] = 0] = "SINGLE_HOST_IP";
|
|
@@ -179,7 +179,7 @@ const outputsToOneKey = (outputs, changeAddress) => {
|
|
|
179
179
|
* @param {Transaction} tx
|
|
180
180
|
*/
|
|
181
181
|
export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress) => {
|
|
182
|
-
var _a, _b, _c
|
|
182
|
+
var _a, _b, _c;
|
|
183
183
|
const keys = generateKeys(initKeys, xpub);
|
|
184
184
|
const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(rawTx, 'hex'));
|
|
185
185
|
let signingMode = CardanoTxSigningMode.ORDINARY_TRANSACTION;
|
|
@@ -312,52 +312,39 @@ export const txToOneKey = async (rawTx, network, initKeys, xpub, changeAddress)
|
|
|
312
312
|
metadata,
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
else if (certKind ===
|
|
316
|
-
//
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
certificate.
|
|
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
|
-
}
|
|
315
|
+
else if (certKind === 15) {
|
|
316
|
+
// VoteDelegation (CertificateKind.VoteDelegation = 15 in WASM lib)
|
|
317
|
+
const voteDelegation = cert.as_vote_delegation();
|
|
318
|
+
const credential = voteDelegation.stake_credential();
|
|
319
|
+
certificate.type = CardanoCertificateType.VOTE_DELEGATION;
|
|
320
|
+
if (credential.kind() === 0) {
|
|
321
|
+
certificate.path = keys.stake.path;
|
|
349
322
|
}
|
|
350
323
|
else {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
324
|
+
const scriptHash = Buffer.from(credential.to_scripthash().to_bytes()).toString('hex');
|
|
325
|
+
certificate.scriptHash = scriptHash;
|
|
326
|
+
}
|
|
327
|
+
// Parse DRep
|
|
328
|
+
const drep = voteDelegation.drep();
|
|
329
|
+
const drepKind = drep.kind();
|
|
330
|
+
// DRepKind: KeyHash = 0, ScriptHash = 1, AlwaysAbstain = 2, AlwaysNoConfidence = 3
|
|
331
|
+
certificate.dRep = {
|
|
332
|
+
type: drepKind,
|
|
333
|
+
};
|
|
334
|
+
if (drepKind === 0) {
|
|
335
|
+
// KEY_HASH
|
|
336
|
+
certificate.dRep.keyHash = (_b = drep.to_key_hash()) === null || _b === void 0 ? void 0 : _b.to_hex();
|
|
337
|
+
}
|
|
338
|
+
else if (drepKind === 1) {
|
|
339
|
+
// SCRIPT_HASH
|
|
340
|
+
certificate.dRep.scriptHash = (_c = drep.to_script_hash()) === null || _c === void 0 ? void 0 : _c.to_hex();
|
|
355
341
|
}
|
|
342
|
+
// ABSTAIN (2) and NO_CONFIDENCE (3) don't need additional fields
|
|
356
343
|
}
|
|
357
344
|
else {
|
|
358
|
-
// Skip unsupported certificate types
|
|
345
|
+
// Skip unsupported certificate types (kind 4, 5, 6, etc.)
|
|
359
346
|
// Don't push empty certificate objects
|
|
360
|
-
console.
|
|
347
|
+
console.warn(`[txToOneKey] Unsupported certificate kind: ${certKind}, cert:`, cert.to_hex());
|
|
361
348
|
continue;
|
|
362
349
|
}
|
|
363
350
|
onekeyCertificates.push(certificate);
|