Skip to content

Commit d6c539a

Browse files
committed
chore: add more types
1 parent 0248068 commit d6c539a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ class Client {
16371637
this.network === 'mainnet' ? Network.Mainnet : Network.Testnet,
16381638
);
16391639
const index = outputs.findIndex((output) => output.type === 'IssueNft');
1640-
const output = outputs[index];
1640+
const output = outputs[index] as IssueNftOutput;
16411641
outputs[index] = {
16421642
...output,
16431643
token_id: token_id,
@@ -1871,17 +1871,19 @@ class Client {
18711871

18721872
async transferNft({ to, token_id }: { to: string; token_id: string }): Promise<any> {
18731873
this.ensureInitialized();
1874+
1875+
if(!token_id) {
1876+
throw new Error('Token ID is required for NFT transfer');
1877+
}
1878+
18741879
const amount = 1;
1875-
let token_details: Record<string, any> = token_id ? { token_id } : {};
1876-
if (token_id) {
1877-
const request = await fetch(`${this.getApiServer()}/nft/${token_id}`);
1878-
if (!request.ok) {
1879-
throw new Error('Failed to fetch token');
1880-
}
1881-
const token = await request.json();
1882-
token_details = token;
1883-
token_details.number_of_decimals = 0; // that's NFT
1880+
const request = await fetch(`${this.getApiServer()}/nft/${token_id}`);
1881+
if (!request.ok) {
1882+
throw new Error('Failed to fetch token');
18841883
}
1884+
const token = await request.json();
1885+
const token_details: TokenDetails = token;
1886+
token_details.number_of_decimals = 0; // that's NFT
18851887
const tx = await this.buildTransaction({ type: 'Transfer', params: { to, amount, token_id, token_details } });
18861888
return this.signTransaction(tx);
18871889
}

0 commit comments

Comments
 (0)