support versioned txs
This commit is contained in:
parent
a4c9b953df
commit
96104fc1cd
|
@ -65,13 +65,13 @@
|
|||
"@project-serum/serum": "^0.13.65",
|
||||
"@pythnetwork/client": "^2.7.0",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
"@solana/web3.js": "^1.63.1",
|
||||
"@solana/web3.js": "^1.66.2",
|
||||
"@switchboard-xyz/switchboard-v2": "^0.0.129",
|
||||
"big.js": "^6.1.1",
|
||||
"bs58": "^5.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@project-serum/anchor/@solana/web3.js": "1.63.1"
|
||||
"@project-serum/anchor/@solana/web3.js": "1.66.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@solana/spl-token-swap": "^0.2.0"
|
||||
|
|
|
@ -127,7 +127,10 @@ export async function buildVersionedTx(
|
|||
});
|
||||
const vTx = new VersionedTransaction(message);
|
||||
// TODO: remove use of any when possible in future
|
||||
|
||||
vTx.sign([
|
||||
((provider as AnchorProvider).wallet as any).payer as Signer,
|
||||
...additionalSigners,
|
||||
]);
|
||||
return vTx;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { AnchorProvider, Wallet } from '@project-serum/anchor';
|
||||
import { AnchorProvider } from '@project-serum/anchor';
|
||||
import {
|
||||
AddressLookupTableAccount,
|
||||
Signer,
|
||||
Transaction,
|
||||
MessageV0,
|
||||
TransactionInstruction,
|
||||
VersionedTransaction,
|
||||
} from '@solana/web3.js';
|
||||
import { buildVersionedTx } from '../utils';
|
||||
|
||||
export async function sendTransaction(
|
||||
provider: AnchorProvider,
|
||||
|
@ -19,29 +18,30 @@ export async function sendTransaction(
|
|||
);
|
||||
|
||||
const payer = (provider as AnchorProvider).wallet;
|
||||
const tx = await buildVersionedTx(
|
||||
provider,
|
||||
ixs,
|
||||
opts.additionalSigners,
|
||||
alts,
|
||||
);
|
||||
// const tx = new Transaction();
|
||||
// tx.recentBlockhash = latestBlockhash.blockhash;
|
||||
// tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
||||
// tx.feePayer = payer.publicKey;
|
||||
// tx.add(...ixs);
|
||||
// if (opts.additionalSigners?.length > 0) {
|
||||
// tx.partialSign(...opts.additionalSigners);
|
||||
// }
|
||||
if (payer instanceof Wallet) {
|
||||
await payer.signTransaction(tx as any);
|
||||
} else {
|
||||
tx.sign([((provider as AnchorProvider).wallet as any).payer as Signer]);
|
||||
|
||||
const message = MessageV0.compile({
|
||||
payerKey: (provider as AnchorProvider).wallet.publicKey,
|
||||
instructions: ixs,
|
||||
recentBlockhash: latestBlockhash.blockhash,
|
||||
addressLookupTableAccounts: alts,
|
||||
});
|
||||
const vtx = new VersionedTransaction(message);
|
||||
if (opts?.additionalSigners?.length) {
|
||||
vtx.sign([...opts?.additionalSigners]);
|
||||
}
|
||||
|
||||
const signature = await connection.sendRawTransaction(tx.serialize(), {
|
||||
skipPreflight: true,
|
||||
});
|
||||
// if (payer instanceof Wallet) {
|
||||
const tx = await payer.signTransaction(vtx as any);
|
||||
// } else {
|
||||
// tx.sign([((provider as AnchorProvider).wallet as any).payer as Signer]);
|
||||
// }
|
||||
|
||||
const signature = await connection.sendTransaction(
|
||||
tx as any as VersionedTransaction,
|
||||
{
|
||||
skipPreflight: true,
|
||||
},
|
||||
);
|
||||
|
||||
if (opts.postSendTxCallback) {
|
||||
try {
|
||||
|
|
|
@ -605,10 +605,10 @@
|
|||
superstruct "^0.14.2"
|
||||
tweetnacl "^1.0.0"
|
||||
|
||||
"@solana/web3.js@1.63.1", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.63.1":
|
||||
version "1.63.1"
|
||||
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.63.1.tgz#88a19a17f5f4aada73ad70a94044c1067cab2b4d"
|
||||
integrity sha512-wgEdGVK5FTS2zENxbcGSvKpGZ0jDS6BUdGu8Gn6ns0CzgJkK83u4ip3THSnBPEQ5i/jrqukg998BwV1H67+qiQ==
|
||||
"@solana/web3.js@1.66.2", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.66.2":
|
||||
version "1.66.2"
|
||||
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.66.2.tgz#80b43c5868b846124fe3ebac7d3943930c3fa60c"
|
||||
integrity sha512-RyaHMR2jGmaesnYP045VLeBGfR/gAW3cvZHzMFGg7bkO+WOYOYp1nEllf0/la4U4qsYGKCsO9eEevR5fhHiVHg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@noble/ed25519" "^1.7.0"
|
||||
|
|
Loading…
Reference in New Issue