Skip to content

Commit

Permalink
v0.6.0-testnet (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
nxqbao authored Aug 9, 2023
2 parents 42aadc9 + 0ea8eca commit 46a4d1e
Show file tree
Hide file tree
Showing 196 changed files with 28,036 additions and 11,296 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
cmd: install

- name: Install Foundry
uses: foundry-rs/[email protected].9
uses: foundry-rs/foundry-toolchain@cb603ca0abb544f301eaed59ac0baf579aa6aecf #v1.0.10

- name: "Run Compile"
uses: borales/actions-yarn@97ba8bebfe5b549bb7999261698a52a81fd62f1b #v4.2.0
Expand All @@ -53,4 +53,4 @@ jobs:
- name: "Run Test"
uses: borales/actions-yarn@97ba8bebfe5b549bb7999261698a52a81fd62f1b #v4.2.0
with:
cmd: test
cmd: test:ci
36 changes: 10 additions & 26 deletions contracts/extensions/GovernanceAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ import "../extensions/sequential-governance/CoreGovernance.sol";
import "../extensions/collections/HasContracts.sol";
import "../interfaces/IRoninTrustedOrganization.sol";
import { ErrorHandler } from "../libraries/ErrorHandler.sol";
import { IdentityGuard } from "../utils/IdentityGuard.sol";
import { HasGovernanceAdminDeprecated, HasBridgeDeprecated } from "../utils/DeprecatedSlots.sol";

abstract contract GovernanceAdmin is CoreGovernance, HasContracts, HasGovernanceAdminDeprecated, HasBridgeDeprecated {
abstract contract GovernanceAdmin is
CoreGovernance,
IdentityGuard,
HasContracts,
HasGovernanceAdminDeprecated,
HasBridgeDeprecated
{
using ErrorHandler for bool;

uint256 public roninChainId;
/// @dev Domain separator
bytes32 public DOMAIN_SEPARATOR;

modifier onlySelfCall() {
_requireSelfCall();
_;
}

constructor(
uint256 _roninChainId,
address _roninTrustedOrganizationContract,
address _bridgeContract,
uint256 _proposalExpiryDuration
) CoreGovernance(_proposalExpiryDuration) {
constructor(uint256 _roninChainId, address _roninTrustedOrganizationContract) {
roninChainId = _roninChainId;

/*
Expand All @@ -48,12 +45,11 @@ abstract contract GovernanceAdmin is CoreGovernance, HasContracts, HasGovernance

mstore(ptr, 0x599a80fcaa47b95e2323ab4d34d34e0cc9feda4b843edafcc30c7bdf60ea15bf) // keccak256("EIP712Domain(string name,string version,bytes32 salt)")
mstore(add(ptr, 0x20), 0x7e7935007966eb860f4a2ee3dcc9fd53fb3205ce2aa86b0126d4893d4d4c14b9) // keccak256("GovernanceAdmin")
mstore(add(ptr, 0x40), 0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5) // keccak256("2")
mstore(add(ptr, 0x40), 0x2a80e1ef1d7842f27f2e6be0972bb708b9a135c38860dbe73c27c3486c34f4de) // keccak256("3")
mstore(add(ptr, 0x60), salt)
sstore(DOMAIN_SEPARATOR.slot, keccak256(ptr, 0x80))
}

_setContract(ContractType.BRIDGE, _bridgeContract);
_setContract(ContractType.RONIN_TRUSTED_ORGANIZATION, _roninTrustedOrganizationContract);
}

Expand Down Expand Up @@ -160,16 +156,4 @@ abstract contract GovernanceAdmin is CoreGovernance, HasContracts, HasGovernance
_success.handleRevert(_selector, _returndata);
return abi.decode(_returndata, (uint256));
}

/**
* @dev Internal method to check method caller.
*
* Requirements:
*
* - The method caller must be this contract.
*
*/
function _requireSelfCall() internal view virtual {
if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);
}
}
28 changes: 16 additions & 12 deletions contracts/extensions/RONTransferHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ abstract contract RONTransferHelper {
* @dev See `_sendRON`.
* Reverts if the recipient does not receive RON.
*/
function _transferRON(address payable _recipient, uint256 _amount) internal {
if (!_sendRON(_recipient, _amount)) revert ErrRecipientRevert(msg.sig);
function _transferRON(address payable recipient, uint256 amount) internal {
if (!_sendRON(recipient, amount)) revert ErrRecipientRevert(msg.sig);
}

/**
* @dev Send `_amount` RON to the address `_recipient`.
* @dev Send `amount` RON to the address `recipient`.
* Returns whether the recipient receives RON or not.
* Reverts once the contract balance is insufficient.
*
* Note: consider using `ReentrancyGuard` before calling this function.
*
*/
function _sendRON(address payable _recipient, uint256 _amount) internal returns (bool _success) {
if (address(this).balance < _amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, _amount);
return _unsafeSendRON(_recipient, _amount);
function _sendRON(address payable recipient, uint256 amount) internal returns (bool success) {
if (address(this).balance < amount) revert ErrInsufficientBalance(msg.sig, address(this).balance, amount);
return _unsafeSendRON(recipient, amount);
}

/**
* @dev Unsafe send `_amount` RON to the address `_recipient`. If the sender's balance is insufficient,
* @dev Unsafe send `amount` RON to the address `recipient`. If the sender's balance is insufficient,
* the call does not revert.
*
* Note:
Expand All @@ -39,14 +39,18 @@ abstract contract RONTransferHelper {
* - Consider using `ReentrancyGuard` before calling this function.
*
*/
function _unsafeSendRON(address payable _recipient, uint256 _amount) internal returns (bool _success) {
(_success, ) = _recipient.call{ value: _amount }("");
function _unsafeSendRON(address payable recipient, uint256 amount) internal returns (bool success) {
(success, ) = recipient.call{ value: amount }("");
}

/**
* @dev Same purpose with {_unsafeSendRON(address,uin256)} but containing gas limit stipend forwarded in the call.
* @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call.
*/
function _unsafeSendRON(address payable _recipient, uint256 _amount, uint256 _gas) internal returns (bool _success) {
(_success, ) = _recipient.call{ value: _amount, gas: _gas }("");
function _unsafeSendRONLimitGas(
address payable recipient,
uint256 amount,
uint256 gas
) internal returns (bool success) {
(success, ) = recipient.call{ value: amount, gas: gas }("");
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 46a4d1e

Please sign in to comment.