Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace EIP-1404 by ERC-1404 #243

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Please see the OpenGSN [documentation](https://docs.opengsn.org/contracts/#recei
### Kill switch

CMTAT initially supported a `kill()` function relying on the SELFDESTRUCT opcode (which effectively destroyed the contract's storage and code).
However, Ethereum's [Cancun update](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md) (rolled out in the second half of 2023) will remove support for SELFDESTRUCT (see
However, Ethereum's [Cancun upgrate](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md) (rolled out in Q1 of 2024) will remove support for SELFDESTRUCT (see
[EIP-6780](https://eips.ethereum.org/EIPS/eip-6780)).

The `kill()` function will therefore not behave as it used to once Cancun is deployed.
Expand Down Expand Up @@ -207,6 +207,12 @@ CMTA providers further documentation describing the CMTAT framework in a platfor
- [CMTA Token (CMTAT)](https://cmta.ch/standards/cmta-token-cmtat)
- [Standard for the tokenization of shares of Swiss corporations using the distributed ledger technology](https://cmta.ch/standards/standard-for-the-tokenization-of-shares-of-swiss-corporations-using-the-distributed-ledger-technology)



## Contract size

![contract-size](./doc/general/contract-size.png)

## Intellectual property

The code is copyright (c) Capital Market and Technology Association, 2018-2023, and is released under [Mozilla Public License 2.0](./LICENSE.md).
2 changes: 1 addition & 1 deletion contracts/CMTAT_STANDALONE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract CMTAT_STANDALONE is CMTAT_BASE {
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) MetaTxModule(forwarderIrrevocable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
pragma solidity ^0.8.0;

/*
@dev Contrary to the EIP-1404, this interface does not inherit from the ERC20 interface
@dev Contrary to the ERC-1404, this interface does not inherit from the ERC20 interface
*/
interface IEIP1404 {
interface IERC1404 {
/**
* @dev See ERC/EIP-1404
* @dev See ERC-1404
*
*/
function detectTransferRestriction(
Expand All @@ -17,7 +17,7 @@ interface IEIP1404 {
) external view returns (uint8);

/**
* @dev See ERC/EIP-1404
* @dev See ERC-1404
*
*/
function messageForTransferRestriction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.0;

import "./IEIP1404.sol";
import "./draft-IERC1404.sol";

interface IEIP1404Wrapper is IEIP1404 {
interface IERC1404Wrapper is IERC1404 {
/*
@dev leave the code 4-9 free/unused for further additions in your ruleEngine implementation
*/
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/RuleEngine/interfaces/IRule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity ^0.8.0;

import "../../../interfaces/IEIP1404/IEIP1404Wrapper.sol";
import "../../../interfaces/draft-IERC1404/draft-IERC1404Wrapper.sol";

interface IRule is IEIP1404Wrapper {
interface IRule is IERC1404Wrapper {
/**
* @dev Returns true if the restriction code exists, and false otherwise.
*/
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/RuleEngine/interfaces/IRuleEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity ^0.8.0;

import "./IRule.sol";
import "../../../interfaces/IEIP1404/IEIP1404Wrapper.sol";
import "../../../interfaces/draft-IERC1404/draft-IERC1404Wrapper.sol";

interface IRuleEngine is IEIP1404Wrapper {
interface IRuleEngine is IERC1404Wrapper {
/**
* @dev define the rules, the precedent rules will be overwritten
*/
Expand Down
6 changes: 2 additions & 4 deletions contracts/modules/CMTAT_BASE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import "./wrapper/extensions/DebtModule/DebtBaseModule.sol";
import "./wrapper/extensions/DebtModule/CreditEventsModule.sol";
import "./security/AuthorizationModule.sol";

import "../interfaces/IEIP1404/IEIP1404Wrapper.sol";

import "../libraries/Errors.sol";

abstract contract CMTAT_BASE is
Expand Down Expand Up @@ -64,7 +62,7 @@ abstract contract CMTAT_BASE is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) public initializer {
Expand Down Expand Up @@ -93,7 +91,7 @@ abstract contract CMTAT_BASE is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) internal onlyInitializing {
Expand Down
10 changes: 5 additions & 5 deletions contracts/modules/internal/ValidationModuleInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;

import "../../../openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol";
import "../../../openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import "../../interfaces/IEIP1404/IEIP1404Wrapper.sol";
import "../../interfaces/draft-IERC1404/draft-IERC1404Wrapper.sol";

/**
* @dev Validation module.
Expand All @@ -18,22 +18,22 @@ abstract contract ValidationModuleInternal is
/**
* @dev Emitted when a rule engine is set.
*/
event RuleEngine(IEIP1404Wrapper indexed newRuleEngine);
event RuleEngine(IERC1404Wrapper indexed newRuleEngine);

IEIP1404Wrapper public ruleEngine;
IERC1404Wrapper public ruleEngine;

/**
* @dev Initializes the contract with rule engine.
*/
function __Validation_init(
IEIP1404Wrapper ruleEngine_
IERC1404Wrapper ruleEngine_
) internal onlyInitializing {
__Context_init_unchained();
__Validation_init_unchained(ruleEngine_);
}

function __Validation_init_unchained(
IEIP1404Wrapper ruleEngine_
IERC1404Wrapper ruleEngine_
) internal onlyInitializing {
if (address(ruleEngine_) != address(0)) {
ruleEngine = ruleEngine_;
Expand Down
6 changes: 3 additions & 3 deletions contracts/modules/wrapper/controllers/ValidationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ abstract contract ValidationModule is
ValidationModuleInternal,
PauseModule,
EnforcementModule,
IEIP1404Wrapper
IERC1404Wrapper
{
string constant TEXT_TRANSFER_OK = "No restriction";
string constant TEXT_UNKNOWN_CODE = "Unknown code";

function __ValidationModule_init(
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
address admin,
uint48 initialDelayToAcceptAdminRole
) internal onlyInitializing {
Expand Down Expand Up @@ -62,7 +62,7 @@ abstract contract ValidationModule is
@param ruleEngine_ the call will be reverted if the new value of ruleEngine is the same as the current one
*/
function setRuleEngine(
IEIP1404Wrapper ruleEngine_
IERC1404Wrapper ruleEngine_
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (ruleEngine == ruleEngine_)
revert Errors.CMTAT_ValidationModule_SameValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract CMTATSnapshotStandaloneTest is CMTAT_BASE_SnapshotTest {
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) MetaTxModule(forwarderIrrevocable) {
Expand Down
6 changes: 2 additions & 4 deletions contracts/test/CMTATSnapshot/CMTAT_BASE_SnapshotTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import "../../modules/wrapper/extensions/DebtModule/DebtBaseModule.sol";
import "../../modules/wrapper/extensions/DebtModule/CreditEventsModule.sol";
import "../../modules/security/AuthorizationModule.sol";

import "../../interfaces/IEIP1404/IEIP1404Wrapper.sol";

import "../../libraries/Errors.sol";

abstract contract CMTAT_BASE_SnapshotTest is
Expand Down Expand Up @@ -55,7 +53,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) public initializer {
Expand Down Expand Up @@ -84,7 +82,7 @@ abstract contract CMTAT_BASE_SnapshotTest is
uint8 decimalsIrrevocable,
string memory tokenId_,
string memory terms_,
IEIP1404Wrapper ruleEngine_,
IERC1404Wrapper ruleEngine_,
string memory information_,
uint256 flag_
) internal onlyInitializing {
Expand Down
Binary file added doc/general/contract-size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 14 additions & 15 deletions doc/interfaces/IEIP1404.md → doc/interfaces/IERC1404.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IEIP1404
# IERC1404

[TOC]

Expand All @@ -7,7 +7,7 @@
The transfer of token from an address to another address is restricted by using the EIP-1404, *Simple Restricted Token Standard*
See [ethereum/EIPs/issues/1404](https://github.com/ethereum/EIPs/issues/1404), [erc1404.org/](https://erc1404.org/).

In the interface IEIP1404Wrapper, we have added one function to the standard : `isTransferValid`
In the interface IERC1404Wrapper, we have added one function to the standard : `isTransferValid`

To apply transfer restriction, you need to deploy a CMTAT containing the module `ValidationModule`, as well as a contract implementing the interface *IEIP1404Wrapper*, which we usually call a *RuleEngine*.

Expand All @@ -18,27 +18,27 @@ You will find an example of this kind of architecture in [](../../contracts/mock
## UML
The following UML describes the different interfaces and their function.

![IEIP1404](./schema/sol2uml/IEIP1404.svg)
![IEIP1404](./schema/sol2uml/IERC1404.svg)



## Sūrya's Description Report

### IEIP1404

### Legend

| Symbol | Meaning |
| :----: | ------------------------- |
| 🛑 | Function can modify state |
| 💵 | Function is payable |

### IERC1404

#### Files Description Table


| File Name | SHA-1 Hash |
| ---------------------------------- | ---------------------------------------- |
| ./interfaces/IEIP1404/IEIP1404.sol | 61b9ba3ee5e6c8ffbb95a590419fb21df9d93a95 |
| File Name | SHA-1 Hash |
| ---------------------------------------------- | ---------------------------------------- |
| ./interfaces/draft-IERC1404/draft-IERC1404.sol | 273e3d0369a8840f4f4a88898bf57bf854729dcc |


#### Contracts Description Table
Expand All @@ -48,18 +48,18 @@ The following UML describes the different interfaces and their function.
| :----------: | :---------------------------: | :------------: | :------------: | :-----------: |
| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
| | | | | |
| **IEIP1404** | Interface | | | |
| **IERC1404** | Interface | | | |
| └ | detectTransferRestriction | External ❗️ | | NO❗️ |
| └ | messageForTransferRestriction | External ❗️ | | NO❗️ |

### IEIP1404Wrapper
### IERC1404Wrapper

#### Files Description Table


| File Name | SHA-1 Hash |
| ----------------------------------------- | ---------------------------------------- |
| ./interfaces/IEIP1404/IEIP1404Wrapper.sol | e3658a9af344df6e49f304c90b7315422b77357d |
| File Name | SHA-1 Hash |
| ----------------------------------------------------- | ---------------------------------------- |
| ./interfaces/draft-IERC1404/draft-IERC1404Wrapper.sol | 72e3b540e88fa503b11c92bcbc633e6dbed917a4 |


#### Contracts Description Table
Expand All @@ -69,6 +69,5 @@ The following UML describes the different interfaces and their function.
| :-----------------: | :---------------: | :------------: | :------------: | :-----------: |
| └ | **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
| | | | | |
| **IEIP1404Wrapper** | Interface | IEIP1404 | | |
| **IERC1404Wrapper** | Interface | IERC1404 | | |
| └ | validateTransfer | External ❗️ | | NO❗️ |

66 changes: 0 additions & 66 deletions doc/interfaces/schema/sol2uml/IEIP1404.svg

This file was deleted.

Loading