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

TREX-133 events at file level #213

Merged
merged 1 commit into from
Jul 30, 2024
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
205 changes: 88 additions & 117 deletions contracts/DVA/IDVATransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,94 @@ pragma solidity 0.8.26;
import "../roles/AgentRole.sol";
import "../token/IToken.sol";

/// Events

/// @dev This event is emitted whenever an approval criteria of a token is modified.
/// @param _tokenAddress is the token address.
/// @param _includeRecipientApprover determines whether the recipient is included in the approver list.
/// @param _includeAgentApprover determines whether the agent is included in the approver list.
/// @param _sequentialApproval determines whether approvals must be sequential.
/// @param _additionalApprovers are the addresses of additional approvers to be added to the approver list.
/// @param _hash is the approval criteria hash
event ApprovalCriteriaSet(
address _tokenAddress,
bool _includeRecipientApprover,
bool _includeAgentApprover,
bool _sequentialApproval,
address[] _additionalApprovers,
bytes32 _hash);

/// @dev This event is emitted whenever a transfer is initiated.
/// @param _transferID is the unique ID of the transfer.
/// @param _tokenAddress is the token address.
/// @param _sender is the address of the sender.
/// @param _recipient is the address of the recipient.
/// @param _amount is the amount of the transfer.
/// @param _approvalCriteriaHash is the approval criteria hash.
event TransferInitiated(
bytes32 _transferID,
address _tokenAddress,
address _sender,
address _recipient,
uint256 _amount,
bytes32 _approvalCriteriaHash);

/// @dev This event is emitted whenever a transfer is approved by an approver.
/// @param _transferID is the unique ID of the transfer.
/// @param _approver is the approver address.
event TransferApproved(bytes32 _transferID, address _approver);

/// @dev This event is emitted whenever a transfer is rejected by an approver.
/// @param _transferID is the unique ID of the transfer.
/// @param _rejectedBy is the approver address.
event TransferRejected(bytes32 _transferID, address _rejectedBy);

/// @dev This event is emitted whenever a transfer is cancelled by the sender.
/// @param _transferID is the unique ID of the transfer.
event TransferCancelled(bytes32 _transferID);

/// @dev This event is emitted whenever all approvers approve a transfer.
/// @param _transferID is the unique ID of the transfer.
/// @param _tokenAddress is the token address.
/// @param _sender is the address of the sender.
/// @param _recipient is the address of the recipient.
/// @param _amount is the amount of the transfer.
event TransferCompleted(
bytes32 _transferID,
address _tokenAddress,
address _sender,
address _recipient,
uint256 _amount);

/// @dev This event is emitted whenever a transfer approval criteria are reset.
/// @param _transferID is the unique ID of the transfer.
/// @param _approvalCriteriaHash is the approval criteria hash.
event TransferApprovalStateReset(bytes32 _transferID, bytes32 _approvalCriteriaHash);


// Errors

error OnlyTokenOwnerCanCall(address _tokenAddress);

error OnlyTransferSenderCanCall(bytes32 _transferID);

error TokenIsNotRegistered(address _tokenAddress);

error RecipientIsNotVerified(address _tokenAddress, address _recipient);

error DVAManagerIsNotAnAgentOfTheToken(address _tokenAddress);

error InvalidTransferID(bytes32 _transferID);

error TransferIsNotInPendingStatus(bytes32 _transferID);

error ApprovalsMustBeSequential(bytes32 _transferID);

error ApproverNotFound(bytes32 _transferID, address _approver);

error SignaturesCanNotBeEmpty(bytes32 _transferID);


interface IDVATransferManager {
enum TransferStatus {
PENDING,
Expand Down Expand Up @@ -109,124 +197,7 @@ interface IDVATransferManager {
bytes32 s;
}

/**
* this event is emitted whenever an approval criteria of a token is modified.
* the event is emitted by 'setApprovalCriteria' function.
* `tokenAddress` is the token address.
* `includeRecipientApprover` determines whether the recipient is included in the approver list
* `includeAgentApprover` determines whether the agent is included in the approver list
* `sequentialApproval` determines whether approvals must be sequential
* `additionalApprovers` are the addresses of additional approvers to be added to the approver list
* `hash` is the approval criteria hash
*/
event ApprovalCriteriaSet(
address tokenAddress,
bool includeRecipientApprover,
bool includeAgentApprover,
bool sequentialApproval,
address[] additionalApprovers,
bytes32 hash
);

/**
* this event is emitted whenever a transfer is initiated
* the event is emitted by 'initiateTransfer' function.
* `transferID` is the unique ID of the transfer
* `tokenAddress` is the token address
* `sender` is the address of the sender
* `recipient` is the address of the recipient
* `amount` is the amount of the transfer
* `approvers` is the list of approvers
* `approvalCriteriaHash` is the approval criteria hash
*/
event TransferInitiated(
bytes32 transferID,
address tokenAddress,
address sender,
address recipient,
uint256 amount,
bytes32 approvalCriteriaHash
);

/**
* this event is emitted whenever a transfer is approved by an approver
* the event is emitted by 'approveTransfer' function.
* `transferID` is the unique ID of the transfer
* `approver` is the approver address
*/
event TransferApproved(
bytes32 transferID,
address approver
);

/**
* this event is emitted whenever a transfer is rejected by an approver
* the event is emitted by 'rejectTransfer' function.
* `transferID` is the unique ID of the transfer
* `rejectedBy` is the approver address
*/
event TransferRejected(
bytes32 transferID,
address rejectedBy
);

/**
* this event is emitted whenever a transfer is cancelled by the sender
* the event is emitted by 'cancelTransfer' function.
* `transferID` is the unique ID of the transfer
*/
event TransferCancelled(
bytes32 transferID
);

/**
* this event is emitted whenever all approvers approve a transfer
* the event is emitted by 'approveTransfer' function.
* `transferID` is the unique ID of the transfer
* `tokenAddress` is the token address
* `sender` is the address of the sender
* `recipient` is the address of the recipient
* `amount` is the amount of the transfer
*/
event TransferCompleted(
bytes32 transferID,
address tokenAddress,
address sender,
address recipient,
uint256 amount
);

/**
* this event is emitted whenever a transfer approval criteria are reset
* the event is emitted by 'approveTransfer' and 'rejectTransfer' functions.
* `transferID` is the unique ID of the transfer
* `approvers` is the list of approvers
* `approvalCriteriaHash` is the approval criteria hash
*/
event TransferApprovalStateReset(
bytes32 transferID,
bytes32 approvalCriteriaHash
);

error OnlyTokenOwnerCanCall(address _tokenAddress);

error OnlyTransferSenderCanCall(bytes32 _transferID);

error TokenIsNotRegistered(address _tokenAddress);

error RecipientIsNotVerified(address _tokenAddress, address _recipient);

error DVAManagerIsNotAnAgentOfTheToken(address _tokenAddress);

error InvalidTransferID(bytes32 _transferID);

error TransferIsNotInPendingStatus(bytes32 _transferID);

error ApprovalsMustBeSequential(bytes32 _transferID);

error ApproverNotFound(bytes32 _transferID, address _approver);

error SignaturesCanNotBeEmpty(bytes32 _transferID);

/**
* @dev modify the approval criteria of a token
Expand Down
89 changes: 45 additions & 44 deletions contracts/DVD/DVDTransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,51 @@ import "../token/IToken.sol";
import "../errors/CommonErrors.sol";
import "../errors/InvalidArgumentErrors.sol";

/// events

/**
* @dev Emitted when a DVD transfer is initiated by `maker` to swap `token1Amount` tokens `token1` (TREX or not)
* for `token2Amount` tokens `token2` with `taker`
* this event is emitted by the `initiateDVDTransfer` function
*/
event DVDTransferInitiated(
bytes32 indexed transferID,
address maker,
address indexed token1,
uint256 token1Amount,
address taker,
address indexed token2,
uint256 token2Amount);

/**
* @dev Emitted when a DVD transfer is validated by `taker` and
* executed either by `taker` either by the agent of the TREX token
* if the TREX token is subject to conditional transfers
* this event is emitted by the `takeDVDTransfer` function
*/
event DVDTransferExecuted(bytes32 indexed transferID);

/**
* @dev Emitted when a DVD transfer is cancelled
* this event is emitted by the `cancelDVDTransfer` function
*/
event DVDTransferCancelled(bytes32 indexed transferID);

/**
* @dev Emitted when a DVD transfer is cancelled
* this event is emitted by the `cancelDVDTransfer` function
*/
event FeeModified(
bytes32 indexed parity,
address token1,
address token2,
uint fee1,
uint fee2,
uint feeBase,
address fee1Wallet,
address fee2Wallet);


/// Errors

// @dev Thrown when the fee settings are invalid.
Expand Down Expand Up @@ -127,50 +172,6 @@ contract DVDTransferManager is Ownable {
// nonce of the transaction allowing the creation of unique transferID
uint256 public txNonce;

/// events

/**
* @dev Emitted when a DVD transfer is initiated by `maker` to swap `token1Amount` tokens `token1` (TREX or not)
* for `token2Amount` tokens `token2` with `taker`
* this event is emitted by the `initiateDVDTransfer` function
*/
event DVDTransferInitiated(
bytes32 indexed transferID,
address maker,
address indexed token1,
uint256 token1Amount,
address taker,
address indexed token2,
uint256 token2Amount);

/**
* @dev Emitted when a DVD transfer is validated by `taker` and
* executed either by `taker` either by the agent of the TREX token
* if the TREX token is subject to conditional transfers
* this event is emitted by the `takeDVDTransfer` function
*/
event DVDTransferExecuted(bytes32 indexed transferID);

/**
* @dev Emitted when a DVD transfer is cancelled
* this event is emitted by the `cancelDVDTransfer` function
*/
event DVDTransferCancelled(bytes32 indexed transferID);

/**
* @dev Emitted when a DVD transfer is cancelled
* this event is emitted by the `cancelDVDTransfer` function
*/
event FeeModified(
bytes32 indexed parity,
address token1,
address token2,
uint fee1,
uint fee2,
uint feeBase,
address fee1Wallet,
address fee2Wallet);

/// functions

// initiates the nonce at 0
Expand Down
57 changes: 24 additions & 33 deletions contracts/compliance/modular/IModularCompliance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,36 @@

pragma solidity 0.8.26;

interface IModularCompliance {
/// events

/// events
/// @dev Event emitted for each executed interaction with a module contract.
/// For gas efficiency, only the interaction calldata selector (first 4 bytes) is included in the event.
/// For interactions without calldata or whose calldata is shorter than 4 bytes, the selector will be `0`.
/// @param _target Address of the module.
/// @param _selector See above comments.
event ModuleInteraction(address indexed _target, bytes4 _selector);

/**
* @dev Event emitted for each executed interaction with a module contract.
* For gas efficiency, only the interaction calldata selector (first 4
* bytes) is included in the event. For interactions without calldata or
* whose calldata is shorter than 4 bytes, the selector will be `0`.
*/
event ModuleInteraction(address indexed target, bytes4 selector);

/**
* this event is emitted when a token has been bound to the compliance contract
* the event is emitted by the bindToken function
* `_token` is the address of the token to bind
*/
event TokenBound(address _token);
/// @dev This event is emitted when a token has been bound to the compliance contract.
/// @param _token is the address of the token to bind.
event TokenBound(address _token);

/**
* this event is emitted when a token has been unbound from the compliance contract
* the event is emitted by the unbindToken function
* `_token` is the address of the token to unbind
*/
event TokenUnbound(address _token);
/// @dev This event is emitted when a token has been unbound from the compliance contract.
/// @param _token is the address of the token to unbind.
event TokenUnbound(address _token);

/**
* this event is emitted when a module has been added to the list of modules bound to the compliance contract
* the event is emitted by the addModule function
* `_module` is the address of the compliance module
*/
event ModuleAdded(address indexed _module);

/**
* this event is emitted when a module has been removed from the list of modules bound to the compliance contract
* the event is emitted by the removeModule function
* `_module` is the address of the compliance module
*/
event ModuleRemoved(address indexed _module);
/// @dev This event is emitted when a module has been added to the list of modules bound to the compliance contract.
/// @param _module The address of the compliance module.
event ModuleAdded(address indexed _module);


/// @dev This event is emitted when a module has been removed from the list of modules bound to the compliance contract.
/// @param _module is the address of the compliance module
event ModuleRemoved(address indexed _module);


interface IModularCompliance {

/// functions

Expand Down
Loading
Loading