# Token.sol

> Tokenコントラクトは、J.P. Morganによって設計された拡張ERC20トークンであり以下の機能を統合したトークンコントラクトです。

- URL: https://cardene.dev/books/jpmd/44db32
- 本: JPMD (https://cardene.dev/books/jpmd.md)
- 章: 7 / 8
- 前の章: https://cardene.dev/books/jpmd/9b6115.md
- 次の章: https://cardene.dev/books/jpmd/064e40.md
- 公開日: 2025-07-08
- 更新日: 2025-07-08
- トピック: Blockchain
- タグ: ブロックチェーン, solidity, ethereum, smartcontract

## 概要

**Token**コントラクトは、J.P. Morganによって設計された拡張ERC20トークンであり以下の機能を統合したトークンコントラクトです。

* 上限供給（Capped）
* Allowlist（許可制アカウント管理）
* 時限ロック付き管理操作（TimeLock）
* 一時停止機能（Pausable）
* UUPSアップグレード対応
* 役割ベースのアクセス制御（RBAC）

主に「**規制下で運用される預金型ステーブルコイン**」のようなユースケースを想定しています。
この `Token` コントラクトは、以下の OpenZeppelin ベースの機能拡張を統合しており、セキュアかつ柔軟な運用を可能にします。

* `ERC20PausableUpgradeable`
    * 緊急停止可能なトークン転送。
* `ERC20AllowlistUpgradeable`
    * ホワイトリストによる転送制限。
* `ERC20CappedUpgradeable`
    * 最大供給量の設定。
* `ERC20TimeLockUpgradeable`
    * 管理操作の実行タイミングを制御。
* `AccessControlUpgradeable`
    * ロールベースのアクセス管理。
* `UUPSUpgradeable`
    * アップグレード可能な実装のサポート。

## コード

```sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {ERC20PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ERC20AllowlistUpgradeable} from "./ERC20AllowlistUpgradeable.sol";
import {ERC20CappedUpgradeable} from "./ERC20CappedUpgradeable.sol";
import {ERC20TimeLockUpgradeable} from "./ERC20TimeLockUpgradeable.sol";

/**
 * @title Base Token contract
 * @author Kinexys by J.P.Morgan
 */
contract Token is ERC20Upgradeable, ERC20PausableUpgradeable, ERC20AllowlistUpgradeable, ERC20CappedUpgradeable, ERC20TimeLockUpgradeable, AccessControlUpgradeable, UUPSUpgradeable {
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    bytes32 public constant ISSUER_ROLE = keccak256("ISSUER_ROLE");
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
    bytes32 public constant ALLOWLIST_ROLE = keccak256("ALLOWLIST_ROLE");
    bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

    error UnsupportedOperation();
    error AccessControlInvalidArgument(bytes32, address);

    /**
     * @dev Locks the contract, preventing any future reinitialization.
     * @custom:oz-upgrades-unsafe-allow constructor
     */
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Sets the token name, symbol and cap. Also grants privileged roles to the provided accounts.
     * @dev This can only be called once during the contract lifecycle.
     *      The Token name and symbol are immutable: they can only be set once during construction of the contract.
     * @param defaultAdmin The address to be granted the default admin role. This role has the authority to
     *                     grant / revoke roles from other accounts.
     * @param pauser The address to be granted the pauser role. This role can pause / unpause the contract state.
     * @param issuer The address to be granted the issuer role. This role can perform the mint, burn and forceTransfer operations
     *               as well as set the cap on total supply.
     * @param upgrader The address to be granted the upgrader role. This role can upgrade the contract proxy
     *                 to use a new implementation contract.
     * @param allowlister The address to be granted the allowlist role. This role can allow / disallow accounts from
     *                    sending and receiving tokens.
     * @param initialCap The cap to be set on the total supply of tokens.
     * @param initialLockPeriod The number of seconds for which time-lock would be applied.
     * @param initialLockExpiryPeriod The number of seconds after which time-lock would be expired.
     */
    function initialize(address defaultAdmin, address pauser, address issuer, address upgrader, address allowlister, address burner,uint256 initialCap, uint256 initialLockPeriod, uint256 initialLockExpiryPeriod)
        external
        initializer
    {
        __ERC20_init("JPMD", "JPMD");
        __ERC20Pausable_init();
        __ERC20Allowlist_init();
        __ERC20Capped_init(initialCap);
        __ERC20TimeLock_init(initialLockPeriod, initialLockExpiryPeriod);
        __AccessControl_init();
        __UUPSUpgradeable_init();

        _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
        _grantRole(PAUSER_ROLE, pauser);
        _grantRole(ISSUER_ROLE, issuer);
        _grantRole(UPGRADER_ROLE, upgrader);
        _grantRole(ALLOWLIST_ROLE, allowlister);
        _grantRole(BURNER_ROLE, burner);
    }

    /**
     * @notice Returns the number of decimals for this token.
     * @dev See {ERC20Upgradeable-decimals}.
     * @return number of decimals supported.
     */
    function decimals() public pure override returns (uint8) {
        return 2;
    }

    /**
     * @notice Creates the requested amount of token to the specified account.
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     *      Emits a {Transfer} event with `from` set to the zero address.
     *      Restrictions:
     *      - This operation can only be performed by an account with the ISSUER role.
     *      - 'to' address cannot be the zero address.
     *      - This operation should not increase the total supply beyond the cap.
     *      - Contract state should not be paused.
     *      - 'to' account should be allow-listed.
     * @param to Address to receive tokens.
     * @param amount Tokens to be minted.
     */
    function mint(address to, uint256 amount) external onlyRole(ISSUER_ROLE) {
        _mint(to, amount);
    }

    /**
     * @notice Destroys the requested amount of token from the specified account.
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     *      Emits a {Transfer} event with `to` set to the zero address.
     *      Restrictions:
     *      - This operation can only be performed by an account with the BURNER role.
     *      - Burn amount should not exceed the current account balance.
     *      - Contract state should not be paused.
     *      - Message sender should be allow-listed.
     * @param amount Tokens to be burned.
     */
    function burn(uint256 amount) external onlyRole(BURNER_ROLE) {
        _burn(_msgSender(), amount);
    }

    // SPDX-License-Identifier: None
    // Copyright
    // ©2025 JPMorgan Chase & Co. All Rights Reserved.
    // This code is written specifically for the deployment and operation of the JPMD token on the Base blockchain. Use, modification, or redistribution is not permitted without prior written permission from the author. These functions are designed for JPMD and may not perform as intended outside of this context.

    /**
     * @notice Allows the token issuer to transfer the requested amount of token from and to the specified accounts.
     * @dev Emits a {Transfer} event with `from` set to the zero address.
     *      Restrictions:
     *      - This operation can only be performed by an account with the ISSUER role.
     *      - 'from' address cannot be the zero address.
     *      - 'to' address cannot be the zero address.
     *      - Transfer amount should not exceed the current balance of 'from' account.
     * @param from Address holding the tokens.
     * @param to Recipient address.
     * @param amount Tokens to be transferred.
     */
    function forcedTransfer(address from, address to, uint256 amount) external onlyRole(ISSUER_ROLE) {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        ERC20Upgradeable._update(from, to, amount);
    }

    // End of SPDX-License-Identifier: None

    /**
     * @dev Removes support for an account to renounce its own role.
     *      This function will always revert when called.
     */
    function renounceRole(bytes32, address) public pure override {
        revert UnsupportedOperation();
    }

    /**
     * @notice Triggers the paused state for the contract.
     * @dev Emits a {Paused} event with the message sender as the argument.
     *      This operation can only be performed by an account with the PAUSER role.
     */
    function pause() external onlyRole(PAUSER_ROLE) {
        _pause();
    }

    /**
     * @notice Removes the paused state from the contract.
     * @dev Emits a {Unpaused} event with the message sender as the argument.
     *      This operation can only be performed by an account with the PAUSER role.
     */
    function unpause() external onlyRole(PAUSER_ROLE) {
        _unpause();
    }

    /**
     * @notice Adds the specified account to the allowlist which allows it to send and receive tokens.
     * @dev Emits an {AccountAllowed} event with the allow-listed account as the argument.
     *      Restrictions:
     *      - This operation can only be performed by an account with the ALLOWLIST role.
     *      - This function is time-lock protected. See {ERC20TimeLockUpgradeable}.
     * @param account The account to be allow-listed.
     */
    function allowAccount(address account) external onlyRole(ALLOWLIST_ROLE) timeLocked() {
        _allowAccount(account);
    }

    /**
     * @notice Removes the specified account from the allowlist which prevents it from sending and receiving tokens.
     * @dev Emits an {AccountDisallowed} event with the specified account as the argument.
     *      Restrictions:
     *      - This operation can only be performed by an account with the ALLOWLIST role.
     * @param account The account to be removed from allow-list.
     */
    function disallowAccount(address account) external onlyRole(ALLOWLIST_ROLE) {
        _disallowAccount(account);
    }

    /**
     * @notice Sets the cap on total supply of tokens.
     * @dev Emits a {CapUpdated} event with the 'newCap' as the argument.
     *      Restrictions:
     *      - This operation can only be performed by an account with the ISSUER role.
     *      - The new cap amount should not be 0.
     *      - The new cap amount should not be less than the current total supply.
     * @param newCap The new cap amount to be set.
     */
    function setCap(uint256 newCap) external onlyRole(ISSUER_ROLE) {
        _setCap(newCap);
    }

    /**
     * @notice Sets the global time-lock period for the token.
     * @dev Emits a {LockPeriodUpdated} event with the 'newLockPeriod' as the argument.
     *      Restrictions:
     *      - This operation can only be performed by an account with the DEFAULT_ADMIN role.
     * @param newLockPeriod The new lock period to be set.
     */
    function setLockPeriod(uint256 newLockPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _setLockPeriod(newLockPeriod);
    }

    /**
     * @notice Sets the global time-lock expiry period for the token.
     * @dev Emits a {LockExpiryPeriodUpdated} event with the 'newLockExpiryPeriod' as the argument.
     *      Restrictions:
     *      - This operation can only be performed by an account with the DEFAULT_ADMIN role.
     * @param newLockExpiryPeriod The new lock expiry period to be set.
     */
    function setLockExpiryPeriod(uint256 newLockExpiryPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _setLockExpiryPeriod(newLockExpiryPeriod);
    }

    /**
     * @dev Internal function that ensures that the contract can only be upgraded by an account with the UPGRADER role.
     *      Called by {upgradeToAndCall}.
     * @param newImplementation Address of the new implementation contract.
     */
    function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {
    }

    /**
     * @dev Internal function that transfers a `value` amount of tokens from `from` to `to`, or alternatively
     *      mints (or burns) if `from` (or `to`) is the zero address.
     *      Emits a {Transfer} event.
     *      See {ERC20Upgradeable-_update}.
     * @param from Address from which to transfer tokens.
     * @param to Address to which tokens are to be transferred.
     * @param value Amount of tokens to be transferred.
     */
    function _update(address from, address to, uint256 value)
        internal
        override(ERC20Upgradeable, ERC20PausableUpgradeable, ERC20AllowlistUpgradeable, ERC20CappedUpgradeable)
    {
        super._update(from, to, value);
    }

    /**
     * @dev Internal function that sets `value` as the allowance of `spender` over the `owner`s tokens.
     *      Emits an {Approval} event.
     *      See {ERC20Upgradeable-_approve}.
     * @param owner Address of the owner of tokens.
     * @param spender Address of the account being allowed to spend the owner's tokens.
     * @param value Amount of tokens that the spender is being allowed to spend from owner's account.
     * @param emitEvent Flag to indicate whether this function should emit the {Approval} event.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent)
        internal
        override(ERC20Upgradeable, ERC20AllowlistUpgradeable)
    {
        if (!allowed(spender)) revert ERC20Disallowed(spender);
        super._approve(owner, spender, value, emitEvent);
    }

    /**
     * @dev Internal function that updates `owner` s allowance for `spender` based on spent `value`.
     *      See {ERC20Upgradeable-_spendAllowance}.
     * @param owner Address of the owner of tokens.
     * @param spender Address of the account spending the owner's tokens.
     * @param value Amount of tokens that the spender is spending from owner's account.
     */
    function _spendAllowance(address owner, address spender, uint256 value)
        internal
        override(ERC20Upgradeable)
    {
        if (!allowed(spender)) revert ERC20Disallowed(spender);
        super._spendAllowance(owner, spender, value);
    }

    /**
     * @dev Internal function that grants `role` to `account` and returns a boolean indicating if `role` was granted.
     *      See {AccessControlUpgradeable-_grantRole}.
     * @param role Role to be granted.
     * @param account Address to which role is to be granted.
     * @return Whether the role was granted successfully.
     */
    function _grantRole(bytes32 role, address account) internal override returns (bool) {
        if (account == address(0)) {
            revert AccessControlInvalidArgument(role, account);
        }
        return super._grantRole(role, account);
    }

    /**
     * @dev Internal function that revokes `role` from `account` and returns a boolean indicating if `role` was revoked.
     *      See {AccessControlUpgradeable-_revokeRole}.
     *      Restrictions:
     *      - This operation cannot be performed on the message sender account.
     * @param role Role to be revoked.
     * @param account Address from which role is to be revoked.
     * @return Whether the role was revoked successfully.
     */
    function _revokeRole(bytes32 role, address account) internal override returns (bool) {
        if (account == address(0) || account == _msgSender()) {
            revert AccessControlInvalidArgument(role, account);
        }
        return super._revokeRole(role, account);
    }
}
```

## 変数

```solidity
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant ISSUER_ROLE = keccak256("ISSUER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
bytes32 public constant ALLOWLIST_ROLE = keccak256("ALLOWLIST_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
```

* `PAUSER_ROLE`
    * 一時停止（pause / unpause）操作を行えるロール
* `ISSUER_ROLE`
    * `mint`, `burn`, `forcedTransfer`, `cap`設定 などの発行者向け操作を行えるロール
* `UPGRADER_ROLE`
    * コントラクトのUUPSアップグレードを実行できるロール
* `ALLOWLIST_ROLE`
    * `Allowlist` に対してアカウントの許可・解除を行うロール
* `BURNER_ROLE`
    * 自身のトークンを `burn` できるロール

## 関数

### `initialize`

```solidity
function initialize(address defaultAdmin, address pauser, address issuer, address upgrader, address allowlister, address burner,uint256 initialCap, uint256 initialLockPeriod, uint256 initialLockExpiryPeriod)
    external
    initializer
{
    __ERC20_init("JPMD", "JPMD");
    __ERC20Pausable_init();
    __ERC20Allowlist_init();
    __ERC20Capped_init(initialCap);
    __ERC20TimeLock_init(initialLockPeriod, initialLockExpiryPeriod);
    __AccessControl_init();
    __UUPSUpgradeable_init();

    _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
    _grantRole(PAUSER_ROLE, pauser);
    _grantRole(ISSUER_ROLE, issuer);
    _grantRole(UPGRADER_ROLE, upgrader);
    _grantRole(ALLOWLIST_ROLE, allowlister);
    _grantRole(BURNER_ROLE, burner);
}
```

初期化処理を行う関数（UUPS Proxy 初期化）。
各ロールの初期設定、**ERC20**設定、拡張機能の初期化を行います。

**引数**

* `defaultAdmin`
    * 管理者ロールを与えるアドレス。
* `pauser`
    * 一時停止権限を持つアドレス。
* `issuer`
    * トークン発行や送金強制操作を行えるアドレス。
* `upgrader`
    * 新実装へのアップグレードを実行できるアドレス。
* `allowlister`
    * Allowlist操作を行えるアドレス。
* `burner`
    * burn操作を行うアドレス。
* `initialCap`
    * 供給上限。
* `initialLockPeriod`
    * タイムロック期間（秒）。
* `initialLockExpiryPeriod`
    * ロック解除後の有効期限（秒）。

### `mint`

```solidity
function mint(address to, uint256 amount) external onlyRole(ISSUER_ROLE) {
    _mint(to, amount);
}
```

新しいトークンを発行する関数。
`ISSUER_ROLE` を保有しているアドレスのみ実行可能。
`amount` 分のトークンを `to` アドレスにMintします。
上限（`cap`）や `Allowlist` 状態、`pause` 状態などのチェックも含まれます。

**引数**

* `to`
    * トークンを受け取るアドレス。
* `amount`
    * 発行するトークンの量。

### `burn`

```solidity
function burn(uint256 amount) external onlyRole(BURNER_ROLE) {
    _burn(_msgSender(), amount);
}
```

呼び出し元のアカウントからトークンをBurnする関数。｀
呼び出し元が `BURNER_ROLE` を持ち、`Allowlist` に登録されており、`paused` でない場合のみ実行可能です。

**引数**

* `amount`
    * Burnするトークン量。

### `forcedTransfer`

```solidity
function forcedTransfer(address from, address to, uint256 amount) external onlyRole(ISSUER_ROLE) {
    if (from == address(0)) {
        revert ERC20InvalidSender(address(0));
    }
    if (to == address(0)) {
        revert ERC20InvalidReceiver(address(0));
    }
    ERC20Upgradeable._update(from, to, amount);
}
```

指定されたアカウント間で強制的にトークンを送付する関数。
`ISSUER_ROLE` を保有しているアドレスが実行でき、「**送信元アドレス**」と「**受信先アドレス**」を指定して強制的にトークン移動を行います。

**引数**

* `from`
    * 送信元。
* `to`
    * 受信先。
* `amount`
    * 送付量。

### `pause`

```solidity
function pause() external onlyRole(PAUSER_ROLE) {
    _pause();
}
```

コントラクトの状態を一時停止する関数。
`PAUSER_ROLE` を保有しているアドレスのみ実行可能。
`paused` 状態になると `transfer`, `approve`, `mint`, `burn` 等が制限されます。

### `unpause`

```solidity
function unpause() external onlyRole(PAUSER_ROLE) {
    _unpause();
}
```

pause状態を解除する関数。
`PAUSER_ROLE` を保有しているアドレスのみ実行可能。

### `allowAccount`

```solidity
function allowAccount(address account) external onlyRole(ALLOWLIST_ROLE) timeLocked() {
    _allowAccount(account);
}
```

`Allowlist` にアカウントを追加する関数。
`ALLOWLIST_ROLE`を保有しているアドレスのみ実行可能。
指定したアカウントを `_allowAccount()` により許可状態にし、`AccountAllowed` イベントを発行します。
TimeLock により即時実行はできません。

**引数**

* `account`
    * 許可対象のアドレス。

### `disallowAccount`

```solidity
function disallowAccount(address account) external onlyRole(ALLOWLIST_ROLE) {
    _disallowAccount(account);
}
```

`Allowlist` からアカウントを除外する関数。
`ALLOWLIST_ROLE` を保有しているアドレスのみ実行可能。
指定アカウントを `_disallowAccount()` により非許可状態にし、`AccountDisallowed` イベントを発行します。
この関数ははTimeLock制御は不要です。

**引数**

* `account`
    * 除外対象アドレス。

### `setCap`

```solidity
function setCap(uint256 newCap) external onlyRole(ISSUER_ROLE) {
    _setCap(newCap);
}
```

供給上限（cap）を更新する関数。
`ISSUER_ROLE` を保有しているアドレスのみ実行可能。
現在の供給量より小さい値や0を設定しようとすると `revert` します。

**引数**

* `newCap`
    * 新しい供給上限。

### `setLockPeriod`

```solidity
function setLockPeriod(uint256 newLockPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) {
    _setLockPeriod(newLockPeriod);
}
```

TimeLockのロック期間を設定する関数。
`DEFAULT_ADMIN_ROLE` を保有しているアドレスのみ実行可能。
内部で `_setLockPeriod()` を呼び出し、`LockPeriodUpdated` イベントを発行します。

**引数**

* `newLockPeriod`
    * 新しいロック期間（秒）。

### `setLockExpiryPeriod`

```solidity
function setLockExpiryPeriod(uint256 newLockExpiryPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) {
    _setLockExpiryPeriod(newLockExpiryPeriod);
}
```

ロック解除後の有効期間を設定する関数。
`DEFAULT_ADMIN_ROLE` を保有しているアドレスのみ実行可能。
内部で `_setLockExpiryPeriod()` を呼び出します。

**引数**

* `newLockExpiryPeriod`
    * 新しい有効期間（秒）。
 
### `_authorizeUpgrade`

```solidity
function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {}
```

コントラクトの新しい実装へのアップグレードを許可する関数。
UUPS (Universal Upgradeable Proxy Standard) に準拠したアップグレード機構で使用される関数です。
この関数では `UPGRADER_ROLE` を持つアカウントのみにアップグレードを許可します。
関数本体では特に何もしませんが、`onlyRole` によるアクセス制御が機能します。

**引数**

* `newImplementation`
    * 新しいロジックコントラクトのアドレス。

### `_update`

```solidity
function _update(address from, address to, uint256 value)
    internal
    override(ERC20Upgradeable, ERC20PausableUpgradeable, ERC20AllowlistUpgradeable, ERC20CappedUpgradeable)
{
    super._update(from, to, value);
}
```

**ERC20**トークンの送受信、mint、burnの際に呼ばれる関数。
複数の継承元（**Pausable** / **Allowlist** / **Capped**）の `_update` を統合して呼び出します。

* Allowlist
    * `from` や `to` が許可されているかを確認。
* Pausable
    * `pause` 状態でないか確認。
* Capped
    * mint時（from = address(0)）に `cap` 超過を確認。

**引数**

* `from`
    * 送信元（mint時は `address(0)`）。
* `to`
    * 送信先（burn時は `address(0)`）。
* `value`
    * 送受信またはmint/burnするトークン量。

### `_approve`

```solidity
function _approve(address owner, address spender, uint256 value, bool emitEvent)
    internal
    override(ERC20Upgradeable, ERC20AllowlistUpgradeable)
{
    if (!allowed(spender)) revert ERC20Disallowed(spender);
    super._approve(owner, spender, value, emitEvent);
}
```

トークンの使用許可（`approve`）を設定する内部関数。
承認対象（`spender`）が Allowlist に登録されている必要があります。
`allowed(spender)` が `false` の場合、**ERC20Disallowed** エラーを返します。

**引数**

* `owner`
    * トークン保有者。
* `spender`
    * 使用を許可するアドレス。
* `value`
    * 許可するトークン量。
* `emitEvent`
    * `Approval` イベントを発行するかどうかのフラグ。

### `_spendAllowance`

```solidity
function _spendAllowance(address owner, address spender, uint256 value)
    internal
    override(ERC20Upgradeable)
{
    if (!allowed(spender)) revert ERC20Disallowed(spender);
    super._spendAllowance(owner, spender, value);
}
```

承認されたトークンの使用量を減算する内部関数。
`transferFrom` 時に呼び出され、`spender` の `Allowlist` 検証を行います。
未許可アカウントが実行しようとすると `revert` します。

**引数**

* `owner`
    * トークンの保有者。
* `spender`
    * 許可されている使用者。
* `value`
    * 使用するトークンの量。

### `_grantRole`

```solidity
function _grantRole(bytes32 role, address account) internal override returns (bool) {
    if (account == address(0)) {
        revert AccessControlInvalidArgument(role, account);
    }
    return super._grantRole(role, account);
}
```

アカウントにロールを割り当てる内部関数。
`0` アドレスに対してロールを付与しようとした場合は `AccessControlInvalidArgument` エラーを返して強制終了します。

**引数**

* `role`
    * 付与するロールの識別子（`bytes32`）。
* `account`
    * 付与対象のアドレス。

**戻り値**

* `bool`
    * ロールの付与に成功したかどうか。

### `_revokeRole`

```solidity
function _revokeRole(bytes32 role, address account) internal override returns (bool) {
    if (account == address(0) || account == _msgSender()) {
        revert AccessControlInvalidArgument(role, account);
    }
    return super._revokeRole(role, account);
}
```

アカウントからロールを剥奪する内部関数。
`0` アドレスや自分自身に対してロールを剥奪しようとすると、`AccessControlInvalidArgument` エラーを返します。

**引数**

* `role`
    * 剥奪するロールの識別子。
* `account`
    * 剥奪対象のアドレス。

**戻り値**

* `bool`
    * ロールの剥奪に成功したかどうか。
