diff --git a/contracts/interfaces/IERC7943.sol b/contracts/interfaces/IERC7943.sol index d045bcad..fb53fb1a 100644 --- a/contracts/interfaces/IERC7943.sol +++ b/contracts/interfaces/IERC7943.sol @@ -11,48 +11,57 @@ interface IERC7943Fungible is IERC165 { /// @param amount The amount seized. event ForcedTransfer(address indexed from, address indexed to, uint256 amount); - /// @notice Emitted when `setFrozenTokens` is called, changing the frozen `amount` of tokens for `user`. - /// @param user The address of the user whose tokens are being frozen. + /// @notice Emitted when `setFrozenTokens` is called, changing the frozen `amount` of tokens for `account`. + /// @param account The address of the account whose tokens are being frozen. /// @param amount The amount of tokens frozen after the change. - event Frozen(address indexed user, uint256 amount); + event Frozen(address indexed account, uint256 amount); - /// @notice Error reverted when a user is not allowed to interact. - /// @param account The address of the user which is not allowed for interactions. - error ERC7943NotAllowedUser(address account); + /// @notice Error reverted when an account is not allowed to transact. + /// @param account The address of the account which is not allowed for transfers. + error ERC7943CannotTransact(address account); - /// @notice Error reverted when a transfer is attempted from `user` with an `amount` less or equal than its balance, but greater than its unfrozen balance. - /// @param user The address holding the tokens. + /// @notice Error reverted when a transfer is not allowed according to internal rules. + /// @param from The address from which tokens are being sent. + /// @param to The address to which tokens are being sent. + /// @param amount The amount sent. + error ERC7943CannotTransfer(address from, address to, uint256 amount); + + /// @notice Error reverted when a transfer is attempted from `account` with an `amount` less than or equal to its balance, but greater than its unfrozen balance. + /// @param account The address holding the tokens. /// @param amount The amount being transferred. /// @param unfrozen The amount of tokens that are unfrozen and available to transfer. - error ERC7943InsufficientUnfrozenBalance(address user, uint256 amount, uint256 unfrozen); + error ERC7943InsufficientUnfrozenBalance(address account, uint256 amount, uint256 unfrozen); /// @notice Takes tokens from one address and transfers them to another. /// @dev Requires specific authorization. Used for regulatory compliance or recovery scenarios. /// @param from The address from which `amount` is taken. /// @param to The address that receives `amount`. /// @param amount The amount to force transfer. - function forcedTransfer(address from, address to, uint256 amount) external; + /// @return result True if the transfer executed correctly, false otherwise. + function forcedTransfer(address from, address to, uint256 amount) external returns (bool result); - /// @notice Changes the frozen status of `amount` tokens belonging to a `user`. + /// @notice Changes the frozen status of `amount` tokens belonging to `account`. /// This overwrites the current value, similar to an `approve` function. - /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the user. - /// @param user The address of the user whose tokens are to be frozen/unfrozen. - /// @param amount The amount of tokens to freeze/unfreeze. - function setFrozenTokens(address user, uint256 amount) external; + /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the account. + /// @param account The address of the account whose tokens are to be frozen. + /// @param amount The amount of tokens to freeze. It can be greater than account balance. + /// @return result True if the freezing executed correctly, false otherwise. + function setFrozenTokens(address account, uint256 amount) external returns (bool result); - /// @notice Checks if a specific user is allowed to interact according to token rules. + /// @notice Checks if a specific account is allowed to transact according to token rules. /// @dev This is often used for allowlist/KYC/KYB/AML checks. - /// @param user The address to check. - /// @return allowed True if the user is allowed, false otherwise. - function isUserAllowed(address user) external view returns (bool allowed); + /// @param account The address to check. + /// @return allowed True if the account is allowed, false otherwise. + function canTransact(address account) external view returns (bool allowed); /// @notice Checks the frozen status/amount. - /// @param user The address of the user. - /// @return amount The amount of tokens currently frozen for `user`. - function getFrozenTokens(address user) external view returns (uint256 amount); + /// @param account The address of the account. + /// @dev It could return an amount higher than the account's balance. + /// @return amount The amount of tokens currently frozen for `account`. + function getFrozenTokens(address account) external view returns (uint256 amount); /// @notice Checks if a transfer is currently possible according to token rules. It enforces validations on the frozen tokens. - /// @dev This may involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. + /// @dev This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. /// @param from The address sending tokens. /// @param to The address receiving tokens. /// @param amount The amount being transferred. @@ -68,50 +77,59 @@ interface IERC7943NonFungible is IERC165 { /// @param tokenId The ID of the token being transferred. event ForcedTransfer(address indexed from, address indexed to, uint256 indexed tokenId); - /// @notice Emitted when `setFrozenTokens` is called, changing the frozen status of `tokenId` for `user`. - /// @param user The address of the user whose `tokenId` is subjected to freeze/unfreeze. + /// @notice Emitted when `setFrozenTokens` is called, changing the frozen status of `tokenId` for `account`. + /// @param account The address of the account whose `tokenId` is subjected to freeze/unfreeze. /// @param tokenId The ID of the token subjected to freeze/unfreeze. /// @param frozenStatus Whether `tokenId` has been frozen or unfrozen. - event Frozen(address indexed user, uint256 indexed tokenId, bool indexed frozenStatus); + event Frozen(address indexed account, uint256 indexed tokenId, bool indexed frozenStatus); - /// @notice Error reverted when a user is not allowed to interact. - /// @param account The address of the user which is not allowed for interactions. - error ERC7943NotAllowedUser(address account); + /// @notice Error reverted when an account is not allowed to transact. + /// @param account The address of the account which is not allowed for transfers. + error ERC7943CannotTransact(address account); - /// @notice Error reverted when a transfer is attempted from `user` with a `tokenId` which has been previously frozen. - /// @param user The address holding the tokens. - /// @param tokenId The ID of the token being frozen. - error ERC7943FrozenTokenId(address user, uint256 tokenId); + /// @notice Error reverted when a transfer is not allowed according to internal rules. + /// @param from The address from which tokens are being sent. + /// @param to The address to which tokens are being sent. + /// @param tokenId The id of the token being sent. + error ERC7943CannotTransfer(address from, address to, uint256 tokenId); + + /// @notice Error reverted when a transfer is attempted from `account` with a `tokenId` which has been previously frozen. + /// @param account The address holding the token with `tokenId`. + /// @param tokenId The ID of the token being frozen and unavailable to be transferred. + error ERC7943InsufficientUnfrozenBalance(address account, uint256 tokenId); /// @notice Takes `tokenId` from one address and transfers it to another. /// @dev Requires specific authorization. Used for regulatory compliance or recovery scenarios. /// @param from The address from which `tokenId` is taken. /// @param to The address that receives `tokenId`. /// @param tokenId The ID of the token being transferred. - function forcedTransfer(address from, address to, uint256 tokenId) external; + /// @return result True if the transfer executed correctly, false otherwise. + function forcedTransfer(address from, address to, uint256 tokenId) external returns (bool result); - /// @notice Changes the frozen status of `tokenId` belonging to a `user`. + /// @notice Changes the frozen status of `tokenId` belonging to an `account`. /// This overwrites the current value, similar to an `approve` function. - /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the user. - /// @param user The address of the user whose tokens are to be frozen/unfrozen. - /// @param tokenId The ID of the token to freeze/unfreeze. - /// @param frozenStatus whether `tokenId` is being frozen or not. - function setFrozenTokens(address user, uint256 tokenId, bool frozenStatus) external; - - /// @notice Checks if a specific user is allowed to interact according to token rules. + /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the account. + /// @param account The address of the account whose tokens are to be frozen. + /// @param tokenId The ID of the token to freeze. + /// @param frozenStatus Whether `tokenId` is being frozen or not. + /// @return result True if the freezing executed correctly, false otherwise. + function setFrozenTokens(address account, uint256 tokenId, bool frozenStatus) external returns (bool result); + + /// @notice Checks if a specific account is allowed to transact according to token rules. /// @dev This is often used for allowlist/KYC/KYB/AML checks. - /// @param user The address to check. - /// @return allowed True if the user is allowed, false otherwise. - function isUserAllowed(address user) external view returns (bool allowed); + /// @param account The address to check. + /// @return allowed True if the account is allowed, false otherwise. + function canTransact(address account) external view returns (bool allowed); /// @notice Checks the frozen status of a specific `tokenId`. - /// @param user The address of the user. + /// @dev It could return true even if account does not hold the token. + /// @param account The address of the account. /// @param tokenId The ID of the token. - /// @return frozenStatus Whether `tokenId` is currently frozen for `user`. - function getFrozenTokens(address user, uint256 tokenId) external view returns (bool frozenStatus); + /// @return frozenStatus Whether `tokenId` is currently frozen for `account`. + function getFrozenTokens(address account, uint256 tokenId) external view returns (bool frozenStatus); /// @notice Checks if a transfer is currently possible according to token rules. It enforces validations on the frozen tokens. - /// @dev This may involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. + /// @dev This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. /// @param from The address sending tokens. /// @param to The address receiving tokens. /// @param tokenId The ID of the token being transferred. @@ -128,22 +146,29 @@ interface IERC7943MultiToken is IERC165 { /// @param amount The amount seized. event ForcedTransfer(address indexed from, address indexed to, uint256 indexed tokenId, uint256 amount); - /// @notice Emitted when `setFrozenTokens` is called, changing the frozen `amount` of `tokenId` tokens for `user`. - /// @param user The address of the user whose tokens are being frozen. + /// @notice Emitted when `setFrozenTokens` is called, changing the frozen `amount` of `tokenId` tokens for `account`. + /// @param account The address of the account whose tokens are being frozen. /// @param tokenId The ID of the token being frozen. /// @param amount The amount of tokens frozen after the change. - event Frozen(address indexed user, uint256 indexed tokenId, uint256 amount); + event Frozen(address indexed account, uint256 indexed tokenId, uint256 amount); - /// @notice Error reverted when a user is not allowed to interact. - /// @param account The address of the user which is not allowed for interactions. - error ERC7943NotAllowedUser(address account); + /// @notice Error reverted when an account is not allowed to transact. + /// @param account The address of the account which is not allowed for transfers. + error ERC7943CannotTransact(address account); - /// @notice Error reverted when a transfer is attempted from `user` with an `amount` of `tokenId` less or equal than its balance, but greater than its unfrozen balance. - /// @param user The address holding the tokens. + /// @notice Error reverted when a transfer is not allowed according to internal rules. + /// @param from The address from which tokens are being sent. + /// @param to The address to which tokens are being sent. + /// @param tokenId The id of the token being sent. + /// @param amount The amount sent. + error ERC7943CannotTransfer(address from, address to, uint256 tokenId, uint256 amount); + + /// @notice Error reverted when a transfer is attempted from `account` with an `amount` of `tokenId` less than or equal to its balance, but greater than its unfrozen balance. + /// @param account The address holding the `amount` of `tokenId` tokens. /// @param tokenId The ID of the token being transferred. - /// @param amount The amount being transferred. + /// @param amount The amount of `tokenId` tokens being transferred. /// @param unfrozen The amount of tokens that are unfrozen and available to transfer. - error ERC7943InsufficientUnfrozenBalance(address user, uint256 tokenId, uint256 amount, uint256 unfrozen); + error ERC7943InsufficientUnfrozenBalance(address account, uint256 tokenId, uint256 amount, uint256 unfrozen); /// @notice Takes tokens from one address and transfers them to another. /// @dev Requires specific authorization. Used for regulatory compliance or recovery scenarios. @@ -151,30 +176,33 @@ interface IERC7943MultiToken is IERC165 { /// @param to The address that receives `amount`. /// @param tokenId The ID of the token being transferred. /// @param amount The amount to force transfer. - function forcedTransfer(address from, address to, uint256 tokenId, uint256 amount) external; + /// @return result True if the transfer executed correctly, false otherwise. + function forcedTransfer(address from, address to, uint256 tokenId, uint256 amount) external returns (bool result); - /// @notice Changes the frozen status of `amount` of `tokenId` tokens belonging to a `user`. + /// @notice Changes the frozen status of `amount` of `tokenId` tokens belonging to an `account`. /// This overwrites the current value, similar to an `approve` function. - /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the user. - /// @param user The address of the user whose tokens are to be frozen/unfrozen. - /// @param tokenId The ID of the token to freeze/unfreeze. - /// @param amount The amount of tokens to freeze/unfreeze. - function setFrozenTokens(address user, uint256 tokenId, uint256 amount) external; - - /// @notice Checks if a specific user is allowed to interact according to token rules. + /// @dev Requires specific authorization. Frozen tokens cannot be transferred by the account. + /// @param account The address of the account whose tokens are to be frozen. + /// @param tokenId The ID of the token to freeze. + /// @param amount The amount of tokens to freeze. It can be greater than account balance. + /// @return result True if the freezing executed correctly, false otherwise. + function setFrozenTokens(address account, uint256 tokenId, uint256 amount) external returns (bool result); + + /// @notice Checks if a specific account is allowed to transact according to token rules. /// @dev This is often used for allowlist/KYC/KYB/AML checks. - /// @param user The address to check. - /// @return allowed True if the user is allowed, false otherwise. - function isUserAllowed(address user) external view returns (bool allowed); + /// @param account The address to check. + /// @return allowed True if the account is allowed, false otherwise. + function canTransact(address account) external view returns (bool allowed); /// @notice Checks the frozen status/amount of a specific `tokenId`. - /// @param user The address of the user. + /// @dev It could return an amount higher than the account's balance. + /// @param account The address of the account. /// @param tokenId The ID of the token. - /// @return amount The amount of `tokenId` tokens currently frozen for `user`. - function getFrozenTokens(address user, uint256 tokenId) external view returns (uint256 amount); + /// @return amount The amount of `tokenId` tokens currently frozen for `account`. + function getFrozenTokens(address account, uint256 tokenId) external view returns (uint256 amount); /// @notice Checks if a transfer is currently possible according to token rules. It enforces validations on the frozen tokens. - /// @dev This may involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. + /// @dev This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. /// @param from The address sending tokens. /// @param to The address receiving tokens. /// @param tokenId The ID of the token being transferred. diff --git a/contracts/token/ERC20/extensions/ERC20Freezable.sol b/contracts/token/ERC20/extensions/ERC20Freezable.sol index e9662fc6..319cf7cf 100644 --- a/contracts/token/ERC20/extensions/ERC20Freezable.sol +++ b/contracts/token/ERC20/extensions/ERC20Freezable.sol @@ -20,8 +20,8 @@ abstract contract ERC20Freezable is ERC20 { /// @dev Frozen amount of tokens per address. mapping(address account => uint256) private _frozenBalances; - /// @dev The operation failed because the user has insufficient unfrozen balance. - error ERC20InsufficientUnfrozenBalance(address user, uint256 needed, uint256 available); + /// @dev The operation failed because the account has insufficient unfrozen balance. + error ERC20InsufficientUnfrozenBalance(address account, uint256 needed, uint256 available); /// @dev Returns the frozen balance of an account. function frozen(address account) public view virtual returns (uint256) { @@ -34,10 +34,10 @@ abstract contract ERC20Freezable is ERC20 { return success ? unfrozen : 0; } - /// @dev Internal function to set the frozen token amount for a user. - function _setFrozen(address user, uint256 amount) internal virtual { - _frozenBalances[user] = amount; - emit IERC7943Fungible.Frozen(user, amount); + /// @dev Internal function to set the frozen token amount for a account. + function _setFrozen(address account, uint256 amount) internal virtual { + _frozenBalances[account] = amount; + emit IERC7943Fungible.Frozen(account, amount); } /** diff --git a/contracts/token/ERC20/extensions/ERC20Restricted.sol b/contracts/token/ERC20/extensions/ERC20Restricted.sol index 78b81183..9d64c1f7 100644 --- a/contracts/token/ERC20/extensions/ERC20Restricted.sol +++ b/contracts/token/ERC20/extensions/ERC20Restricted.sol @@ -6,10 +6,10 @@ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /** * @dev Extension of {ERC20} that allows to implement user account transfer restrictions - * through the {isUserAllowed} function. Inspired by https://eips.ethereum.org/EIPS/eip-7943[EIP-7943]. + * through the {canTransact} function. Inspired by https://eips.ethereum.org/EIPS/eip-7943[EIP-7943]. * - * By default, each account has no explicit restriction. The {isUserAllowed} function acts as - * a blocklist. Developers can override {isUserAllowed} to check that `restriction == ALLOWED` + * By default, each account has no explicit restriction. The {canTransact} function acts as + * a blocklist. Developers can override {canTransact} to check that `restriction == ALLOWED` * to implement an allowlist. */ abstract contract ERC20Restricted is ERC20 { @@ -40,12 +40,12 @@ abstract contract ERC20Restricted is ERC20 { * To convert into an allowlist, override as: * * ```solidity - * function isUserAllowed(address account) public view virtual override returns (bool) { + * function canTransact(address account) public view virtual override returns (bool) { * return getRestriction(account) == Restriction.ALLOWED; * } * ``` */ - function isUserAllowed(address account) public view virtual returns (bool) { + function canTransact(address account) public view virtual returns (bool) { return getRestriction(account) != Restriction.BLOCKED; // i.e. DEFAULT && ALLOWED } @@ -54,8 +54,8 @@ abstract contract ERC20Restricted is ERC20 { * * Requirements: * - * * `from` must be allowed to transfer tokens (see {isUserAllowed}). - * * `to` must be allowed to receive tokens (see {isUserAllowed}). + * * `from` must be allowed to transfer tokens (see {canTransact}). + * * `to` must be allowed to receive tokens (see {canTransact}). */ function _update(address from, address to, uint256 value) internal virtual override { if (from != address(0)) _checkRestriction(from); // Not minting @@ -91,6 +91,6 @@ abstract contract ERC20Restricted is ERC20 { /// @dev Checks if a user account is restricted. Reverts with {ERC20Restricted} if so. function _checkRestriction(address account) internal view virtual { - require(isUserAllowed(account), ERC20UserRestricted(account)); + require(canTransact(account), ERC20UserRestricted(account)); } } diff --git a/contracts/token/ERC20/extensions/ERC20uRWA.sol b/contracts/token/ERC20/extensions/ERC20uRWA.sol index ab93aa34..934a5add 100644 --- a/contracts/token/ERC20/extensions/ERC20uRWA.sol +++ b/contracts/token/ERC20/extensions/ERC20uRWA.sol @@ -11,15 +11,17 @@ import {ERC20Restricted} from "./ERC20Restricted.sol"; /** * @dev Extension of {ERC20} according to https://eips.ethereum.org/EIPS/eip-7943[EIP-7943]. * - * Combines standard ERC-20 functionality with RWA-specific features like user restrictions, - * asset freezing, and forced asset transfers. + * Combines standard ERC-20 functionality with RWA-specific features like account restrictions, + * asset freezing, and forced asset transfers. This contract doesn't expose minting or burning + * capabilities; if implemented in derived contracts as needed, they must include 7943-specific + * logic. */ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, IERC7943Fungible { /// @inheritdoc ERC20Restricted - function isUserAllowed( - address user + function canTransact( + address account ) public view virtual override(IERC7943Fungible, ERC20Restricted) returns (bool) { - return super.isUserAllowed(user); + return super.canTransact(account); } /// @inheritdoc ERC165 @@ -34,28 +36,29 @@ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, I * the internal {_update} function. Consider overriding {_update} accordingly to keep both functions in sync. */ function canTransfer(address from, address to, uint256 amount) external view virtual returns (bool) { - return (amount <= available(from) && isUserAllowed(from) && isUserAllowed(to)); + return (amount <= available(from) && canTransact(from) && canTransact(to)); } /// @inheritdoc IERC7943Fungible - function getFrozenTokens(address user) public view virtual returns (uint256 amount) { - return frozen(user); + function getFrozenTokens(address account) public view virtual returns (uint256 amount) { + return frozen(account); } /** - * @dev See {IERC7943Fungible-setFrozenTokens}. + * @dev See {IERC7943Fungible-setFrozenTokens}. Always returns true if successful. Reverts otherwise. * - * NOTE: The `amount` is capped to the balance of the `user` to ensure the {IERC7943Fungible-Frozen} event + * NOTE: The `amount` is capped to the balance of the `account` to ensure the {IERC7943Fungible-Frozen} event * emits values that consistently reflect the actual amount of tokens that are frozen. */ - function setFrozenTokens(address user, uint256 amount) public virtual { - uint256 actualAmount = Math.min(amount, balanceOf(user)); - _checkFreezer(user, actualAmount); - _setFrozen(user, actualAmount); + function setFrozenTokens(address account, uint256 amount) public virtual returns (bool result) { + uint256 actualAmount = Math.min(amount, balanceOf(account)); + _checkFreezer(account, actualAmount); + _setFrozen(account, actualAmount); + return true; } /** - * @dev See {IERC7943Fungible-forcedTransfer}. + * @dev See {IERC7943Fungible-forcedTransfer}. Always returns true if successful. Reverts otherwise. * * Bypasses the {ERC20Restricted} restrictions for the `from` address and adjusts the frozen balance * to the new balance after the transfer. @@ -65,9 +68,9 @@ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, I * to add additional restrictions or logic, those changes will also apply here. * Consider overriding this function to bypass newer restrictions if needed. */ - function forcedTransfer(address from, address to, uint256 amount) public virtual { + function forcedTransfer(address from, address to, uint256 amount) public virtual returns (bool result) { _checkEnforcer(from, to, amount); - require(isUserAllowed(to), ERC7943NotAllowedUser(to)); + require(canTransact(to), ERC7943CannotTransact(to)); // Update frozen balance if needed. ERC-7943 requires that balance is unfrozen first and then send the tokens. uint256 currentFrozen = frozen(from); @@ -85,11 +88,12 @@ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, I // Assuming `forcedTransfer` will be used occasionally, the added costs of temporary // restrictions would be justifiable under this path. Restriction restriction = getRestriction(from); - bool wasUserAllowed = isUserAllowed(from); - if (!wasUserAllowed) _setRestriction(from, Restriction.ALLOWED); + bool wasAccountAllowed = canTransact(from); + if (!wasAccountAllowed) _setRestriction(from, Restriction.ALLOWED); _update(from, to, amount); // Explicit raw update to bypass all restrictions - if (!wasUserAllowed) _setRestriction(from, restriction); + if (!wasAccountAllowed) _setRestriction(from, restriction); emit ForcedTransfer(from, to, amount); + return true; } /// @inheritdoc ERC20 @@ -99,7 +103,7 @@ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, I uint256 amount ) internal virtual override(ERC20, ERC20Freezable, ERC20Restricted) { // Note: We rely on the inherited _update chain (ERC20Freezable + ERC20Restricted) to enforce - // the same restrictions that isTransferAllowed would check. This avoids duplicate validation + // the same restrictions that canTransfer would check. This avoids duplicate validation // while maintaining consistency between external queries and internal transfer logic. super._update(from, to, amount); } @@ -121,8 +125,8 @@ abstract contract ERC20uRWA is ERC20, ERC165, ERC20Freezable, ERC20Restricted, I * Example usage with {AccessControl-onlyRole}: * * ```solidity - * function _checkFreezer(address user, uint256 amount) internal view override onlyRole(FREEZER_ROLE) {} + * function _checkFreezer(address account, uint256 amount) internal view override onlyRole(FREEZER_ROLE) {} * ``` */ - function _checkFreezer(address user, uint256 amount) internal view virtual; + function _checkFreezer(address account, uint256 amount) internal view virtual; } diff --git a/test/token/ERC20/extensions/ERC20Restricted.test.js b/test/token/ERC20/extensions/ERC20Restricted.test.js index f3ea0591..a2cec7fd 100644 --- a/test/token/ERC20/extensions/ERC20Restricted.test.js +++ b/test/token/ERC20/extensions/ERC20Restricted.test.js @@ -26,26 +26,26 @@ describe('ERC20Restricted', function () { }); it('allows users with DEFAULT restriction', async function () { - await expect(this.token.isUserAllowed(this.holder)).to.eventually.equal(true); + await expect(this.token.canTransact(this.holder)).to.eventually.equal(true); }); it('allows users with ALLOWED status', async function () { await this.token.$_allowUser(this.holder); // Sets to ALLOWED await expect(this.token.getRestriction(this.holder)).to.eventually.equal(2); // ALLOWED - await expect(this.token.isUserAllowed(this.holder)).to.eventually.equal(true); + await expect(this.token.canTransact(this.holder)).to.eventually.equal(true); }); it('blocks users with BLOCKED status', async function () { await this.token.$_blockUser(this.holder); // Sets to BLOCKED await expect(this.token.getRestriction(this.holder)).to.eventually.equal(1); // BLOCKED - await expect(this.token.isUserAllowed(this.holder)).to.eventually.equal(false); + await expect(this.token.canTransact(this.holder)).to.eventually.equal(false); }); it('resets user to DEFAULT restriction', async function () { await this.token.$_blockUser(this.holder); // Sets to BLOCKED await this.token.$_resetUser(this.holder); // Sets to DEFAULT await expect(this.token.getRestriction(this.holder)).to.eventually.equal(0); // DEFAULT - await expect(this.token.isUserAllowed(this.holder)).to.eventually.equal(true); + await expect(this.token.canTransact(this.holder)).to.eventually.equal(true); }); it('emits UserRestrictionsUpdated event when restriction changes', async function () { diff --git a/test/token/ERC20/extensions/ERC20uRWA.test.js b/test/token/ERC20/extensions/ERC20uRWA.test.js index b5c665d0..d8521ee8 100644 --- a/test/token/ERC20/extensions/ERC20uRWA.test.js +++ b/test/token/ERC20/extensions/ERC20uRWA.test.js @@ -30,7 +30,7 @@ describe('ERC20uRWA', function () { 'getFrozenTokens(address)', 'setFrozenTokens(address,uint256)', 'forcedTransfer(address,address,uint256)', - 'isUserAllowed(address)', + 'canTransact(address)', ], }); }); @@ -200,7 +200,7 @@ describe('ERC20uRWA', function () { await this.token.$_blockUser(this.recipient); // Sets to BLOCKED await expect(this.token.connect(this.enforcer).forcedTransfer(this.holder, this.recipient, 40n)) - .to.be.revertedWithCustomError(this.token, 'ERC7943NotAllowedUser') + .to.be.revertedWithCustomError(this.token, 'ERC7943CannotTransact') .withArgs(this.recipient); }); @@ -267,7 +267,7 @@ describe('ERC20uRWA', function () { await this.token.$_blockUser(this.recipient); // Sets to BLOCKED await expect(this.token.$_mint(this.recipient, value)) - // ERC7943NotAllowedUser is not required by ERC-7943 + // ERC7943CannotTransact is not required by ERC-7943 .to.be.revertedWithCustomError(this.token, 'ERC20UserRestricted') .withArgs(this.recipient); });