From be0636c901b1e58a03c2afdb4a185fdd68648ea4 Mon Sep 17 00:00:00 2001 From: Kevin Peters Date: Tue, 18 Jun 2024 10:06:10 -0500 Subject: [PATCH] NTT route: comment out legacy sdk code --- .../src/routes/ntt/chains/evm/getMessage.ts | 43 ++++++++++--------- .../routes/ntt/chains/solana/getMessage.ts | 4 +- .../routes/ntt/chains/solana/nttManager.ts | 18 +++++--- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/wormhole-connect/src/routes/ntt/chains/evm/getMessage.ts b/wormhole-connect/src/routes/ntt/chains/evm/getMessage.ts index bbc4a6bf6..28bfc4961 100644 --- a/wormhole-connect/src/routes/ntt/chains/evm/getMessage.ts +++ b/wormhole-connect/src/routes/ntt/chains/evm/getMessage.ts @@ -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'; @@ -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; diff --git a/wormhole-connect/src/routes/ntt/chains/solana/getMessage.ts b/wormhole-connect/src/routes/ntt/chains/solana/getMessage.ts index cce07fe9b..5019afcf5 100644 --- a/wormhole-connect/src/routes/ntt/chains/solana/getMessage.ts +++ b/wormhole-connect/src/routes/ntt/chains/solana/getMessage.ts @@ -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'; @@ -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, ); diff --git a/wormhole-connect/src/routes/ntt/chains/solana/nttManager.ts b/wormhole-connect/src/routes/ntt/chains/solana/nttManager.ts index 1c0a584b1..2c0985eb6 100644 --- a/wormhole-connect/src/routes/ntt/chains/solana/nttManager.ts +++ b/wormhole-connect/src/routes/ntt/chains/solana/nttManager.ts @@ -22,7 +22,7 @@ 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'; @@ -30,10 +30,10 @@ 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'; @@ -56,6 +56,9 @@ type OutboxRateLimit = type InboxRateLimit = IdlAccounts['inboxRateLimit']; +// TODO: SDKV2 +type SignedVaa = Uint8Array | Buffer; + interface TransferArgs { amount: BN; recipientChain: { id: ChainId }; @@ -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 @@ -597,6 +601,7 @@ export class NttManagerSolana { revertOnDelay: boolean; }): Promise { const program = await this.getProgram(); + // @ts-ignore TODO: SDKV2 const whAccs = getWormholeDerivedAccounts( program.programId, this.wormholeId, @@ -682,6 +687,7 @@ export class NttManagerSolana { vaa: SignedVaa; config?: Config; }): Promise { + // @ts-ignore TODO: SDKV2 const parsedVaa = parseVaa(args.vaa); const { nttManagerPayload } = deserializePayload( 'Ntt:WormholeTransfer', @@ -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, @@ -711,6 +718,7 @@ export class NttManagerSolana { config?: Config; }): Promise { const config = await this.getConfig(args.config); + // @ts-ignore TODO: SDKV2 const parsedVaa = parseVaa(args.vaa); const { nttManagerPayload } = deserializePayload( 'Ntt:WormholeTransfer',