Skip to content

Commit fabec8f

Browse files
authored
Run style:fix (#69)
1 parent 67841ac commit fabec8f

File tree

23 files changed

+221
-221
lines changed

23 files changed

+221
-221
lines changed

examples/react-app/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ This is an example of how to use `@solana/web3.js` and `@solana/react` to build
44

55
## Features
66

7-
- Connects to browser wallets that support the Wallet Standard; one or more at a time
8-
- Fetches and subscribes to the balance of the selected wallet
9-
- Allows you to sign an arbitrary message using a wallet account
10-
- Allows you to make a transfer from the selected wallet to any other connected wallet
7+
- Connects to browser wallets that support the Wallet Standard; one or more at a time
8+
- Fetches and subscribes to the balance of the selected wallet
9+
- Allows you to sign an arbitrary message using a wallet account
10+
- Allows you to make a transfer from the selected wallet to any other connected wallet
1111

1212
## Developing
1313

packages/codecs-core/README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ const person = personCodec.decode(bytes);
3838

3939
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:
4040

41-
- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) for number codecs.
42-
- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) for string codecs.
43-
- [`@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.
44-
- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) for a Rust-like `Option` type and associated codec.
41+
- [`@solana/codecs-numbers`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-numbers) for number codecs.
42+
- [`@solana/codecs-strings`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/codecs-strings) for string codecs.
43+
- [`@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.
44+
- [`@solana/options`](https://github.com/anza-xyz/solana-web3.js/tree/main/packages/options) for a Rust-like `Option` type and associated codec.
4545

4646
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.
4747

@@ -159,19 +159,19 @@ The following type guards are available to identify and/or assert the size of co
159159

160160
Finally, note that the same is true for `Encoders` and `Decoders`.
161161

162-
- A `FixedSizeEncoder` has a `fixedSize` number attribute.
163-
- A `VariableSizeEncoder` has a `getSizeFromValue` function and an optional `maxSize` number attribute.
164-
- A `FixedSizeDecoder` has a `fixedSize` number attribute.
165-
- A `VariableSizeDecoder` has an optional `maxSize` number attribute.
162+
- A `FixedSizeEncoder` has a `fixedSize` number attribute.
163+
- A `VariableSizeEncoder` has a `getSizeFromValue` function and an optional `maxSize` number attribute.
164+
- A `FixedSizeDecoder` has a `fixedSize` number attribute.
165+
- A `VariableSizeDecoder` has an optional `maxSize` number attribute.
166166

167167
## Creating custom codecs
168168

169169
If composing codecs isn’t enough for you, you may implement your own codec logic by using the `createCodec` function. This function requires an object with a `read` and a `write` function telling us how to read from and write to an existing byte array.
170170

171171
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:
172172

173-
- The first item should be the decoded value.
174-
- The second item should be the next offset to read from.
173+
- The first item should be the decoded value.
174+
- The second item should be the next offset to read from.
175175

176176
```ts
177177
createCodec({
@@ -533,14 +533,14 @@ u32InTheMiddleCodec.encode(0xffffffff);
533533

534534
Both the `preOffset` and `postOffset` functions offer the following attributes:
535535

536-
- `bytes`: The entire byte array being encoded or decoded.
537-
- `preOffset`: The original and unaltered pre-offset.
538-
- `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.
536+
- `bytes`: The entire byte array being encoded or decoded.
537+
- `preOffset`: The original and unaltered pre-offset.
538+
- `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.
539539

540540
Additionally, the post-offset function also provides the following attributes:
541541

542-
- `newPreOffset`: The new pre-offset after the pre-offset function has been applied.
543-
- `postOffset`: The original and unaltered post-offset.
542+
- `newPreOffset`: The new pre-offset after the pre-offset function has been applied.
543+
- `postOffset`: The original and unaltered post-offset.
544544

545545
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.
546546

@@ -635,10 +635,10 @@ const getBigEndianU64Codec = () => combineCodec(getBigEndianU64Encoder(), getBig
635635

636636
This package also provides utility functions for managing bytes such as:
637637

638-
- `mergeBytes`: Concatenates an array of `Uint8Arrays` into a single `Uint8Array`.
639-
- `padBytes`: Pads a `Uint8Array` with zeroes (to the right) to the specified length.
640-
- `fixBytes`: Pads or truncates a `Uint8Array` so it has the specified length.
641-
- `containsBytes`: Checks if a `Uint8Array` contains another `Uint8Array` at a given offset.
638+
- `mergeBytes`: Concatenates an array of `Uint8Arrays` into a single `Uint8Array`.
639+
- `padBytes`: Pads a `Uint8Array` with zeroes (to the right) to the specified length.
640+
- `fixBytes`: Pads or truncates a `Uint8Array` so it has the specified length.
641+
- `containsBytes`: Checks if a `Uint8Array` contains another `Uint8Array` at a given offset.
642642

643643
```ts
644644
// Merge multiple Uint8Array buffers into one.

packages/codecs-data-structures/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ getArrayCodec(getU8Codec()).encode([1, 2, 3]);
3535

3636
However, you may use the `size` option to configure this behaviour. It can be one of the following three strategies:
3737

38-
- `Codec<number>`: When a number codec is provided, that codec will be used to encode and decode the size prefix.
39-
- `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.
40-
- `"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.
38+
- `Codec<number>`: When a number codec is provided, that codec will be used to encode and decode the size prefix.
39+
- `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.
40+
- `"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.
4141

4242
```ts
4343
getArrayCodec(getU8Codec(), { size: getU16Codec() }).encode([1, 2, 3]);
@@ -310,9 +310,9 @@ const value = getLiteralUnionDecoder(['left', 'right']).decode(bytes); // 'left'
310310

311311
In Rust, enums are powerful data types whose variants can be one of the following:
312312

313-
- An empty variant — e.g. `enum Message { Quit }`.
314-
- A tuple variant — e.g. `enum Message { Write(String) }`.
315-
- A struct variant — e.g. `enum Message { Move { x: i32, y: i32 } }`.
313+
- An empty variant — e.g. `enum Message { Quit }`.
314+
- A tuple variant — e.g. `enum Message { Write(String) }`.
315+
- A struct variant — e.g. `enum Message { Move { x: i32, y: i32 } }`.
316316

317317
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**.
318318

@@ -434,9 +434,9 @@ The `getUnionCodec` is a lower-lever codec helper that can be used to encode/dec
434434

435435
It accepts the following arguments:
436436

437-
- An array of codecs, each defining a variant of the union.
438-
- A `getIndexFromValue` function which, given a value of the union, returns the index of the codec that should be used to encode that value.
439-
- 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.
437+
- An array of codecs, each defining a variant of the union.
438+
- A `getIndexFromValue` function which, given a value of the union, returns the index of the codec that should be used to encode that value.
439+
- 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.
440440

441441
```ts
442442
const codec: Codec<number | boolean> = getUnionCodec(

packages/codecs-strings/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The `@solana/codecs-strings` package offers a variety of string codecs such as `
2121

2222
By default, all available string codecs will return a `VariableSizeCodec<string>` meaning that:
2323

24-
- When encoding a string, all bytes necessary to encode the string will be used.
25-
- When decoding a byte array at a given offset, all bytes starting from that offset will be decoded as a string.
24+
- When encoding a string, all bytes necessary to encode the string will be used.
25+
- When decoding a byte array at a given offset, all bytes starting from that offset will be decoded as a string.
2626

2727
For instance, here's how you can encode/decode `utf8` strings without any size boundary:
2828

0 commit comments

Comments
 (0)