Comparing version 0.0.13 to 0.0.14
@@ -13,3 +13,3 @@ import { ResolvedConfig } from './config'; | ||
export declare type SolidityInt = `${'u' | ''}int${MBits}`; | ||
export declare type SolidityFixedArrayRange = Range<ResolvedConfig['FixedArrayLengthLowerBound'], ResolvedConfig['FixedArrayLengthUpperBound']>[number]; | ||
export declare type SolidityFixedArrayRange = Range<ResolvedConfig['FixedArrayMinLength'], ResolvedConfig['FixedArrayMaxLength']>[number]; | ||
export declare type SolidityFixedArraySizeLookup = { | ||
@@ -16,0 +16,0 @@ [Prop in SolidityFixedArrayRange as `${Prop}`]: Prop; |
@@ -0,1 +1,3 @@ | ||
import { Address } from './abi'; | ||
import { IsUnknown } from './types'; | ||
/** | ||
@@ -7,3 +9,3 @@ * Override `Config` to customize type options | ||
* export interface Config { | ||
* FixedArrayLengthUpperBound: 6 | ||
* FixedArrayMaxLength: 6 | ||
* } | ||
@@ -22,7 +24,11 @@ * } | ||
/** Lower bound for fixed array length */ | ||
FixedArrayLengthLowerBound: 1; | ||
FixedArrayMinLength: 1; | ||
/** Upper bound for fixed array length */ | ||
FixedArrayLengthUpperBound: 5; | ||
FixedArrayMaxLength: 5; | ||
/** TypeScript type to use for `address` values */ | ||
AddressType: Address; | ||
/** TypeScript type to use for `bytes` values */ | ||
BytesType: string | ArrayLike<number>; | ||
/** TypeScript type to use for `int` and `uint` values */ | ||
NumberType: number | bigint; | ||
IntType: number | bigint; | ||
} | ||
@@ -39,5 +45,7 @@ /** | ||
ArrayMaxDepth: Config['ArrayMaxDepth'] extends number | false ? Config['ArrayMaxDepth'] : DefaultConfig['ArrayMaxDepth']; | ||
FixedArrayLengthLowerBound: Config['FixedArrayLengthLowerBound'] extends number ? Config['FixedArrayLengthLowerBound'] : DefaultConfig['FixedArrayLengthLowerBound']; | ||
FixedArrayLengthUpperBound: Config['FixedArrayLengthUpperBound'] extends number ? Config['FixedArrayLengthUpperBound'] : DefaultConfig['FixedArrayLengthUpperBound']; | ||
NumberType: Config['NumberType'] extends number | bigint ? Config['NumberType'] : DefaultConfig['NumberType']; | ||
FixedArrayMinLength: Config['FixedArrayMinLength'] extends number ? Config['FixedArrayMinLength'] : DefaultConfig['FixedArrayMinLength']; | ||
FixedArrayMaxLength: Config['FixedArrayMaxLength'] extends number ? Config['FixedArrayMaxLength'] : DefaultConfig['FixedArrayMaxLength']; | ||
AddressType: IsUnknown<Config['AddressType']> extends true ? DefaultConfig['AddressType'] : Config['AddressType']; | ||
BytesType: IsUnknown<Config['BytesType']> extends true ? DefaultConfig['BytesType'] : Config['BytesType']; | ||
IntType: IsUnknown<Config['IntType']> extends true ? DefaultConfig['IntType'] : Config['IntType']; | ||
} |
/** | ||
* Merges two types into new type | ||
* Checks if {@link T} is `unknown` | ||
* | ||
* @param T - Type to check | ||
* @returns `true` if `T` is `unknown`, otherwise `false` | ||
* | ||
* @example | ||
* type Result = IsUnknown<unknown> | ||
*/ | ||
export declare type IsUnknown<T> = unknown extends T ? true : false; | ||
/** | ||
* Merges two object types into new type | ||
* | ||
* @param Object1 - Object to merge into | ||
@@ -5,0 +15,0 @@ * @param Object2 - Object to merge and override keys from {@link Object1} |
@@ -1,2 +0,2 @@ | ||
import { Abi, AbiEvent, AbiFunction, AbiParameter, AbiStateMutability, AbiType, Address, SolidityAddress, SolidityArray, SolidityBool, SolidityBytes, SolidityFixedArrayRange, SolidityFixedArraySizeLookup, SolidityFunction, SolidityInt, SolidityString, SolidityTuple, TypedData, TypedDataParameter, TypedDataType } from './abi'; | ||
import { Abi, AbiEvent, AbiFunction, AbiParameter, AbiStateMutability, AbiType, SolidityAddress, SolidityArray, SolidityBool, SolidityBytes, SolidityFixedArrayRange, SolidityFixedArraySizeLookup, SolidityFunction, SolidityInt, SolidityString, SolidityTuple, TypedData, TypedDataParameter, TypedDataType } from './abi'; | ||
import { ResolvedConfig } from './config'; | ||
@@ -14,11 +14,11 @@ import { Merge, Tuple } from './types'; | ||
declare type PrimitiveTypeLookup = { | ||
[_ in SolidityAddress]: Address; | ||
[_ in SolidityAddress]: ResolvedConfig['AddressType']; | ||
} & { | ||
[_ in SolidityBool]: boolean; | ||
} & { | ||
[_ in SolidityBytes]: string | ArrayLike<number>; | ||
[_ in SolidityBytes]: ResolvedConfig['BytesType']; | ||
} & { | ||
[_ in SolidityFunction]: `${Address}${string}`; | ||
[_ in SolidityFunction]: `${ResolvedConfig['AddressType']}${string}`; | ||
} & { | ||
[_ in SolidityInt]: ResolvedConfig['NumberType']; | ||
[_ in SolidityInt]: ResolvedConfig['IntType']; | ||
} & { | ||
@@ -25,0 +25,0 @@ [_ in SolidityString]: string; |
@@ -5,3 +5,3 @@ { | ||
"license": "WAGMIT", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -372,8 +372,10 @@ # ABIType | ||
| Option | Type | Default | Description | | ||
| ---------------------------- | ----------------- | ------------------ | -------------------------------------------------------------------------------------------------------- | | ||
| `ArrayMaxDepth` | `number \| false` | `2` | Maximum depth for nested array types (e.g. `string[][]`). When `false`, there is no maximum array depth. | | ||
| `FixedArrayLengthLowerBound` | `number` | `1` | Lower bound for fixed array length | | ||
| `FixedArrayLengthUpperBound` | `number` | `5` | Upper bound for fixed array length | | ||
| `NumberType` | TypeScript type | `number \| bigint` | TypeScript type to use for `int` and `uint` values. | | ||
| Option | Type | Default | Description | | ||
| --------------------- | ----------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------- | | ||
| `AddressType` | `any` | `` `0x${string}` `` | TypeScript type to use for `address` values. | | ||
| `ArrayMaxDepth` | `number \| false` | `2` | Maximum depth for nested array types (e.g. `string[][]`). When `false`, there is no maximum array depth. | | ||
| `BytesType` | `any` | `string \| ArrayLike<number>` | TypeScript type to use for `bytes<M>` values. | | ||
| `FixedArrayMinLength` | `number` | `1` | Lower bound for fixed-length arrays | | ||
| `FixedArrayMaxLength` | `number` | `5` | Upper bound for fixed-length arrays | | ||
| `IntType` | `any` | `number \| bigint` | TypeScript type to use for `int<M>` and `uint<M>` values. | | ||
@@ -385,3 +387,3 @@ Configuration options are customizable using [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html). Just extend the `Config` interface either directly in your code or in a `d.ts` file (e.g. `abi.d.ts`): | ||
export interface Config { | ||
FixedArrayUpperBound: 6 | ||
FixedArrayMaxLength: 6 | ||
} | ||
@@ -392,3 +394,3 @@ } | ||
> **Warning** | ||
> When configuring these options, there are trade-offs. For example, increasing the upper bound on fixed-length arrays 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 large numbers 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. | ||
@@ -395,0 +397,0 @@ ## Support |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33409
420
413