From 82f7efb00f7fbb5b4d685d3c1b917c4b810678cc Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 25 Apr 2024 13:22:26 +0100 Subject: [PATCH 1/3] Fix docgen warnings, scripts, readme links --- README.md | 2 +- docgen/templates.ts | 2 +- docs/README.md | 1 + docs/SUMMARY.md | 44 ++++ docs/contracts/SUMMARY.md | 29 --- docs/contracts/mocks/README.md | 1 + docs/js/classes/hardhat_setup.Networks.md | 18 +- .../interfaces/src.DeployContractOptions.md | 200 ++++++++++++++++++ docs/js/modules/hardhat_setup.md | 39 +++- docs/js/modules/src.md | 138 ++++++++---- hardhat-setup/networks.ts | 12 +- package.json | 6 +- src/utils.ts | 84 +++++--- 13 files changed, 459 insertions(+), 117 deletions(-) create mode 100644 docs/README.md create mode 100644 docs/SUMMARY.md delete mode 100644 docs/contracts/SUMMARY.md create mode 100644 docs/contracts/mocks/README.md create mode 100644 docs/js/interfaces/src.DeployContractOptions.md diff --git a/README.md b/README.md index e3650fb..4f879e4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This repository is a comprehensive toolkit designed to streamline and optimize t - **[Configuration and Management](https://github.com/1inch/solidity-utils/blob/master/docs/js/modules/hardhat_setup.md)**: Tools for setting up Hardhat network configurations and managing project settings efficiently. -- **[Solidity Contracts and Libraries](https://github.com/1inch/solidity-utils/blob/master/docs/contracts/SUMMARY.md)**: Frequently used smart contracts, libraries, and interfaces aimed at providing reusable code for common use cases, alongside optimizations to improve contract efficiency. +- **[Solidity Contracts and Libraries](https://github.com/1inch/solidity-utils/blob/master/docs/SUMMARY.md)**: Frequently used smart contracts, libraries, and interfaces aimed at providing reusable code for common use cases, alongside optimizations to improve contract efficiency. ## Contributing diff --git a/docgen/templates.ts b/docgen/templates.ts index 394513e..c7d4dbc 100644 --- a/docgen/templates.ts +++ b/docgen/templates.ts @@ -7,4 +7,4 @@ import path from 'path'; */ export function oneInchTemplates(): string { return path.normalize(path.join(__dirname, '../../docgen/templates')); -} \ No newline at end of file +} diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..9b69328 --- /dev/null +++ b/docs/README.md @@ -0,0 +1 @@ +# docs diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md new file mode 100644 index 0000000..15af190 --- /dev/null +++ b/docs/SUMMARY.md @@ -0,0 +1,44 @@ +# Table of contents + +* [Main Readme](README.md) +* [contracts](contracts/README.md) + * [interfaces](contracts/interfaces/README.md) + * [ICreate3Deployer](contracts/interfaces/ICreate3Deployer.md) + * [IDaiLikePermit](contracts/interfaces/IDaiLikePermit.md) + * [IERC20MetadataUppercase](contracts/interfaces/IERC20MetadataUppercase.md) + * [IERC7597Permit](contracts/interfaces/IERC7597Permit.md) + * [IPermit2](contracts/interfaces/IPermit2.md) + * [IWETH](contracts/interfaces/IWETH.md) + * [libraries](contracts/libraries/README.md) + * [AddressArray](contracts/libraries/AddressArray.md) + * [AddressLib](contracts/libraries/AddressLib.md) + * [AddressSet](contracts/libraries/AddressSet.md) + * [BySigTraits](contracts/libraries/BySigTraits.md) + * [BytesMemory](contracts/libraries/BytesMemory.md) + * [BytesStorage](contracts/libraries/BytesStorage.md) + * [ECDSA](contracts/libraries/ECDSA.md) + * [RevertReasonForwarder](contracts/libraries/RevertReasonForwarder.md) + * [RevertReasonParser](contracts/libraries/RevertReasonParser.md) + * [SafeERC20](contracts/libraries/SafeERC20.md) + * [StringUtil](contracts/libraries/StringUtil.md) + * [UniERC20](contracts/libraries/UniERC20.md) + * [mixins](contracts/mixins/README.md) + * [BySig](contracts/mixins/BySig.md) + * [EthReceiver](contracts/mixins/EthReceiver.md) + * [OnlyWethReceiver](contracts/mixins/OnlyWethReceiver.md) + * [PermitAndCall](contracts/mixins/PermitAndCall.md) + * [SelfdestructEthSender](contracts/mixins/SelfdestructEthSender.md) + * [mocks](contracts/mocks/README.md) + * [ERC20PermitMock](contracts/mocks/ERC20PermitMock.md) + * [SelfdestructEthSenderMock](contracts/mocks/SelfdestructEthSenderMock.md) + * [TokenCustomDecimalsMock](contracts/mocks/TokenCustomDecimalsMock.md) + * [TokenMock](contracts/mocks/TokenMock.md) +* [js](js/README.md) + * [classes](js/classes/README.md) + * [hardhat_setup.Networks](js/classes/hardhat_setup.Networks.md) + * [interfaces](js/interfaces/README.md) + * [src.DeployContractOptions](js/interfaces/src.DeployContractOptions.md) + * [modules](js/modules/README.md) + * [hardhat_setup](js/modules/hardhat_setup.md) + * [src](js/modules/src.md) + * [modules](js/modules.md) \ No newline at end of file diff --git a/docs/contracts/SUMMARY.md b/docs/contracts/SUMMARY.md deleted file mode 100644 index fb430b1..0000000 --- a/docs/contracts/SUMMARY.md +++ /dev/null @@ -1,29 +0,0 @@ -# Table of contents - -* [Main Readme](README.md) -* [interfaces](interfaces/README.md) - * [ICreate3Deployer](interfaces/ICreate3Deployer.md) - * [IDaiLikePermit](interfaces/IDaiLikePermit.md) - * [IERC20MetadataUppercase](interfaces/IERC20MetadataUppercase.md) - * [IERC7597Permit](interfaces/IERC7597Permit.md) - * [IPermit2](interfaces/IPermit2.md) - * [IWETH](interfaces/IWETH.md) -* [libraries](libraries/README.md) - * [AddressArray](libraries/AddressArray.md) - * [AddressLib](libraries/AddressLib.md) - * [AddressSet](libraries/AddressSet.md) - * [BySigTraits](libraries/BySigTraits.md) - * [BytesMemory](libraries/BytesMemory.md) - * [BytesStorage](libraries/BytesStorage.md) - * [ECDSA](libraries/ECDSA.md) - * [RevertReasonForwarder](libraries/RevertReasonForwarder.md) - * [RevertReasonParser](libraries/RevertReasonParser.md) - * [SafeERC20](libraries/SafeERC20.md) - * [StringUtil](libraries/StringUtil.md) - * [UniERC20](libraries/UniERC20.md) -* [mixins](mixins/README.md) - * [BySig](mixins/BySig.md) - * [EthReceiver](mixins/EthReceiver.md) - * [OnlyWethReceiver](mixins/OnlyWethReceiver.md) - * [PermitAndCall](mixins/PermitAndCall.md) - * [SelfdestructEthSender](mixins/SelfdestructEthSender.md) \ No newline at end of file diff --git a/docs/contracts/mocks/README.md b/docs/contracts/mocks/README.md new file mode 100644 index 0000000..61a7223 --- /dev/null +++ b/docs/contracts/mocks/README.md @@ -0,0 +1 @@ +# mocks diff --git a/docs/js/classes/hardhat_setup.Networks.md b/docs/js/classes/hardhat_setup.Networks.md index 644f2be..77c22f6 100644 --- a/docs/js/classes/hardhat_setup.Networks.md +++ b/docs/js/classes/hardhat_setup.Networks.md @@ -47,17 +47,17 @@ See the [README](https://github.com/1inch/solidity-utils/tree/master/hardhat-set #### Defined in -[hardhat-setup/networks.ts:67](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L67) +[hardhat-setup/networks.ts:75](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L75) ## Properties ### etherscan -• **etherscan**: `Etherscan` +• **etherscan**: [`Etherscan`](../modules/hardhat_setup.md#etherscan) #### Defined in -[hardhat-setup/networks.ts:65](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L65) +[hardhat-setup/networks.ts:73](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L73) ___ @@ -67,7 +67,7 @@ ___ #### Defined in -[hardhat-setup/networks.ts:64](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L64) +[hardhat-setup/networks.ts:72](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L72) ## Methods @@ -93,7 +93,7 @@ ___ #### Defined in -[hardhat-setup/networks.ts:88](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L88) +[hardhat-setup/networks.ts:96](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L96) ___ @@ -107,12 +107,12 @@ ___ | Name | Type | | :------ | :------ | -| `etherscan` | `Etherscan` | +| `etherscan` | [`Etherscan`](../modules/hardhat_setup.md#etherscan) | | `networks` | `NetworksUserConfig` | #### Defined in -[hardhat-setup/networks.ts:131](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L131) +[hardhat-setup/networks.ts:139](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L139) ___ @@ -139,7 +139,7 @@ ___ #### Defined in -[hardhat-setup/networks.ts:105](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L105) +[hardhat-setup/networks.ts:113](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L113) ___ @@ -165,4 +165,4 @@ ___ #### Defined in -[hardhat-setup/networks.ts:112](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L112) +[hardhat-setup/networks.ts:120](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L120) diff --git a/docs/js/interfaces/src.DeployContractOptions.md b/docs/js/interfaces/src.DeployContractOptions.md new file mode 100644 index 0000000..c6acf6d --- /dev/null +++ b/docs/js/interfaces/src.DeployContractOptions.md @@ -0,0 +1,200 @@ +[@1inch/solidity-utils](../README.md) / [Modules](../modules.md) / [src](../modules/src.md) / DeployContractOptions + +# Interface: DeployContractOptions + +[src](../modules/src.md).DeployContractOptions + +**`Notice`** + +Options for deployment methods. + +**`Param`** + +Name of the contract to deploy. + +**`Param`** + +Arguments for the contract's constructor. + +**`Param`** + +Deployment facilitator object from Hardhat. + +**`Param`** + +Wallet deploying the contract. + +**`Param`** + +Optional custom name for deployment. + +**`Param`** + +Skips Etherscan verification if true. + +**`Param`** + +Avoids redeployment if contract already deployed. + +**`Param`** + +Gas strategy option. + +**`Param`** + +Gas strategy option. + +**`Param`** + +Gas strategy option. + +**`Param`** + +Toggles deployment logging. + +**`Param`** + +Number of confirmations to wait based on network. Ussually it's need for waiting before Etherscan verification. + +## Table of contents + +### Properties + +- [constructorArgs](src.DeployContractOptions.md#constructorargs) +- [contractName](src.DeployContractOptions.md#contractname) +- [deployer](src.DeployContractOptions.md#deployer) +- [deploymentName](src.DeployContractOptions.md#deploymentname) +- [deployments](src.DeployContractOptions.md#deployments) +- [gasPrice](src.DeployContractOptions.md#gasprice) +- [log](src.DeployContractOptions.md#log) +- [maxFeePerGas](src.DeployContractOptions.md#maxfeepergas) +- [maxPriorityFeePerGas](src.DeployContractOptions.md#maxpriorityfeepergas) +- [skipIfAlreadyDeployed](src.DeployContractOptions.md#skipifalreadydeployed) +- [skipVerify](src.DeployContractOptions.md#skipverify) +- [waitConfirmations](src.DeployContractOptions.md#waitconfirmations) + +## Properties + +### constructorArgs + +• `Optional` **constructorArgs**: `any`[] + +#### Defined in + +[src/utils.ts:29](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L29) + +___ + +### contractName + +• **contractName**: `string` + +#### Defined in + +[src/utils.ts:27](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L27) + +___ + +### deployer + +• **deployer**: `string` + +#### Defined in + +[src/utils.ts:31](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L31) + +___ + +### deploymentName + +• `Optional` **deploymentName**: `string` + +#### Defined in + +[src/utils.ts:32](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L32) + +___ + +### deployments + +• **deployments**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `deploy` | (`name`: `string`, `options`: `DeployOptions`) => `Promise`\<`DeployResult`\> | + +#### Defined in + +[src/utils.ts:30](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L30) + +___ + +### gasPrice + +• `Optional` **gasPrice**: `bigint` + +#### Defined in + +[src/utils.ts:35](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L35) + +___ + +### log + +• `Optional` **log**: `boolean` + +#### Defined in + +[src/utils.ts:38](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L38) + +___ + +### maxFeePerGas + +• `Optional` **maxFeePerGas**: `bigint` + +#### Defined in + +[src/utils.ts:37](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L37) + +___ + +### maxPriorityFeePerGas + +• `Optional` **maxPriorityFeePerGas**: `bigint` + +#### Defined in + +[src/utils.ts:36](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L36) + +___ + +### skipIfAlreadyDeployed + +• `Optional` **skipIfAlreadyDeployed**: `boolean` + +#### Defined in + +[src/utils.ts:34](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L34) + +___ + +### skipVerify + +• `Optional` **skipVerify**: `boolean` + +#### Defined in + +[src/utils.ts:33](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L33) + +___ + +### waitConfirmations + +• `Optional` **waitConfirmations**: `number` + +#### Defined in + +[src/utils.ts:39](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L39) diff --git a/docs/js/modules/hardhat_setup.md b/docs/js/modules/hardhat_setup.md index a7e92be..652fe0c 100644 --- a/docs/js/modules/hardhat_setup.md +++ b/docs/js/modules/hardhat_setup.md @@ -8,6 +8,10 @@ - [Networks](../classes/hardhat_setup.Networks.md) +### Type Aliases + +- [Etherscan](hardhat_setup.md#etherscan) + ### Functions - [getNetwork](hardhat_setup.md#getnetwork) @@ -16,6 +20,35 @@ ## Hardhat-Setup +### Etherscan + +Ƭ **Etherscan**: `Object` + +**`Notice`** + +Configuration type for managing Etherscan integration in Hardhat setups. + +**`Param`** + +Dictionary of API keys for accessing Etherscan, indexed by network name. + +**`Param`** + +Array of custom blockchain network configurations. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `apiKey` | \{ `[key: string]`: `string`; } | +| `customChains` | `ChainConfig`[] | + +#### Defined in + +[hardhat-setup/networks.ts:11](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L11) + +___ + ### getNetwork ▸ **getNetwork**(): `string` @@ -32,7 +65,7 @@ A helper method to get the network name from the command line arguments. #### Defined in -[hardhat-setup/networks.ts:13](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L13) +[hardhat-setup/networks.ts:21](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L21) ___ @@ -63,7 +96,7 @@ A helper method to parse RPC configuration strings. Checks that the string is in #### Defined in -[hardhat-setup/networks.ts:24](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L24) +[hardhat-setup/networks.ts:32](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L32) ___ @@ -88,4 +121,4 @@ A helper method to reset the Hardhat network to the local network or to a fork. #### Defined in -[hardhat-setup/networks.ts:38](https://github.com/1inch/solidity-utils/blob/5a4227e/hardhat-setup/networks.ts#L38) +[hardhat-setup/networks.ts:46](https://github.com/1inch/solidity-utils/blob/cdb7d95/hardhat-setup/networks.ts#L46) diff --git a/docs/js/modules/src.md b/docs/js/modules/src.md index 75a9a44..fba0a34 100644 --- a/docs/js/modules/src.md +++ b/docs/js/modules/src.md @@ -4,6 +4,15 @@ ## Table of contents +### Interfaces + +- [DeployContractOptions](../interfaces/src.DeployContractOptions.md) + +### Type Aliases + +- [Token](src.md#token) +- [TrackReceivedTokenAndTxResult](src.md#trackreceivedtokenandtxresult) + ### Variables - [DaiLikePermit](src.md#dailikepermit) @@ -52,7 +61,7 @@ #### Defined in -[src/permit.ts:30](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L30) +[src/permit.ts:30](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L30) ___ @@ -62,7 +71,7 @@ ___ #### Defined in -[src/permit.ts:15](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L15) +[src/permit.ts:15](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L15) ___ @@ -72,7 +81,7 @@ ___ #### Defined in -[src/permit.ts:22](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L22) +[src/permit.ts:22](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L22) ___ @@ -82,7 +91,7 @@ ___ #### Defined in -[src/permit.ts:11](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L11) +[src/permit.ts:11](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L11) ___ @@ -107,7 +116,7 @@ ___ #### Defined in -[src/prelude.ts:4](https://github.com/1inch/solidity-utils/blob/5a4227e/src/prelude.ts#L4) +[src/prelude.ts:4](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/prelude.ts#L4) ___ @@ -117,7 +126,7 @@ ___ #### Defined in -[src/permit.ts:12](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L12) +[src/permit.ts:12](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L12) ___ @@ -127,7 +136,7 @@ ___ #### Defined in -[src/permit.ts:13](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L13) +[src/permit.ts:13](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L13) ## expect @@ -159,7 +168,7 @@ or if the actual value deviates from the expected by more than the specified rel #### Defined in -[src/expect.ts:15](https://github.com/1inch/solidity-utils/blob/5a4227e/src/expect.ts#L15) +[src/expect.ts:15](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/expect.ts#L15) ## permit @@ -207,7 +216,7 @@ Constructs structured data for EIP-2612 permit function, including types, domain #### Defined in -[src/permit.ts:97](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L97) +[src/permit.ts:97](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L97) ___ @@ -257,7 +266,7 @@ Prepares structured data similar to the Dai permit function, including types, do #### Defined in -[src/permit.ts:129](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L129) +[src/permit.ts:129](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L129) ___ @@ -286,7 +295,7 @@ Compresses a permit function call to a shorter format based on its type. #### Defined in -[src/permit.ts:352](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L352) +[src/permit.ts:352](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L352) ___ @@ -312,7 +321,7 @@ Trims the method selector from transaction data, removing the first 8 characters #### Defined in -[src/permit.ts:58](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L58) +[src/permit.ts:58](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L58) ___ @@ -341,7 +350,7 @@ Decompresses a compressed permit function call back to its original full format. #### Defined in -[src/permit.ts:401](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L401) +[src/permit.ts:401](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L401) ___ @@ -370,7 +379,7 @@ Generates a domain separator for EIP-712 structured data using the provided para #### Defined in -[src/permit.ts:72](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L72) +[src/permit.ts:72](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L72) ___ @@ -403,7 +412,7 @@ Generates a permit signature for ERC20 tokens with EIP-2612 standard. #### Defined in -[src/permit.ts:172](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L172) +[src/permit.ts:172](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L172) ___ @@ -436,7 +445,7 @@ Creates a permit for spending tokens on Permit2 standard contracts. #### Defined in -[src/permit.ts:214](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L214) +[src/permit.ts:214](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L214) ___ @@ -469,7 +478,7 @@ Generates a Dai-like permit signature for tokens. #### Defined in -[src/permit.ts:256](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L256) +[src/permit.ts:256](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L256) ___ @@ -502,7 +511,7 @@ Generates a ERC-7597 permit signature for tokens. #### Defined in -[src/permit.ts:301](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L301) +[src/permit.ts:301](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L301) ___ @@ -522,7 +531,7 @@ Ensures contract code is set for a given address and returns a contract instance #### Defined in -[src/permit.ts:152](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L152) +[src/permit.ts:152](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L152) ___ @@ -548,7 +557,7 @@ Removes the '0x' prefix from a string. If no '0x' prefix is found, returns the o #### Defined in -[src/permit.ts:44](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L44) +[src/permit.ts:44](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L44) ___ @@ -575,7 +584,7 @@ Concatenates a target address with data, trimming the '0x' prefix from the data. #### Defined in -[src/permit.ts:339](https://github.com/1inch/solidity-utils/blob/5a4227e/src/permit.ts#L339) +[src/permit.ts:339](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/permit.ts#L339) ## prelude @@ -601,7 +610,7 @@ Converts an Ether amount represented as a string into its Wei equivalent as a bi #### Defined in -[src/prelude.ts:26](https://github.com/1inch/solidity-utils/blob/5a4227e/src/prelude.ts#L26) +[src/prelude.ts:26](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/prelude.ts#L26) ## profileEVM @@ -623,7 +632,7 @@ Default configuration options for the `gasspectEVM` function to analyze gas usag #### Defined in -[src/profileEVM.ts:11](https://github.com/1inch/solidity-utils/blob/5a4227e/src/profileEVM.ts#L11) +[src/profileEVM.ts:11](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/profileEVM.ts#L11) ___ @@ -653,7 +662,7 @@ Analyzes gas usage by operations within a transaction, applying filters and form #### Defined in -[src/profileEVM.ts:141](https://github.com/1inch/solidity-utils/blob/5a4227e/src/profileEVM.ts#L141) +[src/profileEVM.ts:141](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/profileEVM.ts#L141) ___ @@ -682,10 +691,28 @@ Profiles EVM execution by counting occurrences of specified instructions in a tr #### Defined in -[src/profileEVM.ts:112](https://github.com/1inch/solidity-utils/blob/5a4227e/src/profileEVM.ts#L112) +[src/profileEVM.ts:112](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/profileEVM.ts#L112) ## utils +### TrackReceivedTokenAndTxResult + +Ƭ **TrackReceivedTokenAndTxResult**: [`bigint`, `ContractTransactionReceipt` \| [`TrackReceivedTokenAndTxResult`](src.md#trackreceivedtokenandtxresult)] + +**`Notice`** + +Represents a tuple containing a token quantity and either a transaction receipt or a recursive instance of the same tuple type. +This type is used in `trackReceivedTokenAndTx` method to track token transfers and their transaction receipts in a nested structure, +allowing for handling of complex scenarios like chained or batched transactions and tracking several tokens. + - result[0]: The amount of the token received. + - result[1]: The transaction receipt or another nested token tracking result. + +#### Defined in + +[src/utils.ts:164](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L164) + +___ + ### countInstructions ▸ **countInstructions**(`provider`, `txHash`, `instructions`): `Promise`\<`number`[]\> @@ -710,19 +737,19 @@ Counts the occurrences of specified EVM instructions in a transaction's executio #### Defined in -[src/utils.ts:208](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L208) +[src/utils.ts:238](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L238) ___ ### deployAndGetContract -▸ **deployAndGetContract**(`«destructured»`): `Promise`\<`Contract`\> +▸ **deployAndGetContract**(`options`): `Promise`\<`Contract`\> #### Parameters -| Name | Type | -| :------ | :------ | -| `«destructured»` | `DeployContractOptions` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `options` | [`DeployContractOptions`](../interfaces/src.DeployContractOptions.md) | Deployment options. Default values: - deploymentName: contractName - skipVerify: false - skipIfAlreadyDeployed: true - log: true - waitConfirmations: 1 on dev chains, 6 on others | #### Returns @@ -736,7 +763,7 @@ Deploys a contract with optional Etherscan verification. #### Defined in -[src/utils.ts:41](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L41) +[src/utils.ts:53](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L53) ___ @@ -763,7 +790,7 @@ Deploys a contract given a name and optional constructor parameters. #### Defined in -[src/utils.ts:105](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L105) +[src/utils.ts:120](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L120) ___ @@ -792,7 +819,7 @@ Deploys a contract from bytecode, useful for testing and deployment of minimal p #### Defined in -[src/utils.ts:122](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L122) +[src/utils.ts:137](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L137) ___ @@ -818,7 +845,7 @@ Corrects the ECDSA signature 'v' value according to Ethereum's standard. #### Defined in -[src/utils.ts:174](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L174) +[src/utils.ts:204](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L204) ___ @@ -848,7 +875,7 @@ important part of test. #### Defined in -[src/utils.ts:233](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L233) +[src/utils.ts:263](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L263) ___ @@ -875,7 +902,7 @@ Signs a message with a given signer and fixes the signature format. #### Defined in -[src/utils.ts:193](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L193) +[src/utils.ts:223](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L223) ___ @@ -899,13 +926,13 @@ Advances the blockchain time to a specific timestamp for testing purposes. #### Defined in -[src/utils.ts:92](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L92) +[src/utils.ts:107](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L107) ___ ### trackReceivedTokenAndTx -▸ **trackReceivedTokenAndTx**\<`T`\>(`provider`, `token`, `wallet`, `txPromise`, `...args`): `Promise`\<`TrackReceivedTokenAndTxResult`\> +▸ **trackReceivedTokenAndTx**\<`T`\>(`provider`, `token`, `wallet`, `txPromise`, `...args`): `Promise`\<[`TrackReceivedTokenAndTxResult`](src.md#trackreceivedtokenandtxresult)\> #### Type parameters @@ -918,14 +945,14 @@ ___ | Name | Type | Description | | :------ | :------ | :------ | | `provider` | `JsonRpcProvider` \| \{ `getBalance`: (`address`: `string`) => `Promise`\<`bigint`\> } | JSON RPC provider or custom provider object. | -| `token` | `Token` \| \{ `address`: ``"0x0000000000000000000000000000000000000000"`` } \| \{ `address`: ``"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"`` } | Token contract instance or ETH address constants. | +| `token` | [`Token`](src.md#token) \| \{ `address`: ``"0x0000000000000000000000000000000000000000"`` } \| \{ `address`: ``"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"`` } | Token contract instance or ETH address constants. | | `wallet` | `string` | Wallet address to track. | -| `txPromise` | (...`args`: `T`) => `Promise`\<`ContractTransactionResponse` \| `TrackReceivedTokenAndTxResult`\> | Function returning a transaction promise. | +| `txPromise` | (...`args`: `T`) => `Promise`\<`ContractTransactionResponse` \| [`TrackReceivedTokenAndTxResult`](src.md#trackreceivedtokenandtxresult)\> | Function returning a transaction promise. | | `...args` | `T` | Arguments for the transaction promise function. | #### Returns -`Promise`\<`TrackReceivedTokenAndTxResult`\> +`Promise`\<[`TrackReceivedTokenAndTxResult`](src.md#trackreceivedtokenandtxresult)\> Tuple of balance change and transaction receipt. @@ -936,4 +963,31 @@ It could be used recursively for multiple tokens via specific `txPromise` functi #### Defined in -[src/utils.ts:147](https://github.com/1inch/solidity-utils/blob/5a4227e/src/utils.ts#L147) +[src/utils.ts:177](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L177) + +## utils +Represents the interface for a token, providing methods to fetch its balance and address. +This type is used in `trackReceivedTokenAndTx` method. + +### Token + +Ƭ **Token**: `Object` + +**`Param`** + +Method which retrieves the balance of the specified address. + +**`Param`** + +Method which retrieves the token contract's address. + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `balanceOf` | (`address`: `string`) => `Promise`\<`bigint`\> | +| `getAddress` | () => `Promise`\<`string`\> | + +#### Defined in + +[src/utils.ts:151](https://github.com/1inch/solidity-utils/blob/cdb7d95/src/utils.ts#L151) diff --git a/hardhat-setup/networks.ts b/hardhat-setup/networks.ts index f6bc14f..661539c 100644 --- a/hardhat-setup/networks.ts +++ b/hardhat-setup/networks.ts @@ -2,8 +2,16 @@ import dotenv from 'dotenv'; import { ChainConfig } from '@nomicfoundation/hardhat-verify/src/types'; import { Network, NetworkUserConfig, NetworksUserConfig } from 'hardhat/types'; -/** @internal */ -export type Etherscan = { apiKey: {[key: string]: string}, customChains: ChainConfig[] }; +/** + * @category Hardhat-Setup + * @notice Configuration type for managing Etherscan integration in Hardhat setups. + * @param apiKey Dictionary of API keys for accessing Etherscan, indexed by network name. + * @param customChains Array of custom blockchain network configurations. + */ +export type Etherscan = { + apiKey: {[key: string]: string}, + customChains: ChainConfig[], +}; /** * @category Hardhat-Setup diff --git a/package.json b/package.json index 89640f4..d89277d 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "build": "yarn typechain && cti src hardhat-setup docgen -b && tsc -p tsconfig.publish.json", "prepack": "yarn clean && yarn build", "coverage": "hardhat coverage", - "docgen": "yarn hardhat docgen && npx typedoc --options typedoc.json; npx solidity-utils-docify", - "docgen:ts": "npx typedoc --options typedoc.json", - "docgen:sol": "yarn hardhat docgen", + "docgen": "yarn docify:sol && yarn docify:ts", + "docgen:ts": "npx typedoc --options typedoc.json 2>&1 | grep -v \"typechain-types\"", + "docgen:sol": "yarn hardhat docgen; npx solidity-utils-docify", "format": "yarn format-ts && yarn format-sol", "format-ts": "prettier '**/*.ts' --write", "format-sol": "prettier '**/*.sol' --write", diff --git a/src/utils.ts b/src/utils.ts index ea14005..3711e19 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,7 +7,23 @@ import { DeployOptions, DeployResult } from 'hardhat-deploy/types'; import { constants } from './prelude'; -interface DeployContractOptions { +/** + * @category utils + * @notice Options for deployment methods. + * @param contractName Name of the contract to deploy. + * @param constructorArgs Arguments for the contract's constructor. + * @param deployments Deployment facilitator object from Hardhat. + * @param deployer Wallet deploying the contract. + * @param deploymentName Optional custom name for deployment. + * @param skipVerify Skips Etherscan verification if true. + * @param skipIfAlreadyDeployed Avoids redeployment if contract already deployed. + * @param gasPrice Gas strategy option. + * @param maxPriorityFeePerGas Gas strategy option. + * @param maxFeePerGas Gas strategy option. + * @param log Toggles deployment logging. + * @param waitConfirmations Number of confirmations to wait based on network. Ussually it's need for waiting before Etherscan verification. + */ +export interface DeployContractOptions { contractName: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any constructorArgs?: any[]; @@ -26,32 +42,31 @@ interface DeployContractOptions { /** * @category utils * @notice Deploys a contract with optional Etherscan verification. - * @param contractName Name of the contract to deploy. - * @param constructorArgs Arguments for the contract's constructor. - * @param deployments Deployment facilitator object from Hardhat. - * @param deployer Address deploying the contract. - * @param deploymentName Optional custom name for deployment; defaults to contract name. - * @param skipVerify Skips Etherscan verification if true. - * @param skipIfAlreadyDeployed Avoids redeployment if contract already deployed. - * @param gasPrice, maxPriorityFeePerGas, maxFeePerGas Gas strategy options. - * @param log Toggles deployment logging. - * @param waitConfirmations Number of confirmations to wait based on network. Ussually it's need for waiting before Etherscan verification. + * @param options Deployment options. Default values: + * - deploymentName: contractName + * - skipVerify: false + * - skipIfAlreadyDeployed: true + * - log: true + * - waitConfirmations: 1 on dev chains, 6 on others * @returns The deployed contract instance. */ -export async function deployAndGetContract({ - contractName, - constructorArgs, - deployments, - deployer, - deploymentName = contractName, - skipVerify = false, - skipIfAlreadyDeployed = true, - gasPrice, - maxPriorityFeePerGas, - maxFeePerGas, - log = true, - waitConfirmations = constants.DEV_CHAINS.includes(hre.network.name) ? 1 : 6, -}: DeployContractOptions): Promise { +export async function deployAndGetContract(options: DeployContractOptions): Promise { + // Set default values for options + const { + contractName, + constructorArgs, + deployments, + deployer, + deploymentName = contractName, + skipVerify = false, + skipIfAlreadyDeployed = true, + gasPrice, + maxPriorityFeePerGas, + maxFeePerGas, + log = true, + waitConfirmations = constants.DEV_CHAINS.includes(hre.network.name) ? 1 : 6, + } = options; + /** * Deploys contract and tries to verify it on Etherscan if requested. * @remarks @@ -126,12 +141,27 @@ export async function deployContractFromBytecode(abi: any[], bytecode: BytesLike return instance; } -type Token = { +/** + * @category utils + * Represents the interface for a token, providing methods to fetch its balance and address. + * This type is used in `trackReceivedTokenAndTx` method. + * @param balanceOf Method which retrieves the balance of the specified address. + * @param getAddress Method which retrieves the token contract's address. + */ +export type Token = { balanceOf: (address: string) => Promise; getAddress: () => Promise; } -type TrackReceivedTokenAndTxResult = [bigint, ContractTransactionReceipt | TrackReceivedTokenAndTxResult]; +/** + * @category utils + * @notice Represents a tuple containing a token quantity and either a transaction receipt or a recursive instance of the same tuple type. + * This type is used in `trackReceivedTokenAndTx` method to track token transfers and their transaction receipts in a nested structure, + * allowing for handling of complex scenarios like chained or batched transactions and tracking several tokens. + * - result[0]: The amount of the token received. + * - result[1]: The transaction receipt or another nested token tracking result. + */ +export type TrackReceivedTokenAndTxResult = [bigint, ContractTransactionReceipt | TrackReceivedTokenAndTxResult]; /** * @category utils From 6884232bc3e8863abfd50e72f5152f6f53ad5690 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 25 Apr 2024 13:28:30 +0100 Subject: [PATCH 2/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d89277d..8e74add 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@1inch/solidity-utils", - "version": "4.2.0", + "version": "4.2.1", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "exports": { From 797a55520701267d8bbf22fc090eae5e63b79a80 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 26 Apr 2024 10:59:13 +0100 Subject: [PATCH 3/3] Fix typo in script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8e74add..233db2e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build": "yarn typechain && cti src hardhat-setup docgen -b && tsc -p tsconfig.publish.json", "prepack": "yarn clean && yarn build", "coverage": "hardhat coverage", - "docgen": "yarn docify:sol && yarn docify:ts", + "docgen": "yarn docgen:sol && yarn docgen:ts", "docgen:ts": "npx typedoc --options typedoc.json 2>&1 | grep -v \"typechain-types\"", "docgen:sol": "yarn hardhat docgen; npx solidity-utils-docify", "format": "yarn format-ts && yarn format-sol",