chilled-waves-lay
This version of the @solana/web3.js Technology Preview fixes a bug with the default RPC transport, adds a utility that you can use to get an estimate of a transaction message's compute unit cost, and introduces @solana/react hooks for interacting with Wallet Standard wallets.
To install the fourth Technology Preview:
npm install --save @solana/web3.js@tp4
For an example of how to use the new @solana/react package to interact with wallets in a React application, see the example application in examples/react-app. We hope to see similar wallet-connection packages patterned off @solana/react for other application frameworks soon.
Try a demo of Technology Preview 4 in your browser at CodeSandbox.
-
#2858
22a34aaThanks @steveluscher! - Transaction signers' methods now takeminContextSlotas an option. This is important for signers that simulate transactions, like wallets. They might be interested in knowing the slot at which the transaction was prepared, lest they run simulation at too early a slot. -
#2852
cec9048Thanks @lorisleiva! - ThesignAndSendTransactionMessageWithSignersfunction now automatically asserts that the provided transaction message contains a single sending signer and fails otherwise. -
#2707
cb49bfaThanks @mcintyre94! - Allow creating keypairs and keys from ReadonlyUint8Array -
#2715
26dae19Thanks @lorisleiva! - ConsolidatedgetNullableCodecandgetOptionCodecwith theirZeroablecounterparts and added more configurationsNamely, the
prefixoption can now be set tonulland thefixedoption was replaced with thenoneValueoption which can be set to"zeroes"forZeroablecodecs or a custom byte array for custom representations of none values. This means thegetZeroableNullableCodecandgetZeroableOptionCodecfunctions were removed in favor of the new options.// Before.
getZeroableNullableCodec(getU16Codec());
// After.
getNullableCodec(getU16Codec(), { noneValue: 'zeroes', prefix: null });Additionally, it is now possible to create nullable codecs that have no
prefixnornoneValue. In this case, the existence of the nullable item is indicated by the presence of any remaining bytes left to decode.const codec = getNullableCodec(getU16Codec(), { prefix: null });
codec.encode(42); // 0x2a00
codec.encode(null); // Encodes nothing.
codec.decode(new Uint8Array([42, 0])); // 42
codec.decode(new Uint8Array([])); // nullAlso note that it is now possible for custom
noneValuebyte arrays to be of any length — previously, it had to match the fixed-size of the nullable item.Here is a recap of all supported scenarios, using a
u16codec as an example:encode(42)/encode(null)No noneValue(default)noneValue: "zeroes"Custom noneValue(0xff)u8prefix (default)0x012a00/0x000x012a00/0x0000000x012a00/0x00ffCustom prefix(u16)0x01002a00/0x00000x01002a00/0x000000000x01002a00/0x0000ffNo prefix0x2a00/0x0x2a00/0x00000x2a00/0xffReciprocal changes were made with
getOptionCodec. -
#2785
4f19842Thanks @steveluscher! - The development mode error message printer no longer fatals on Safari < 16.4. -
#2867
be36babThanks @steveluscher! - TheinnerInstructionsproperty of JSON-RPC errors used snake case rather than camelCase forstackHeightandprogramId. This has been corrected. -
#2728
f1e9ac2Thanks @joncinque! - Simulate with the maximum quantity of compute units (1.4M) instead ofu32::MAX -
#2703
0908628Thanks @steveluscher! - Created a utility function to estimate the compute unit consumption of a transaction message -
#2795
ce876d9Thanks @steveluscher! - Added React hooks to which you can pass a Wallet StandardUiWalletAccountand obtain aMessageModifyingSigner,TransactionModifyingSigner, orTransactionSendingSignerfor use in constructing, signing, and sending Solana transactions and messages -
#2772
8fe4551Thanks @steveluscher! - Added a series of React hooks to which you can pass a Wallet StandardUiWalletAccountto extract itssignMessage,signTransaction, andsignAndSendTransactionfeatures -
#2819
7ee47aeThanks @steveluscher! - Fixed a bug where coalesced RPC calls could end up aborted even though there were still interested consumers. This would happen if the consumer count fell to zero, then rose above zero again, in the same runloop. -
#2868
91fb1f3Thanks @steveluscher! - ThesimulateTransactionRPC method now accepts aninnerInstructionsparam. Whentrue, the simulation result will include an array of inner instructions, if any. -
#2866
73bd5a9Thanks @steveluscher! - TheTransactionInstructionRPC type now hasstackHeight -
#2751
6340744Thanks @mcintyre94! - Allow Rpc Request params to be any type, instead of requiring an array