Skip to content

Commit

Permalink
♻️ chore(ethers): Migrate ethers to jsdoc (#574)
Browse files Browse the repository at this point in the history
## Description

Migrate ethers.js to jsdoc

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:

---------

Co-authored-by: Will Cory <[email protected]>
  • Loading branch information
roninjin10 and Will Cory authored Oct 16, 2023
1 parent a32a196 commit 2bca006
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 80 deletions.
87 changes: 35 additions & 52 deletions docs/reference/ethers/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

### Type Aliases

- [BaseContractMethod](/reference/ethers/modules.md#basecontractmethod)
- [ContractMethodArgs](/reference/ethers/modules.md#contractmethodargs)
- [TypesafeEthersContract](/reference/ethers/modules.md#typesafeetherscontract)
- [TypesafeEthersContractConstructor](/reference/ethers/modules.md#typesafeetherscontractconstructor)
- [TypesafeEthersInterfaceConstructor](/reference/ethers/modules.md#typesafeethersinterfaceconstructor)

### Variables

Expand All @@ -17,99 +16,83 @@

## Type Aliases

### BaseContractMethod
### TypesafeEthersContractConstructor

Ƭ **BaseContractMethod**<`TArguments`, `TReturnType`, `TExtendedReturnType`\>: `Object`
Ƭ **TypesafeEthersContractConstructor**: <TAbi\>(`target`: `string` \| `Addressable`, `abi`: `TAbi` \| { `fragments`: `TAbi` }, `runner?`: ``null`` \| `ContractRunner`, `_deployTx?`: ``null`` \| `TransactionResponse`) => `BaseContract` & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0]\> } & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], ContractTransactionResponse\> } & { `queryFilter`: <TContractEventName\>(`event`: `TContractEventName`, `fromBlock?`: `BlockTag`, `toBlock?`: `BlockTag`) => `Promise`<`TContractEventName` extends `ExtractAbiEventNames`<`TAbi`\> ? `ExtractAbiEvent`<`TAbi`, `TContractEventName`\> : `EventLog` \| `Log`[]\> } & `Contract`

#### Type parameters
#### Type declaration

| Name | Type |
| :------ | :------ |
| `TArguments` | extends `ReadonlyArray`<`any`\> = `ReadonlyArray`<`any`\> |
| `TReturnType` | `any` |
| `TExtendedReturnType` | extends `TReturnType` \| `ContractTransactionResponse` = `ContractTransactionResponse` |
• **new TypesafeEthersContractConstructor**<`TAbi`\>(`target`, `abi`, `runner?`, `_deployTx?`): `BaseContract` & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0]\> } & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], ContractTransactionResponse\> } & { `queryFilter`: <TContractEventName\>(`event`: `TContractEventName`, `fromBlock?`: `BlockTag`, `toBlock?`: `BlockTag`) => `Promise`<`TContractEventName` extends `ExtractAbiEventNames`<`TAbi`\> ? `ExtractAbiEvent`<`TAbi`, `TContractEventName`\> : `EventLog` \| `Log`[]\> } & `Contract`

#### Call signature
##### Type parameters

▸ (`...args`): `Promise`<`TReturnType` \| `TExtendedReturnType`\>
| Name | Type |
| :------ | :------ |
| `TAbi` | extends `Abi` |

##### Parameters

| Name | Type |
| :------ | :------ |
| `...args` | [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\> |
| `target` | `string` \| `Addressable` |
| `abi` | `TAbi` \| { `fragments`: `TAbi` } |
| `runner?` | ``null`` \| `ContractRunner` |
| `_deployTx?` | ``null`` \| `TransactionResponse` |

##### Returns

`Promise`<`TReturnType` \| `TExtendedReturnType`\>

#### Type declaration

| Name | Type |
| :------ | :------ |
| `_contract` | `BaseContract` |
| `_key` | `string` |
| `estimateGas` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `Promise`<`bigint`\> |
| `fragment` | `FunctionFragment` |
| `getFragment` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `FunctionFragment` |
| `name` | `string` |
| `populateTransaction` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `Promise`<`ContractTransaction`\> |
| `send` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `Promise`<`ContractTransactionResponse`\> |
| `staticCall` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `Promise`<`TReturnType`\> |
| `staticCallResult` | (...`args`: [`ContractMethodArgs`](/reference/ethers/modules.md#contractmethodargs)<`TArguments`\>) => `Promise`<`Result`\> |
`BaseContract` & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0]\> } & { [TFunctionName in string]: BaseContractMethod<{ [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["inputs"][K], AbiParameterKind\> }[K] } & any[], { [K in string \| number \| symbol]: { [K in string \| number \| symbol]: AbiParameterToPrimitiveType<Extract<Extract<TAbi[number], Object\>, Object\>["outputs"][K], AbiParameterKind\> }[K] }[0], ContractTransactionResponse\> } & { `queryFilter`: <TContractEventName\>(`event`: `TContractEventName`, `fromBlock?`: `BlockTag`, `toBlock?`: `BlockTag`) => `Promise`<`TContractEventName` extends `ExtractAbiEventNames`<`TAbi`\> ? `ExtractAbiEvent`<`TAbi`, `TContractEventName`\> : `EventLog` \| `Log`[]\> } & `Contract`

#### Defined in

[BaseContractMethod.ts:10](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/BaseContractMethod.ts#L10)
[ethers/src/Contract.d.ts:21](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.d.ts#L21)

___

### ContractMethodArgs
### TypesafeEthersInterfaceConstructor

Ƭ **ContractMethodArgs**<`A`\>: [...A, `Overrides`] \| `A`
Ƭ **TypesafeEthersInterfaceConstructor**: <TAbi\>(`abi`: `InterfaceAbi`) => `Omit`<`Interface`, ``"fragments"``\> & { `fragments`: `TAbi` }

#### Type parameters

| Name | Type |
| :------ | :------ |
| `A` | extends `ReadonlyArray`<`any`\> |

#### Defined in
#### Type declaration

[ContractMethodArgs.ts:3](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/ContractMethodArgs.ts#L3)
**new TypesafeEthersInterfaceConstructor**<`TAbi`\>(`abi`): `Omit`<`Interface`, ``"fragments"``\> & { `fragments`: `TAbi` }

___
##### Type parameters

### TypesafeEthersContract

Ƭ **TypesafeEthersContract**<`TAbi`\>: `BaseContract` & { [TFunctionName in ExtractAbiFunctionNames<TAbi, "pure" \| "view"\>]: BaseContractMethod<AbiParametersToPrimitiveTypes<ExtractAbiFunction<TAbi, TFunctionName\>["inputs"]\> & any[], AbiParametersToPrimitiveTypes<ExtractAbiFunction<TAbi, TFunctionName\>["outputs"]\>[0], AbiParametersToPrimitiveTypes<ExtractAbiFunction<TAbi, TFunctionName\>["outputs"]\>[0]\> } & { [TFunctionName in ExtractAbiFunctionNames<TAbi, "nonpayable" \| "payable"\>]: BaseContractMethod<AbiParametersToPrimitiveTypes<ExtractAbiFunction<TAbi, TFunctionName\>["inputs"]\> & any[], AbiParametersToPrimitiveTypes<ExtractAbiFunction<TAbi, TFunctionName\>["outputs"]\>[0], ContractTransactionResponse\> } & { `queryFilter`: <TContractEventName\>(`event`: `TContractEventName`, `fromBlock?`: `BlockTag`, `toBlock?`: `BlockTag`) => `Promise`<`TContractEventName` extends `ExtractAbiEventNames`<`TAbi`\> ? `ExtractAbiEvent`<`TAbi`, `TContractEventName`\> : `EventLog` \| `Log`[]\> }
| Name | Type |
| :------ | :------ |
| `TAbi` | extends `Abi` |

#### Type parameters
##### Parameters

| Name | Type |
| :------ | :------ |
| `TAbi` | extends `Abi` |
| `abi` | `InterfaceAbi` |

##### Returns

`Omit`<`Interface`, ``"fragments"``\> & { `fragments`: `TAbi` }

#### Defined in

[TypesafeEthersContract.ts:19](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/TypesafeEthersContract.ts#L19)
[ethers/src/Contract.d.ts:12](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.d.ts#L12)

## Variables

### Contract

`Const` **Contract**: `TypesafeEthersContractConstructor`
`Const` **Contract**: [`TypesafeEthersContractConstructor`](/reference/ethers/modules.md#typesafeetherscontractconstructor)

#### Defined in

[Contract.ts:30](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.ts#L30)
[ethers/src/Contract.d.ts:30](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.d.ts#L30)

___

### Interface

`Const` **Interface**: `TypesafeEthersInterfaceConstructor`
`Const` **Interface**: [`TypesafeEthersInterfaceConstructor`](/reference/ethers/modules.md#typesafeethersinterfaceconstructor)

#### Defined in

[Contract.ts:19](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.ts#L19)
[ethers/src/Contract.d.ts:19](https://github.com/evmts/evmts-monorepo/blob/main/ethers/src/Contract.d.ts#L19)
2 changes: 1 addition & 1 deletion ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"module": "src/index.js",
"types": "types/index.d.ts",
"files": [
"dist",
Expand Down
8 changes: 4 additions & 4 deletions ethers/src/Contract.ts → ethers/src/Contract.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { TypesafeEthersContract } from './TypesafeEthersContract.js'
import type { Abi } from 'abitype'
import {
type Addressable,
Contract as EthersContract,
type Contract as EthersContract,
type ContractRunner,
Interface as EthersInterface,
type Interface as EthersInterface,
type InterfaceAbi,
type TransactionResponse,
} from 'ethers'
Expand All @@ -16,7 +16,7 @@ type TypesafeEthersInterfaceConstructor = {
> & { fragments: TAbi }
}

export const Interface = EthersInterface as TypesafeEthersInterfaceConstructor
export const Interface: TypesafeEthersInterfaceConstructor

type TypesafeEthersContractConstructor = {
new <TAbi extends Abi>(
Expand All @@ -27,4 +27,4 @@ type TypesafeEthersContractConstructor = {
): TypesafeEthersContract<TAbi> & EthersContract
}

export const Contract = EthersContract as TypesafeEthersContractConstructor
export const Contract: TypesafeEthersContractConstructor
20 changes: 20 additions & 0 deletions ethers/src/Contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Contract as EthersContract,
Interface as EthersInterface,
} from 'ethers'

/**
* Typesafe version of the ethers Interface class.
*/
export const Interface =
/** @type {import('./Contract.js').TypesafeEthersInterfaceConstructor} */ (
EthersInterface
)

/**
* Typesafe version of the ethers Contract class.
*/
export const Contract =
/** @type {import('./Contract.js').TypesafeEthersContractConstructor} */ (
EthersContract
)
File renamed without changes.
1 change: 1 addition & 0 deletions ethers/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Contract.js'
4 changes: 2 additions & 2 deletions ethers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"rootDir": "src",
"composite": true,
"outDir": "types",
"skipLibCheck": true,
"skipLibCheck": true
},
"include": [
"src",
"src/**/*.json"
]
}
}
2 changes: 1 addition & 1 deletion ethers/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'tsup'

export default defineConfig({
name: packageJson.name,
entry: ['src/index.ts'],
entry: ['src/index.js'],
outDir: 'dist',
format: ['esm', 'cjs'],
splitting: false,
Expand Down
2 changes: 1 addition & 1 deletion ethers/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://typedoc.org/schema.json",
"out": "../docs/reference/ethers",
"entryPoints": ["./src/index.ts"],
"entryPoints": ["./src/index.js"],
"publicPath": "/reference/ethers/",
"plugin": ["typedoc-plugin-markdown"],
"gitRevision": "main"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

1 comment on commit 2bca006

@vercel
Copy link

@vercel vercel bot commented on 2bca006 Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deployment failed with the following error:

Resource is limited - try again in 5 minutes (more than 100, code: "api-deployments-free-per-day").

Please sign in to comment.