Skip to content

Commit

Permalink
Merge pull request #6 from vocdoni/f/update-contracts
Browse files Browse the repository at this point in the history
update smart contracts and deploy to sepolia
  • Loading branch information
emmdim authored Feb 15, 2024
2 parents 38c7de9 + 7939886 commit 00d9029
Show file tree
Hide file tree
Showing 40 changed files with 1,055 additions and 342 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.documentSelectors": ["**/*.sol"],
"solidity.formatter": "prettier"
"solidity.formatter": "prettier",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
6 changes: 5 additions & 1 deletion packages/contracts-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "@vocdoni/gasless-voting-ethers",
"author": "Vocdoni Association",
"version": "0.0.1-rc1",
"version": "0.0.1-rc3",
"description": "Aragon DAO Gasless Voting Plugin contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
"types": "dist/bundle.d.ts",
"publishConfig": {
"access": "public"
},
"files": [
"dist",
"types"
],
"keywords": [
"voting",
"blockchain",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/deploy/01_repo/10_create_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
};

export default func;
func.tags = ['PluginRepo', 'Deployment'];
func.tags = ['PluginRepo'];
7 changes: 5 additions & 2 deletions packages/contracts/deploy/02_setup/10_setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {PLUGIN_SETUP_CONTRACT_NAME} from '../../plugin-settings';
import {getTokensAddresses} from '../../utils/helpers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

Expand All @@ -8,12 +9,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const {deployer} = await getNamedAccounts();
const addresses = getTokensAddresses(hre.network.name);
console.log('addresses', addresses);

await deploy(PLUGIN_SETUP_CONTRACT_NAME, {
from: deployer,
args: [
'0xf868169bde323f45005e476287f4c76411a610f8',
'0x073b8528bcfbb2454c8fa792558aa4a1e64c613b',
addresses[0], // GovernanceERC20
addresses[1], // GovernanceWrappedERC20
],
log: true,
});
Expand Down
9 changes: 5 additions & 4 deletions packages/contracts/deploy/02_setup/12_publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
PLUGIN_SETUP_CONTRACT_NAME,
VERSION,
} from '../../plugin-settings';
import {VocdoniVotingSetup__factory} from '../../typechain';
import {addCreatedVersion, getPluginInfo} from '../../utils/helpers';
import {toHex} from '../../utils/ipfs';
import {uploadToIPFS} from '../../utils/ipfs';
import {PluginRepo__factory, PluginSetup__factory} from '@aragon/osx-ethers';
import {PluginRepo__factory} from '@aragon/osx-ethers';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

Expand All @@ -22,10 +23,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Upload the metadata to IPFS
const releaseMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(METADATA.release),
JSON.stringify(METADATA.release)
)}`;
const buildMetadataURI = `ipfs://${await uploadToIPFS(
JSON.stringify(METADATA.build),
JSON.stringify(METADATA.build)
)}`;

console.log(`Uploaded release metadata: ${releaseMetadataURI}`);
Expand Down Expand Up @@ -87,7 +88,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
throw Error('something went wrong');
}

const implementationAddress = await PluginSetup__factory.connect(
const implementationAddress = await VocdoniVotingSetup__factory.connect(
setup.address,
deployer
).implementation();
Expand Down
42 changes: 21 additions & 21 deletions packages/contracts/deployments/goerli/VocdoniVotingSetup.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const apiUrls: NetworkNameMapping = {
polygon: 'https://polygon-mainnet.infura.io/v3/',
polygonMumbai: 'https://polygon-mumbai.infura.io/v3/',
baseGoerli: 'https://goerli.base.org',
sepolia: 'https://sepolia.infura.io/v3/',
};

export const networks: {[index: string]: NetworkUserConfig} = {
Expand Down Expand Up @@ -58,6 +59,12 @@ export const networks: {[index: string]: NetworkUserConfig} = {
url: `${apiUrls.baseGoerli}`,
gasPrice: 20000000000,
},
sepolia: {
chainId: 11155111,
gasPrice: 100000000,
// blockGasLimit: 30000000,
url: `${apiUrls.sepolia}${process.env.INFURA_API_KEY}`,
},
};

// Uses hardhats private key if none is set. DON'T USE THIS ACCOUNT FOR DEPLOYMENTS
Expand Down Expand Up @@ -89,6 +96,7 @@ const config: HardhatUserConfig = {
goerli: process.env.ETHERSCAN_API_KEY || '',
polygon: process.env.POLYGONSCAN_API_KEY || '',
polygonMumbai: process.env.POLYGONSCAN_API_KEY || '',
sepolia: process.env.ETHERSCAN_API_KEY || '',
baseGoerli: process.env.BASESCAN_API_KEY || '',
},
customChains: [
Expand All @@ -100,6 +108,14 @@ const config: HardhatUserConfig = {
browserURL: 'https://goerli.basescan.org',
},
},
{
network: 'sepolia',
chainId: 11155111,
urls: {
apiURL: 'https://api-sepolia.etherscan.io/api',
browserURL: 'https://sepolia.etherscan.io',
},
},
],
},

Expand Down
6 changes: 4 additions & 2 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"tmp-promise": "^3.0.3"
},
"dependencies": {
"@aragon/osx": "^1.3.0-rc0.3",
"@aragon/osx-ethers": "^1.3.0-rc0.3",
"@aragon/osx": "1.3.0",
"@aragon/osx-ethers": "1.4.0-alpha.0",
"@aragon/osx-commons-configs": "0.2.0",
"@aragon/osx-commons-contracts": "1.4.0-alpha.3",
"@ensdomains/ens-contracts": "0.0.20",
"@openzeppelin/contracts": "^4.8.2",
"@openzeppelin/contracts-upgradeable": "^4.8.2",
Expand Down
30 changes: 30 additions & 0 deletions packages/contracts/plugin-info-testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,35 @@
"releaseMetadataURI": "ipfs://QmR9r1GLfsPoET8Mya1rr6AXjwpAvrCGZJ13oMEFFTYCsE"
}
}
},
"sepolia": {
"repo": "vocdoni-gasless-voting-poc-vanilla-erc20",
"address": "0xb663C36d6fd959beeF2b82Bb40823660FEAaa55f",
"args": [],
"blockNumberOfDeployment": 5288754,
"releases": {
"1": {
"builds": {
"1": {
"setup": {
"name": "VocdoniVotingSetup",
"address": "0x5A6E29875cCa6eb7a9c39938720e6096468a8917",
"args": [],
"blockNumberOfDeployment": 5288947
},
"implementation": {
"name": "VocdoniVoting",
"address": "0xa28A89Dcf2A94a751FE094C794624cB101EB460a",
"args": [],
"blockNumberOfDeployment": 5288947
},
"helpers": [],
"buildMetadataURI": "ipfs://QmSH3MLwaKV4SH4r4RdrqFQUoSjk97H2Z4VjMewXvu7yLT",
"blockNumberOfPublication": 5288969
}
},
"releaseMetadataURI": "ipfs://QmcuUcHeFcQe4LhLyXBkLCxU61Asy6nYi1WRYZ6C4Ui42V"
}
}
}
}
33 changes: 25 additions & 8 deletions packages/contracts/plugin-info.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
{
"goerli": {
"repo": "vocdoni-gasless-voting-poc",
"address": "0x74057f3F3809a874f28E3EbE80A1f1a5a137b64E",
"repo": "vocdoni-gasless-voting-poc-vanilla-erc20",
"address": "0x98C60A356f03244f9C33C9cA224d960cD45FD2C1",
"args": [],
"blockNumberOfDeployment": 10008529,
"blockNumberOfDeployment": 10451417,
"releases": {
"1": {
"builds": {
"1": {
"setup": {
"name": "VocdoniVotingSetup",
"address": "0xf8454f52f3ecA6c1a9E5Da0119173832F208ab18",
"address": "0x4EeFE283C193AA561E0C3B4977171305C2C2Dd01",
"args": [],
"blockNumberOfDeployment": 10008531
"blockNumberOfDeployment": 10451418
},
"implementation": {
"name": "VocdoniVoting",
"address": "0x46f31156Ff2557EA7C1E592bdB3Ad81CfCCE297c",
"address": "0x3193b4C1E3dBE4b650ACB493476D2A3894133649",
"args": [],
"blockNumberOfDeployment": 10008531
"blockNumberOfDeployment": 10451418
},
"helpers": [],
"buildMetadataURI": "ipfs://QmSH3MLwaKV4SH4r4RdrqFQUoSjk97H2Z4VjMewXvu7yLT",
"blockNumberOfPublication": 10008533
"blockNumberOfPublication": 10451419
},
"2": {
"setup": {
"name": "VocdoniVotingSetup",
"address": "0x6847B82F943D7a761F12878b93a25868408D6cc3",
"args": [],
"blockNumberOfDeployment": 10452517
},
"implementation": {
"name": "VocdoniVoting",
"address": "0x39f85f184611A9A1D8e6bE042e4Fa9eE984F230b",
"args": [],
"blockNumberOfDeployment": 10452517
},
"helpers": [],
"buildMetadataURI": "ipfs://QmSH3MLwaKV4SH4r4RdrqFQUoSjk97H2Z4VjMewXvu7yLT",
"blockNumberOfPublication": 10452518
}
},
"releaseMetadataURI": "ipfs://QmcuUcHeFcQe4LhLyXBkLCxU61Asy6nYi1WRYZ6C4Ui42V"
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/plugin-settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import buildMetadata from './src/build-metadata.json';
import releaseMetadata from './src/release-metadata.json';

export const PLUGIN_REPO_ENS_NAME = 'vocdoni-gasless-voting-poc';
export const PLUGIN_REPO_ENS_NAME = 'vocdoni-gasless-voting-poc-vanilla-erc20';
export const PLUGIN_CONTRACT_NAME = 'VocdoniVoting';
export const PLUGIN_SETUP_CONTRACT_NAME = 'VocdoniVotingSetup';

Expand Down
119 changes: 119 additions & 0 deletions packages/contracts/src/ExecutionMultisig.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.17;

import {ERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {SafeCastUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {PluginUUPSUpgradeable} from "@aragon/osx/core/plugin/PluginUUPSUpgradeable.sol";
import {Addresslist} from "@aragon/osx/plugins/utils/Addresslist.sol";

import {IExecutionMultisig} from "./IExecutionMultisig.sol";

abstract contract ExecutionMultisig is
IExecutionMultisig,
Initializable,
ERC165Upgradeable,
PluginUUPSUpgradeable,
Addresslist
{
using SafeCastUpgradeable for uint256;

/// @notice The ID of the permission required to add/remove executionMultisig members.
bytes32 public constant UPDATE_PLUGIN_EXECUTION_MULTISIG_PERMISSION_ID =
keccak256("UPDATE_PLUGIN_EXECUTION_MULTISIG_PERMISSION");

/// @notice Keeps track at which block number the executionMultisig has been changed the last time.
uint64 internal lastExecutionMultisigChange;

/// @notice Initializes the component to be used by inheriting contracts.
/// @dev This method is required to support [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822).
/// @param _dao The IDAO interface of the associated DAO.
function __ExecutionMultisig_init(IDAO _dao) internal onlyInitializing {
__PluginUUPSUpgradeable_init(_dao);
}

/// @notice Checks if this or the parent contract supports an interface by its ID.
/// @param _interfaceId The ID of the interface.
/// @return Returns `true` if the interface is supported.
function supportsInterface(
bytes4 _interfaceId
) public view virtual override(ERC165Upgradeable, PluginUUPSUpgradeable) returns (bool) {
return
_interfaceId == type(IExecutionMultisig).interfaceId ||
_interfaceId == type(Addresslist).interfaceId ||
super.supportsInterface(_interfaceId);
}

/// @inheritdoc IExecutionMultisig
function addExecutionMultisigMembers(
address[] calldata _members
) external override auth(UPDATE_PLUGIN_EXECUTION_MULTISIG_PERMISSION_ID) {
_addExecutionMultisigMembers(_members);
}

/// @notice Private function for adding execution multisig members.
/// @param _members The addresses to add.
function _addExecutionMultisigMembers(address[] calldata _members) internal {
_guardExecutionMultisig();
if (_members.length == 0) {
revert InvalidListLength({length: _members.length});
}

uint256 newAddresslistLength = addresslistLength() + _members.length;

// Check if the new address list length would be greater than `type(uint16).max`, the maximal number of approvals.
if (newAddresslistLength > type(uint16).max) {
revert AddresslistLengthOutOfBounds({
limit: type(uint16).max,
actual: newAddresslistLength
});
}

_addAddresses(_members);
lastExecutionMultisigChange = uint64(block.number);

emit ExecutionMultisigMembersAdded({newMembers: _members});
}

/// @inheritdoc IExecutionMultisig
function removeExecutionMultisigMembers(address[] calldata _members) external virtual {}

/// @inheritdoc IExecutionMultisig
function isExecutionMultisigMember(address _member) public view override returns (bool) {
return _isExecutionMultisigMember(_member);
}

/// @notice Internal function for checking whether an address is a executionMultisig member.
/// @param _member The address to check.
/// @return Whether the address is a executionMultisig member.
function _isExecutionMultisigMember(address _member) internal view returns (bool) {
return isListed(_member);
}

/// @notice Returns true if msg.sender has approved the given proposal tally
/// @param _proposalId The ID of the proposal.
/// @return Whether the msg.sender has approved the proposal tally.
function hasApprovedTally(
uint256 _proposalId,
address _member
) external view virtual returns (bool);

/// @notice Returns the block number of the last executionMultisig change.
/// @return The block number of the last executionMultisig change.
function getLastExecutionMultisigChange() external view returns (uint64) {
return lastExecutionMultisigChange;
}

/// @notice Guard checks that processes key updates are not executed in the same block
/// where the executionMultisig changed.
function _guardExecutionMultisig() internal view {
if (lastExecutionMultisigChange == uint64(block.number)) {
revert ExecutionMultisigUpdatedTooRecently({lastUpdate: lastExecutionMultisigChange});
}
}

/// @notice This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain (see [OpenZeppelin's guide about storage gaps](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps)).
uint256[49] private __gap;
}
Loading

0 comments on commit 00d9029

Please sign in to comment.