Skip to content

Commit

Permalink
Deploy scripts (CMTA#188)
Browse files Browse the repository at this point in the history
* Add deploy script for CMTAT

---------

Co-authored-by: Diego G <[email protected]>
  • Loading branch information
mariogutval and diego-G committed Jun 1, 2023
1 parent 0652ce6 commit 5fd6d55
Show file tree
Hide file tree
Showing 19 changed files with 2,308 additions and 467 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PRIVATE_KEY=""

MAINNET_NODE=""
GOERLI_NODE=""

ETHERSCAN_API_KEY=""

ADMIN_ADDRESS=""
16 changes: 12 additions & 4 deletions contracts/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ pragma solidity ^0.8.17;
library Errors {
error InvalidTransfer(address from, address to, uint256 amount);
error SnapshotScheduledInThePast(uint256 time, uint256 timestamp);
error SnapshotTimestampBeforeLastSnapshot(uint256 time, uint256 lastSnapshotTimestamp);
error SnapshotTimestampAfterNextSnapshot(uint256 time, uint256 nextSnapshotTimestamp);
error SnapshotTimestampBeforePreviousSnapshot(uint256 time, uint256 previousSnapshotTimestamp);
error SnapshotTimestampBeforeLastSnapshot(
uint256 time,
uint256 lastSnapshotTimestamp
);
error SnapshotTimestampAfterNextSnapshot(
uint256 time,
uint256 nextSnapshotTimestamp
);
error SnapshotTimestampBeforePreviousSnapshot(
uint256 time,
uint256 previousSnapshotTimestamp
);
error SnapshotAlreadyExists();
error SnapshotAlreadyDone();
error SnapshotNotScheduled();
Expand All @@ -18,4 +27,3 @@ library Errors {
error WrongAllowance(uint256 allowance, uint256 currentAllowance);
error SameValue();
}

12 changes: 8 additions & 4 deletions contracts/mocks/RuleEngine/RuleEngineMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract RuleEngineMock is IRuleEngine {
uint256 _amount
) public view override returns (uint8) {
uint256 ruleArrayLength = _rules.length;
for (uint256 i; i < ruleArrayLength;) {
for (uint256 i; i < ruleArrayLength; ) {
uint8 restriction = _rules[i].detectTransferRestriction(
_from,
_to,
Expand All @@ -52,7 +52,9 @@ contract RuleEngineMock is IRuleEngine {
if (restriction != uint8(REJECTED_CODE_BASE.TRANSFER_OK)) {
return restriction;
}
unchecked { ++i; }
unchecked {
++i;
}
}
return uint8(REJECTED_CODE_BASE.TRANSFER_OK);
}
Expand All @@ -73,12 +75,14 @@ contract RuleEngineMock is IRuleEngine {
uint8 _restrictionCode
) public view override returns (string memory) {
uint256 ruleArrayLength = _rules.length;
for (uint256 i; i < ruleArrayLength;) {
for (uint256 i; i < ruleArrayLength; ) {
if (_rules[i].canReturnTransferRestrictionCode(_restrictionCode)) {
return
_rules[i].messageForTransferRestriction(_restrictionCode);
}
unchecked { ++i; }
unchecked {
++i;
}
}
return "Unknown restriction code";
}
Expand Down
34 changes: 17 additions & 17 deletions contracts/modules/CMTAT_BASE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import "./wrapper/mandatory/ERC20BaseModule.sol";
/*
SnapshotModule:
Add this import in case you add the SnapshotModule
import "./wrapper/optional/SnapshotModule.sol";
*/
import "./wrapper/optional/SnapshotModule.sol";*/
import "./wrapper/mandatory/PauseModule.sol";
import "./wrapper/optional/ValidationModule.sol";
import "./wrapper/optional/MetaTxModule.sol";
Expand All @@ -42,10 +41,10 @@ abstract contract CMTAT_BASE is
CreditEventsModule
{
/**
@notice
initialize the proxy contract
The calls to this function will revert if the contract was deployed without a proxy
*/
* @notice
* initialize the proxy contract
* The calls to this function will revert if the contract was deployed without a proxy
*/
function initialize(
address admin,
string memory nameIrrevocable,
Expand All @@ -69,8 +68,8 @@ abstract contract CMTAT_BASE is
}

/**
@dev calls the different initialize functions from the different modules
*/
* @dev calls the different initialize functions from the different modules
*/
function __CMTAT_init(
address admin,
string memory nameIrrevocable,
Expand Down Expand Up @@ -132,8 +131,8 @@ abstract contract CMTAT_BASE is
}

/**
@notice Returns the number of decimals used to get its user representation.
*/
* @notice Returns the number of decimals used to get its user representation.
*/
function decimals()
public
view
Expand Down Expand Up @@ -169,7 +168,8 @@ abstract contract CMTAT_BASE is
address to,
uint256 amount
) internal view override(ERC20Upgradeable) {
if(!ValidationModule.validateTransfer(from, to, amount)) revert Errors.InvalidTransfer(from, to, amount);
if (!ValidationModule.validateTransfer(from, to, amount))
revert Errors.InvalidTransfer(from, to, amount);
// We call the SnapshotModule only if the transfer is valid
/*
SnapshotModule:
Expand All @@ -178,9 +178,9 @@ abstract contract CMTAT_BASE is
*/
}

/**
@dev This surcharge is not necessary if you do not use the MetaTxModule
*/
/**
* @dev This surcharge is not necessary if you do not use the MetaTxModule
*/
function _msgSender()
internal
view
Expand All @@ -190,9 +190,9 @@ abstract contract CMTAT_BASE is
return MetaTxModule._msgSender();
}

/**
@dev This surcharge is not necessary if you do not use the MetaTxModule
*/
/**
* @dev This surcharge is not necessary if you do not use the MetaTxModule
*/
function _msgData()
internal
view
Expand Down
Loading

0 comments on commit 5fd6d55

Please sign in to comment.