Skip to content

Commit

Permalink
chore: sync tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Oct 25, 2024
1 parent 3787512 commit a9a3d37
Show file tree
Hide file tree
Showing 57 changed files with 103 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/internal/AbiConstructor/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { AbiConstructor } from './types.js'
* ```
*
* @param abiConstructor - The ABI Constructor to decode.
* @param data - The encoded constructor inputs.
* @param options - Decoding options.
* @returns The decoded constructor inputs.
*/
export function AbiConstructor_decode<
Expand Down
3 changes: 2 additions & 1 deletion src/internal/AbiFunction/decodeResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ import type { AbiFunction } from './types.js'
*
* :::
*
* @param abiItem - ABI Function to decode
* @param abiFunction - ABI Function to decode
* @param data - ABI-encoded function output
* @param options - Decoding options
* @returns Decoded function output
*/
export function AbiFunction_decodeResult<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/AesGcm/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { AesGcm_ivLength } from './constants.js'
* // @log: Hex.fromString('i am a secret message')
* ```
*
* @param data - The data to encrypt.
* @param value - The data to encrypt.
* @param key - The `CryptoKey` to use for encryption.
* @param options - Decryption options.
* @returns The decrypted data.
Expand Down
2 changes: 1 addition & 1 deletion src/internal/AesGcm/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { AesGcm_ivLength } from './constants.js'
* // @log: '0x5e257b25bcf53d5431e54e5a68ca0138306d31bb6154f35a97bb8ea18111e7d82bcf619d3c76c4650688bc5310eed80b8fc86d1e3e'
* ```
*
* @param data - The data to encrypt.
* @param value - The data to encrypt.
* @param key - The `CryptoKey` to use for encryption.
* @param options - Encryption options.
* @returns The encrypted data.
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/commitmentToVersionedHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import type { Hex } from '../Hex/types.js'
* ```
*
* @param commitment - The commitment.
* @param as - The return type.
* @param options - Options.
* @returns The Blob Versioned Hash.
*/
export function Blobs_commitmentToVersionedHash<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/commitmentsToVersionedHashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { Blobs_commitmentToVersionedHash } from './commitmentToVersionedHash.js'
* ```
*
* @param commitments - A list of commitments.
* @param as - The return type.
* @param options - Options.
* @returns A list of Blob Versioned Hashes.
*/
export function Blobs_commitmentsToVersionedHashes<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { Blobs_BlobSizeTooLargeError, Blobs_EmptyBlobError } from './errors.js'
* ```
*
* @param data - The data to convert to {@link ox#Blobs.Blobs}.
* @param options -
* @param options - Options.
* @returns The {@link ox#Blobs.Blobs}.
*/
export function Blobs_from<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/sidecarsToVersionedHashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import type { BlobSidecars } from './types.js'
* ```
*
* @param sidecars - The {@link ox#Blobs.BlobSidecars} to transform to Blob Versioned Hashes.
* @param options -
* @param options - Options.
* @returns The versioned hashes.
*/
export function Blobs_sidecarsToVersionedHashes<
Expand Down
20 changes: 10 additions & 10 deletions src/internal/Blobs/to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ export function Blobs_to<
| (blobs extends Blobs<Hex> ? 'Hex' : never)
| (blobs extends Blobs<Bytes> ? 'Bytes' : never),
>(
blobs_: blobs | Blobs<Hex> | Blobs<Bytes>,
to_?: to | 'Hex' | 'Bytes' | undefined,
blobs: blobs | Blobs<Hex> | Blobs<Bytes>,
to?: to | 'Hex' | 'Bytes' | undefined,
): Blobs_to.ReturnType<to> {
const to = to_ ?? (typeof blobs_[0] === 'string' ? 'Hex' : 'Bytes')
const blobs = (
typeof blobs_[0] === 'string'
? blobs_.map((x) => Bytes_fromHex(x as Hex))
: blobs_
const to_ = to ?? (typeof blobs[0] === 'string' ? 'Hex' : 'Bytes')
const blobs_ = (
typeof blobs[0] === 'string'
? blobs.map((x) => Bytes_fromHex(x as Hex))
: blobs
) as Bytes[]

const length = blobs.reduce((length, blob) => length + blob.length, 0)
const length = blobs_.reduce((length, blob) => length + blob.length, 0)
const data = createCursor(new Uint8Array(length))
let active = true

for (const blob of blobs) {
for (const blob of blobs_) {
const cursor = createCursor(blob)
while (active && cursor.position < blob.length) {
// First byte will be a zero 0x00 byte – we can skip.
Expand All @@ -79,7 +79,7 @@ export function Blobs_to<
}

const trimmedData = data.bytes.slice(0, data.position)
return (to === 'Hex' ? Hex_fromBytes(trimmedData) : trimmedData) as never
return (to_ === 'Hex' ? Hex_fromBytes(trimmedData) : trimmedData) as never
}

export declare namespace Blobs_to {
Expand Down
16 changes: 8 additions & 8 deletions src/internal/Blobs/toCommitments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import type { Blobs } from './types.js'
* ```
*
* @param blobs - The {@link ox#Blobs.Blobs} to transform to commitments.
* @param options -
* @param options - Options.
* @returns The commitments.
*/
export function Blobs_toCommitments<
Expand All @@ -48,20 +48,20 @@ export function Blobs_toCommitments<
| (blobs extends Blobs<Hex> ? 'Hex' : never)
| (blobs extends Blobs<Bytes> ? 'Bytes' : never),
>(
blobs_: blobs | Blobs<Bytes> | Blobs<Hex>,
blobs: blobs | Blobs<Bytes> | Blobs<Hex>,
options: Blobs_toCommitments.Options<as>,
): Blobs_toCommitments.ReturnType<as> {
const { kzg } = options

const as = options.as ?? (typeof blobs_[0] === 'string' ? 'Hex' : 'Bytes')
const blobs = (
typeof blobs_[0] === 'string'
? blobs_.map((x) => Bytes_fromHex(x as any))
: blobs_
const as = options.as ?? (typeof blobs[0] === 'string' ? 'Hex' : 'Bytes')
const blobs_ = (
typeof blobs[0] === 'string'
? blobs.map((x) => Bytes_fromHex(x as any))
: blobs
) as Bytes[]

const commitments: Bytes[] = []
for (const blob of blobs)
for (const blob of blobs_)
commitments.push(Uint8Array.from(kzg.blobToKzgCommitment(blob)))

return (
Expand Down
18 changes: 9 additions & 9 deletions src/internal/Blobs/toProofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Blobs } from './types.js'
* ```
*
* @param blobs - The {@link ox#Blobs.Blobs} to compute proofs for.
* @param options -
* @param options - Options.
* @returns The Blob proofs.
*/
export function Blobs_toProofs<
Expand All @@ -31,17 +31,17 @@ export function Blobs_toProofs<
| (blobs extends readonly Hex[] ? 'Hex' : never)
| (blobs extends readonly Bytes[] ? 'Bytes' : never),
>(
blobs_: blobs | Blobs<Bytes> | Blobs<Hex>,
blobs: blobs | Blobs<Bytes> | Blobs<Hex>,
options: Blobs_toProofs.Options<blobs, commitments, as>,
): Blobs_toProofs.ReturnType<as> {
const { kzg } = options

const as = options.as ?? (typeof blobs_[0] === 'string' ? 'Hex' : 'Bytes')
const as = options.as ?? (typeof blobs[0] === 'string' ? 'Hex' : 'Bytes')

const blobs = (
typeof blobs_[0] === 'string'
? blobs_.map((x) => Bytes_fromHex(x as any))
: blobs_
const blobs_ = (
typeof blobs[0] === 'string'
? blobs.map((x) => Bytes_fromHex(x as any))
: blobs
) as Bytes[]
const commitments = (
typeof options.commitments[0] === 'string'
Expand All @@ -50,8 +50,8 @@ export function Blobs_toProofs<
) as Bytes[]

const proofs: Bytes[] = []
for (let i = 0; i < blobs.length; i++) {
const blob = blobs[i]!
for (let i = 0; i < blobs_.length; i++) {
const blob = blobs_[i]!
const commitment = commitments[i]!
proofs.push(Uint8Array.from(kzg.computeBlobKzgProof(blob, commitment)))
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/toSidecars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type { BlobSidecars, Blobs } from './types.js'
* ```
*
* @param blobs - The {@link ox#Blobs.Blobs} to transform into {@link ox#Blobs.BlobSidecars}.
* @param options -
* @param options - Options.
* @returns The {@link ox#Blobs.BlobSidecars}.
*/
export function Blobs_toSidecars<const blobs extends Blobs<Hex> | Blobs<Bytes>>(
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Blobs/toVersionedHashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Blobs } from './types.js'
* ```
*
* @param blobs - The {@link ox#Blobs.Blobs} to transform into Blob Versioned Hashes.
* @param options -
* @param options - Options.
* @returns The Blob Versioned Hashes.
*/
export function Blobs_toVersionedHashes<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Bytes/fromHex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function charCodeToBase16(char: number) {
* // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
* ```
*
* @param hex - {@link ox#Hex.Hex} value to encode.
* @param value - {@link ox#Hex.Hex} value to encode.
* @param options - Encoding options.
* @returns Encoded {@link ox#Bytes.Bytes}.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/internal/Bytes/toBoolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import type { Bytes } from './types.js'
* @returns Decoded boolean.
*/
export function Bytes_toBoolean(
bytes_: Bytes,
bytes: Bytes,
options: Bytes_toBoolean.Options = {},
): boolean {
const { size } = options
let bytes = bytes_
let bytes_ = bytes
if (typeof size !== 'undefined') {
Bytes_assertSize(bytes, size)
bytes = Bytes_trimLeft(bytes)
Bytes_assertSize(bytes_, size)
bytes_ = Bytes_trimLeft(bytes_)
}
if (bytes.length > 1 || bytes[0]! > 1)
throw new Bytes_InvalidBytesBooleanError(bytes)
return Boolean(bytes[0])
if (bytes_.length > 1 || bytes_[0]! > 1)
throw new Bytes_InvalidBytesBooleanError(bytes_)
return Boolean(bytes_[0])
}

export declare namespace Bytes_toBoolean {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/Bytes/toHex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type { Bytes } from './types.js'
* // '0x48656c6c6f20576f726c6421'
* ```
*
* @param bytes - The {@link ox#Bytes.Bytes} to decode.
* @param options -
* @param value - The {@link ox#Bytes.Bytes} to decode.
* @param options - Options.
* @returns Decoded {@link ox#Hex.Hex} value.
*/
export function Bytes_toHex(
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Bytes/toString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const decoder = /*#__PURE__*/ new TextDecoder()
* ```
*
* @param bytes - The {@link ox#Bytes.Bytes} to decode.
* @param options -
* @param options - Options.
* @returns Decoded string.
*/
export function Bytes_toString(
Expand Down
6 changes: 3 additions & 3 deletions src/internal/Filter/fromRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Hex_validate } from '../Hex/validate.js'
import type { Filter, Filter_Rpc } from './types.js'

/**
* Converts a {@link ox#Log.Rpc} to an {@link ox#Log.Log}.
* Converts a {@link ox#Filter.Rpc} to an {@link ox#Filter.Filter}.
*
* @example
* ```ts twoslash
Expand Down Expand Up @@ -31,8 +31,8 @@ import type { Filter, Filter_Rpc } from './types.js'
* // @log: }
* ```
*
* @param log - The RPC log to convert.
* @returns An instantiated {@link ox#Log.Log}.
* @param filter - The RPC filter to convert.
* @returns An instantiated {@link ox#Filter.Filter}.
*/
export function Filter_fromRpc(filter: Filter_Rpc): Filter {
const { address, topics, fromBlock, toBlock } = filter
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hash/keccak256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import type { Hex } from '../Hex/types.js'
* ```
*
* @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.
* @param to - The return type.
* @param options - Options.
* @returns Keccak256 hash.
*/
export function Hash_keccak256<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hash/ripemd160.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { Hex } from '../Hex/types.js'
* ```
*
* @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.
* @param to - The return type.
* @param options - Options.
* @returns Ripemd160 hash.
*/
export function Hash_ripemd160<
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hash/sha256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { Hex } from '../Hex/types.js'
* ```
*
* @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.
* @param to - The return type.
* @param options - Options.
* @returns Sha256 hash.
*/
export function Hash_sha256<
Expand Down
1 change: 0 additions & 1 deletion src/internal/HdKey/fromExtendedKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type { HdKey } from './types.js'
* ```
*
* @param extendedKey - The extended private key.
* @param options - Creation options.
* @returns The HD Key.
*/
export function HdKey_fromExtendedKey(extendedKey: string): HdKey {
Expand Down
1 change: 0 additions & 1 deletion src/internal/HdKey/fromJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type { HdKey } from './types.js'
* ```
*
* @param json - The JSON object containing an extended private key (`xpriv`).
* @param options - Creation options.
* @returns The HD Key.
*/
export function HdKey_fromJson(json: { xpriv: string }): HdKey {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hex/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { Hex } from './types.js'
* ```
*
* @param value - The value to assert.
* @param options -
* @param options - Options.
*/
export function Hex_assert(
value: unknown,
Expand Down
1 change: 0 additions & 1 deletion src/internal/Hex/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import type { Hex } from './types.js'
* ```
*
* @param value - The {@link ox#Bytes.Bytes} value to encode.
* @param options -
* @returns The encoded {@link ox#Hex.Hex} value.
*/
export function Hex_from(value: Hex | Bytes | readonly number[]): Hex {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hex/fromBoolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Hex } from './types.js'
* ```
*
* @param value - The boolean value to encode.
* @param options -
* @param options - Options.
* @returns The encoded {@link ox#Hex.Hex} value.
*/
export function Hex_fromBoolean(
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hex/fromBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const hexes = /*#__PURE__*/ Array.from({ length: 256 }, (_v, i) =>
* ```
*
* @param value - The {@link ox#Bytes.Bytes} value to encode.
* @param options -
* @param options - Options.
* @returns The encoded {@link ox#Hex.Hex} value.
*/
export function Hex_fromBytes(
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hex/fromNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { Hex } from './types.js'
* ```
*
* @param value - The number or bigint value to encode.
* @param options -
* @param options - Options.
* @returns The encoded {@link ox#Hex.Hex} value.
*/
export function Hex_fromNumber(
Expand Down
2 changes: 1 addition & 1 deletion src/internal/Hex/fromString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const encoder = /*#__PURE__*/ new TextEncoder()
* ```
*
* @param value - The string value to encode.
* @param options -
* @param options - Options.
* @returns The encoded {@link ox#Hex.Hex} value.
*/
export function Hex_fromString(
Expand Down
Loading

0 comments on commit a9a3d37

Please sign in to comment.