@@ -289,6 +289,31 @@ Generated by [AVA](https://avajs.dev).
289289 }␊
290290 `
291291
292+ ## stablecoin mintable with role managed
293+
294+ > Snapshot 1
295+
296+ `// SPDX-License-Identifier: MIT␊
297+ // Compatible with OpenZeppelin Contracts ^5.5.0␊
298+ pragma solidity ^0.8.27;␊
299+ ␊
300+ import {AccessManaged} from "@openzeppelin/contracts/access/manager/AccessManaged.sol";␊
301+ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
302+ import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";␊
303+ ␊
304+ contract MyStablecoin is ERC20, AccessManaged, ERC20Permit {␊
305+ constructor(address initialAuthority)␊
306+ ERC20("MyStablecoin", "MST")␊
307+ AccessManaged(initialAuthority)␊
308+ ERC20Permit("MyStablecoin")␊
309+ {}␊
310+ ␊
311+ function mint(address to, uint256 amount) public restricted {␊
312+ _mint(to, amount);␊
313+ }␊
314+ }␊
315+ `
316+
292317## stablecoin callback
293318
294319> Snapshot 1
@@ -322,7 +347,7 @@ Generated by [AVA](https://avajs.dev).
322347 }␊
323348 `
324349
325- ## stablecoin custodian
350+ ## stablecoin freezable
326351
327352> Snapshot 1
328353
@@ -331,26 +356,26 @@ Generated by [AVA](https://avajs.dev).
331356 pragma solidity ^0.8.27;␊
332357 ␊
333358 import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
334- import {ERC20Custodian } from "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Custodian .sol";␊
359+ import {ERC20Freezable } from "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Freezable .sol";␊
335360 import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";␊
336361 import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
337362 ␊
338- contract MyStablecoin is ERC20, ERC20Permit, ERC20Custodian , Ownable {␊
363+ contract MyStablecoin is ERC20, ERC20Permit, ERC20Freezable , Ownable {␊
339364 constructor(address initialOwner)␊
340365 ERC20("MyStablecoin", "MST")␊
341366 ERC20Permit("MyStablecoin")␊
342367 Ownable(initialOwner)␊
343368 {}␊
344369 ␊
345- function _isCustodian (address user) internal view override returns (bool) {␊
346- return user == owner( );␊
370+ function freeze (address user, uint256 amount) public onlyOwner {␊
371+ _setFrozen( user, amount );␊
347372 }␊
348373 ␊
349374 // The following functions are overrides required by Solidity.␊
350375 ␊
351376 function _update(address from, address to, uint256 value)␊
352377 internal␊
353- override(ERC20, ERC20Custodian )␊
378+ override(ERC20, ERC20Freezable )␊
354379 {␊
355380 super._update(from, to, value);␊
356381 }␊
@@ -586,23 +611,23 @@ Generated by [AVA](https://avajs.dev).
586611 import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
587612 import {ERC20Bridgeable} from "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol";␊
588613 import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";␊
589- import {ERC20Custodian} from "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Custodian.sol";␊
590614 import {ERC20FlashMint} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol";␊
615+ import {ERC20Freezable} from "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Freezable.sol";␊
591616 import {ERC20Pausable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";␊
592617 import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";␊
593618 import {ERC20Restricted} from "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Restricted.sol";␊
594619 import {ERC20Votes} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";␊
595620 import {Nonces} from "@openzeppelin/contracts/utils/Nonces.sol";␊
596621 ␊
597- contract MyStablecoin is ERC20, ERC20Bridgeable, AccessControl, ERC20Burnable, ERC20Pausable, ERC1363, ERC20Permit, ERC20Votes, ERC20FlashMint, ERC20Custodian , ERC20Restricted {␊
622+ contract MyStablecoin is ERC20, ERC20Bridgeable, AccessControl, ERC20Burnable, ERC20Pausable, ERC1363, ERC20Permit, ERC20Votes, ERC20FlashMint, ERC20Freezable , ERC20Restricted {␊
598623 bytes32 public constant TOKEN_BRIDGE_ROLE = keccak256("TOKEN_BRIDGE_ROLE");␊
599624 error Unauthorized();␊
600625 bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");␊
601626 bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");␊
602- bytes32 public constant CUSTODIAN_ROLE = keccak256("CUSTODIAN_ROLE ");␊
627+ bytes32 public constant FREEZER_ROLE = keccak256("FREEZER_ROLE ");␊
603628 bytes32 public constant LIMITER_ROLE = keccak256("LIMITER_ROLE");␊
604629 ␊
605- constructor(address defaultAdmin, address tokenBridge, address recipient, address pauser, address minter, address custodian , address limiter)␊
630+ constructor(address defaultAdmin, address tokenBridge, address recipient, address pauser, address minter, address freezer , address limiter)␊
606631 ERC20("MyStablecoin", "MST")␊
607632 ERC20Permit("MyStablecoin")␊
608633 {␊
@@ -613,7 +638,7 @@ Generated by [AVA](https://avajs.dev).
613638 }␊
614639 _grantRole(PAUSER_ROLE, pauser);␊
615640 _grantRole(MINTER_ROLE, minter);␊
616- _grantRole(CUSTODIAN_ROLE, custodian );␊
641+ _grantRole(FREEZER_ROLE, freezer );␊
617642 _grantRole(LIMITER_ROLE, limiter);␊
618643 }␊
619644 ␊
@@ -633,8 +658,8 @@ Generated by [AVA](https://avajs.dev).
633658 _mint(to, amount);␊
634659 }␊
635660 ␊
636- function _isCustodian (address user) internal view override returns (bool ) {␊
637- return hasRole(CUSTODIAN_ROLE, user );␊
661+ function freeze (address user, uint256 amount) public onlyRole(FREEZER_ROLE ) {␊
662+ _setFrozen(user, amount );␊
638663 }␊
639664 ␊
640665 function isUserAllowed(address user) public view override returns (bool) {␊
@@ -653,7 +678,7 @@ Generated by [AVA](https://avajs.dev).
653678 ␊
654679 function _update(address from, address to, uint256 value)␊
655680 internal␊
656- override(ERC20, ERC20Pausable, ERC20Votes, ERC20Custodian , ERC20Restricted)␊
681+ override(ERC20, ERC20Pausable, ERC20Votes, ERC20Freezable , ERC20Restricted)␊
657682 {␊
658683 super._update(from, to, value);␊
659684 }␊
0 commit comments