Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDoge committed Oct 15, 2024
1 parent aedfcb6 commit a8eb52d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nomadshiba/typed-contracts",
"version": "0.2.5",
"version": "0.2.6",
"exports": {
"./abi": "./types/abi.ts",
"./ethers6": "./types/ethers6/exports.ts"
Expand Down
27 changes: 11 additions & 16 deletions types/abi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type Abi = readonly Abi.Item[]

/**
* `Abi` represents the structure of an Ethereum contract's Application Binary Interface (ABI),
* which defines the functions, events, and errors that can be interacted with in the contract.
Expand Down Expand Up @@ -30,18 +32,12 @@
* ];
* ```
*/
export type Abi = readonly Abi.Item[]

export namespace Abi {
/**
* `Abi.Item` represents a single item in an ABI, which can be either a function, event, or error.
*/
export type Item = FunctionItem | EventItem | ErrorItem

/**
* `Abi.FunctionItem` defines a function in a contract's ABI, including its name, inputs, outputs,
* and state mutability.
*/
export type FunctionItem =
| {
type: "function"
Expand All @@ -57,9 +53,8 @@ export namespace Abi {
}

/**
* `Abi.FunctionItem.Input` and `Abi.FunctionItem.Output` represent the arguments and return values of a function.
* They both share the same structure, defined by `Abi.Argument`, which includes the argument's type, name,
* and internal type used in Solidity.
* `Abi.FunctionItem` defines a function in a contract's ABI, including its name, inputs, outputs,
* and state mutability.
*/
export namespace FunctionItem {
export type Input = Argument & {}
Expand All @@ -81,17 +76,17 @@ export namespace Abi {
| "payable"
}

/**
* `Abi.EventItem` defines an event in the contract's ABI, which can be emitted by the contract.
* Each event has a name, inputs, and an `anonymous` flag indicating whether the event is anonymous.
*/
export type EventItem = {
type: "event"
name: string
inputs: readonly EventItem.Input[]
anonymous: boolean
}

/**
* `Abi.EventItem` defines an event in the contract's ABI, which can be emitted by the contract.
* Each event has a name, inputs, and an `anonymous` flag indicating whether the event is anonymous.
*/
export namespace EventItem {
/**
* `Abi.EventItem.Input` represents an argument to an event, with an additional `indexed` flag
Expand All @@ -100,15 +95,15 @@ export namespace Abi {
export type Input = Argument & { indexed: boolean }
}

/**
* `Abi.ErrorItem` defines an error in the contract's ABI, which can be used for custom error handling.
*/
export type ErrorItem = {
type: "error"
name: string
inputs: readonly ErrorItem.Input[]
}

/**
* `Abi.ErrorItem` defines an error in the contract's ABI, which can be used for custom error handling.
*/
export namespace ErrorItem {
/**
* `Abi.ErrorItem.Input` represents an argument to an error.
Expand Down
2 changes: 1 addition & 1 deletion types/ethers6/typedContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type ProcessAbi<
* `Contract` from ethers.js and ensures that function inputs and outputs are correctly
* typed according to the ABI.
*
* @template TAbi - The ABI type representing the structure of the contract.
* @template {Abi} TAbi - The ABI type representing the structure of the contract.
*
* Each function in the contract is dynamically typed based on its input and output
* types as specified in the ABI. Functions with no outputs return a `ContractTransaction`,
Expand Down

0 comments on commit a8eb52d

Please sign in to comment.