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