|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity 0.8.24; |
| 3 | + |
| 4 | +import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol"; |
| 5 | +import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol"; |
| 6 | + |
| 7 | +import {Pool} from "../../libraries/Pool.sol"; |
| 8 | +import {TokenPool} from "../../pools/TokenPool.sol"; |
| 9 | + |
| 10 | +import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; |
| 11 | +import {SafeERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol"; |
| 12 | + |
| 13 | +/// @notice This mock contract facilitates testing of LBTC token transfers by burning and minting tokens. |
| 14 | +contract MockLBTCTokenPool is TokenPool, ITypeAndVersion { |
| 15 | + using SafeERC20 for IERC20; |
| 16 | + |
| 17 | + string public constant override typeAndVersion = "MockLBTCTokenPool 1.5.1"; |
| 18 | + |
| 19 | + // This variable i_destPoolData will have either a 32-byte or non-32-byte value, which will change the off-chain behavior. |
| 20 | + // If it is 32 bytes, the off-chain will consider it as attestation enabled and call the attestation API. |
| 21 | + // If it is non-32 bytes, the off-chain will consider it as attestation disabled. |
| 22 | + bytes public i_destPoolData; |
| 23 | + |
| 24 | + constructor( |
| 25 | + IERC20 token, |
| 26 | + address[] memory allowlist, |
| 27 | + address rmnProxy, |
| 28 | + address router, |
| 29 | + bytes memory destPoolData |
| 30 | + ) TokenPool(token, 8, allowlist, rmnProxy, router) { |
| 31 | + i_destPoolData = destPoolData; |
| 32 | + } |
| 33 | + |
| 34 | + function lockOrBurn( |
| 35 | + Pool.LockOrBurnInV1 calldata lockOrBurnIn |
| 36 | + ) public virtual override returns (Pool.LockOrBurnOutV1 memory) { |
| 37 | + IBurnMintERC20(address(i_token)).burn(lockOrBurnIn.amount); |
| 38 | + emit Burned(msg.sender, lockOrBurnIn.amount); |
| 39 | + |
| 40 | + return |
| 41 | + Pool.LockOrBurnOutV1({ |
| 42 | + destTokenAddress: getRemoteToken( |
| 43 | + lockOrBurnIn.remoteChainSelector |
| 44 | + ), |
| 45 | + destPoolData: i_destPoolData |
| 46 | + }); |
| 47 | + } |
| 48 | + |
| 49 | + function releaseOrMint( |
| 50 | + Pool.ReleaseOrMintInV1 calldata releaseOrMintIn |
| 51 | + ) public virtual override returns (Pool.ReleaseOrMintOutV1 memory) { |
| 52 | + IBurnMintERC20(address(i_token)).mint(releaseOrMintIn.receiver, releaseOrMintIn.amount); |
| 53 | + |
| 54 | + emit Minted( |
| 55 | + msg.sender, |
| 56 | + releaseOrMintIn.receiver, |
| 57 | + releaseOrMintIn.amount |
| 58 | + ); |
| 59 | + |
| 60 | + return |
| 61 | + Pool.ReleaseOrMintOutV1({ |
| 62 | + destinationAmount: releaseOrMintIn.amount |
| 63 | + }); |
| 64 | + } |
| 65 | +} |
| 66 | + |
0 commit comments