Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fix to allow sending canonical tBTC to non canonical supported network #504

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/assets/providers/tbtc/solana/WormholeGateway.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
THRESHOLD_TBTC_SOLANA_PROGRAM,
} from "../../../../utils/consts";
import {
CHAIN_ID_ETH,
CHAIN_ID_ARBITRUM,
CHAIN_ID_BASE,
CHAIN_ID_OPTIMISM,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
ChainId,
SignedVaa,
Expand Down Expand Up @@ -176,6 +179,18 @@ function sendTbtcWrapped(
return tx;
}

const CANNONICAL_CHAINS: number[] = [
CHAIN_ID_POLYGON,
CHAIN_ID_OPTIMISM,
CHAIN_ID_ARBITRUM,
CHAIN_ID_BASE,
CHAIN_ID_SOLANA,
];

const isCanonical = (chainId: number) => {
return CANNONICAL_CHAINS.includes(chainId);
};

/**
* Send tBtc beween gateways allow burn and mint of tBtc
*/
Expand Down Expand Up @@ -347,7 +362,7 @@ export function newThresholdWormholeGateway(
new PublicKey(senderToken),
new PublicKey(wallet.getAddress()!)
);
if (recipientChain === CHAIN_ID_ETH) {
if (!isCanonical(recipientChain)) {
const wrappedAccounts = {
custodian,
wrappedTbtcToken,
Expand Down