Skip to content

Commit b23ee5b

Browse files
committed
fix: sending token
1 parent a740e68 commit b23ee5b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/sdk/src/mintlayer-connect-sdk.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class Client {
619619
}
620620
}
621621

622-
private selectUTXOs(utxos: UtxoEntry[], amount: bigint, outputType: string, token_id: string | null): UtxoInput[] {
622+
private selectUTXOs(utxos: UtxoEntry[], amount: bigint, token_id: string | null): UtxoInput[] {
623623
return this.selectUTXOsForTransfer(utxos, amount, token_id);
624624
}
625625

@@ -714,11 +714,15 @@ class Client {
714714
})
715715
.filter((utxo) => transferableUtxoTypes.includes(utxo.utxo.type))
716716
.filter((utxo) => {
717-
if (token_id === null) {
718-
return utxo.utxo.value.type === 'Coin';
719-
}
720-
if (utxo.utxo.value.type === 'TokenV1') {
721-
return utxo.utxo.value.token_id === token_id;
717+
if (utxo.utxo.type === 'IssueNft') {
718+
return utxo.utxo.token_id === token_id;
719+
} else {
720+
if (token_id === null) {
721+
return utxo.utxo.value.type === 'Coin';
722+
}
723+
if (utxo.utxo.value.type === 'TokenV1') {
724+
return utxo.utxo.value.token_id === token_id;
725+
}
722726
}
723727
});
724728

@@ -1551,9 +1555,9 @@ class Client {
15511555
fee += BigInt(2 * Math.pow(10, 11));
15521556
input_amount_coin_req += fee;
15531557

1554-
const inputObjCoin = this.selectUTXOs(utxos, input_amount_coin_req, 'Transfer', null);
1558+
const inputObjCoin = this.selectUTXOs(utxos, input_amount_coin_req, null);
15551559
const inputObjToken = send_token?.token_id
1556-
? this.selectUTXOs(utxos, input_amount_token_req, 'Transfer', send_token.token_id)
1560+
? this.selectUTXOs(utxos, input_amount_token_req, send_token.token_id)
15571561
: [];
15581562

15591563
const totalInputValueCoin = inputObjCoin.reduce((acc, item) => acc + BigInt(item.utxo!.value.amount.atoms), 0n);

0 commit comments

Comments
 (0)