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

NTT route: comment out legacy sdk code #1

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
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
43 changes: 23 additions & 20 deletions wormhole-connect/src/routes/ntt/chains/evm/getMessage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ChainName, ChainId } from '@wormhole-foundation/wormhole-connect-sdk';
import { Implementation__factory } from '@certusone/wormhole-sdk/lib/esm/ethers-contracts';
import {
parseWormholeLog,
RelayerPayloadId,
DeliveryInstruction,
} from '@certusone/wormhole-sdk/lib/esm/relayer';
// TODO: SDKV2
//import {
// parseWormholeLog,
// RelayerPayloadId,
// DeliveryInstruction,
//} from '@certusone/wormhole-sdk/lib/esm/relayer';
import { ethers } from 'ethers';
import { hexlify } from 'ethers/lib/utils';
import { NttRelayingType, UnsignedNttMessage } from 'routes/types';
import { /*NttRelayingType,*/ UnsignedNttMessage } from 'routes/types';
import { getTokenById } from 'utils';
import { getWormholeLogEvm } from 'utils/vaa';
import config from 'config';
Expand Down Expand Up @@ -73,22 +74,24 @@ export const getMessageEvm = async (
const parsedRelayingInfo = RELAYING_INFO_IFACE.parseLog(relayingInfoEvent);
const { relayingType, deliveryPayment } = parsedRelayingInfo.args;
let payload: Buffer;
if (relayingType === NttRelayingType.Standard) {
const { type, parsed } = parseWormholeLog(wormholeLog);
if (type !== RelayerPayloadId.Delivery) {
throw new Error(`Unexpected standard relayer payload type ${type}`);
}
payload = (parsed as DeliveryInstruction).payload;
} else if (
relayingType === NttRelayingType.Manual ||
relayingType === NttRelayingType.Special
) {
payload = Buffer.from(parsedWormholeLog.args.payload.slice(2), 'hex');
} else {
throw new Error(`Unexpected relaying type ${relayingType}`);
}
// TODO: SDKV2
//if (relayingType === NttRelayingType.Standard) {
// const { type, parsed } = parseWormholeLog(wormholeLog);
// if (type !== RelayerPayloadId.Delivery) {
// throw new Error(`Unexpected standard relayer payload type ${type}`);
// }
// payload = (parsed as DeliveryInstruction).payload;
//} else if (
// relayingType === NttRelayingType.Manual ||
// relayingType === NttRelayingType.Special
//) {
// payload = Buffer.from(parsedWormholeLog.args.payload.slice(2), 'hex');
//} else {
// throw new Error(`Unexpected relaying type ${relayingType}`);
//}
const transceiverMessage = deserializePayload(
'Ntt:WormholeTransfer',
//@ts-ignore
payload,
);
const nttManagerMessage = transceiverMessage.nttManagerPayload;
Expand Down
4 changes: 3 additions & 1 deletion wormhole-connect/src/routes/ntt/chains/solana/getMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { solanaContext } from 'utils/sdk';
import { PostedMessageData } from '@certusone/wormhole-sdk/lib/esm/solana/wormhole';
// import { PostedMessageData } from '@certusone/wormhole-sdk/lib/esm/solana/wormhole';
import { hexlify } from 'ethers/lib/utils';
import { NttRelayingType, UnsignedNttMessage } from 'routes/types';
import { getTokenById } from 'utils';
Expand Down Expand Up @@ -39,6 +39,8 @@ export const getMessageSolana = async (
);
if (wormholeMessageAccount === null)
throw new Error('wormhole message account not found');
// TODO: SDKV2
// @ts-ignore
const messageData = PostedMessageData.deserialize(
wormholeMessageAccount.data,
);
Expand Down
18 changes: 13 additions & 5 deletions wormhole-connect/src/routes/ntt/chains/solana/nttManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ import {
createAssociatedTokenAccountInstruction,
} from '@solana/spl-token';
import { BN, IdlAccounts, Program } from '@coral-xyz/anchor';
import { SignedVaa, parseVaa } from '@certusone/wormhole-sdk/lib/esm';
// import { SignedVaa, parseVaa } from '@certusone/wormhole-sdk/lib/esm';
import { utils } from 'ethers';
import { deserializePayload } from '@wormhole-foundation/sdk-definitions';
import { Ntt } from '@wormhole-foundation/sdk-definitions-ntt';
import {
ExampleNativeTokenTransfers,
IDL,
} from './types/1.0.0/example_native_token_transfers';
import {
derivePostedVaaKey,
getWormholeDerivedAccounts,
} from '@certusone/wormhole-sdk/lib/esm/solana/wormhole';
//import {
// derivePostedVaaKey,
// getWormholeDerivedAccounts,
//} from '@certusone/wormhole-sdk/lib/esm/solana/wormhole';
import { associatedAddress } from '@coral-xyz/anchor/dist/esm/utils/token';
import { NttQuoter } from './nttQuoter';
import { Keccak } from 'sha3';
Expand All @@ -56,6 +56,9 @@ type OutboxRateLimit =
type InboxRateLimit =
IdlAccounts<ExampleNativeTokenTransfers>['inboxRateLimit'];

// TODO: SDKV2
type SignedVaa = Uint8Array | Buffer;

interface TransferArgs {
amount: BN;
recipientChain: { id: ChainId };
Expand Down Expand Up @@ -177,6 +180,7 @@ export class NttManagerSolana {
vaa: vaaArray,
config,
};
// @ts-ignore TODO: SDKV2
const parsedVaa = parseVaa(vaaArray);
const chainId = toChainId(parsedVaa.emitterChain as ChainId);
// First post the VAA
Expand Down Expand Up @@ -597,6 +601,7 @@ export class NttManagerSolana {
revertOnDelay: boolean;
}): Promise<TransactionInstruction> {
const program = await this.getProgram();
// @ts-ignore TODO: SDKV2
const whAccs = getWormholeDerivedAccounts(
program.programId,
this.wormholeId,
Expand Down Expand Up @@ -682,6 +687,7 @@ export class NttManagerSolana {
vaa: SignedVaa;
config?: Config;
}): Promise<TransactionInstruction> {
// @ts-ignore TODO: SDKV2
const parsedVaa = parseVaa(args.vaa);
const { nttManagerPayload } = deserializePayload(
'Ntt:WormholeTransfer',
Expand All @@ -696,6 +702,7 @@ export class NttManagerSolana {
payer: args.payer,
config: { config: this.configAccountAddress() },
peer: transceiverPeer,
// @ts-ignore TODO: SDKV2
vaa: derivePostedVaaKey(this.wormholeId, parseVaa(args.vaa).hash),
transceiverMessage: this.transceiverMessageAccountAddress(
chainId,
Expand All @@ -711,6 +718,7 @@ export class NttManagerSolana {
config?: Config;
}): Promise<TransactionInstruction> {
const config = await this.getConfig(args.config);
// @ts-ignore TODO: SDKV2
const parsedVaa = parseVaa(args.vaa);
const { nttManagerPayload } = deserializePayload(
'Ntt:WormholeTransfer',
Expand Down
Loading