Skip to content

Commit b205b60

Browse files
authoredJan 21, 2025
Fix WSOL redemption (#781)
* dont override for "native" * handle WSOL properly * handle WSOL in tokenTransfer * compare addresses correctly
1 parent 4be2f8c commit b205b60

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎connect/src/protocols/tokenBridge/tokenTransfer.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
canonicalAddress,
2626
deserialize,
2727
isNative,
28+
isSameToken,
2829
isTokenId,
2930
isTokenTransferDetails,
3031
isTransactionIdentifier,
@@ -820,9 +821,9 @@ export namespace TokenTransfer {
820821
// or the transaction could fail if the account does not have enough lamports
821822
if (dstToken.chain === "Solana") {
822823
const nativeWrappedTokenId = await dstChain.getNativeWrappedTokenId();
824+
const isNativeSol = (isNative(dstToken.address) || isSameToken(dstToken, nativeWrappedTokenId));
823825
if (
824-
dstToken.address === nativeWrappedTokenId.address &&
825-
destAmountLessFee < solanaMinBalanceForRentExemptAccount
826+
isNativeSol && destAmountLessFee < solanaMinBalanceForRentExemptAccount
826827
) {
827828
throw new Error(
828829
`Destination amount must be at least ${solanaMinBalanceForRentExemptAccount} lamports`,
@@ -860,9 +861,12 @@ export namespace TokenTransfer {
860861
dstChain,
861862
_transfer.token,
862863
);
863-
// TODO: If the token is native, no need to overwrite the destination address check for native
864-
//if (!destinationToken.address.equals((await dstChain.getNativeWrappedTokenId()).address))
865-
_transfer.to = await dstChain.getTokenAccount(_transfer.to.address, destinationToken.address);
864+
if (isNative(destinationToken.address)) {
865+
const nativeWrappedTokenId = await dstChain.getNativeWrappedTokenId();
866+
_transfer.to = await dstChain.getTokenAccount(_transfer.to.address, nativeWrappedTokenId.address);
867+
} else {
868+
_transfer.to = await dstChain.getTokenAccount(_transfer.to.address, destinationToken.address)
869+
}
866870
}
867871

868872
if (_transfer.to.chain === "Sei") {

0 commit comments

Comments
 (0)