Skip to content

Commit

Permalink
refactor: type parameters to camelCase (#239)
Browse files Browse the repository at this point in the history
* refactor: switch to lowercase type params

* chore: changeset

* chore: format

* docs: format

* refactor: register case

* chore: format

* chore: changeset

---------

Co-authored-by: tmm <[email protected]>
  • Loading branch information
tmm and tmm authored Jun 19, 2024
1 parent 7f52eed commit f083a7c
Show file tree
Hide file tree
Showing 33 changed files with 852 additions and 785 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-geckos-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"abitype": patch
---

Changed type parameters and register properties to camelCase.
130 changes: 65 additions & 65 deletions docs/pages/api/human.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ Types for parsing and formatting human-readable ABIs.
Parses human-readable ABI into JSON [`Abi`](/api/types#abi).
| Name | Description | Type |
| ------------- | ------------------------------ | ----------------- |
| `TSignatures` | Human-Readable ABI. | `string[]` |
| returns | Parsed [`Abi`](/api/types#abi) | `TAbi` (inferred) |
| Name | Description | Type |
| ------------ | ------------------------------ | ---------------- |
| `signatures` | Human-Readable ABI. | `string[]` |
| returns | Parsed [`Abi`](/api/types#abi) | `abi` (inferred) |
#### Example
Expand Down Expand Up @@ -239,10 +239,10 @@ let result: Result

Parses human-readable ABI item (e.g. error, event, function) into ABI item.

| Name | Description | Type |
| ------------ | ------------------------ | --------------------- |
| `TSignature` | Human-Readable ABI item. | `string[]` |
| returns | Parsed ABI item | `TAbiItem` (inferred) |
| Name | Description | Type |
| ----------- | ------------------------ | -------------------- |
| `signature` | Human-Readable ABI item. | `string[]` |
| returns | Parsed ABI item | `abiItem` (inferred) |

#### Example

Expand Down Expand Up @@ -293,10 +293,10 @@ let resultStruct: ResultStruct

Parses human-readable ABI parameter into [`AbiParameter`](/api/types#abiparameter).

| Name | Description | Type |
| -------- | ------------------------------------------------ | -------------------------- |
| `TParam` | Human-Readable ABI parameter. | `string \| string[]` |
| returns | Parsed [`AbiParameter`](/api/types#abiparameter) | `TAbiParameter` (inferred) |
| Name | Description | Type |
| ------- | ------------------------------------------------ | ------------------------- |
| `param` | Human-Readable ABI parameter. | `string \| string[]` |
| returns | Parsed [`AbiParameter`](/api/types#abiparameter) | `abiParameter` (inferred) |

#### Example

Expand Down Expand Up @@ -331,10 +331,10 @@ type ResultStruct = ParseAbiParameter<[
Parses human-readable ABI parameters into [`AbiParameter`s](/api/types#abiparameter).
| Name | Description | Type |
| --------- | ------------------------------------------------- | ---------------------------- |
| `TParams` | Human-Readable ABI parameters. | `string \| string[]` |
| returns | Parsed [`AbiParameter`s](/api/types#abiparameter) | `TAbiParameter[]` (inferred) |
| Name | Description | Type |
| -------- | ------------------------------------------------- | --------------------------- |
| `params` | Human-Readable ABI parameters. | `string \| string[]` |
| returns | Parsed [`AbiParameter`s](/api/types#abiparameter) | `abiParameter[]` (inferred) |
#### Example
Expand Down Expand Up @@ -373,10 +373,10 @@ type ResultStruct = ParseAbiParameters<[
Formats [`Abi`](/api/types#abi) into human-readable ABI.
| Name | Description | Type |
| ----------- | ------------------- | --------------------------- |
| `TAbi` | ABI | [`Abi`](/api/types#abi) |
| returns | Human-Readable ABI. | `string[]` (inferred) |
| Name | Description | Type |
| ------- | ------------------- | ----------------------- |
| `abi` | ABI | [`Abi`](/api/types#abi) |
| returns | Human-Readable ABI. | `string[]` (inferred) |
#### Example
Expand Down Expand Up @@ -411,10 +411,10 @@ type Result = FormatAbi<[
Formats Abi item (e.g. error, event, function) into human-readable ABI parameter.
| Name | Description | Type |
| --------------- | ------------------------ | ----------------------------------- |
| `TAbiItem` | ABI item | [`Abi[number]`](/api/types#abi) |
| returns | Human-Readable ABI item. | `string` (inferred) |
| Name | Description | Type |
| --------- | ------------------------ | ------------------------------- |
| `abiItem` | ABI item | [`Abi[number]`](/api/types#abi) |
| returns | Human-Readable ABI item. | `string` (inferred) |
#### Example
Expand All @@ -438,10 +438,10 @@ type Result = FormatAbiItem<{
Formats [`AbiParameter`](/api/types#abiparameter) into human-readable ABI parameter.
| Name | Description | Type |
| --------------- | ------------------------------ | ------------------------------------------------ |
| `TAbiParameter` | ABI parameter | [`AbiParameter`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameters. | `string[]` (inferred) |
| Name | Description | Type |
| -------------- | ------------------------------ | ----------------------------------------- |
| `abiParameter` | ABI parameter | [`AbiParameter`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameters. | `string[]` (inferred) |
#### Example
Expand All @@ -456,10 +456,10 @@ type Result = FormatAbiParameter<{ type: 'address'; name: 'from' }>
Formats [`AbiParameter`s](/api/types#abiparameter) into human-readable ABI parameters.
| Name | Description | Type |
| ---------------- | ----------------------------- | -------------------------------------------------- |
| `TAbiParameters` | ABI parameters | [`AbiParameter[]`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |
| Name | Description | Type |
| --------------- | ----------------------------- | ------------------------------------------- |
| `abiParameters` | ABI parameters | [`AbiParameter[]`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |
#### Example
Expand Down Expand Up @@ -487,10 +487,10 @@ These functions throw [errors](#errors-1) for invalid inputs. Make sure you hand
Parses human-readable ABI into JSON [`Abi`](/api/types#abi).
| Name | Description | Type |
| ------------ | ------------------------------ | ----------------- |
| `signatures` | Human-Readable ABI. | `string[]` |
| returns | Parsed [`Abi`](/api/types#abi) | `TAbi` (inferred) |
| Name | Description | Type |
| ------------ | ------------------------------ | ---------------- |
| `signatures` | Human-Readable ABI. | `string[]` |
| returns | Parsed [`Abi`](/api/types#abi) | `abi` (inferred) |
#### Example
Expand Down Expand Up @@ -522,10 +522,10 @@ abi

Parses human-readable ABI item (e.g. error, event, function) into ABI item.

| Name | Description | Type |
| ----------- | ------------------------ | --------------------- |
| `signature` | Human-Readable ABI item. | `string \| string[]` |
| returns | Parsed ABI item | `TAbiItem` (inferred) |
| Name | Description | Type |
| ----------- | ------------------------ | -------------------- |
| `signature` | Human-Readable ABI item. | `string \| string[]` |
| returns | Parsed ABI item | `abiItem` (inferred) |

#### Example

Expand Down Expand Up @@ -577,10 +577,10 @@ abiItemStruct

Parses human-readable ABI parameter into [`AbiParameter`](/api/types#abiparameter).

| Name | Description | Type |
| ------- | ------------------------------------------------ | -------------------------- |
| `param` | Human-Readable ABI parameter. | `string \| string[]` |
| returns | Parsed [`AbiParameter`](/api/types#abiparameter) | `TAbiParameter` (inferred) |
| Name | Description | Type |
| ------- | ------------------------------------------------ | ------------------------- |
| `param` | Human-Readable ABI parameter. | `string \| string[]` |
| returns | Parsed [`AbiParameter`](/api/types#abiparameter) | `abiParameter` (inferred) |

#### Example

Expand Down Expand Up @@ -615,10 +615,10 @@ abiParameterStruct

Parses human-readable ABI parameters into [`AbiParameter`s](/api/types#abiparameter).

| Name | Description | Type |
| -------- | ------------------------------------------------- | ---------------------------- |
| `params` | Human-Readable ABI parameters. | `string \| string[]` |
| returns | Parsed [`AbiParameter`s](/api/types#abiparameter) | `TAbiParameter[]` (inferred) |
| Name | Description | Type |
| -------- | ------------------------------------------------- | --------------------------- |
| `params` | Human-Readable ABI parameters. | `string \| string[]` |
| returns | Parsed [`AbiParameter`s](/api/types#abiparameter) | `abiParameter[]` (inferred) |

#### Example

Expand Down Expand Up @@ -662,10 +662,10 @@ abiParametersStruct

Formats [`Abi`](/api/types#abi) into human-readable ABI.

| Name | Description | Type |
| ----------- | ------------------- | --------------------------- |
| `abi` | ABI | [`Abi`](/api/types#abi) |
| returns | Human-Readable ABI. | `string[]` (inferred) |
| Name | Description | Type |
| ----------- | ------------------- | ----------------------- |
| `abi` | ABI | [`Abi`](/api/types#abi) |
| returns | Human-Readable ABI. | `string[]` (inferred) |

#### Example

Expand Down Expand Up @@ -700,10 +700,10 @@ const result = formatAbi([

Formats Abi item (e.g. error, event, function) into human-readable ABI parameter.

| Name | Description | Type |
| --------------- | ------------------------ | ----------------------------------- |
| `abiItem` | ABI item | [`Abi[number]`](/api/types#abi) |
| returns | Human-Readable ABI item. | `string` (inferred) |
| Name | Description | Type |
| --------------- | ------------------------ | ------------------------------- |
| `abiItem` | ABI item | [`Abi[number]`](/api/types#abi) |
| returns | Human-Readable ABI item. | `string` (inferred) |

#### Example

Expand All @@ -727,10 +727,10 @@ const result = formatAbiItem({

Formats [`AbiParameter`](/api/types#abiparameter) into human-readable ABI parameter.

| Name | Description | Type |
| -------------- | ----------------------------- | ------------------------------------------------ |
| `abiParameter` | ABI parameter | [`AbiParameter`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |
| Name | Description | Type |
| -------------- | ----------------------------- | ----------------------------------------- |
| `abiParameter` | ABI parameter | [`AbiParameter`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |

#### Example

Expand All @@ -745,10 +745,10 @@ const result = formatAbiParameter({ type: 'address', name: 'from' })

Formats [`AbiParameter`s](/api/types#abiparameter) into human-readable ABI parameters.

| Name | Description | Type |
| ---------------- | ----------------------------- | -------------------------------------------------- |
| `abiParameters` | ABI parameters | [`AbiParameter[]`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |
| Name | Description | Type |
| ---------------- | ----------------------------- | ------------------------------------------- |
| `abiParameters` | ABI parameters | [`AbiParameter[]`](/api/types#abiparameter) |
| returns | Human-Readable ABI parameter. | `string` (inferred) |

#### Example

Expand Down Expand Up @@ -784,4 +784,4 @@ import {
InvalidAbiItemError,
UnknownTypeError,
} from 'abitype'
```
```
2 changes: 1 addition & 1 deletion docs/pages/api/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Converts array of `AbiParameter` to corresponding TypeScript primitive types.
| ------------------- | ---------------------------------------------------- | ----------------------------- |
| `abiParameters` | Parameters to convert to TypeScript representations. | `readonly AbiParameter[]` |
| `abiParameterKind` | Kind to narrow by parameter type. | `AbiParameterKind` (optional) |
| returns | TypeScript primitive types. | `type[]` (in ferred) |
| returns | TypeScript primitive types. | `type[]` (inferred) |
#### Example
Expand Down
34 changes: 17 additions & 17 deletions docs/pages/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ ABIType's types are customizable using [declaration merging](https://www.typescr
```ts twoslash
declare module 'abitype' {
export interface Register {
BigIntType: bigint & { foo: 'bar' }
bigIntType: bigint & { foo: 'bar' }
}
}

import { ResolvedRegister } from 'abitype'
type Result = ResolvedRegister['BigIntType']
type Result = ResolvedRegister['bigIntType']
// ^?


Expand All @@ -31,7 +31,7 @@ If you are using ABIType via another package (e.g. [`viem`](https://viem.sh)), y
```ts
declare module 'viem/node_modules/abitype' {
export interface Register {
BigIntType: MyCustomBigIntType
bigIntType: MyCustomBigIntType
}
}
```
Expand All @@ -42,10 +42,10 @@ declare module 'viem/node_modules/abitype' {
ABIType tries to strike a balance between type exhaustiveness and speed with sensible defaults. In some cases, you might want to tune your configuration (e.g. use a custom `bigint` type). To do this, the following configuration options are available:

:::warning
When configuring `ArrayMaxDepth`, `FixedArrayMinLength`, and `FixedArrayMaxLength`, there are trade-offs. For example, choosing a non-false value for `ArrayMaxDepth` and increasing the range between `FixedArrayMinLength` and `FixedArrayMaxLength` will make your types more exhaustive, but will also slow down the compiler for type checking, autocomplete, etc.
When configuring `arrayMaxDepth`, `fixedArrayMinLength`, and `fixedArrayMaxLength`, there are trade-offs. For example, choosing a non-false value for `arrayMaxDepth` and increasing the range between `fixedArrayMinLength` and `fixedArrayMaxLength` will make your types more exhaustive, but will also slow down the compiler for type checking, autocomplete, etc.
:::

### `AddressType`
### `addressType`

TypeScript type to use for `address` values.

Expand All @@ -55,12 +55,12 @@ TypeScript type to use for `address` values.
```ts twoslash
declare module 'abitype' {
export interface Register {
AddressType: `0x${string}`
addressType: `0x${string}`
}
}
```

### `ArrayMaxDepth`
### `arrayMaxDepth`

Maximum depth for nested array types (e.g. `string[][]`). When `false`, there is no maximum array depth.

Expand All @@ -75,7 +75,7 @@ declare module 'abitype' {
}
```

### `BigIntType`
### `bigIntType`

TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`.

Expand All @@ -85,12 +85,12 @@ TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`.
```ts twoslash
declare module 'abitype' {
export interface Register {
BigIntType: bigint
bigIntType: bigint
}
}
```

### `BytesType`
### `bytesType`

TypeScript type to use for `bytes<M>` values.

Expand All @@ -100,15 +100,15 @@ TypeScript type to use for `bytes<M>` values.
```ts twoslash
declare module 'abitype' {
export interface Register {
BytesType: {
bytesType: {
inputs: `0x${string}`
outputs: `0x${string}`
}
}
}
```

### `FixedArrayMinLength`
### `fixedArrayMinLength`

Lower bound for fixed-length arrays.

Expand All @@ -123,7 +123,7 @@ declare module 'abitype' {
}
```

### `FixedArrayMaxLength`
### `fixedArrayMaxLength`

Upper bound for fixed-length arrays.

Expand All @@ -138,7 +138,7 @@ declare module 'abitype' {
}
```

### `IntType`
### `intType`

TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`.

Expand All @@ -148,12 +148,12 @@ TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`.
```ts twoslash
declare module 'abitype' {
export interface Register {
IntType: number
intType: number
}
}
```

### `StrictAbiType`
### `strictAbiType`

When set, validates `AbiParameter`'s `type` against `AbiType`.

Expand All @@ -163,7 +163,7 @@ When set, validates `AbiParameter`'s `type` against `AbiType`.
```ts twoslash
declare module 'abitype' {
export interface Register {
StrictAbiType: false
strictAbiType: false
}
}
```
Expand Down
Loading

0 comments on commit f083a7c

Please sign in to comment.