From fd86347777cf95ae1efa9c6d947e75829dcf798d Mon Sep 17 00:00:00 2001 From: pedromcunha Date: Mon, 23 Dec 2024 14:56:27 -0500 Subject: [PATCH 1/2] Expose transactions better in svm adapter --- .../relay-svm-wallet-adapter/src/adapter.ts | 21 ++++++++++++++----- packages/sdk/src/actions/getQuote.ts | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/relay-svm-wallet-adapter/src/adapter.ts b/packages/relay-svm-wallet-adapter/src/adapter.ts index ff41333f..6f34be8f 100644 --- a/packages/relay-svm-wallet-adapter/src/adapter.ts +++ b/packages/relay-svm-wallet-adapter/src/adapter.ts @@ -2,22 +2,28 @@ import { AddressLookupTableAccount, Connection, PublicKey, - Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction, type SendOptions, type TransactionSignature } from '@solana/web3.js' -import { LogLevel, getClient, type AdaptedWallet } from '@reservoir0x/relay-sdk' +import { + LogLevel, + getClient, + type AdaptedWallet, + type TransactionStepItem +} from '@reservoir0x/relay-sdk' export const adaptSolanaWallet = ( walletAddress: string, chainId: number, connection: Connection, signAndSendTransaction: ( - transaction: Transaction | VersionedTransaction, - options?: SendOptions + transaction: VersionedTransaction, + options?: SendOptions, + instructions?: TransactionInstruction[], + rawInstructions?: TransactionStepItem['data']['instructions'] ) => Promise<{ signature: TransactionSignature }> @@ -71,7 +77,12 @@ export const adaptSolanaWallet = ( ) const transaction = new VersionedTransaction(messageV0) - const signature = await signAndSendTransaction(transaction) + const signature = await signAndSendTransaction( + transaction, + undefined, + instructions, + stepItem.data.instructions + ) client.log( ['Transaction Signature obtained', signature], diff --git a/packages/sdk/src/actions/getQuote.ts b/packages/sdk/src/actions/getQuote.ts index 363ee3e6..27658ad1 100644 --- a/packages/sdk/src/actions/getQuote.ts +++ b/packages/sdk/src/actions/getQuote.ts @@ -1,6 +1,6 @@ import { type AxiosRequestConfig } from 'axios' import { axios } from '../utils/axios.js' -import { zeroAddress, type Address, type WalletClient } from 'viem' +import { zeroAddress, type WalletClient } from 'viem' import prepareCallTransaction from '../utils/prepareCallTransaction.js' import { isSimulateContractRequest, @@ -33,7 +33,7 @@ export type GetQuoteParameters = { tradeType: QuoteBodyOptions['tradeType'] wallet?: AdaptedWallet | WalletClient amount?: string - recipient?: Address + recipient?: string options?: Omit txs?: (NonNullable[0] | SimulateContractRequest)[] } From 2b257cdeaffc41f7cf44038ab16b1bd3af35ec18 Mon Sep 17 00:00:00 2001 From: pedromcunha Date: Mon, 23 Dec 2024 14:57:22 -0500 Subject: [PATCH 2/2] feat: changeset --- .changeset/cyan-cougars-love.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/cyan-cougars-love.md diff --git a/.changeset/cyan-cougars-love.md b/.changeset/cyan-cougars-love.md new file mode 100644 index 00000000..5f2ef8e6 --- /dev/null +++ b/.changeset/cyan-cougars-love.md @@ -0,0 +1,6 @@ +--- +'@reservoir0x/relay-svm-wallet-adapter': patch +'@reservoir0x/relay-sdk': patch +--- + +Expose instructions in signature function