Skip to content

Commit

Permalink
Merge pull request #415 from reservoirprotocol/pedro/relay-6543-expos…
Browse files Browse the repository at this point in the history
…e-instructions-in-svm-signandsendtransaction

Expose instructions in svm signandsendtransaction
  • Loading branch information
pedromcunha authored Jan 3, 2025
2 parents 662462b + 2b257cd commit a735617
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/cyan-cougars-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@reservoir0x/relay-svm-wallet-adapter': patch
'@reservoir0x/relay-sdk': patch
---

Expose instructions in signature function
21 changes: 16 additions & 5 deletions packages/relay-svm-wallet-adapter/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}>
Expand Down Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/actions/getQuote.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -33,7 +33,7 @@ export type GetQuoteParameters = {
tradeType: QuoteBodyOptions['tradeType']
wallet?: AdaptedWallet | WalletClient
amount?: string
recipient?: Address
recipient?: string
options?: Omit<QuoteBodyOptions, 'user' | 'source' | 'txs' | 'tradeType'>
txs?: (NonNullable<QuoteBody['txs']>[0] | SimulateContractRequest)[]
}
Expand Down

0 comments on commit a735617

Please sign in to comment.