Skip to content

Commit

Permalink
Merge branch 'audit/ackee'
Browse files Browse the repository at this point in the history
  • Loading branch information
gislik committed Aug 23, 2023
2 parents ba6dd0a + 281c60b commit b1fa8a8
Show file tree
Hide file tree
Showing 97 changed files with 23,009 additions and 16,626 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,14 @@ Code coverage for the token system can be checked with [solidity-coverage](https

![Code coverage](docs/code-coverage.png)

## Smart contract audit

The smart contracts were audited by [Ackee Blockchain Security](https://ackeeblockchain.com). The report is available [here](docs/ackee-blockchain-monerium-smart-contracts-report-1.2.pdf).

## License

```text
Copyright 2022 Monerium ehf.
Copyright 2023 Monerium ehf.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
56 changes: 56 additions & 0 deletions assets/tokens/eur/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "Monerium EUR emoney",
"symbol": "EURe",
"ticker": "EUR",
"decimals": "18",
"website": "https://monerium.com",
"source_code": "https://github.com/monerium/smart-contracts",
"short_description": "The Monerium e-money offers programmable fiat money on blockchains, an indispensable building block for the nascent blockchain economy.",
"networks": {
"1" : {
"name": "Ethereum Mainnet",
"short_name": "eth",
"chain": "ETH",
"network": "mainnet",
"chain_id": 1,
"network_id": 1,
"contract_address": "0x3231cb76718cdef2155fc47b5286d82e6eda273f",
"ens": "eur.monerium.com",
"explorer": "https://etherscan.io/token/0x3231cb76718cdef2155fc47b5286d82e6eda273f"

},
"3" : {
"name": "Ethereum Ropsten",
"short_name": "rop",
"chain": "ETH",
"network": "ropsten",
"chain_id": 3,
"network_id": 3,
"contract_address": "0x0ae91c2b9e31e92871129117d908b0963c054048",
"explorer": "https:/ropsten./etherscan.io/token/0x0ae91c2b9e31e92871129117d908b0963c054048"

},
"4" : {
"name": "Ethereum Rinkeby",
"short_name": "rin",
"chain": "ETH",
"network": "rinkeby",
"chain_id": 4,
"network_id": 4,
"contract_address": "0x25c13fc529dc4afe4d488bd1f2ee5e1ec4918e0b",
"explorer": "https://rinkeby.etherscan.io/token/0x25c13fc529dc4afe4d488bd1f2ee5e1ec4918e0b"

},
"42" : {
"name": "Ethereum Kovan",
"short_name": "kov",
"chain": "ETH",
"network": "kovan",
"chain_id": 42,
"network_id": 42,
"contract_address": "0x9b8fd8fcfaa2438d11e7ed77d5afb6c2e1044b37",
"explorer": "https://kovan.etherscan.io/token/0x9b8fd8fcfaa2438d11e7ed77d5afb6c2e1044b37"

}
}
}
56 changes: 56 additions & 0 deletions assets/tokens/gbp/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "Monerium GBP emoney",
"symbol": "GBPe",
"ticker": "GBP",
"decimals": "18",
"website": "https://monerium.com",
"source_code": "https://github.com/monerium/smart-contracts",
"short_description": "The Monerium e-money offers programmable fiat money on blockchains, an indispensable building block for the nascent blockchain economy.",
"networks": {
"1" : {
"name": "Ethereum Mainnet",
"short_name": "eth",
"chain": "ETH",
"network": "mainnet",
"chain_id": 1,
"network_id": 1,
"contract_address": "0x7ba92741bf2a568abc6f1d3413c58c6e0244f8fd",
"ens": "gbp.monerium.com",
"explorer": "https://etherscan.io/token/0x7ba92741bf2a568abc6f1d3413c58c6e0244f8fd"

},
"3" : {
"name": "Ethereum Ropsten",
"short_name": "rop",
"chain": "ETH",
"network": "ropsten",
"chain_id": 3,
"network_id": 3,
"contract_address": "0xd9979346224e7b147caddf399b56357e20d3e67c",
"explorer": "https:/ropsten./etherscan.io/token/0xd9979346224e7b147caddf399b56357e20d3e67c"

},
"4" : {
"name": "Ethereum Rinkeby",
"short_name": "rin",
"chain": "ETH",
"network": "rinkeby",
"chain_id": 4,
"network_id": 4,
"contract_address": "0x01df10e345d0364d3a5b8422a66af6305803bd1e",
"explorer": "https://rinkeby.etherscan.io/token/0x01df10e345d0364d3a5b8422a66af6305803bd1e"

},
"42" : {
"name": "Ethereum Kovan",
"short_name": "kov",
"chain": "ETH",
"network": "kovan",
"chain_id": 42,
"network_id": 42,
"contract_address": "0xe28884ed5bd43e3f9f1dd733d254c9f5c6f983d2",
"explorer": "https://kovan.etherscan.io/token/0xe28884ed5bd43e3f9f1dd733d254c9f5c6f983d2"

}
}
}
74 changes: 62 additions & 12 deletions contracts/BlacklistValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

pragma solidity ^0.8.11;
pragma solidity 0.8.11;

import "./ownership/Claimable.sol";
import "./ClaimableSystemRole.sol";
import "./ownership/NoOwner.sol";
import "./ownership/CanReclaimToken.sol";
import "./IValidator.sol";
Expand All @@ -26,9 +26,13 @@ import "./IValidator.sol";
* @title BlacklistValidator
* @dev Implements a validator which rejects transfers to blacklisted addresses.
*/
contract BlacklistValidator is IValidator, Claimable, CanReclaimToken, NoOwner {

mapping (address => bool) public blacklist;
contract BlacklistValidator is
IValidator,
ClaimableSystemRole,
CanReclaimToken,
NoOwner
{
mapping(address => bool) public blacklist;

/**
* @dev Emitted when an address is added to the blacklist.
Expand All @@ -42,11 +46,22 @@ contract BlacklistValidator is IValidator, Claimable, CanReclaimToken, NoOwner {
*/
event Unban(address indexed friend);

constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

/**
* @dev Adds an address to the blacklist.
* @param adversary Address to add.
*/
function ban(address adversary) external onlyOwner {
function ban(address adversary) external {
require(
owner == msg.sender ||
hasRole(SYSTEM_ROLE, msg.sender) ||
hasRole(ADMIN_ROLE, msg.sender),
"BlacklistValidator: must have admin role to ban"
);

blacklist[adversary] = true;
emit Ban(adversary);
}
Expand All @@ -64,10 +79,11 @@ contract BlacklistValidator is IValidator, Claimable, CanReclaimToken, NoOwner {
* @dev Validates token transfer.
* Implements IValidator interface.
*/
function validate(address from, address to, uint amount)
external
returns (bool valid)
{
function validate(
address from,
address to,
uint256 amount
) external returns (bool valid) {
if (blacklist[from]) {
valid = false;
} else {
Expand All @@ -80,7 +96,41 @@ contract BlacklistValidator is IValidator, Claimable, CanReclaimToken, NoOwner {
* @dev Explicit override of transferOwnership from Claimable and Ownable
* @param newOwner Address to transfer ownership to.
*/
function transferOwnership(address newOwner) public override(Claimable, Ownable) {
Claimable.transferOwnership(newOwner);
function transferOwnership(
address newOwner
) public override(ClaimableSystemRole, Ownable) {
ClaimableSystemRole.transferOwnership(newOwner);
}

/**
* @dev Explicit override of addSystemAccount from ClaimableSystemRole
* @param account Address to add as system account.
*/
function addSystemAccount(address account) public override onlyOwner {
super.addSystemAccount(account);
}

/**
* @dev Explicit override of removeSystemAccount from ClaimableSystemRole
* @param account Address to remove as system account.
*/
function removeSystemAccount(address account) public override onlyOwner {
super.removeSystemAccount(account);
}

/**
* @dev Explicit override of addAdminAccount from ClaimableSystemRole
* @param account Address to add as admin account.
*/
function addAdminAccount(address account) public override onlyOwner {
super.addAdminAccount(account);
}

/**
* @dev Explicit override of removeAdminAccount from ClaimableSystemRole
* @param account Address to remove as admin account.
*/
function removeAdminAccount(address account) public override onlyOwner {
super.removeAdminAccount(account);
}
}
52 changes: 52 additions & 0 deletions contracts/ClaimableSystemRole.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

import "./SystemRole.sol";

/**
* @title ClaimableSystemRole
* @dev Extension for the SystemRole contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
abstract contract ClaimableSystemRole is SystemRole {
address public pendingOwner;

/**
* @dev emitted when the pendingOwner address is changed
* @param previousPendingOwner previous pendingOwner address
* @param newPendingOwner new pendingOwner address
*/
event OwnershipTransferPending(
address indexed previousPendingOwner,
address indexed newPendingOwner
);

/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}

/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(
address newOwner
) public virtual override onlyOwner {
emit OwnershipTransferPending(pendingOwner, newOwner);
pendingOwner = newOwner;
}

/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
_setupRole(DEFAULT_ADMIN_ROLE, owner);
pendingOwner = address(0);
}
}
Loading

0 comments on commit b1fa8a8

Please sign in to comment.