From c60b4815f424782a56713e945601152e2a1c9dd2 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 17 Jan 2025 22:22:59 +0000 Subject: [PATCH] Run `style:fix` --- examples/react-app/README.md | 8 +- packages/codecs-core/README.md | 38 ++++---- packages/codecs-data-structures/README.md | 18 ++-- packages/codecs-strings/README.md | 4 +- packages/codecs/README.md | 102 +++++++++++----------- packages/compat/README.md | 2 +- packages/errors/README.md | 8 +- packages/fast-stable-stringify/README.md | 10 +-- packages/programs/README.md | 8 +- packages/react/README.md | 22 ++--- packages/rpc-api/README.md | 10 +-- packages/rpc-graphql/README.md | 52 +++++------ packages/rpc-spec-types/README.md | 4 +- packages/rpc-spec/README.md | 30 +++---- packages/rpc-subscriptions-api/README.md | 10 +-- packages/rpc-subscriptions-spec/README.md | 4 +- packages/rpc-subscriptions/README.md | 8 +- packages/rpc/README.md | 10 +-- packages/signers/README.md | 54 ++++++------ packages/subscribable/README.md | 10 +-- packages/sysvars/README.md | 20 ++--- packages/transaction-messages/README.md | 4 +- packages/transactions/README.md | 6 +- 23 files changed, 221 insertions(+), 221 deletions(-) diff --git a/examples/react-app/README.md b/examples/react-app/README.md index 4b4041b4c..4625caf47 100644 --- a/examples/react-app/README.md +++ b/examples/react-app/README.md @@ -4,10 +4,10 @@ This is an example of how to use `@solana/web3.js` and `@solana/react` to build ## Features -- Connects to browser wallets that support the Wallet Standard; one or more at a time -- Fetches and subscribes to the balance of the selected wallet -- Allows you to sign an arbitrary message using a wallet account -- Allows you to make a transfer from the selected wallet to any other connected wallet +- Connects to browser wallets that support the Wallet Standard; one or more at a time +- Fetches and subscribes to the balance of the selected wallet +- Allows you to sign an arbitrary message using a wallet account +- Allows you to make a transfer from the selected wallet to any other connected wallet ## Developing diff --git a/packages/codecs-core/README.md b/packages/codecs-core/README.md index a0d869b11..033b34cfa 100644 --- a/packages/codecs-core/README.md +++ b/packages/codecs-core/README.md @@ -38,10 +38,10 @@ const person = personCodec.decode(bytes); There is a significant library of composable codecs at your disposal, enabling you to compose complex types. You may be interested in the documentation of these other packages to learn more about them: -- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) for number codecs. -- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) for string codecs. -- [`@solana/codecs-data-structures`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. -- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) for a Rust-like `Option` type and associated codec. +- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) for number codecs. +- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) for string codecs. +- [`@solana/codecs-data-structures`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures) for many data structure codecs such as objects, arrays, tuples, sets, maps, enums, discriminated unions, booleans, etc. +- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) for a Rust-like `Option` type and associated codec. You may also be interested in some of the helpers of this `@solana/codecs-core` library such as `transformCodec`, `fixCodecSize` or `reverseCodec` that create new codecs from existing ones. @@ -159,10 +159,10 @@ The following type guards are available to identify and/or assert the size of co Finally, note that the same is true for `Encoders` and `Decoders`. -- A `FixedSizeEncoder` has a `fixedSize` number attribute. -- A `VariableSizeEncoder` has a `getSizeFromValue` function and an optional `maxSize` number attribute. -- A `FixedSizeDecoder` has a `fixedSize` number attribute. -- A `VariableSizeDecoder` has an optional `maxSize` number attribute. +- A `FixedSizeEncoder` has a `fixedSize` number attribute. +- A `VariableSizeEncoder` has a `getSizeFromValue` function and an optional `maxSize` number attribute. +- A `FixedSizeDecoder` has a `fixedSize` number attribute. +- A `VariableSizeDecoder` has an optional `maxSize` number attribute. ## Creating custom codecs @@ -170,8 +170,8 @@ If composing codecs isn’t enough for you, you may implement your own codec log The `read` function accepts the `bytes` to decode from and the `offset` at each we should start reading. It returns an array with two items: -- The first item should be the decoded value. -- The second item should be the next offset to read from. +- The first item should be the decoded value. +- The second item should be the next offset to read from. ```ts createCodec({ @@ -533,14 +533,14 @@ u32InTheMiddleCodec.encode(0xffffffff); Both the `preOffset` and `postOffset` functions offer the following attributes: -- `bytes`: The entire byte array being encoded or decoded. -- `preOffset`: The original and unaltered pre-offset. -- `wrapBytes`: A helper function that wraps the given offset around the byte array length. E.g. `wrapBytes(-1)` will refer to the last byte of the byte array. +- `bytes`: The entire byte array being encoded or decoded. +- `preOffset`: The original and unaltered pre-offset. +- `wrapBytes`: A helper function that wraps the given offset around the byte array length. E.g. `wrapBytes(-1)` will refer to the last byte of the byte array. Additionally, the post-offset function also provides the following attributes: -- `newPreOffset`: The new pre-offset after the pre-offset function has been applied. -- `postOffset`: The original and unaltered post-offset. +- `newPreOffset`: The new pre-offset after the pre-offset function has been applied. +- `postOffset`: The original and unaltered post-offset. Note that you may also decide to ignore these attributes to achieve absolute offsets. However, relative offsets are usually recommended as they won't break your codecs when composed with other codecs. @@ -635,10 +635,10 @@ const getBigEndianU64Codec = () => combineCodec(getBigEndianU64Encoder(), getBig This package also provides utility functions for managing bytes such as: -- `mergeBytes`: Concatenates an array of `Uint8Arrays` into a single `Uint8Array`. -- `padBytes`: Pads a `Uint8Array` with zeroes (to the right) to the specified length. -- `fixBytes`: Pads or truncates a `Uint8Array` so it has the specified length. -- `containsBytes`: Checks if a `Uint8Array` contains another `Uint8Array` at a given offset. +- `mergeBytes`: Concatenates an array of `Uint8Arrays` into a single `Uint8Array`. +- `padBytes`: Pads a `Uint8Array` with zeroes (to the right) to the specified length. +- `fixBytes`: Pads or truncates a `Uint8Array` so it has the specified length. +- `containsBytes`: Checks if a `Uint8Array` contains another `Uint8Array` at a given offset. ```ts // Merge multiple Uint8Array buffers into one. diff --git a/packages/codecs-data-structures/README.md b/packages/codecs-data-structures/README.md index 2dfb12542..ae785a66e 100644 --- a/packages/codecs-data-structures/README.md +++ b/packages/codecs-data-structures/README.md @@ -35,9 +35,9 @@ getArrayCodec(getU8Codec()).encode([1, 2, 3]); However, you may use the `size` option to configure this behaviour. It can be one of the following three strategies: -- `Codec`: When a number codec is provided, that codec will be used to encode and decode the size prefix. -- `number`: When a number is provided, the codec will expect a fixed number of items in the array. An error will be thrown when trying to encode an array of a different length. -- `"remainder"`: When the string `"remainder"` is passed as a size, the codec will use the remainder of the bytes to encode/decode its items. This means the size is not stored or known in advance but simply inferred from the rest of the buffer. For instance, if we have an array of `u16` numbers and 10 bytes remaining, we know there are 5 items in this array. +- `Codec`: When a number codec is provided, that codec will be used to encode and decode the size prefix. +- `number`: When a number is provided, the codec will expect a fixed number of items in the array. An error will be thrown when trying to encode an array of a different length. +- `"remainder"`: When the string `"remainder"` is passed as a size, the codec will use the remainder of the bytes to encode/decode its items. This means the size is not stored or known in advance but simply inferred from the rest of the buffer. For instance, if we have an array of `u16` numbers and 10 bytes remaining, we know there are 5 items in this array. ```ts getArrayCodec(getU8Codec(), { size: getU16Codec() }).encode([1, 2, 3]); @@ -310,9 +310,9 @@ const value = getLiteralUnionDecoder(['left', 'right']).decode(bytes); // 'left' In Rust, enums are powerful data types whose variants can be one of the following: -- An empty variant — e.g. `enum Message { Quit }`. -- A tuple variant — e.g. `enum Message { Write(String) }`. -- A struct variant — e.g. `enum Message { Move { x: i32, y: i32 } }`. +- An empty variant — e.g. `enum Message { Quit }`. +- A tuple variant — e.g. `enum Message { Write(String) }`. +- A struct variant — e.g. `enum Message { Move { x: i32, y: i32 } }`. Whilst we do not have such powerful enums in JavaScript, we can emulate them in TypeScript using a union of objects such that each object is differentiated by a specific field. **We call this a discriminated union**. @@ -434,9 +434,9 @@ The `getUnionCodec` is a lower-lever codec helper that can be used to encode/dec It accepts the following arguments: -- An array of codecs, each defining a variant of the union. -- A `getIndexFromValue` function which, given a value of the union, returns the index of the codec that should be used to encode that value. -- A `getIndexFromBytes` function which, given the byte array to decode at a given offset, returns the index of the codec that should be used to decode the next bytes. +- An array of codecs, each defining a variant of the union. +- A `getIndexFromValue` function which, given a value of the union, returns the index of the codec that should be used to encode that value. +- A `getIndexFromBytes` function which, given the byte array to decode at a given offset, returns the index of the codec that should be used to decode the next bytes. ```ts const codec: Codec = getUnionCodec( diff --git a/packages/codecs-strings/README.md b/packages/codecs-strings/README.md index e31b06fcb..b70e4069e 100644 --- a/packages/codecs-strings/README.md +++ b/packages/codecs-strings/README.md @@ -21,8 +21,8 @@ The `@solana/codecs-strings` package offers a variety of string codecs such as ` By default, all available string codecs will return a `VariableSizeCodec` meaning that: -- When encoding a string, all bytes necessary to encode the string will be used. -- When decoding a byte array at a given offset, all bytes starting from that offset will be decoded as a string. +- When encoding a string, all bytes necessary to encode the string will be used. +- When decoding a byte array at a given offset, all bytes starting from that offset will be decoded as a string. For instance, here's how you can encode/decode `utf8` strings without any size boundary: diff --git a/packages/codecs/README.md b/packages/codecs/README.md index d7c365bbb..bf6e62e9e 100644 --- a/packages/codecs/README.md +++ b/packages/codecs/README.md @@ -45,54 +45,54 @@ const getPersonDecoder = (): Decoder => The `@solana/codecs` package is composed of several smaller packages, each with its own set of responsibilities. You can learn more about codecs and how to create your own by reading their respective documentation. -- [`@solana/codecs-core`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core) This package lays the foundation of codecs by providing core type and helper functions to create and compose them. - - [Composing codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#composing-codecs). - - [Composing encoders and decoders](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#composing-encoders-and-decoders). - - [Combining encoders and decoders](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#combining-encoders-and-decoders). - - [Different From and To types](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#different-from-and-to-types). - - [Fixed-size and variable-size codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#fixed-size-and-variable-size-codecs). - - [Creating custom codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#creating-custom-codecs). - - [Transforming codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#transforming-codecs). - - [Fixing the size of codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#fixing-the-size-of-codecs). - - [Prefixing codecs with their size](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#prefixing-codecs-with-their-size). - - [Adding sentinels to codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#adding-sentinels-to-codecs). - - [Adjusting the size of codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#adjusting-the-size-of-codecs). - - [Offsetting codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#offsetting-codecs). - - [Padding codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#padding-codecs). - - [Reversing codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#reversing-codecs). - - [Byte helpers](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#byte-helpers). -- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) This package offers codecs for numbers of various sizes and characteristics. - - [Integer codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#integer-codecs). - - [Decimal number codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#decimal-number-codecs). - - [Short u16 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#short-u16-codec). -- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) This package provides codecs for strings of various encodings and size strategies. - - [Sizing string codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#sizing-string-codecs). - - [Utf8 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#utf8-codec). - - [Base 64 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-64-codec). - - [Base 58 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-58-codec). - - [Base 16 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-16-codec). - - [Base 10 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-10-codec). - - [Base X codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-x-codec). - - [Re-slicing base X codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#re-slicing-base-x-codec). -- [`@solana/codecs-data-structures`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures) This package offers a set of helpers for a variety of data structures such as objects, enums, arrays, maps, etc. - - [Array codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#array-codec). - - [Set codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#set-codec). - - [Map codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#map-codec). - - [Tuple codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#tuple-codec). - - [Struct codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#struct-codec). - - [Enum codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#enum-codec). - - [Literal union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#literal-union-codec). - - [Discriminated union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#discriminated-union-codec). - - [Union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#union-codec). - - [Boolean codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#boolean-codec). - - [Nullable codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#nullable-codec). - - [Bytes codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#bytes-codec). - - [Bit array codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#bit-array-codec). - - [Constant codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#constant-codec). - - [Unit codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#unit-codec). - - [Hidden prefix and suffix codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#hidden-prefix-and-suffix-codec). -- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) This package adds Rust-like `Options` to JavaScript and offers codecs and helpers to manage them. - - [Creating options](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#creating-options). - - [Option helpers](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#option-helpers). - - [Unwrapping options](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#unwrapping-options). - - [Option codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#option-codec). +- [`@solana/codecs-core`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core) This package lays the foundation of codecs by providing core type and helper functions to create and compose them. + - [Composing codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#composing-codecs). + - [Composing encoders and decoders](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#composing-encoders-and-decoders). + - [Combining encoders and decoders](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#combining-encoders-and-decoders). + - [Different From and To types](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#different-from-and-to-types). + - [Fixed-size and variable-size codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#fixed-size-and-variable-size-codecs). + - [Creating custom codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#creating-custom-codecs). + - [Transforming codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#transforming-codecs). + - [Fixing the size of codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#fixing-the-size-of-codecs). + - [Prefixing codecs with their size](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#prefixing-codecs-with-their-size). + - [Adding sentinels to codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#adding-sentinels-to-codecs). + - [Adjusting the size of codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#adjusting-the-size-of-codecs). + - [Offsetting codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#offsetting-codecs). + - [Padding codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#padding-codecs). + - [Reversing codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#reversing-codecs). + - [Byte helpers](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-core#byte-helpers). +- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) This package offers codecs for numbers of various sizes and characteristics. + - [Integer codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#integer-codecs). + - [Decimal number codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#decimal-number-codecs). + - [Short u16 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers#short-u16-codec). +- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) This package provides codecs for strings of various encodings and size strategies. + - [Sizing string codecs](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#sizing-string-codecs). + - [Utf8 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#utf8-codec). + - [Base 64 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-64-codec). + - [Base 58 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-58-codec). + - [Base 16 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-16-codec). + - [Base 10 codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-10-codec). + - [Base X codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#base-x-codec). + - [Re-slicing base X codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings#re-slicing-base-x-codec). +- [`@solana/codecs-data-structures`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures) This package offers a set of helpers for a variety of data structures such as objects, enums, arrays, maps, etc. + - [Array codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#array-codec). + - [Set codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#set-codec). + - [Map codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#map-codec). + - [Tuple codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#tuple-codec). + - [Struct codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#struct-codec). + - [Enum codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#enum-codec). + - [Literal union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#literal-union-codec). + - [Discriminated union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#discriminated-union-codec). + - [Union codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#union-codec). + - [Boolean codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#boolean-codec). + - [Nullable codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#nullable-codec). + - [Bytes codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#bytes-codec). + - [Bit array codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#bit-array-codec). + - [Constant codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#constant-codec). + - [Unit codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#unit-codec). + - [Hidden prefix and suffix codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-data-structures#hidden-prefix-and-suffix-codec). +- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) This package adds Rust-like `Options` to JavaScript and offers codecs and helpers to manage them. + - [Creating options](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#creating-options). + - [Option helpers](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#option-helpers). + - [Unwrapping options](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#unwrapping-options). + - [Option codec](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options#option-codec). diff --git a/packages/compat/README.md b/packages/compat/README.md index 9bc3e9b34..eefbd96be 100644 --- a/packages/compat/README.md +++ b/packages/compat/README.md @@ -55,4 +55,4 @@ import { fromLegacyTransactionInstruction } from '@solana/compat'; // imagine a function that returns a legacy `TransactionInstruction` const legacyInstruction = getMyLegacyInstruction(); const instruction = fromLegacyTransactionInstruction(legacyInstruction); -``` \ No newline at end of file +``` diff --git a/packages/errors/README.md b/packages/errors/README.md index f6a4d29af..4d1b003d7 100644 --- a/packages/errors/README.md +++ b/packages/errors/README.md @@ -43,10 +43,10 @@ npx @solana/errors decode -- 123 ## Removing an error message -- Don't remove errors. -- Don't change the meaning of an error message. -- Don't change or reorder error codes. -- Don't change or remove members of an error's context. +- Don't remove errors. +- Don't change the meaning of an error message. +- Don't change or reorder error codes. +- Don't change or remove members of an error's context. When an older client throws an error, we want to make sure that they can always decode the error. If you make any of the changes above, old clients will, by definition, not have received your changes. This could make the errors that they throw impossible to decode going forward. diff --git a/packages/fast-stable-stringify/README.md b/packages/fast-stable-stringify/README.md index a645e475c..5242a022e 100644 --- a/packages/fast-stable-stringify/README.md +++ b/packages/fast-stable-stringify/README.md @@ -13,14 +13,14 @@ stringify({ d: 0, c: 1, a: 2, b: 3, e: 4 }); // '{"a":2,"b":3,"c":1,"d":0,"e":4} Just like substack's, it does: -- handle all variations of all basic javascript values (number, string, boolean, array, object, null, Date, BigInt) -- handle undefined _and_ function in the same way as `JSON.stringify` -- **not support ie8 (and below) with complete certainty**. +- handle all variations of all basic javascript values (number, string, boolean, array, object, null, Date, BigInt) +- handle undefined _and_ function in the same way as `JSON.stringify` +- **not support ie8 (and below) with complete certainty**. Unlike substack's, it does: -- not implement the 'replacer' or 'space' arguments of the JSON.stringify method -- not check for circular references +- not implement the 'replacer' or 'space' arguments of the JSON.stringify method +- not check for circular references ## Running tests diff --git a/packages/programs/README.md b/packages/programs/README.md index 044cb6d5c..117483a4f 100644 --- a/packages/programs/README.md +++ b/packages/programs/README.md @@ -19,10 +19,10 @@ This package contains helpers for identifying custom program errors. It can be u This function takes any error — typically caused by a transaction failure — and identifies whether it is a custom program error from the provided program address. It takes the following parameters: -- The `error` to identify. -- The `transactionMessage` object that failed to execute. Since the RPC response only provide the index of the failed instruction, we need the transaction message to access its program address. -- The `programAddress` of the program from which the error is expected. -- Optionally, the expected error `code` of the custom program error. When provided, the function will also check that the custom program error code matches the given value. +- The `error` to identify. +- The `transactionMessage` object that failed to execute. Since the RPC response only provide the index of the failed instruction, we need the transaction message to access its program address. +- The `programAddress` of the program from which the error is expected. +- Optionally, the expected error `code` of the custom program error. When provided, the function will also check that the custom program error code matches the given value. ```ts try { diff --git a/packages/react/README.md b/packages/react/README.md index f5c5b5546..f0ce03737 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -180,14 +180,14 @@ Given a `UiWalletAccount`, this hook returns a function you can call to sign a b A config object with the following properties: -- `message`: A `Uint8Array` of bytes to sign +- `message`: A `Uint8Array` of bytes to sign #### Returns An object with the following properties: -- `signature`: The 64-byte Ed25519 signature as a `Uint8Array` -- `signedMessage`: The `Uint8Array` of bytes signed by the wallet. These bytes might differ from the input bytes if the wallet modified the message +- `signature`: The 64-byte Ed25519 signature as a `Uint8Array` +- `signedMessage`: The `Uint8Array` of bytes signed by the wallet. These bytes might differ from the input bytes if the wallet modified the message #### Example @@ -223,15 +223,15 @@ Given a `UiWalletAccount` and a chain that begins with `solana:`, this hook retu A config object with the following properties: -- `options`: An object with the following properties: - - `minContextSlot`: A slot at which any blockhash/nonce in the transaction is known to exist. This may be used by the signer and/or RPC to determine the validity of the blockhashes/nonces it has observed. -- `transaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) +- `options`: An object with the following properties: + - `minContextSlot`: A slot at which any blockhash/nonce in the transaction is known to exist. This may be used by the signer and/or RPC to determine the validity of the blockhashes/nonces it has observed. +- `transaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) #### Returns An object with the following properties: -- `signedTransaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) +- `signedTransaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) #### Example @@ -267,15 +267,15 @@ Given a `UiWalletAccount` and a chain that begins with `solana:`, this hook retu A config object with the following properties: -- `options`: An object with the following properties: - - `minContextSlot`: A slot at which any blockhash/nonce in the transaction is known to exist. This may be used by the signer and/or RPC to determine the validity of the blockhashes/nonces it has observed. -- `transaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) +- `options`: An object with the following properties: + - `minContextSlot`: A slot at which any blockhash/nonce in the transaction is known to exist. This may be used by the signer and/or RPC to determine the validity of the blockhashes/nonces it has observed. +- `transaction`: A `Uint8Array` of bytes that conforms to the [Solana transaction schema](https://solana.com/docs/core/transactions#transaction) #### Returns That function returns an object with the following properties: -- `signature`: A `Uint8Array` of bytes representing the signature of the sent transaction. +- `signature`: A `Uint8Array` of bytes representing the signature of the sent transaction. #### Example diff --git a/packages/rpc-api/README.md b/packages/rpc-api/README.md index cbe2bcf6d..9bc7c3acd 100644 --- a/packages/rpc-api/README.md +++ b/packages/rpc-api/README.md @@ -44,13 +44,13 @@ Creates a `RpcApi` implementation of the Solana JSON RPC API with some default b The default behaviours include: -- A transform that converts `bigint` inputs to `number` for compatibility with version 1.0 of the Solana JSON RPC. -- A transform that calls the config's `onIntegerOverflow` handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more information. -- A transform that applies a default commitment wherever not specified +- A transform that converts `bigint` inputs to `number` for compatibility with version 1.0 of the Solana JSON RPC. +- A transform that calls the config's `onIntegerOverflow` handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more information. +- A transform that applies a default commitment wherever not specified #### Arguments A config object with the following properties: -- `defaultCommitment`: An optional default `Commitment` value. Given an RPC method that takes `commitment` as a parameter, this value will be used when the caller does not supply one. -- `onIntegerOverflow(request, keyPath, value): void`: An optional function that will be called whenever a `bigint` input exceeds that which can be expressed using JavaScript numbers. This is used in the default `SolanaRpcApi` to throw an exception rather than to allow truncated values to propagate through a program. +- `defaultCommitment`: An optional default `Commitment` value. Given an RPC method that takes `commitment` as a parameter, this value will be used when the caller does not supply one. +- `onIntegerOverflow(request, keyPath, value): void`: An optional function that will be called whenever a `bigint` input exceeds that which can be expressed using JavaScript numbers. This is used in the default `SolanaRpcApi` to throw an exception rather than to allow truncated values to propagate through a program. diff --git a/packages/rpc-graphql/README.md b/packages/rpc-graphql/README.md index 76c227af7..8ec3e546a 100644 --- a/packages/rpc-graphql/README.md +++ b/packages/rpc-graphql/README.md @@ -123,9 +123,9 @@ const lamportsAccountB = await rpcGraphQL.query(source, { Solana data can be categorized into three main types: -- Accounts -- Transactions -- Blocks +- Accounts +- Transactions +- Blocks These types encompass everything that can be queried from the Solana ledger. @@ -209,13 +209,13 @@ data: { A set of specific parsed account types are supported in GraphQL. -- `GenericAccount`: A generic base account type -- `NonceAccount`: A nonce account -- `LookupTableAccount`: An address lookup table account -- `MintAccount`: An SPL mint -- `TokenAccount`: An SPL token account -- `StakeAccount`: A stake account -- `VoteAccount`: A vote account +- `GenericAccount`: A generic base account type +- `NonceAccount`: A nonce account +- `LookupTableAccount`: An address lookup table account +- `MintAccount`: An SPL mint +- `TokenAccount`: An SPL token account +- `StakeAccount`: A stake account +- `VoteAccount`: A vote account You can choose how to handle querying of specific account types. For example, you might _only_ want specifically any account that matches `MintAccount`. @@ -660,15 +660,15 @@ queried by specific instruction types. Instructions for the following programs are supported. -- Address Lookup Table -- BPF Loader -- BPF Upgradeable Loader -- Stake -- SPL Associated Token -- SPL Memo -- SPL Token -- System -- Vote +- Address Lookup Table +- BPF Loader +- BPF Upgradeable Loader +- Stake +- SPL Associated Token +- SPL Memo +- SPL Token +- System +- Vote Additionally, the `GenericInstruction` type is the base parsed instruction type. @@ -944,10 +944,10 @@ application the requested response. This results in four main benefits: -- Caching -- Request coalescing -- Minimized network payloads -- Batch loading +- Caching +- Request coalescing +- Minimized network payloads +- Batch loading ## Caching @@ -1048,9 +1048,9 @@ In fact, the resolver will minimize bytes over the wire by only requesting the specific slice of the data that encompasses all requested data slices. In the above example, we've requested three ranges of data: -- `0` - `8` -- `8` - `16` -- `16` - `24` +- `0` - `8` +- `8` - `16` +- `16` - `24` If this account has a massive amount of data, fetching more than the query asks for would be wasteful. The resolver will only fetch `0` - `24` and slice the diff --git a/packages/rpc-spec-types/README.md b/packages/rpc-spec-types/README.md index 30b111415..a9887a6c2 100644 --- a/packages/rpc-spec-types/README.md +++ b/packages/rpc-spec-types/README.md @@ -19,8 +19,8 @@ This package contains core types that can be used on both RPC and RPC Subscripti An object that describes the elements of an RPC or RPC Subscriptions request. It consists of the following properties: -- `methodName`: The name of the RPC method or subscription requested. -- `params`: The parameters to be passed to the RPC server. +- `methodName`: The name of the RPC method or subscription requested. +- `params`: The parameters to be passed to the RPC server. ### `RpcRequestTransformer` diff --git a/packages/rpc-spec/README.md b/packages/rpc-spec/README.md index f78253897..81c58548f 100644 --- a/packages/rpc-spec/README.md +++ b/packages/rpc-spec/README.md @@ -52,22 +52,22 @@ This type allows an `RpcApi` to describe how a particular request should be issu This function accepts an `RpcTransport` and an `AbortSignal` and asynchronously returns an `RpcResponse`. This gives us the opportunity to: -- define the `payload` from the requested method name and parameters before passing it to the transport. -- call the underlying transport zero, one or multiple times depending on the use-case (e.g. caching or aggregating multiple responses). -- transform the response from the JSON RPC server, in case it does not match the `TResponse` specified by the `PendingRpcRequest` returned from that function. +- define the `payload` from the requested method name and parameters before passing it to the transport. +- call the underlying transport zero, one or multiple times depending on the use-case (e.g. caching or aggregating multiple responses). +- transform the response from the JSON RPC server, in case it does not match the `TResponse` specified by the `PendingRpcRequest` returned from that function. ### `RpcSendOptions` A configuration object consisting of the following properties: -- `abortSignal`: An optional signal that you can supply when triggering a `PendingRpcRequest` that you might later need to abort. +- `abortSignal`: An optional signal that you can supply when triggering a `PendingRpcRequest` that you might later need to abort. ### `RpcTransport` Any function that implements this interface can act as a transport for an `Rpc`. It need only return a promise for a response given the following config: -- `payload`: A value of arbitrary type to be sent. -- `signal`: An optional `AbortSignal` on which the `'abort'` event will be fired if the request should be cancelled. +- `payload`: A value of arbitrary type to be sent. +- `signal`: An optional `AbortSignal` on which the `'abort'` event will be fired if the request should be cancelled. ## Functions @@ -79,15 +79,15 @@ Creates an RPC instance given an `RpcApi` and a `RpcTransport` capa A config object with the following properties: -- `api`: An instance of `RpcApi` -- `transport`: A function that implements the `RpcTransport` interface +- `api`: An instance of `RpcApi` +- `transport`: A function that implements the `RpcTransport` interface ### `createJsonRpcApi(config)` Creates a JavaScript proxy that converts _any_ function call called on it to a `RpcPlan` by creating an `execute` function that: -- sets the transport payload to a JSON RPC v2 payload object with the requested `methodName` and `params` properties, optionally transformed by `config.requestTransformer`. -- transforms the transport's response using the `config.responseTransformer` function, if provided. +- sets the transport payload to a JSON RPC v2 payload object with the requested `methodName` and `params` properties, optionally transformed by `config.requestTransformer`. +- transforms the transport's response using the `config.responseTransformer` function, if provided. ```ts // For example, given this `RpcApi`: @@ -108,16 +108,16 @@ rpcApi.foo('bar', { baz: 'bat' }); A config object with the following properties: -- `requestTransformer(request: RpcRequest): RpcRequest`: An optional function that transforms the `RpcRequest` before it is sent to the JSON RPC server. -- `responseTransformer(response: RpcResponse, request: RpcRequest): RpcResponse`: An optional function that transforms the `RpcResponse` before it is returned to the caller. +- `requestTransformer(request: RpcRequest): RpcRequest`: An optional function that transforms the `RpcRequest` before it is sent to the JSON RPC server. +- `responseTransformer(response: RpcResponse, request: RpcRequest): RpcResponse`: An optional function that transforms the `RpcResponse` before it is returned to the caller. ### `isJsonRpcPayload(payload)` A helper function that returns `true` if the given payload is a JSON RPC v2 payload. This means, the payload is an object such that: -- It has a `jsonrpc` property with a value of `'2.0'`. -- It has a `method` property that is a string. -- It has a `params` property of any type. +- It has a `jsonrpc` property with a value of `'2.0'`. +- It has a `method` property that is a string. +- It has a `params` property of any type. ```ts import { isJsonRpcPayload } from '@solana/rpc-spec'; diff --git a/packages/rpc-subscriptions-api/README.md b/packages/rpc-subscriptions-api/README.md index cd326209a..36234d5d6 100644 --- a/packages/rpc-subscriptions-api/README.md +++ b/packages/rpc-subscriptions-api/README.md @@ -53,13 +53,13 @@ Creates a `RpcSubscriptionsApi` implementation of the Solana JSON RPC Subscripti The default behaviours include: -- A transform that converts `bigint` inputs to `number` for compatibility with version 1.0 of the Solana JSON RPC. -- A transform that calls the config's `onIntegerOverflow` handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more information. -- A transform that applies a default commitment wherever not specified +- A transform that converts `bigint` inputs to `number` for compatibility with version 1.0 of the Solana JSON RPC. +- A transform that calls the config's `onIntegerOverflow` handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more information. +- A transform that applies a default commitment wherever not specified #### Arguments A config object with the following properties: -- `defaultCommitment`: An optional default `Commitment` value. Given an RPC method that takes `commitment` as a parameter, this value will be used when the caller does not supply one. -- `onIntegerOverflow(request, keyPath, value): void`: An optional function that will be called whenever a `bigint` input exceeds that which can be expressed using JavaScript numbers. This is used in the default `SolanaRpcSubscriptionsApi` to throw an exception rather than to allow truncated values to propagate through a program. +- `defaultCommitment`: An optional default `Commitment` value. Given an RPC method that takes `commitment` as a parameter, this value will be used when the caller does not supply one. +- `onIntegerOverflow(request, keyPath, value): void`: An optional function that will be called whenever a `bigint` input exceeds that which can be expressed using JavaScript numbers. This is used in the default `SolanaRpcSubscriptionsApi` to throw an exception rather than to allow truncated values to propagate through a program. diff --git a/packages/rpc-subscriptions-spec/README.md b/packages/rpc-subscriptions-spec/README.md index 792877966..783d0b9b9 100644 --- a/packages/rpc-subscriptions-spec/README.md +++ b/packages/rpc-subscriptions-spec/README.md @@ -50,8 +50,8 @@ A channel creator is a function that accepts an `AbortSignal`, returns a new `Rp Subscription channels publish events on two channel names: -- `error`: Fires when the channel closes unexpectedly -- `message`: Fires on every message received from the remote end +- `error`: Fires when the channel closes unexpectedly +- `message`: Fires on every message received from the remote end ## Functions diff --git a/packages/rpc-subscriptions/README.md b/packages/rpc-subscriptions/README.md index ce211f6e7..ceb77a44d 100644 --- a/packages/rpc-subscriptions/README.md +++ b/packages/rpc-subscriptions/README.md @@ -27,10 +27,10 @@ Similar to `createDefaultRpcSubscriptionsChannelCreator` with some Solana-specif A config object with the following properties: -- `intervalMs`: The number of milliseconds to wait since the last message sent or received over the channel before sending a ping message to keep the channel open. -- `maxSubscriptionsPerChannel`: The number of subscribers that may share a channel before a new channel must be created (default: 100). It is important that you set this to the maximum number of subscriptions that your RPC provider recommends making over a single connection; the default is set deliberately low, so as to comply with the restrictive limits of the public mainnet RPC node. -- `minChannels`: The number of channels to create before reusing a channel for a new subscription. -- `sendBufferHighWatermark`: The number of bytes of data to admint into the `WebSocket` buffer before buffering data on the client. -`url`: The URL of the web socket server. Must use the `ws` or `wss` protocols. +- `intervalMs`: The number of milliseconds to wait since the last message sent or received over the channel before sending a ping message to keep the channel open. +- `maxSubscriptionsPerChannel`: The number of subscribers that may share a channel before a new channel must be created (default: 100). It is important that you set this to the maximum number of subscriptions that your RPC provider recommends making over a single connection; the default is set deliberately low, so as to comply with the restrictive limits of the public mainnet RPC node. +- `minChannels`: The number of channels to create before reusing a channel for a new subscription. +- `sendBufferHighWatermark`: The number of bytes of data to admint into the `WebSocket` buffer before buffering data on the client. -`url`: The URL of the web socket server. Must use the `ws` or `wss` protocols. ### `getChannelPoolingChannelCreator(createChannel, { maxSubscriptionsPerChannel, minChannels })` diff --git a/packages/rpc/README.md b/packages/rpc/README.md index f6149cbed..54910d7a5 100644 --- a/packages/rpc/README.md +++ b/packages/rpc/README.md @@ -100,16 +100,16 @@ Creates a `RpcTransport` with some default behaviours. The default behaviours include: -- An automatically-set `Solana-Client` request header, containing the version of `@solana/web3.js` -- Logic that coalesces multiple calls in the same runloop, for the same methods with the same arguments, into a single network request. +- An automatically-set `Solana-Client` request header, containing the version of `@solana/web3.js` +- Logic that coalesces multiple calls in the same runloop, for the same methods with the same arguments, into a single network request. #### Arguments A config object with the following properties: -- `dispatcher_NODE_ONLY`: An optional `Undici.Dispatcher` instance that governs how the networking stack should behave. This option is only relevant in Node applications. Consult the documentation for the various subclasses of `Undici.Dispatcher`, such as `Agent`, `Client`, and `Pool`, at https://undici.nodejs.org/#/docs/api/Client. -- `headers`: An optional object where the keys are HTTP header names and the values are HTTP header values. This parameter is typed to disallow certain headers from being overwritten. -- `url`: A `ClusterUrl` at which the RPC server can be contacted. +- `dispatcher_NODE_ONLY`: An optional `Undici.Dispatcher` instance that governs how the networking stack should behave. This option is only relevant in Node applications. Consult the documentation for the various subclasses of `Undici.Dispatcher`, such as `Agent`, `Client`, and `Pool`, at https://undici.nodejs.org/#/docs/api/Client. +- `headers`: An optional object where the keys are HTTP header names and the values are HTTP header values. This parameter is typed to disallow certain headers from being overwritten. +- `url`: A `ClusterUrl` at which the RPC server can be contacted. ### `createSolanaRpc(clusterUrl, config)` diff --git a/packages/signers/README.md b/packages/signers/README.md index 0726792d2..a8257fbcf 100644 --- a/packages/signers/README.md +++ b/packages/signers/README.md @@ -44,9 +44,9 @@ This package offers a total of five different types of signers that may be used They are separated into three categories: -- **Partial signers**: Given a message or transaction, provide one or more signatures for it. These signers are not able to modify the given data which allows us to run many of them in parallel. -- **Modifying signers**: Can choose to modify a message or transaction before signing it with zero or more private keys. Because modifying a message or transaction invalidates any pre-existing signatures over it, modifying signers must do their work before any other signer. -- **Sending signers**: Given a transaction, signs it and sends it immediately to the blockchain. When applicable, the signer may also decide to modify the provided transaction before signing it. This interface accommodates wallets that simply cannot sign a transaction without sending it at the same time. This category of signers does not apply to regular messages. +- **Partial signers**: Given a message or transaction, provide one or more signatures for it. These signers are not able to modify the given data which allows us to run many of them in parallel. +- **Modifying signers**: Can choose to modify a message or transaction before signing it with zero or more private keys. Because modifying a message or transaction invalidates any pre-existing signatures over it, modifying signers must do their work before any other signer. +- **Sending signers**: Given a transaction, signs it and sends it immediately to the blockchain. When applicable, the signer may also decide to modify the provided transaction before signing it. This interface accommodates wallets that simply cannot sign a transaction without sending it at the same time. This category of signers does not apply to regular messages. Thus, we end up with the following interfaces. @@ -59,8 +59,8 @@ We will go through each of these five signer interfaces and their respective cha This package also provides the following concrete signer implementations: -- The `KeyPairSigner` which uses a `CryptoKeyPair` to sign messages and transactions. -- The Noop signer which does not sign anything and is mostly useful for testing purposes or for indicating that an account will be signed in a different environment (e.g. sending a transaction to your server so it can sign it). +- The `KeyPairSigner` which uses a `CryptoKeyPair` to sign messages and transactions. +- The Noop signer which does not sign anything and is mostly useful for testing purposes or for indicating that an account will be signed in a different environment (e.g. sending a transaction to your server so it can sign it). Additionally, this package allows transaction signers to be stored inside the account meta of an instruction. This allows us to create instructions by passing around signers instead of addresses when applicable which, in turn, allows us to sign an entire transaction automatically without having to scan through its instructions to find the required signers. @@ -96,8 +96,8 @@ const myMessagePartialSigner: MessagePartialSigner<'1234..5678'> = { **Characteristics**: -- **Parallel**. When multiple signers sign the same message, we can perform this operation in parallel to obtain all their signatures. -- **Flexible order**. The order in which we use these signers for a given message doesn’t matter. +- **Parallel**. When multiple signers sign the same message, we can perform this operation in parallel to obtain all their signatures. +- **Flexible order**. The order in which we use these signers for a given message doesn’t matter. #### `MessageModifyingSigner` @@ -114,9 +114,9 @@ const myMessageModifyingSigner: MessageModifyingSigner<'1234..5678'> = { **Characteristics**: -- **Sequential**. Contrary to partial signers, these cannot be executed in parallel as each call can modify the content of the message. -- **First signers**. For a given message, a modifying signer must always be used before a partial signer as the former will likely modify the message and thus impact the outcome of the latter. -- **Potential conflicts**. If more than one modifying signer is provided, the second signer may invalidate the signature of the first one. However, modifying signers may decide not to modify a message based on the existence of signatures for that message. +- **Sequential**. Contrary to partial signers, these cannot be executed in parallel as each call can modify the content of the message. +- **First signers**. For a given message, a modifying signer must always be used before a partial signer as the former will likely modify the message and thus impact the outcome of the latter. +- **Potential conflicts**. If more than one modifying signer is provided, the second signer may invalidate the signature of the first one. However, modifying signers may decide not to modify a message based on the existence of signatures for that message. #### `MessageSigner` @@ -184,8 +184,8 @@ const myTransactionPartialSigner: TransactionPartialSigner<'1234..5678'> = { **Characteristics**: -- **Parallel**. It returns a signature directory for each provided transaction without modifying them, making it possible for multiple partial signers to sign the same transaction in parallel. -- **Flexible order**. The order in which we use these signers for a given transaction doesn’t matter. +- **Parallel**. It returns a signature directory for each provided transaction without modifying them, making it possible for multiple partial signers to sign the same transaction in parallel. +- **Flexible order**. The order in which we use these signers for a given transaction doesn’t matter. #### `TransactionModifyingSigner` @@ -202,9 +202,9 @@ const myTransactionModifyingSigner: TransactionModifyingSigner<'1234..5678'> = { **Characteristics**: -- **Sequential**. Contrary to partial signers, these cannot be executed in parallel as each call can modify the provided transactions. -- **First signers**. For a given transaction, a modifying signer must always be used before a partial signer as the former will likely modify the transaction and thus impact the outcome of the latter. -- **Potential conflicts**. If more than one modifying signer is provided, the second signer may invalidate the signature of the first one. However, modifying signers may decide not to modify a transaction based on the existence of signatures for that transaction. +- **Sequential**. Contrary to partial signers, these cannot be executed in parallel as each call can modify the provided transactions. +- **First signers**. For a given transaction, a modifying signer must always be used before a partial signer as the former will likely modify the transaction and thus impact the outcome of the latter. +- **Potential conflicts**. If more than one modifying signer is provided, the second signer may invalidate the signature of the first one. However, modifying signers may decide not to modify a transaction based on the existence of signatures for that transaction. #### `TransactionSendingSigner` @@ -223,10 +223,10 @@ const myTransactionSendingSigner: TransactionSendingSigner<'1234..5678'> = { **Characteristics**: -- **Single signer**. Since this signer also sends the provided transactions, we can only use a single `TransactionSendingSigner` for a given set of transactions. -- **Last signer**. Trivially, that signer must also be the last one used. -- **Potential conflicts**. Since signers may decide to modify the given transactions before sending them, they may invalidate previous signatures. However, signers may decide not to modify a transaction based on the existence of signatures for that transaction. -- **Potential confirmation**. Whilst this is not required by this interface, it is also worth noting that most wallets will also wait for the transaction to be confirmed (typically with a `confirmed` commitment) before notifying the app that they are done. +- **Single signer**. Since this signer also sends the provided transactions, we can only use a single `TransactionSendingSigner` for a given set of transactions. +- **Last signer**. Trivially, that signer must also be the last one used. +- **Potential conflicts**. Since signers may decide to modify the given transactions before sending them, they may invalidate previous signatures. However, signers may decide not to modify a transaction based on the existence of signatures for that transaction. +- **Potential confirmation**. Whilst this is not required by this interface, it is also worth noting that most wallets will also wait for the transaction to be confirmed (typically with a `confirmed` commitment) before notifying the app that they are done. #### `TransactionSigner` @@ -369,8 +369,8 @@ For a given address, a Noop (No-Operation) signer can be created to offer an imp This signer may be useful: -- For testing purposes. -- For indicating that a given account is a signer and taking the responsibility to provide the signature for that account ourselves. For instance, if we need to send the transaction to a server that will sign it and send it for us. +- For testing purposes. +- For indicating that a given account is a signer and taking the responsibility to provide the signature for that account ourselves. For instance, if we need to send the transaction to a server that will sign it and send it for us. ### Types @@ -484,9 +484,9 @@ const transactionSigners = getSignersFromTransactionMessage(myTransactionMessage Helper function that adds the provided signers to any of the applicable account metas. For an account meta to match a provided signer it: -- Must have a signer role (`AccountRole.READONLY_SIGNER` or `AccountRole.WRITABLE_SIGNER`). -- Must have the same address as the provided signer. -- Must not have an attached signer already. +- Must have a signer role (`AccountRole.READONLY_SIGNER` or `AccountRole.WRITABLE_SIGNER`). +- Must have the same address as the provided signer. +- Must not have an attached signer already. ```ts const myInstruction: IInstruction = { @@ -572,9 +572,9 @@ Similarly to the `partiallySignTransactionMessageWithSigners` function, it first Here as well, composite transaction signers are treated such that at least one sending signer is used if any. When a `TransactionSigner` implements more than one interface, use it as a: -- `TransactionSendingSigner`, if no other `TransactionSendingSigner` exists. -- `TransactionModifyingSigner`, if no other `TransactionModifyingSigner` exists. -- `TransactionPartialSigner`, otherwise. +- `TransactionSendingSigner`, if no other `TransactionSendingSigner` exists. +- `TransactionModifyingSigner`, if no other `TransactionModifyingSigner` exists. +- `TransactionPartialSigner`, otherwise. The provided transaction must contain exactly one `TransactionSendingSigner` inside its account metas. If more than one composite signers implement the `TransactionSendingSigner` interface, one of them will be selected as the sending signer. Otherwise, if multiple `TransactionSendingSigners` must be selected, the function will throw an error. diff --git a/packages/subscribable/README.md b/packages/subscribable/README.md index 52edd460c..349a8948d 100644 --- a/packages/subscribable/README.md +++ b/packages/subscribable/README.md @@ -75,11 +75,11 @@ try { Things to note: -- If a message is published over a channel before the `AsyncIterator` attached to it has polled for the next result, the message will be queued in memory. -- Messages only begin to be queued after the first time an iterator begins to poll. Channel messages published before that time will be dropped. -- If there are messages in the queue and an error occurs, all queued messages will be vended to the iterator before the error is thrown. -- If there are messages in the queue and the abort signal fires, all queued messages will be vended to the iterator after which it will return. -- Any new iterators created after the first error is encountered will reject with that error when polled. +- If a message is published over a channel before the `AsyncIterator` attached to it has polled for the next result, the message will be queued in memory. +- Messages only begin to be queued after the first time an iterator begins to poll. Channel messages published before that time will be dropped. +- If there are messages in the queue and an error occurs, all queued messages will be vended to the iterator before the error is thrown. +- If there are messages in the queue and the abort signal fires, all queued messages will be vended to the iterator after which it will return. +- Any new iterators created after the first error is encountered will reject with that error when polled. ### `demultiplexDataPublisher(publisher, sourceChannelName, messageTransformer)` diff --git a/packages/sysvars/README.md b/packages/sysvars/README.md index 755370e08..73274fac4 100644 --- a/packages/sysvars/README.md +++ b/packages/sysvars/README.md @@ -75,16 +75,16 @@ const clock: SysvarClock = await fetchSysvarClock(rpc); This package supports the following Solana sysvars: -- [`Clock`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/clock.ts) -- [`EpochRewards`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/epoch-rewards.ts) -- [`EpochSchedule`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/epoch-schedule.ts) -- [`Fees`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/fees.ts) -- [`LastRestartSlot`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/last-restart-slot.ts) -- [`RecentBlockhashes`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/recent-blockhashes.ts) -- [`Rent`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/rent.ts) -- [`SlotHashes`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/slot-hashes.ts) -- [`SlotHistory`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/slot-history.ts) -- [`StakeHistory`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/stake-history.ts) +- [`Clock`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/clock.ts) +- [`EpochRewards`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/epoch-rewards.ts) +- [`EpochSchedule`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/epoch-schedule.ts) +- [`Fees`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/fees.ts) +- [`LastRestartSlot`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/last-restart-slot.ts) +- [`RecentBlockhashes`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/recent-blockhashes.ts) +- [`Rent`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/rent.ts) +- [`SlotHashes`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/slot-hashes.ts) +- [`SlotHistory`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/slot-history.ts) +- [`StakeHistory`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/sysvars/src/stake-history.ts) The `Instructions` sysvar is also supported but does not exist on-chain, therefore has no corresponding module or codec. diff --git a/packages/transaction-messages/README.md b/packages/transaction-messages/README.md index 0fc193858..1ce2845f3 100644 --- a/packages/transaction-messages/README.md +++ b/packages/transaction-messages/README.md @@ -78,8 +78,8 @@ const txPaidByMe = setTransactionMessageFeePayer(myAddress, tx); A signed transaction can be only be landed on the network if certain conditions are met: -- It includes the hash of a recent block -- Or it includes the value of an unused nonce known to the network +- It includes the hash of a recent block +- Or it includes the value of an unused nonce known to the network These conditions define a transaction's lifetime, after which it can no longer be landed, even if signed. The lifetime must be added to the transaction message before it is compiled to be sent. diff --git a/packages/transactions/README.md b/packages/transactions/README.md index 9b5ae49cf..9756b93ca 100644 --- a/packages/transactions/README.md +++ b/packages/transactions/README.md @@ -25,9 +25,9 @@ Given a `TransactionMessage`, this function returns a `Transaction` object. This Whether a transaction message is ready to be compiled or not is enforced for you at the type level. In order to be signable, a transaction message must: -- have a version and a list of zero or more instructions (ie. conform to `BaseTransactionMessage`) -- have a fee payer set (ie. conform to `ITransactionMessageWithFeePayer`) -- have a lifetime specified (ie. conform to `TransactionMessageWithBlockhashLifetime | TransactionMessageWithDurableNonceLifetime`) +- have a version and a list of zero or more instructions (ie. conform to `BaseTransactionMessage`) +- have a fee payer set (ie. conform to `ITransactionMessageWithFeePayer`) +- have a lifetime specified (ie. conform to `TransactionMessageWithBlockhashLifetime | TransactionMessageWithDurableNonceLifetime`) ## Signing transactions