Skip to content

Commit

Permalink
solana send and receive work
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Mar 19, 2024
1 parent 01a0704 commit 5e88a94
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 108 deletions.
58 changes: 28 additions & 30 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion wormhole-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@reduxjs/toolkit": "^1.9.1",
"@solana/wallet-adapter-wallets": "^0.19.25",
"@solana/web3.js": "^1.73.0",
"@wormhole-foundation/connect-sdk": "^0.3.3",
"@wormhole-foundation/sdk-definitions": "^0.5.0",
"@wormhole-foundation/wormhole-connect-sdk": "0.1.0-beta.0",
"@xlabs-libs/wallet-aggregator-aptos": "^0.0.1-alpha.14",
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.18",
"@xlabs-libs/wallet-aggregator-cosmos": "^0.0.1-alpha.14",
Expand Down
30 changes: 19 additions & 11 deletions wormhole-connect/src/routes/cctpManual/cctpManual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
getDisplayName,
calculateUSDPrice,
} from 'utils';
import { isEvmChain, toChainId } from 'utils/sdk';
import { isEvmChain, toChainId, toChainName } from 'utils/sdk';
import { TransferWallet, signAndSendTransaction } from 'utils/wallet';
import { NO_INPUT } from 'utils/style';
import { toDecimals } from '../../utils/balance';
import { getSolanaAssociatedTokenAccount } from '../../utils/solana';
import { getAssociatedTokenAddress } from '@solana/spl-token';
import { BaseRoute } from '../bridge/baseRoute';
import {
ManualCCTPMessage,
Expand All @@ -40,6 +40,8 @@ import {
tryGetCircleAttestation,
} from './utils';
import { TokenPrices } from 'store/tokenPrices';
import { getNativeVersionOfToken } from 'store/transferInput';
import { PublicKey } from '@solana/web3.js';

export class CCTPManualRoute extends BaseRoute {
readonly NATIVE_GAS_DROPOFF_SUPPORTED: boolean = false;
Expand Down Expand Up @@ -248,15 +250,21 @@ export class CCTPManualRoute extends BaseRoute {
destToken: string,
routeOptions: any,
): Promise<string> {
const recipientAccount =
config.wh.toChainName(recipientChain) === 'solana'
? await getSolanaAssociatedTokenAccount(
token,
sendingChain,
recipientAddress,
)
: recipientAddress;

// TODO: make sure sending to the ATA is right
let recipientAccount = recipientAddress;
if (toChainName(recipientChain) === 'solana') {
const tokenKey = getNativeVersionOfToken('USDC', 'solana');
const tokenConfig = config.tokens[tokenKey];
if (!tokenConfig || !tokenConfig.tokenId) {
throw new Error('Solana USDC not found');
}
recipientAccount = (
await getAssociatedTokenAddress(
new PublicKey(tokenConfig.tokenId.address),
new PublicKey(recipientAddress),
)
).toString();
}
const tx = await this.getImplementation(sendingChain).send(
token,
amount,
Expand Down
Loading

0 comments on commit 5e88a94

Please sign in to comment.