Skip to content

Commit

Permalink
Improvement with computedBudget commented
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna committed Jun 18, 2024
1 parent b02009e commit 8e9bb62
Show file tree
Hide file tree
Showing 14 changed files with 859 additions and 131 deletions.
182 changes: 144 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
"@project-serum/serum": "^0.13.60",
"@reduxjs/toolkit": "^1.6.1",
"@sei-js/react": "^1.3.3",
"@solana/spl-token": "^0.1.6",
"@solana/spl-token": "^0.3.7",
"@solana/spl-token-registry": "^0.2.216",
"@solana/wallet-adapter-base": "^0.9.3",
"@solana/wallet-adapter-react": "^0.15.32",
"@solana/wallet-adapter-react-ui": "^0.9.5",
"@solana/wallet-adapter-wallets": "^0.19.20",
"@solana/web3.js": "^1.35.1",
"@solana/web3.js": "^1.93.0",
"@terra-money/wallet-provider": "^3.9.4",
"@types/react-dom": "^17.0.20",
"@walletconnect/web3-provider": "^1.7.8",
"@wormhole-foundation/sdk-icons": "^0.6.8",
"@xlabs-libs/wallet-aggregator-algorand": "0.0.1-alpha.26",
"@xlabs-libs/wallet-aggregator-aptos": "^0.0.1-alpha.12",
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.21",
"@xlabs-libs/wallet-aggregator-evm": "^0.0.1-alpha.43",
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.20",
"@xlabs-libs/wallet-aggregator-evm": "^0.0.1-alpha.42",
"@xlabs-libs/wallet-aggregator-injective": "^0.0.1-alpha.15",
"@xlabs-libs/wallet-aggregator-near": "^0.0.1-alpha.7",
"@xlabs-libs/wallet-aggregator-react": "^0.0.1-alpha.16",
Expand Down
40 changes: 22 additions & 18 deletions src/assets/providers/tbtc/solana/WormholeGateway.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import * as tokenBridge from "@certusone/wormhole-sdk/lib/esm/solana/tokenBridge
import { SolanaWallet } from "@xlabs-libs/wallet-aggregator-solana";
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
Token,
createAssociatedTokenAccountInstruction,
getAssociatedTokenAddress,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";

Expand Down Expand Up @@ -232,35 +233,37 @@ export function newThresholdWormholeGateway(
const wrappedTbtcMint = new PublicKey(
custodianData.wrappedTbtcMint as string
);
const recipientTokenKey = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
const recipientTokenKey = await getAssociatedTokenAddress(
tbtcMint,
recipient
recipient,
undefined,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);
const transaction = new Transaction();
const recipientToken = await connection.getAccountInfo(recipientTokenKey);
console.log(recipientToken, recipientTokenKey.toBase58());
if (!recipientToken) {
const recipientTokenAtaIx = Token.createAssociatedTokenAccountInstruction(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
tbtcMint,
const recipientTokenAtaIx = createAssociatedTokenAccountInstruction(
recipient, // payer
recipientTokenKey,
recipient, // owner
recipient // payer
tbtcMint,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);
transaction.add(recipientTokenAtaIx);
}
const tokenBridgeWrappedAsset = tokenBridge.deriveWrappedMetaKey(
TOKEN_BRIDGE_PROGRAM_ID,
wrappedTbtcMint
);
const recipientWrappedToken = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
const recipientWrappedToken = await getAssociatedTokenAddress(
wrappedTbtcMint,
recipient
recipient,
undefined,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);
const accounts = {
payer: new PublicKey(wallet.getAddress()!),
Expand Down Expand Up @@ -356,11 +359,12 @@ export function newThresholdWormholeGateway(
recipient: recipientAddress,
nonce: 0,
};
const associatedTokenAccount = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
const associatedTokenAccount = await getAssociatedTokenAddress(
new PublicKey(senderToken),
new PublicKey(wallet.getAddress()!)
new PublicKey(wallet.getAddress()!),
undefined,
TOKEN_PROGRAM_ID,
ASSOCIATED_TOKEN_PROGRAM_ID
);
if (!isCanonical(recipientChain)) {
const wrappedAccounts = {
Expand Down
Loading

0 comments on commit 8e9bb62

Please sign in to comment.