-
Notifications
You must be signed in to change notification settings - Fork 245
feat: use sendTransaction for OIS #2555
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { | ||
sendTransactions, | ||
TransactionBuilder, | ||
} from "@pythnetwork/solana-utils"; | ||
import type { AnchorWallet } from "@solana/wallet-adapter-react"; | ||
import { TransactionBuilder } from "@pythnetwork/solana-utils"; | ||
import { Connection, TransactionInstruction } from "@solana/web3.js"; | ||
|
||
import type { PythStakingWallet } from "./wallet"; | ||
|
||
export const sendTransaction = async ( | ||
instructions: TransactionInstruction[], | ||
connection: Connection, | ||
wallet: AnchorWallet, | ||
wallet: PythStakingWallet, | ||
) => { | ||
const transactions = await TransactionBuilder.batchIntoVersionedTransactions( | ||
wallet.publicKey, | ||
|
@@ -20,5 +18,7 @@ export const sendTransaction = async ( | |
{}, | ||
); | ||
|
||
return sendTransactions(transactions, connection, wallet); | ||
for (const transaction of transactions) { | ||
await wallet.sendTransaction(transaction.tx, connection); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remind me why the interface needs a connection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure tbh, my guess is that some wallets will use this connection to send the tx instead of their own. |
||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
import type { AnchorWallet } from "@solana/wallet-adapter-react"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
import type { TransactionSignature } from "@solana/web3.js"; | ||
import { | ||
Connection, | ||
PublicKey, | ||
Transaction, | ||
VersionedTransaction, | ||
} from "@solana/web3.js"; | ||
|
||
export const DummyWallet: AnchorWallet = { | ||
export type PythStakingWallet = AnchorWallet & { | ||
sendTransaction: ( | ||
tx: Transaction | VersionedTransaction, | ||
connection: Connection, | ||
) => Promise<TransactionSignature>; | ||
}; | ||
|
||
export const DummyWallet: PythStakingWallet = { | ||
publicKey: PublicKey.default, | ||
signTransaction: () => { | ||
throw new Error("Cannot sign transaction without a wallet"); | ||
}, | ||
signAllTransactions: () => { | ||
throw new Error("Cannot sign transactions without a wallet"); | ||
}, | ||
sendTransaction: () => { | ||
throw new Error("Cannot send transaction without a wallet"); | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signTransaction
andsignAllTransactions
are not used anymore?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they are not used afaik, but I thought it's better to keep them.