Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abitype

Package Overview
Dependencies
Maintainers
2
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abitype - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

7

dist/abi.d.ts

@@ -26,5 +26,6 @@ import { ResolvedConfig } from './config';

export declare type AbiType = SolidityArray | SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString | SolidityTuple;
export declare type AbiInternalType = AbiType | `address ${string}` | `contract ${string}` | `enum ${string}` | `struct ${string}`;
declare type ResolvedAbiType = ResolvedConfig['StrictAbiType'] extends true ? AbiType : string;
export declare type AbiInternalType = ResolvedAbiType | `address ${string}` | `contract ${string}` | `enum ${string}` | `struct ${string}`;
export declare type AbiParameter = {
type: AbiType;
type: ResolvedAbiType;
name: string;

@@ -34,3 +35,3 @@ /** Representation used by Solidity compiler */

} & ({
type: Exclude<AbiType, SolidityTuple | SolidityArrayWithTuple>;
type: Exclude<ResolvedAbiType, SolidityTuple | SolidityArrayWithTuple>;
} | {

@@ -37,0 +38,0 @@ type: SolidityTuple | SolidityArrayWithTuple;

@@ -20,7 +20,7 @@ import { IsUnknown } from './types';

/** Maximum depth for nested array types (e.g. string[][]) */
ArrayMaxDepth: 2;
ArrayMaxDepth: false;
/** Lower bound for fixed array length */
FixedArrayMinLength: 1;
/** Upper bound for fixed array length */
FixedArrayMaxLength: 5;
FixedArrayMaxLength: 99;
/** TypeScript type to use for `address` values */

@@ -34,2 +34,4 @@ AddressType: `0x${string}`;

IntType: number;
/** When set, validates {@link AbiParameter}'s `type` against {@link AbiType} */
StrictAbiType: false;
}

@@ -47,3 +49,7 @@ /**

* Maximum depth for nested array types (e.g. string[][])
* @default 2
*
* Note: You probably only want to set this to a specific number if parsed types are returning as `unknown`
* and you want to figure out why. If you set this, you should probably also reduce `FixedArrayMaxLength`.
*
* @default false
*/

@@ -58,3 +64,3 @@ ArrayMaxDepth: Config['ArrayMaxDepth'] extends number | false ? Config['ArrayMaxDepth'] : DefaultConfig['ArrayMaxDepth'];

* Upper bound for fixed array length
* @default 5
* @default 99
*/

@@ -82,2 +88,11 @@ FixedArrayMaxLength: Config['FixedArrayMaxLength'] extends number ? Config['FixedArrayMaxLength'] : DefaultConfig['FixedArrayMaxLength'];

IntType: IsUnknown<Config['IntType']> extends true ? DefaultConfig['IntType'] : Config['IntType'];
/**
* When set, validates {@link AbiParameter}'s `type` against {@link AbiType}
*
* Note: You probably only want to set this to `true` if parsed types are returning as `unknown`
* and you want to figure out why.
*
* @default false
*/
StrictAbiType: Config['StrictAbiType'] extends true ? Config['StrictAbiType'] : DefaultConfig['StrictAbiType'];
}

@@ -22,3 +22,3 @@ import { Abi, AbiParameter, AbiStateMutability, AbiType, MBits, SolidityAddress, SolidityArray, SolidityBool, SolidityBytes, SolidityFixedArrayRange, SolidityFixedArraySizeLookup, SolidityFunction, SolidityInt, SolidityString, SolidityTuple, TypedData, TypedDataParameter, TypedDataType } from './abi';

} & {
[_ in SolidityInt]: TAbiType extends `${'u' | ''}int${infer TBits}` ? TBits extends keyof BitsTypeLookup ? BitsTypeLookup[TBits] : never : never;
[_ in SolidityInt]: TAbiType extends `${'u' | ''}int${infer TBits}` ? TBits extends keyof BitsTypeLookup ? BitsTypeLookup[TBits] : 'Error: Unknown bits value.' : `Error: Unknown 'SolidityInt' format.`;
} & {

@@ -50,3 +50,4 @@ [_ in SolidityString]: string;

type: unknown;
}> = TAbiParameter['type'] extends Exclude<AbiType, SolidityTuple | SolidityArray> ? AbiTypeToPrimitiveType<TAbiParameter['type']> : TAbiParameter['type'] extends SolidityTuple ? TAbiParameter extends {
}> = TAbiParameter['type'] extends Exclude<AbiType, SolidityTuple | SolidityArray> ? AbiTypeToPrimitiveType<TAbiParameter['type']> : TAbiParameter extends {
type: SolidityTuple;
components: infer TComponents extends readonly AbiParameter[];

@@ -59,3 +60,3 @@ } ? _HasUnnamedAbiParameter<TComponents> extends true ? readonly [

[Component in TComponents[number] as Component['name']]: AbiParameterToPrimitiveType<Component>;
} : never :
} :
/**

@@ -73,3 +74,3 @@ * First, infer `Head` against a known size type (either fixed-length array value or `""`).

type: Head;
}>>[] : never : unknown;
}>>[] : never : ResolvedConfig['StrictAbiType'] extends true ? TAbiParameter['type'] extends infer TAbiType extends string ? `Error: Unknown type '${TAbiType}'.` : never : unknown;
declare type _HasUnnamedAbiParameter<TAbiParameters extends readonly AbiParameter[]> = TAbiParameters extends readonly [

@@ -76,0 +77,0 @@ infer Head extends AbiParameter,

@@ -5,3 +5,3 @@ {

"license": "WAGMIT",
"version": "0.1.4",
"version": "0.1.5",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -16,3 +16,3 @@ # ABIType

Works great for adding blazing fast [autocomplete](https://twitter.com/awkweb/status/1555678944770367493) and type checking to functions, variables, or your own types ([see examples](/src/examples/examples.ts)). No need to generate types with third-party tools – just use your ABI and let TypeScript do the rest!
Works great for adding blazing fast [autocomplete](https://twitter.com/awkweb/status/1555678944770367493) and type checking to functions, variables, or your own types ([see examples](/src/examples/)). No need to generate types with third-party tools – just use your ABI and let TypeScript do the rest!

@@ -357,3 +357,3 @@ ## Installation

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. fixed array length). To do this, the following configuration options are available:
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:

@@ -363,8 +363,9 @@ | 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. |
| `ArrayMaxDepth` | `number \| false` | `false` | Maximum depth for nested array types (e.g. `string[][]`). When `false`, there is no maximum array depth. |
| `BigIntType` | `any` | `bigint` | TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`. |
| `BytesType` | `any` | `` `0x${string}` `` | 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 |
| `FixedArrayMaxLength` | `number` | `99` | Upper bound for fixed-length arrays |
| `IntType` | `any` | `number` | TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`. |
| `StrictAbiType` | `boolean` | `false` | When set, validates `AbiParameter`'s `type` against `AbiType`. |

@@ -376,3 +377,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 {
FixedArrayMaxLength: 6
BigIntType: MyCustomBigIntType
}

@@ -383,3 +384,3 @@ }

> **Warning**
> 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.
> 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.

@@ -386,0 +387,0 @@ ## Support

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc