v3.1.0
Full changelog: v3.0.2...v3.1.0
Published Packages
Installation
pnpm add @solana/web3.js@3.1.0 @solana/wallet-adapter@3.1.0What's Changed
- fix(web3.js): handle nullish memcmp in data-size filters by @snuff12 in #3977
- fix(web3.js): reject unsupported memcmp encodings in getProgramAccounts filters by @amilz in #3978
- docs(web3.js): note planned durable nonce deprecation on nonce APIs by @amilz in #3979
- chore(wallet-adapter): bump @solana/surfpool to ^1.6.1 by @amilz in #3981
- chore: bump next from 16.3.6 to 16.3.8 in the npm_and_yarn group across 1 directory by @dependabot[bot] in #3982
- feat(examples): add web3.js v3 basics node scripts by @amilz in #3980
- chore(web3.js): bump to @solana/kit 8.5 ^8.5.0 and support verifySignature change by @amilz in #3984
- ci: skip PR hygiene checks on closed pull requests by @amilz in #3988
- feat(web3.js): make Connection a Kit client (rpc, rpcSubscriptions, getMinimumBalance) by @amilz in #3983
- fix(web3.js): skip ws error log when the socket closes with no active subscriptions by @amilz in #3987
- feat(examples): add Anchor 2 example and use Connection as a Kit client by @amilz in #3985
- chore: bump version to v3.1.0 by @amilz in #3989
Connection now implements a Kit client
That means you can pass it straight to Kit-native libraries like Anchor 2 and the Codama-generated @solana-program/* clients, without building a second RPC.
Anchor 2: give a Connection and Keypair to AnchorProvider:
import {AnchorProvider, Program} from '@anchor-lang/core';
import {Connection, Keypair, sendAndConfirmTransaction, Transaction} from '@solana/web3.js';
const connection = new Connection(rpcUrl, 'confirmed');
const provider = new AnchorProvider(connection, trader);
const program = new Program<Whirlpool>(idl, provider);
const {data: pool} = await program.account.whirlpool.fetch(SOL_USDC_POOL);
const swapIx = await program.methods
.swap(USDC_IN, 0n, MAX_SQRT_PRICE, true, false)
.accounts({whirlpool: SOL_USDC_POOL, tokenVaultA: pool.tokenVaultA, /* ... */})
.instruction();
await sendAndConfirmTransaction(connection, new Transaction().add(swapIx), [trader]);Solana program clients: pass the Connection to helpers that need rent. You don't need to call getMinimumBalanceForRentExemption or build createAccount yourself:
import {getCreateMintInstructionPlan} from '@solana-program/token';
import {Connection, Keypair, sendAndConfirmTransaction, Transaction} from '@solana/web3.js';
const connection = new Connection(rpcUrl, 'confirmed');
const mint = await Keypair.generate();
const createMint = await getCreateMintInstructionPlan(connection, {
decimals: 6,
mintAuthority: payer.publicKey,
newMint: mint,
payer,
});
await sendAndConfirmTransaction(connection, new Transaction().add(createMint), [payer, mint]);Full examples: examples/ecosystem/anchor and examples/basics
New Contributors
Full Changelog: v3.0.2...v3.1.0