@onekeyfe/cardano-coin-selection-asmjs 1.1.8 → 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.
|
@@ -90,13 +90,20 @@ const getUtxos = async (address, utxos, amount) => {
|
|
|
90
90
|
const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) => {
|
|
91
91
|
var _a, _b, _c, _d;
|
|
92
92
|
let body;
|
|
93
|
+
let rawTxHex;
|
|
93
94
|
console.log('CARDANO LOCAL_VERSION : 1');
|
|
94
95
|
try {
|
|
95
96
|
const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex'));
|
|
96
97
|
body = tx.body();
|
|
98
|
+
rawTxHex = txHex;
|
|
97
99
|
}
|
|
98
100
|
catch (_e) {
|
|
101
|
+
// Input is TransactionBody only (e.g., from staking providers like stakefish)
|
|
102
|
+
// Build a complete Transaction with empty witness set
|
|
99
103
|
body = CardanoWasm.TransactionBody.from_bytes(Buffer.from(txHex, 'hex'));
|
|
104
|
+
const emptyWitnessSet = CardanoWasm.TransactionWitnessSet.new();
|
|
105
|
+
const tx = CardanoWasm.Transaction.new(body, emptyWitnessSet);
|
|
106
|
+
rawTxHex = Buffer.from(tx.to_bytes(), 'hex').toString('hex');
|
|
100
107
|
}
|
|
101
108
|
// Fee
|
|
102
109
|
const fee = body.fee().to_str();
|
|
@@ -251,7 +258,7 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
251
258
|
.transaction_hash()
|
|
252
259
|
.to_hex(),
|
|
253
260
|
size: 0,
|
|
254
|
-
rawTxHex
|
|
261
|
+
rawTxHex,
|
|
255
262
|
},
|
|
256
263
|
signOnly: true,
|
|
257
264
|
staking: stakingInfo,
|
|
@@ -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
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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
|
}
|
|
@@ -60,13 +60,20 @@ const getUtxos = async (address, utxos, amount) => {
|
|
|
60
60
|
const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) => {
|
|
61
61
|
var _a, _b, _c, _d;
|
|
62
62
|
let body;
|
|
63
|
+
let rawTxHex;
|
|
63
64
|
console.log('CARDANO LOCAL_VERSION : 1');
|
|
64
65
|
try {
|
|
65
66
|
const tx = CardanoWasm.Transaction.from_bytes(Buffer.from(txHex, 'hex'));
|
|
66
67
|
body = tx.body();
|
|
68
|
+
rawTxHex = txHex;
|
|
67
69
|
}
|
|
68
70
|
catch (_e) {
|
|
71
|
+
// Input is TransactionBody only (e.g., from staking providers like stakefish)
|
|
72
|
+
// Build a complete Transaction with empty witness set
|
|
69
73
|
body = CardanoWasm.TransactionBody.from_bytes(Buffer.from(txHex, 'hex'));
|
|
74
|
+
const emptyWitnessSet = CardanoWasm.TransactionWitnessSet.new();
|
|
75
|
+
const tx = CardanoWasm.Transaction.new(body, emptyWitnessSet);
|
|
76
|
+
rawTxHex = Buffer.from(tx.to_bytes(), 'hex').toString('hex');
|
|
70
77
|
}
|
|
71
78
|
// Fee
|
|
72
79
|
const fee = body.fee().to_str();
|
|
@@ -221,7 +228,7 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
221
228
|
.transaction_hash()
|
|
222
229
|
.to_hex(),
|
|
223
230
|
size: 0,
|
|
224
|
-
rawTxHex
|
|
231
|
+
rawTxHex,
|
|
225
232
|
},
|
|
226
233
|
signOnly: true,
|
|
227
234
|
staking: stakingInfo,
|
|
@@ -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
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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
|
}
|