From 6e690020aac9fe100a2c3a0a6dd405a8d36bddca Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:00:08 +0100 Subject: [PATCH 1/7] Create add PolyERC20Factory-contract constructor(string memory name, string memory symbol) ERC20(name, symbol) UniversalChanIbcApp() {} function mint(address account, uint256 amount) public onlyOwner { function mint(address account, uint256 amount) public virtual onlyOwner { _mint(account, amount); } function burn(address account, uint256 amount) public onlyOwner { function burn(address account, uint256 amount) public virtual onlyOwner { _burn(account, amount); } --- add PolyERC20Factory-contract | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 add PolyERC20Factory-contract diff --git a/add PolyERC20Factory-contract b/add PolyERC20Factory-contract new file mode 100644 index 0000000..ab46a1c --- /dev/null +++ b/add PolyERC20Factory-contract @@ -0,0 +1,11 @@ +constructor(string memory name, string memory symbol) ERC20(name, symbol) UniversalChanIbcApp() {} + + function mint(address account, uint256 amount) public onlyOwner { + function mint(address account, uint256 amount) public virtual onlyOwner { + _mint(account, amount); + } + + function burn(address account, uint256 amount) public onlyOwner { + function burn(address account, uint256 amount) public virtual onlyOwner { + _burn(account, amount); + } From 7abf324d5f615cbb7dc32396b71974c4a428c3ea Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:03:04 +0100 Subject: [PATCH 2/7] Create PolyERC20Factory.sol // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import './UniversalChanIbcApp.sol'; import {PolyERC20} from './PolyERC20.sol'; import {receiverNotOriginPacketSender} from '@open-ibc/vibc-core-smart-contracts/contracts/libs/Ibc.sol'; contract PolyERC20FixedSupply is PolyERC20 { constructor(string memory _name, string memory _symbol, uint256 tokenSupply) PolyERC20(_name, _symbol) { _mint(msg.sender, tokenSupply); } function mint(address account, uint256 amount) public virtual override onlyOwner { revert('minting disabled'); } function burn(address account, uint256 amount) public virtual override onlyOwner { revert('burning disabled'); } } contract PolyERC20Factory is UniversalChanIbcApp { event TokenMint(address indexed token, address indexed receiver, uint256 amount); event BridgeSuccess(bytes32 indexed channelId); event BridgeFailure(bytes32 indexed channelId); constructor() UniversalChanIbcApp() {} function deployXPolyERC20( string[] memory channels, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply ) external returns (PolyERC20FixedSupply token) { return this.deployXPolyERC20(channels, _name, _symbol, _salt, _tokenSupply, 60); } function deployXPolyERC20( string[] memory channels, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply, uint64 timeoutSeconds ) external returns (PolyERC20FixedSupply token) { // deploy on the current chain token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); // deploy to other chains for (uint256 i = 0; i < channels.length; i++) { bytes memory payload = abi.encode(msg.sender, _name, _symbol, _salt, _tokenSupply); uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * 1_000_000_000); IbcUniversalPacketSender(mw).sendUniversalPacket( IbcUtils.toBytes32(channels[i]), IbcUtils.toBytes32(address(this)), payload, timeoutTimestamp ); } return token; } function deployPolyERC20( string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply ) external returns (PolyERC20FixedSupply token) { token = new PolyERC20FixedSupply{salt: _salt}(_name, _symbol, _tokenSupply); return token; } function onRecvUniversalPacket( bytes32 channelId, UniversalPacket calldata packet ) external override onlyIbcMw returns (AckPacket memory ackPacket) { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, bytes32, uint256)); PolyERC20FixedSupply token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); emit TokenMint(address(token), sender, _tokenSupply); return AckPacket(true, abi.encode(address(this))); } function onUniversalAcknowledgement( bytes32 channelId, UniversalPacket memory packet, AckPacket calldata ack ) external override onlyIbcMw { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, bytes32, uint256)); if (ack.success) { emit BridgeSuccess(channelId); (address receiver) = abi.decode(ack.data, (address)); } else { emit BridgeFailure(channelId); } } function onTimeoutUniversalPacket(bytes32 channelId, UniversalPacket calldata packet) external override onlyIbcMw { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, string memory _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, string, uint256)); emit BridgeFailure(channelId); } } --- solidity/contracts/PolyERC20Factory.sol | 119 ++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 solidity/contracts/PolyERC20Factory.sol diff --git a/solidity/contracts/PolyERC20Factory.sol b/solidity/contracts/PolyERC20Factory.sol new file mode 100644 index 0000000..4f9c57f --- /dev/null +++ b/solidity/contracts/PolyERC20Factory.sol @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.0; + +import './UniversalChanIbcApp.sol'; +import {PolyERC20} from './PolyERC20.sol'; +import {receiverNotOriginPacketSender} from '@open-ibc/vibc-core-smart-contracts/contracts/libs/Ibc.sol'; + +contract PolyERC20FixedSupply is PolyERC20 { + constructor(string memory _name, string memory _symbol, uint256 tokenSupply) PolyERC20(_name, _symbol) { + _mint(msg.sender, tokenSupply); + } + + function mint(address account, uint256 amount) public virtual override onlyOwner { + revert('minting disabled'); + } + + function burn(address account, uint256 amount) public virtual override onlyOwner { + revert('burning disabled'); + } +} + +contract PolyERC20Factory is UniversalChanIbcApp { + event TokenMint(address indexed token, address indexed receiver, uint256 amount); + event BridgeSuccess(bytes32 indexed channelId); + event BridgeFailure(bytes32 indexed channelId); + + constructor() UniversalChanIbcApp() {} + + function deployXPolyERC20( + string[] memory channels, + string memory _name, + string memory _symbol, + bytes32 _salt, + uint256 _tokenSupply + ) external returns (PolyERC20FixedSupply token) { + return this.deployXPolyERC20(channels, _name, _symbol, _salt, _tokenSupply, 60); + } + + function deployXPolyERC20( + string[] memory channels, + string memory _name, + string memory _symbol, + bytes32 _salt, + uint256 _tokenSupply, + uint64 timeoutSeconds + ) external returns (PolyERC20FixedSupply token) { + // deploy on the current chain + token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); + + // deploy to other chains + for (uint256 i = 0; i < channels.length; i++) { + bytes memory payload = abi.encode(msg.sender, _name, _symbol, _salt, _tokenSupply); + + uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * 1_000_000_000); + + IbcUniversalPacketSender(mw).sendUniversalPacket( + IbcUtils.toBytes32(channels[i]), IbcUtils.toBytes32(address(this)), payload, timeoutTimestamp + ); + } + return token; + } + + function deployPolyERC20( + string memory _name, + string memory _symbol, + bytes32 _salt, + uint256 _tokenSupply + ) external returns (PolyERC20FixedSupply token) { + token = new PolyERC20FixedSupply{salt: _salt}(_name, _symbol, _tokenSupply); + return token; + } + + function onRecvUniversalPacket( + bytes32 channelId, + UniversalPacket calldata packet + ) external override onlyIbcMw returns (AckPacket memory ackPacket) { + if (packet.srcPortAddr != packet.destPortAddr) { + revert receiverNotOriginPacketSender(); + } + + (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = + abi.decode(packet.appData, (address, string, string, bytes32, uint256)); + + PolyERC20FixedSupply token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); + emit TokenMint(address(token), sender, _tokenSupply); + + return AckPacket(true, abi.encode(address(this))); + } + + function onUniversalAcknowledgement( + bytes32 channelId, + UniversalPacket memory packet, + AckPacket calldata ack + ) external override onlyIbcMw { + if (packet.srcPortAddr != packet.destPortAddr) { + revert receiverNotOriginPacketSender(); + } + + (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = + abi.decode(packet.appData, (address, string, string, bytes32, uint256)); + + if (ack.success) { + emit BridgeSuccess(channelId); + (address receiver) = abi.decode(ack.data, (address)); + } else { + emit BridgeFailure(channelId); + } + } + + function onTimeoutUniversalPacket(bytes32 channelId, UniversalPacket calldata packet) external override onlyIbcMw { + if (packet.srcPortAddr != packet.destPortAddr) { + revert receiverNotOriginPacketSender(); + } + + (address sender, string memory _name, string memory _symbol, string memory _salt, uint256 _tokenSupply) = + abi.decode(packet.appData, (address, string, string, string, uint256)); + emit BridgeFailure(channelId); + } +} From 5ff873f6ccdccc24aa581dc9be82ad8a3a11256e Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:04:34 +0100 Subject: [PATCH 3/7] Create PolyERC20Deploy.sol @@ -5,6 +5,7 @@ import 'forge-std/Script.sol'; import {IbcMwUser} from '@open-ibc/vibc-core-smart-contracts/contracts/interfaces/IbcMiddleware.sol'; import '../contracts/PolyERC20.sol'; import './XERC20Deploy.sol'; import '../contracts/PolyERC20Factory.sol'; contract PolyERC20Deploy is Script { using stdJson for string; @@ -15,7 +16,7 @@ contract PolyERC20Deploy is Script { return keccak256(bytes(vm.envString('SALT'))); } function run() external { function deployPolyERC20() public { string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); @@ -47,4 +48,51 @@ contract PolyERC20Deploy is Script { vm.stopBroadcast(); } function deployPolyERC20WithFactory() public { string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); uint256 baseFork = vm.createFork(vm.rpcUrl(vm.envString('BASE_SEPOLIA_RPC'))); uint256 opFork = vm.createFork(vm.rpcUrl(vm.envString('OPTIMISM_SEPOLIA_RPC'))); uint256 chainId = vm.envUint('CHAIN_ID'); if (chainId == 84_532) { string[] memory channels = new string[](1); channels[0] = 'channel-11'; vm.selectFork(baseFork); vm.startBroadcast(deployer); IbcMwUser baseMW = IbcMwUser(payable(vm.envAddress('BASE_UC_MW_SIM'))); PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); factory.setDefaultMw(address(baseMW)); PolyERC20FixedSupply basePolyToken = factory.deployXPolyERC20(channels, _data.name, _data.symbol, salt(), 1_000_000_000); // solhint-disable-next-line no-console console.log('factory deployed on Base chain at:', address(factory)); // solhint-disable-next-line no-console console.log('PolyERC20 token deployed on Base chain at:', address(basePolyToken)); } if (chainId == 11_155_420) { string[] memory channels = new string[](1); channels[0] = 'channel-10'; vm.selectFork(opFork); vm.startBroadcast(deployer); IbcMwUser opMW = IbcMwUser(payable(vm.envAddress('OP_UC_MW_SIM'))); PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); factory.setDefaultMw(address(opMW)); // solhint-disable-next-line no-console console.log('factory deployed on Optimism chain at:', address(factory)); } vm.stopBroadcast(); } function run() external { deployPolyERC20(); } } --- .../solidity/scripts/PolyERC20Deploy.sol | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 solidity/contracts/solidity/scripts/PolyERC20Deploy.sol diff --git a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol new file mode 100644 index 0000000..0be6399 --- /dev/null +++ b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol @@ -0,0 +1,69 @@ +@@ -5,6 +5,7 @@ import 'forge-std/Script.sol'; +import {IbcMwUser} from '@open-ibc/vibc-core-smart-contracts/contracts/interfaces/IbcMiddleware.sol'; +import '../contracts/PolyERC20.sol'; +import './XERC20Deploy.sol'; +import '../contracts/PolyERC20Factory.sol'; + +contract PolyERC20Deploy is Script { + using stdJson for string; +@@ -15,7 +16,7 @@ contract PolyERC20Deploy is Script { + return keccak256(bytes(vm.envString('SALT'))); + } + + function run() external { + function deployPolyERC20() public { + string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); + DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); + +@@ -47,4 +48,51 @@ contract PolyERC20Deploy is Script { + + vm.stopBroadcast(); + } + + function deployPolyERC20WithFactory() public { + string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); + DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); + + uint256 baseFork = vm.createFork(vm.rpcUrl(vm.envString('BASE_SEPOLIA_RPC'))); + uint256 opFork = vm.createFork(vm.rpcUrl(vm.envString('OPTIMISM_SEPOLIA_RPC'))); + uint256 chainId = vm.envUint('CHAIN_ID'); + + if (chainId == 84_532) { + string[] memory channels = new string[](1); + channels[0] = 'channel-11'; + + vm.selectFork(baseFork); + vm.startBroadcast(deployer); + IbcMwUser baseMW = IbcMwUser(payable(vm.envAddress('BASE_UC_MW_SIM'))); + PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); + factory.setDefaultMw(address(baseMW)); + PolyERC20FixedSupply basePolyToken = + factory.deployXPolyERC20(channels, _data.name, _data.symbol, salt(), 1_000_000_000); + + // solhint-disable-next-line no-console + console.log('factory deployed on Base chain at:', address(factory)); + // solhint-disable-next-line no-console + console.log('PolyERC20 token deployed on Base chain at:', address(basePolyToken)); + } + + if (chainId == 11_155_420) { + string[] memory channels = new string[](1); + channels[0] = 'channel-10'; + + vm.selectFork(opFork); + vm.startBroadcast(deployer); + IbcMwUser opMW = IbcMwUser(payable(vm.envAddress('OP_UC_MW_SIM'))); + PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); + factory.setDefaultMw(address(opMW)); + + // solhint-disable-next-line no-console + console.log('factory deployed on Optimism chain at:', address(factory)); + } + + vm.stopBroadcast(); + } + + function run() external { + deployPolyERC20(); + } +} From 80e0c0c450c735e8c7690613a2c87f5ef6e61fa1 Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:40:25 +0100 Subject: [PATCH 4/7] Update PolyERC20Deploy.sol --- solidity/contracts/solidity/scripts/PolyERC20Deploy.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol index 0be6399..da9e275 100644 --- a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol +++ b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol @@ -1,4 +1,3 @@ -@@ -5,6 +5,7 @@ import 'forge-std/Script.sol'; import {IbcMwUser} from '@open-ibc/vibc-core-smart-contracts/contracts/interfaces/IbcMiddleware.sol'; import '../contracts/PolyERC20.sol'; import './XERC20Deploy.sol'; From f7fef8f8395f055261de9f8036d51ec0e2dde247 Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:41:47 +0100 Subject: [PATCH 5/7] Update PolyERC20Deploy.sol --- .../solidity/scripts/PolyERC20Deploy.sol | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol index da9e275..8b13789 100644 --- a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol +++ b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol @@ -1,68 +1 @@ -import {IbcMwUser} from '@open-ibc/vibc-core-smart-contracts/contracts/interfaces/IbcMiddleware.sol'; -import '../contracts/PolyERC20.sol'; -import './XERC20Deploy.sol'; -import '../contracts/PolyERC20Factory.sol'; -contract PolyERC20Deploy is Script { - using stdJson for string; -@@ -15,7 +16,7 @@ contract PolyERC20Deploy is Script { - return keccak256(bytes(vm.envString('SALT'))); - } - - function run() external { - function deployPolyERC20() public { - string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); - DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); - -@@ -47,4 +48,51 @@ contract PolyERC20Deploy is Script { - - vm.stopBroadcast(); - } - - function deployPolyERC20WithFactory() public { - string memory _json = vm.readFile('./solidity/scripts/xerc20-deployment-config.json'); - DeploymentConfig memory _data = abi.decode(_json.parseRaw('.'), (DeploymentConfig)); - - uint256 baseFork = vm.createFork(vm.rpcUrl(vm.envString('BASE_SEPOLIA_RPC'))); - uint256 opFork = vm.createFork(vm.rpcUrl(vm.envString('OPTIMISM_SEPOLIA_RPC'))); - uint256 chainId = vm.envUint('CHAIN_ID'); - - if (chainId == 84_532) { - string[] memory channels = new string[](1); - channels[0] = 'channel-11'; - - vm.selectFork(baseFork); - vm.startBroadcast(deployer); - IbcMwUser baseMW = IbcMwUser(payable(vm.envAddress('BASE_UC_MW_SIM'))); - PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); - factory.setDefaultMw(address(baseMW)); - PolyERC20FixedSupply basePolyToken = - factory.deployXPolyERC20(channels, _data.name, _data.symbol, salt(), 1_000_000_000); - - // solhint-disable-next-line no-console - console.log('factory deployed on Base chain at:', address(factory)); - // solhint-disable-next-line no-console - console.log('PolyERC20 token deployed on Base chain at:', address(basePolyToken)); - } - - if (chainId == 11_155_420) { - string[] memory channels = new string[](1); - channels[0] = 'channel-10'; - - vm.selectFork(opFork); - vm.startBroadcast(deployer); - IbcMwUser opMW = IbcMwUser(payable(vm.envAddress('OP_UC_MW_SIM'))); - PolyERC20Factory factory = new PolyERC20Factory{salt: salt()}(); - factory.setDefaultMw(address(opMW)); - - // solhint-disable-next-line no-console - console.log('factory deployed on Optimism chain at:', address(factory)); - } - - vm.stopBroadcast(); - } - - function run() external { - deployPolyERC20(); - } -} From 22f5970bbba15e3210c4cc159a321f5827c4300f Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:42:38 +0100 Subject: [PATCH 6/7] Delete solidity/contracts/solidity/scripts/PolyERC20Deploy.sol --- solidity/contracts/solidity/scripts/PolyERC20Deploy.sol | 1 - 1 file changed, 1 deletion(-) delete mode 100644 solidity/contracts/solidity/scripts/PolyERC20Deploy.sol diff --git a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol b/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol deleted file mode 100644 index 8b13789..0000000 --- a/solidity/contracts/solidity/scripts/PolyERC20Deploy.sol +++ /dev/null @@ -1 +0,0 @@ - From 4b859579901d2e368225f62f9a765d3cfcce8b93 Mon Sep 17 00:00:00 2001 From: Neme <64239422+Nemeswat@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:46:26 +0100 Subject: [PATCH 7/7] Update PolyERC20Factory.sol (#1) // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import './UniversalChanIbcApp.sol'; import {PolyERC20} from './PolyERC20.sol'; import {receiverNotOriginPacketSender} from '@open-ibc/vibc-core-smart-contracts/contracts/libs/Ibc.sol'; contract PolyERC20FixedSupply is PolyERC20 { constructor(string memory _name, string memory _symbol, uint256 tokenSupply) PolyERC20(_name, _symbol) { _mint(msg.sender, tokenSupply); } function mint(address account, uint256 amount) public virtual override onlyOwner { revert('minting disabled'); } function burn(address account, uint256 amount) public virtual override onlyOwner { revert('burning disabled'); } } contract PolyERC20Factory is UniversalChanIbcApp { event TokenMint(address indexed token, address indexed receiver, uint256 amount); event BridgeSuccess(bytes32 indexed channelId); event BridgeFailure(bytes32 indexed channelId); constructor() UniversalChanIbcApp() {} function deployXPolyERC20( string[] memory channels, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply ) external returns (PolyERC20FixedSupply token) { return this.deployXPolyERC20(channels, _name, _symbol, _salt, _tokenSupply, 60); } function deployXPolyERC20( string[] memory channels, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply, uint64 timeoutSeconds ) external returns (PolyERC20FixedSupply token) { // deploy on the current chain token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); // deploy to other chains for (uint256 i = 0; i < channels.length; i++) { bytes memory payload = abi.encode(msg.sender, _name, _symbol, _salt, _tokenSupply); uint64 timeoutTimestamp = uint64((block.timestamp + timeoutSeconds) * 1_000_000_000); IbcUniversalPacketSender(mw).sendUniversalPacket( IbcUtils.toBytes32(channels[i]), IbcUtils.toBytes32(address(this)), payload, timeoutTimestamp ); } return token; } function deployPolyERC20( string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply ) external returns (PolyERC20FixedSupply token) { token = new PolyERC20FixedSupply{salt: _salt}(_name, _symbol, _tokenSupply); return token; } function onRecvUniversalPacket( bytes32 channelId, UniversalPacket calldata packet ) external override onlyIbcMw returns (AckPacket memory ackPacket) { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, bytes32, uint256)); PolyERC20FixedSupply token = this.deployPolyERC20(_name, _symbol, _salt, _tokenSupply); emit TokenMint(address(token), sender, _tokenSupply); return AckPacket(true, abi.encode(address(this))); } function onUniversalAcknowledgement( bytes32 channelId, UniversalPacket memory packet, AckPacket calldata ack ) external override onlyIbcMw { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, bytes32 _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, bytes32, uint256)); if (ack.success) { emit BridgeSuccess(channelId); (address receiver) = abi.decode(ack.data, (address)); } else { emit BridgeFailure(channelId); } } function onTimeoutUniversalPacket(bytes32 channelId, UniversalPacket calldata packet) external override onlyIbcMw { if (packet.srcPortAddr != packet.destPortAddr) { revert receiverNotOriginPacketSender(); } (address sender, string memory _name, string memory _symbol, string memory _salt, uint256 _tokenSupply) = abi.decode(packet.appData, (address, string, string, string, uint256)); emit BridgeFailure(channelId); } } --- solidity/contracts/PolyERC20Factory.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity/contracts/PolyERC20Factory.sol b/solidity/contracts/PolyERC20Factory.sol index 4f9c57f..e7e8a76 100644 --- a/solidity/contracts/PolyERC20Factory.sol +++ b/solidity/contracts/PolyERC20Factory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.0; +pragma solidity ^0.8.0; import './UniversalChanIbcApp.sol'; import {PolyERC20} from './PolyERC20.sol';