@onekeyfe/cardano-coin-selection-asmjs 1.1.10-alpha.5 → 1.1.10-alpha.7
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as CardanoWasm from '@emurgo/cardano-serialization-lib-asmjs';
|
|
2
|
-
import { IAdaAmount, IAdaUTXO,
|
|
2
|
+
import { IAdaAmount, IAdaUTXO, IEncodedTxADA, IConvertCborTxParams } from './types';
|
|
3
3
|
export declare const assetsToValue: (assets: IAdaAmount[]) => Promise<CardanoWasm.Value>;
|
|
4
4
|
export declare const extractKeyHash: (address: string) => Promise<string>;
|
|
5
5
|
export declare const dAppUtils: {
|
|
6
6
|
getBalance: (balances: IAdaAmount[]) => Promise<string>;
|
|
7
7
|
getAddresses: (addresses: string[]) => Promise<string[]>;
|
|
8
8
|
getUtxos: (address: string, utxos: IAdaUTXO[], amount?: string) => Promise<string[] | null | undefined>;
|
|
9
|
-
convertCborTxToEncodeTx: (txHex
|
|
9
|
+
convertCborTxToEncodeTx: ({ txHex, utxos, addresses, changeAddress, isSignOnly, }: IConvertCborTxParams) => Promise<IEncodedTxADA>;
|
|
10
10
|
signData: (address: string, payload: string, xprv: string, accountIndex: number) => Promise<{
|
|
11
11
|
signature: string;
|
|
12
12
|
key: string;
|
|
@@ -87,7 +87,7 @@ const getUtxos = async (address, utxos, amount) => {
|
|
|
87
87
|
}
|
|
88
88
|
return converted === null || converted === void 0 ? void 0 : converted.map(utxo => Buffer.from(utxo.to_bytes(), 'hex').toString('hex'));
|
|
89
89
|
};
|
|
90
|
-
const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) => {
|
|
90
|
+
const convertCborTxToEncodeTx = async ({ txHex, utxos, addresses, changeAddress, isSignOnly, }) => {
|
|
91
91
|
var _a, _b, _c, _d;
|
|
92
92
|
let body;
|
|
93
93
|
let rawTxHex;
|
|
@@ -189,6 +189,20 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
189
189
|
// All valid transactions must have at least one output
|
|
190
190
|
// Empty outputs means insufficient funds to cover the transaction
|
|
191
191
|
if (outputsLen === 0) {
|
|
192
|
+
console.log('[convertCborTxToEncodeTx] Empty outputs detected, transaction data:', {
|
|
193
|
+
fee,
|
|
194
|
+
totalFeeInNative,
|
|
195
|
+
inputsCount: inputsLen,
|
|
196
|
+
inputs: inputs,
|
|
197
|
+
matchedUtxos: encodeInputs.map(u => ({
|
|
198
|
+
tx_hash: u.tx_hash,
|
|
199
|
+
tx_index: u.tx_index,
|
|
200
|
+
amount: u.amount,
|
|
201
|
+
})),
|
|
202
|
+
isStakingTx,
|
|
203
|
+
certificates,
|
|
204
|
+
poolId,
|
|
205
|
+
});
|
|
192
206
|
throw new errors_1.CoinSelectionError(constants_1.ERROR.UTXO_BALANCE_INSUFFICIENT);
|
|
193
207
|
}
|
|
194
208
|
for (let i = 0; i < outputsLen; i++) {
|
|
@@ -260,7 +274,7 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
260
274
|
size: 0,
|
|
261
275
|
rawTxHex,
|
|
262
276
|
},
|
|
263
|
-
signOnly:
|
|
277
|
+
signOnly: isSignOnly,
|
|
264
278
|
staking: stakingInfo,
|
|
265
279
|
};
|
|
266
280
|
console.log('Cardano DApp EncodedTx: ', encodedTx);
|
|
@@ -94,4 +94,11 @@ export type ICardanoCertificate = {
|
|
|
94
94
|
stakeCredential?: string;
|
|
95
95
|
poolKeyHash?: string;
|
|
96
96
|
};
|
|
97
|
+
export type IConvertCborTxParams = {
|
|
98
|
+
txHex: string;
|
|
99
|
+
utxos: IAdaUTXO[];
|
|
100
|
+
addresses: string[];
|
|
101
|
+
changeAddress: IChangeAddress;
|
|
102
|
+
isSignOnly: boolean;
|
|
103
|
+
};
|
|
97
104
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as CardanoWasm from '@emurgo/cardano-serialization-lib-asmjs';
|
|
2
|
-
import { IAdaAmount, IAdaUTXO,
|
|
2
|
+
import { IAdaAmount, IAdaUTXO, IEncodedTxADA, IConvertCborTxParams } from './types';
|
|
3
3
|
export declare const assetsToValue: (assets: IAdaAmount[]) => Promise<CardanoWasm.Value>;
|
|
4
4
|
export declare const extractKeyHash: (address: string) => Promise<string>;
|
|
5
5
|
export declare const dAppUtils: {
|
|
6
6
|
getBalance: (balances: IAdaAmount[]) => Promise<string>;
|
|
7
7
|
getAddresses: (addresses: string[]) => Promise<string[]>;
|
|
8
8
|
getUtxos: (address: string, utxos: IAdaUTXO[], amount?: string) => Promise<string[] | null | undefined>;
|
|
9
|
-
convertCborTxToEncodeTx: (txHex
|
|
9
|
+
convertCborTxToEncodeTx: ({ txHex, utxos, addresses, changeAddress, isSignOnly, }: IConvertCborTxParams) => Promise<IEncodedTxADA>;
|
|
10
10
|
signData: (address: string, payload: string, xprv: string, accountIndex: number) => Promise<{
|
|
11
11
|
signature: string;
|
|
12
12
|
key: string;
|
|
@@ -57,7 +57,7 @@ const getUtxos = async (address, utxos, amount) => {
|
|
|
57
57
|
}
|
|
58
58
|
return converted === null || converted === void 0 ? void 0 : converted.map(utxo => Buffer.from(utxo.to_bytes(), 'hex').toString('hex'));
|
|
59
59
|
};
|
|
60
|
-
const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) => {
|
|
60
|
+
const convertCborTxToEncodeTx = async ({ txHex, utxos, addresses, changeAddress, isSignOnly, }) => {
|
|
61
61
|
var _a, _b, _c, _d;
|
|
62
62
|
let body;
|
|
63
63
|
let rawTxHex;
|
|
@@ -159,6 +159,20 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
159
159
|
// All valid transactions must have at least one output
|
|
160
160
|
// Empty outputs means insufficient funds to cover the transaction
|
|
161
161
|
if (outputsLen === 0) {
|
|
162
|
+
console.log('[convertCborTxToEncodeTx] Empty outputs detected, transaction data:', {
|
|
163
|
+
fee,
|
|
164
|
+
totalFeeInNative,
|
|
165
|
+
inputsCount: inputsLen,
|
|
166
|
+
inputs: inputs,
|
|
167
|
+
matchedUtxos: encodeInputs.map(u => ({
|
|
168
|
+
tx_hash: u.tx_hash,
|
|
169
|
+
tx_index: u.tx_index,
|
|
170
|
+
amount: u.amount,
|
|
171
|
+
})),
|
|
172
|
+
isStakingTx,
|
|
173
|
+
certificates,
|
|
174
|
+
poolId,
|
|
175
|
+
});
|
|
162
176
|
throw new CoinSelectionError(ERROR.UTXO_BALANCE_INSUFFICIENT);
|
|
163
177
|
}
|
|
164
178
|
for (let i = 0; i < outputsLen; i++) {
|
|
@@ -230,7 +244,7 @@ const convertCborTxToEncodeTx = async (txHex, utxos, addresses, changeAddress) =
|
|
|
230
244
|
size: 0,
|
|
231
245
|
rawTxHex,
|
|
232
246
|
},
|
|
233
|
-
signOnly:
|
|
247
|
+
signOnly: isSignOnly,
|
|
234
248
|
staking: stakingInfo,
|
|
235
249
|
};
|
|
236
250
|
console.log('Cardano DApp EncodedTx: ', encodedTx);
|
|
@@ -94,4 +94,11 @@ export type ICardanoCertificate = {
|
|
|
94
94
|
stakeCredential?: string;
|
|
95
95
|
poolKeyHash?: string;
|
|
96
96
|
};
|
|
97
|
+
export type IConvertCborTxParams = {
|
|
98
|
+
txHex: string;
|
|
99
|
+
utxos: IAdaUTXO[];
|
|
100
|
+
addresses: string[];
|
|
101
|
+
changeAddress: IChangeAddress;
|
|
102
|
+
isSignOnly: boolean;
|
|
103
|
+
};
|
|
97
104
|
export {};
|