Skip to content

Commit

Permalink
chore: contract deployment fixes & enhancements (#415)
Browse files Browse the repository at this point in the history
* set contract configs

* refactor deployment util

* set config for dao acls

* set acls flags for extensions

* refactor acl configs

* refactor adapter acl config

* config ext that use other extensions

* renamed utility files

* enabled ts

* tests fixed

* truffle ts

* coverage fixed

* generic function to create extensions

* generic function to create extensions

* refactor adapter creation

* refactor factory creation

* generic test deployment configs

* fix test

* generic configs for adapters

* update deployment logs + docs
  • Loading branch information
fforbeck authored Oct 21, 2021
1 parent 928a9ab commit 1fa828f
Show file tree
Hide file tree
Showing 66 changed files with 6,452 additions and 3,100 deletions.
2 changes: 1 addition & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
compileCommand: "npm run compile",
providerOptions: {
default_balance_ether: "10000000000000000000000000",
allowUnlimetedContractSize: true,
allowUnlimitedContractSize: true,
gasLimit: 0xfffffffffff,
gasPrice: 0x0,
},
Expand Down
15 changes: 8 additions & 7 deletions contracts/adapters/CouponOnboarding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ contract CouponOnboardingContract is AdapterGuard, Signatures {
uint256 amount
);

constructor(uint256 chainId) {
_chainId = chainId;
}

/**
* @notice Configures the Adapter with the coupon signer address and token to mint.
* @param signerAddress is the DAO instance to be configured
* @param tokenAddrToMint is the coupon to hash
* @param signerAddress the address of the coupon signer
* @param erc20 the address of the internal ERC20 token to issue shares
* @param tokenAddrToMint the address of the token to mint the coupon
* @param maxAmount max amount of coupons to mint
* @param chainId the chain id in which it will be minted, and is used as part of the hash
*/
function configureDao(
DaoRegistry dao,
address signerAddress,
address erc20,
address tokenAddrToMint,
uint88 maxAmount
uint88 maxAmount,
uint256 chainId
) external onlyAdapter(dao) {
dao.setAddressConfiguration(SignerAddressConfig, signerAddress);
dao.setAddressConfiguration(ERC20InternalTokenAddr, erc20);
Expand All @@ -97,6 +97,7 @@ contract CouponOnboardingContract is AdapterGuard, Signatures {
maxAmount - currentBalance
);
}
_chainId = chainId;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions contracts/adapters/TributeNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ contract TributeNFTContract is AdapterGuard, IERC1155Receiver, IERC721Receiver {
* @dev A DAO Bank extension must exist and be configured with proper access for this adapter.
* @param dao The DAO address.
*/
function configureDao(DaoRegistry dao) external onlyAdapter(dao) {
function configureDao(DaoRegistry dao, address tokenAddrToMint)
external
onlyAdapter(dao)
{
BankExtension bank =
BankExtension(dao.getExtensionAddress(DaoHelper.BANK));
bank.registerPotentialNewInternalToken(DaoHelper.UNITS);
bank.registerPotentialNewInternalToken(tokenAddrToMint);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/extensions/bank/BankFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SOFTWARE.
contract BankFactory is CloneFactory {
address public identityAddress;

event BankCreated(address bankAddress);
event BankCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand All @@ -44,7 +44,7 @@ contract BankFactory is CloneFactory {
* @notice Create and initialize a new BankExtension
* @param maxExternalTokens The maximum number of external tokens stored in the Bank
*/
function createBank(uint8 maxExternalTokens) external {
function create(uint8 maxExternalTokens) external {
BankExtension bank = BankExtension(_createClone(identityAddress));
bank.setMaxExternalTokens(maxExternalTokens);
//slither-disable-next-line reentrancy-events
Expand Down
4 changes: 2 additions & 2 deletions contracts/extensions/erc1155/ERC1155TokenExtensionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.
contract ERC1155TokenCollectionFactory is CloneFactory {
address public identityAddress;

event ERC1155CollectionCreated(address nftCollAddress);
event ERC1155CollectionCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand All @@ -41,7 +41,7 @@ contract ERC1155TokenCollectionFactory is CloneFactory {
/**
* @notice Create and initialize a new Standard NFT Extension which is based on ERC1155
*/
function createERC1155Collection() external {
function create() external {
ERC1155TokenExtension extension =
ERC1155TokenExtension(_createClone(identityAddress));
emit ERC1155CollectionCreated(address(extension));
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/erc1271/ERC1271Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SOFTWARE.
contract ERC1271ExtensionFactory is CloneFactory {
address public identityAddress;

event ERC1271Created(address erc1271Address);
event ERC1271Created(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/executor/ExecutorFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SOFTWARE.
contract ExecutorExtensionFactory is CloneFactory {
address public identityAddress;

event ExecutorCreated(address executorAddress);
event ExecutorCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand Down
4 changes: 2 additions & 2 deletions contracts/extensions/nft/NFTCollectionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SOFTWARE.
contract NFTCollectionFactory is CloneFactory {
address public identityAddress;

event NFTCollectionCreated(address nftCollAddress);
event NFTCollectionCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand All @@ -43,7 +43,7 @@ contract NFTCollectionFactory is CloneFactory {
/**
* @notice Create and initialize a new Standard NFT Extension which is based on ERC712
*/
function createNFTCollection() external {
function create() external {
NFTExtension extension = NFTExtension(_createClone(identityAddress));
// slither-disable-next-line reentrancy-events
emit NFTCollectionCreated(address(extension));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SOFTWARE.
contract ERC20TokenExtensionFactory is CloneFactory {
address public identityAddress;

event ERC20TokenExtensionCreated(address erc20ExtTokenAddress);
event ERC20TokenExtensionCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SOFTWARE.
contract InternalTokenVestingExtensionFactory is CloneFactory {
address public identityAddress;

event InternalTokenVestingExtensionCreated(address addr);
event InternalTokenVestingExtensionCreated(address extensionAddress);

constructor(address _identityAddress) {
require(_identityAddress != address(0x0), "invalid addr");
Expand Down
15 changes: 15 additions & 0 deletions contracts/helpers/DaoHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,21 @@ library DaoHelper {
bytes32 internal constant TRIBUTE_NFT = keccak256("tribute-nft");
bytes32 internal constant TRANSFER_STRATEGY =
keccak256("erc20-transfer-strategy");
bytes32 internal constant DAO_REGISTRY_ADAPT = keccak256("daoRegistry");
bytes32 internal constant BANK_ADAPT = keccak256("bank");
bytes32 internal constant ERC721_ADAPT = keccak256("nft");
bytes32 internal constant ERC1155_ADAPT = keccak256("erc1155-adpt");
bytes32 internal constant ERC1271_ADAPT = keccak256("signatures");
bytes32 internal constant SNAPSHOT_PROPOSAL_ADPT =
keccak256("snapshot-proposal-adpt");
bytes32 internal constant VOTING_HASH_ADPT = keccak256("voting-hash-adpt");
bytes32 internal constant KICK_BAD_REPORTER_ADPT =
keccak256("kick-bad-reporter-adpt");
bytes32 internal constant COUPON_ONBOARDING_ADPT =
keccak256("coupon-onboarding");
bytes32 internal constant LEND_NFT_ADPT = keccak256("coupon-onboarding");
bytes32 internal constant ERC20_TRANSFER_STRATEGY_ADPT =
keccak256("erc20-transfer-strategy");

// Extensions
bytes32 internal constant BANK = keccak256("bank");
Expand All @@ -53,6 +67,7 @@ library DaoHelper {
bytes32 internal constant INTERNAL_TOKEN_VESTING_EXT =
keccak256("internal-token-vesting-ext");
bytes32 internal constant ERC1155_EXT = keccak256("erc1155-ext");
bytes32 internal constant ERC20_EXT = keccak256("erc20-ext");

// Reserved Addresses
address internal constant GUILD = address(0xdead);
Expand Down
Loading

0 comments on commit 1fa828f

Please sign in to comment.