Skip to content

Commit

Permalink
Lock: Return a hash() to get the operation hash
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Feb 10, 2024
1 parent 861ac44 commit 16baf3f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/handlers/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type TLockNFT<Signer, ExtraArgs, RetTx> = {
to: string,
tokenId: bigint,
extraArgs: ExtraArgs,
) => Promise<RetTx>;
) => Promise<RetTx | { hash: () => string }>;
};

/**
Expand Down Expand Up @@ -191,7 +191,7 @@ export type TLockSFT<Signer, ExtraArgs, RetTx> = {
tokenId: bigint,
amt: bigint,
extraArgs: ExtraArgs,
) => Promise<RetTx>;
) => Promise<RetTx | { hash: () => string }>;
};

/**
Expand Down
10 changes: 8 additions & 2 deletions src/handlers/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function evmHandler({
extraArgs,
);
},
lockNft(
async lockNft(
signer,
sourceNftAddress,
destinationChain,
Expand All @@ -147,13 +147,19 @@ export function evmHandler({
extraArgs,
) {
const contract = Bridge__factory.connect(bridge, signer);
return contract.lock721(
const result = await contract.lock721(
tokenId.toString(),
destinationChain,
to,
sourceNftAddress,
extraArgs,
);
return {
...result,
hash() {
return result.hash;
},
};
},
};
}
7 changes: 6 additions & 1 deletion src/handlers/multiversx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ export function multiversxHandler({
tx3.applySignature(transactionSignature);

const txHash = await provider.sendTransaction(tx3);
return txHash;
return {
txHash,
hash() {
return txHash;
},
};
},
async claimNft(signer, claimData, _, sig) {
const userAddress = new Address(signer.getAddress().bech32());
Expand Down
7 changes: 6 additions & 1 deletion src/handlers/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ export function secretHandler({
...extraArgs,
},
);
return tx;
return {
...tx,
hash() {
return tx.transactionHash;
},
};
},
};
}
7 changes: 6 additions & 1 deletion src/handlers/tezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ export function tezosHandler({
})
.send({ ...extraArgs });

return tx;
return {
...tx,
hash() {
return tx.hash;
},
};
},
async nftData(tokenId, contract) {
const tokenMd = await getNftTokenMetaData(contract, BigInt(tokenId));
Expand Down
5 changes: 5 additions & 0 deletions src/handlers/ton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export function tonHandler({
tokenId: BigInt(tokenId),
},
);
return {
hash() {
return "";
},
};
},
async approveNft(_signer, _tokenId, _contract) {},
async nftData(_tokenId, contract, _overrides) {
Expand Down

0 comments on commit 16baf3f

Please sign in to comment.