Skip to content

Commit

Permalink
chore: Implement erc1155 deployment (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcar121293 authored Mar 19, 2024
1 parent 1fe57a3 commit 6e16f36
Show file tree
Hide file tree
Showing 9 changed files with 417 additions and 212 deletions.
2 changes: 1 addition & 1 deletion migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const PausableContract = artifacts.require("Pausable");
const BridgeContract = artifacts.require("Bridge");
const ERC20HandlerContract = artifacts.require("ERC20Handler");
const ERC721HandlerContract = artifacts.require("ERC721Handler");

const PermissionedGenericHandlerContract = artifacts.require(
"PermissionedGenericHandler"
);
Expand Down Expand Up @@ -161,7 +162,6 @@ module.exports = async function (deployer, network) {
}
}


// set MPC address
if (currentNetworkConfig.MPCAddress)
await bridgeInstance.endKeygen(currentNetworkConfig.MPCAddress);
Expand Down
48 changes: 48 additions & 0 deletions migrations/5_deploy_erc1155.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// The Licensed Work is (c) 2022 Sygma
// SPDX-License-Identifier: LGPL-3.0-only

const Utils = require("./utils");

const BridgeContract = artifacts.require("Bridge");
const ERC1155HandlerContract = artifacts.require("ERC1155Handler");

module.exports = async function (deployer, network) {
const networksConfig = Utils.getNetworksConfig();
// trim suffix from network name and fetch current network config
const currentNetworkName = network.split("-")[0];
const currentNetworkConfig = networksConfig[currentNetworkName];

delete networksConfig[currentNetworkName];
// fetch deployed contracts addresses
const bridgeInstance = await BridgeContract.deployed();

// deploy generic handler
const erc1155HandlerInstance = await deployer.deploy(
ERC1155HandlerContract,
bridgeInstance.address
);

console.table({

"ERC1155Handler Address": erc1155HandlerInstance.address,

});

for (const erc1155 of currentNetworkConfig.erc1155) {
await Utils.setupErc1155(
deployer,
erc1155,
bridgeInstance,
erc1155HandlerInstance
);

console.log(
"-------------------------------------------------------------------------------"
);
console.log("ERC1155 address:", "\t", erc1155.address);
console.log("ResourceID:", "\t", erc1155.resourceID);
console.log(
"-------------------------------------------------------------------------------"
);
}
};
34 changes: 34 additions & 0 deletions migrations/6_register_routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// The Licensed Work is (c) 2022 Sygma
// SPDX-License-Identifier: LGPL-3.0-only

const Utils = require("./utils");

const BasicFeeHandlerContract = artifacts.require("BasicFeeHandler");
const PercentageFeeHandler = artifacts.require("PercentageERC20FeeHandlerEVM");
const FeeRouterContract = artifacts.require("FeeHandlerRouter");

module.exports = async function (deployer, network) {
const networksConfig = Utils.getNetworksConfig();
// trim suffix from network name and fetch current network config
const currentNetworkName = network.split("-")[0];
const currentNetworkConfig = networksConfig[currentNetworkName];

delete networksConfig[currentNetworkName];
// fetch deployed contracts addresses
const basicFeeHandlerInstance = await BasicFeeHandlerContract.deployed()
const percentageFeeHandlerInstance = await PercentageFeeHandler.deployed()
const feeRouterInstance = await FeeRouterContract.deployed()

for(const fee of currentNetworkConfig.fee) {
console.log(`registering resource ${fee.resourceID} for destination domain
${fee.toDomain} using feeHandler: ${basicFeeHandlerInstance.address}`)
if (fee.type == "basic") {
await feeRouterInstance.adminSetResourceHandler(fee.toDomain, fee.resourceID, basicFeeHandlerInstance.address)
await basicFeeHandlerInstance.changeFee(fee.toDomain, fee.resourceID, fee.feeAmount)
} else if (fee.type == "percentage") {
await feeRouterInstance.adminSetResourceHandler(
fee.toDomain, fee.resourceID, percentageFeeHandlerInstance.address)
await percentageFeeHandlerInstance.changeFee(fee.toDomain, fee.resourceID, fee.feeAmount)
}
}
};
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6e16f36

Please sign in to comment.