From 43255c2b5f9b771525eee686c2eebd9fe48c1cbc Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Fri, 22 Nov 2024 11:52:55 +0400 Subject: [PATCH] new changes --- .../docs/ERC20/IERC20MintableUpgradeable.md | 20 --- .../docs/ERC20/governance/GovernanceERC20.md | 117 --------------- .../governance/GovernanceWrappedERC20.md | 138 ------------------ .../governance/IGovernanceWrappedERC20.md | 38 ----- packages/contracts/docs/config.js | 4 +- .../docs/modules/api/pages/TokenVoting.adoc | 8 +- packages/contracts/hardhat.config.ts | 2 +- packages/contracts/package.json | 4 +- 8 files changed, 9 insertions(+), 322 deletions(-) delete mode 100644 packages/contracts/docs/ERC20/IERC20MintableUpgradeable.md delete mode 100644 packages/contracts/docs/ERC20/governance/GovernanceERC20.md delete mode 100644 packages/contracts/docs/ERC20/governance/GovernanceWrappedERC20.md delete mode 100644 packages/contracts/docs/ERC20/governance/IGovernanceWrappedERC20.md diff --git a/packages/contracts/docs/ERC20/IERC20MintableUpgradeable.md b/packages/contracts/docs/ERC20/IERC20MintableUpgradeable.md deleted file mode 100644 index 26ee0612..00000000 --- a/packages/contracts/docs/ERC20/IERC20MintableUpgradeable.md +++ /dev/null @@ -1,20 +0,0 @@ -# Solidity API - -## IERC20MintableUpgradeable - -Interface to allow minting of [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens. - -### mint - -```solidity -function mint(address _to, uint256 _amount) external -``` - -Mints [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens for a receiving address. - -#### Parameters - -| Name | Type | Description | -| -------- | ------- | ---------------------- | -| \_to | address | The receiving address. | -| \_amount | uint256 | The amount of tokens. | diff --git a/packages/contracts/docs/ERC20/governance/GovernanceERC20.md b/packages/contracts/docs/ERC20/governance/GovernanceERC20.md deleted file mode 100644 index 403412d7..00000000 --- a/packages/contracts/docs/ERC20/governance/GovernanceERC20.md +++ /dev/null @@ -1,117 +0,0 @@ -# Solidity API - -## GovernanceERC20 - -An [OpenZeppelin `Votes`](https://docs.openzeppelin.com/contracts/4.x/api/governance#Votes) -compatible [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token, used for voting and managed by a DAO. - -### MINT_PERMISSION_ID - -```solidity -bytes32 MINT_PERMISSION_ID -``` - -The permission identifier to mint new tokens - -### MintSettings - -```solidity -struct MintSettings { - address[] receivers; - uint256[] amounts; -} -``` - -### MintSettingsArrayLengthMismatch - -```solidity -error MintSettingsArrayLengthMismatch(uint256 receiversArrayLength, uint256 amountsArrayLength) -``` - -Thrown if the number of receivers and amounts specified in the mint settings do not match. - -#### Parameters - -| Name | Type | Description | -| -------------------- | ------- | ------------------------------------ | -| receiversArrayLength | uint256 | The length of the `receivers` array. | -| amountsArrayLength | uint256 | The length of the `amounts` array. | - -### constructor - -```solidity -constructor(contract IDAO _dao, string _name, string _symbol, struct GovernanceERC20.MintSettings _mintSettings) public -``` - -Calls the initialize function. - -#### Parameters - -| Name | Type | Description | -| -------------- | ----------------------------------- | ----------------------------------------------------------------------------------- | -| \_dao | contract IDAO | The managing DAO. | -| \_name | string | The name of the [ERC-20](https://eips.ethereum.org/EIPS/eip-20) governance token. | -| \_symbol | string | The symbol of the [ERC-20](https://eips.ethereum.org/EIPS/eip-20) governance token. | -| \_mintSettings | struct GovernanceERC20.MintSettings | The token mint settings struct containing the `receivers` and `amounts`. | - -### initialize - -```solidity -function initialize(contract IDAO _dao, string _name, string _symbol, struct GovernanceERC20.MintSettings _mintSettings) public -``` - -Initializes the contract and mints tokens to a list of receivers. - -#### Parameters - -| Name | Type | Description | -| -------------- | ----------------------------------- | ----------------------------------------------------------------------------------- | -| \_dao | contract IDAO | The managing DAO. | -| \_name | string | The name of the [ERC-20](https://eips.ethereum.org/EIPS/eip-20) governance token. | -| \_symbol | string | The symbol of the [ERC-20](https://eips.ethereum.org/EIPS/eip-20) governance token. | -| \_mintSettings | struct GovernanceERC20.MintSettings | The token mint settings struct containing the `receivers` and `amounts`. | - -### supportsInterface - -```solidity -function supportsInterface(bytes4 _interfaceId) public view virtual returns (bool) -``` - -Checks if this or the parent contract supports an interface by its ID. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------ | ------------------------ | -| \_interfaceId | bytes4 | The ID of the interface. | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | --------------------------------------------- | -| [0] | bool | Returns `true` if the interface is supported. | - -### mint - -```solidity -function mint(address to, uint256 amount) external -``` - -Mints tokens to an address. - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ---------------------------------- | -| to | address | The address receiving the tokens. | -| amount | uint256 | The amount of tokens to be minted. | - -### \_afterTokenTransfer - -```solidity -function _afterTokenTransfer(address from, address to, uint256 amount) internal -``` - -\_Move voting power when tokens are transferred. - -Emits a {IVotes-DelegateVotesChanged} event.\_ diff --git a/packages/contracts/docs/ERC20/governance/GovernanceWrappedERC20.md b/packages/contracts/docs/ERC20/governance/GovernanceWrappedERC20.md deleted file mode 100644 index 41c46a5b..00000000 --- a/packages/contracts/docs/ERC20/governance/GovernanceWrappedERC20.md +++ /dev/null @@ -1,138 +0,0 @@ -# Solidity API - -## GovernanceWrappedERC20 - -Wraps an existing [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token by -inheriting from `ERC20WrapperUpgradeable` and allows using it for voting by inheriting from `ERC20VotesUpgradeable`. -The latter is compatible with -[OpenZeppelin's `Votes`](https://docs.openzeppelin.com/contracts/4.x/api/governance#Votes) interface. -The contract supports meta transactions. To use an `amount` of underlying tokens for voting, the token owner must: - -1. call `approve` for the tokens to be used by this contract -2. call `depositFor` to wrap them, which safely transfers the underlying - [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens to the contract and mints wrapped - [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens. - To get the [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens back, the owner of the wrapped tokens can call - `withdrawFor`, which burns the wrapped [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens and - safely transfers the underlying tokens back to the owner. - -_This contract intentionally has no public mint functionality because this is the -responsibility of the underlying [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token contract._ - -### constructor - -```solidity -constructor(contract IERC20Upgradeable _token, string _name, string _symbol) public -``` - -Calls the initialize function. - -#### Parameters - -| Name | Type | Description | -| -------- | -------------------------- | --------------------------------------------------------------------- | -| \_token | contract IERC20Upgradeable | The underlying [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token. | -| \_name | string | The name of the wrapped token. | -| \_symbol | string | The symbol of the wrapped token. | - -### initialize - -```solidity -function initialize(contract IERC20Upgradeable _token, string _name, string _symbol) public -``` - -Initializes the contract. - -#### Parameters - -| Name | Type | Description | -| -------- | -------------------------- | --------------------------------------------------------------------- | -| \_token | contract IERC20Upgradeable | The underlying [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token. | -| \_name | string | The name of the wrapped token. | -| \_symbol | string | The symbol of the wrapped token. | - -### supportsInterface - -```solidity -function supportsInterface(bytes4 _interfaceId) public view virtual returns (bool) -``` - -Checks if this or the parent contract supports an interface by its ID. - -#### Parameters - -| Name | Type | Description | -| ------------- | ------ | ------------------------ | -| \_interfaceId | bytes4 | The ID of the interface. | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | --------------------------------------------- | -| [0] | bool | Returns `true` if the interface is supported. | - -### decimals - -```solidity -function decimals() public view returns (uint8) -``` - -_Uses the `decimals` of the underlying [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token._ - -### depositFor - -```solidity -function depositFor(address account, uint256 amount) public returns (bool) -``` - -Deposits an amount of underlying token -and mints the corresponding number of wrapped tokens for a receiving address. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------- | -| account | address | The address receiving the minted, wrapped tokens. | -| amount | uint256 | The amount of tokens to deposit. | - -### withdrawTo - -```solidity -function withdrawTo(address account, uint256 amount) public returns (bool) -``` - -Withdraws an amount of underlying tokens to a receiving address -and burns the corresponding number of wrapped tokens. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------- | -| account | address | The address receiving the withdrawn, underlying tokens. | -| amount | uint256 | The amount of underlying tokens to withdraw. | - -### \_afterTokenTransfer - -```solidity -function _afterTokenTransfer(address from, address to, uint256 amount) internal -``` - -\_Move voting power when tokens are transferred. - -Emits a {IVotes-DelegateVotesChanged} event.\_ - -### \_mint - -```solidity -function _mint(address to, uint256 amount) internal -``` - -_Snapshots the totalSupply after it has been increased._ - -### \_burn - -```solidity -function _burn(address account, uint256 amount) internal -``` - -_Snapshots the totalSupply after it has been decreased._ diff --git a/packages/contracts/docs/ERC20/governance/IGovernanceWrappedERC20.md b/packages/contracts/docs/ERC20/governance/IGovernanceWrappedERC20.md deleted file mode 100644 index 6a91ba13..00000000 --- a/packages/contracts/docs/ERC20/governance/IGovernanceWrappedERC20.md +++ /dev/null @@ -1,38 +0,0 @@ -# Solidity API - -## IGovernanceWrappedERC20 - -An interface for the token wrapping contract wrapping existing -[ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens. - -### depositFor - -```solidity -function depositFor(address account, uint256 amount) external returns (bool) -``` - -Deposits an amount of underlying token -and mints the corresponding number of wrapped tokens for a receiving address. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------- | -| account | address | The address receiving the minted, wrapped tokens. | -| amount | uint256 | The amount of tokens to deposit. | - -### withdrawTo - -```solidity -function withdrawTo(address account, uint256 amount) external returns (bool) -``` - -Withdraws an amount of underlying tokens to a receiving address -and burns the corresponding number of wrapped tokens. - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ------------------------------------------------------- | -| account | address | The address receiving the withdrawn, underlying tokens. | -| amount | uint256 | The amount of underlying tokens to withdraw. | diff --git a/packages/contracts/docs/config.js b/packages/contracts/docs/config.js index cd816c6d..1d02bc12 100644 --- a/packages/contracts/docs/config.js +++ b/packages/contracts/docs/config.js @@ -1,12 +1,12 @@ const path = require('path'); const fs = require('fs'); -const {version, repository} = require('../package.json'); +const { version, repository } = require('../package.json'); const helpers = require(path.resolve(__dirname, './templates/helpers')); // overwrite the functions. -helpers.version = () => version; +helpers.version = () => `${version}/packages/contracts`; helpers.githubURI = () => repository.url; /** @type import('solidity-docgen/dist/config').UserConfig */ diff --git a/packages/contracts/docs/modules/api/pages/TokenVoting.adoc b/packages/contracts/docs/modules/api/pages/TokenVoting.adoc index ffba1e7f..eeca4cea 100644 --- a/packages/contracts/docs/modules/api/pages/TokenVoting.adoc +++ b/packages/contracts/docs/modules/api/pages/TokenVoting.adoc @@ -112,7 +112,7 @@ This is for testing purposes. [.contract] [[TokenVoting]] -=== `++TokenVoting++` link:https://github.com/aragon/token-voting-plugin/blob/v/src/TokenVoting.sol[{github-icon},role=heading-link] +=== `++TokenVoting++` link:https://github.com/aragon/token-voting-plugin/blob/1.4.0-alpha.1/packages/contracts/src/TokenVoting.sol[{github-icon},role=heading-link] v1.3 (Release 1, Build 3). For each upgrade, if the reinitialization step is required, increment the version numbers in the modifier for both the initialize and initializeFrom functions. @@ -597,7 +597,7 @@ The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contra [.contract] [[MajorityVotingBase]] -=== `++MajorityVotingBase++` link:https://github.com/aragon/token-voting-plugin/blob/v/src/MajorityVotingBase.sol[{github-icon},role=heading-link] +=== `++MajorityVotingBase++` link:https://github.com/aragon/token-voting-plugin/blob/1.4.0-alpha.1/packages/contracts/src/MajorityVotingBase.sol[{github-icon},role=heading-link] This contract implements the `IMajorityVoting` interface. @@ -1228,7 +1228,7 @@ A mapping between proposal IDs and proposal information. [.contract] [[TokenVotingSetup]] -=== `++TokenVotingSetup++` link:https://github.com/aragon/token-voting-plugin/blob/v/src/TokenVotingSetup.sol[{github-icon},role=heading-link] +=== `++TokenVotingSetup++` link:https://github.com/aragon/token-voting-plugin/blob/1.4.0-alpha.1/packages/contracts/src/TokenVotingSetup.sol[{github-icon},role=heading-link] v1.3 (Release 1, Build 3) @@ -1355,7 +1355,7 @@ Thrown if token address is not ERC20. [.contract] [[VotingPowerCondition]] -=== `++VotingPowerCondition++` link:https://github.com/aragon/token-voting-plugin/blob/v/src/VotingPowerCondition.sol[{github-icon},role=heading-link] +=== `++VotingPowerCondition++` link:https://github.com/aragon/token-voting-plugin/blob/1.4.0-alpha.1/packages/contracts/src/VotingPowerCondition.sol[{github-icon},role=heading-link] [.contract-index] .Functions diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index a30fe173..43cf4729 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -179,7 +179,7 @@ const config: HardhatUserConfig = { outDir: 'typechain', target: 'ethers-v5', }, - docgen: require('./docs/config.js'), + docgen: process.env.DOCS ? require('./docs/config.js') : undefined, }; export default config; diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 553aeb88..d456d745 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,5 +1,6 @@ { "license": "AGPL-3.0-or-later", + "version": "1.4.0-alpha.1", "scripts": { "build": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile", "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain", @@ -8,8 +9,7 @@ "lint:sol": "cd ../../ && yarn run lint:contracts:sol", "lint:ts": "cd ../../ && yarn run lint:contracts:ts", "test": "hardhat test", - "docgen": "hardhat docgen", - "docs": "scripts/prepare-docs.sh", + "docs": "DOCS=true scripts/prepare-docs.sh", "typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain", "clean": "rimraf ./artifacts ./cache ./coverage ./typechain ./types ./coverage.json && yarn typechain" },