Skip to content

Commit

Permalink
fixed bit shifting
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Mar 21, 2024
1 parent 6eb113b commit a3dc795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 11 additions & 1 deletion wormhole-connect/src/routes/cctpManual/chains/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ export default class ManualCCTPEvmImpl
const destContext = config.wh.getContext(toChain);
let recipient = destContext.parseAddress(parsedCCTPLog.args.mintRecipient);
if (toChain === 'solana') {
recipient = await solanaContext().getTokenAccountOwner(recipient);
try {
console.log(recipient);
recipient = await solanaContext().getTokenAccountOwner(recipient);
} catch (e: any) {
// we'll promp them to create it before claiming it
if (e.name === 'TokenAccountNotFoundError') {
recipient = '';
} else {
throw e;
}
}
}
const fromChain = toChainName(chain);
const tokenId: TokenId = {
Expand Down
12 changes: 3 additions & 9 deletions wormhole-connect/src/routes/cctpManual/chains/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import {
addComputeBudget,
ChainId,
ChainName,
SolanaContext,
TokenId,
WormholeContext,
} from '@wormhole-foundation/wormhole-connect-sdk';
import { BigNumber, utils as ethUtils } from 'ethers';
import { PayloadType, solanaContext, toChainId, toChainName } from 'utils/sdk';
Expand Down Expand Up @@ -71,9 +69,7 @@ const findProgramAddress = (
};

function getMessageTransmitter(): Program<MessageTransmitter> {
const context = config.wh.getContext(
CHAIN_ID_SOLANA,
) as SolanaContext<WormholeContext>;
const context = solanaContext();
const connection = context.connection;
const contracts =
context.contracts.mustGetContracts(CHAIN_ID_SOLANA).cctpContracts;
Expand All @@ -88,9 +84,7 @@ function getMessageTransmitter(): Program<MessageTransmitter> {
}

function getTokenMessenger(): Program<TokenMessenger> {
const context = config.wh.getContext(
CHAIN_ID_SOLANA,
) as SolanaContext<WormholeContext>;
const context = solanaContext();
const connection = context.connection;
const contracts =
context.contracts.mustGetContracts(CHAIN_ID_SOLANA).cctpContracts;
Expand Down Expand Up @@ -502,7 +496,7 @@ export class ManualCCTPSolanaImpl implements ManualCCTP<Transaction> {

// get the nonce flag index and build a bitmask
const nonceBitIndex = nonceIndex % 64;
const mask = new BN(1 << nonceBitIndex);
const mask = new BN((BigInt(1) << BigInt(nonceBitIndex)).toString());

const nonceByte = usedNonces[nonceElementIndex];
if (!nonceByte) throw new Error('Invalid nonce byte index');
Expand Down

0 comments on commit a3dc795

Please sign in to comment.