Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 6eb7041

Browse files
authored
chore: permission generic handlers (#195)
1 parent 26dc82a commit 6eb7041

File tree

2 files changed

+54
-36
lines changed

2 files changed

+54
-36
lines changed

migrations/2_deploy_contracts.js

+42-28
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ module.exports = async function (deployer, network) {
5757
ERC721HandlerContract,
5858
bridgeInstance.address
5959
);
60-
const permissionedGenericHandlerInstance = await deployer.deploy(
61-
PermissionedGenericHandlerContract,
62-
bridgeInstance.address
63-
);
6460

6561
// deploy fee handlers
6662
const feeRouterInstance = await deployer.deploy(
@@ -105,8 +101,6 @@ module.exports = async function (deployer, network) {
105101
"Bridge Address": bridgeInstance.address,
106102
"ERC20Handler Address": erc20HandlerInstance.address,
107103
"ERC721Handler Address": erc721HandlerInstance.address,
108-
"PermissionedGenericHandler Address":
109-
permissionedGenericHandlerInstance.address,
110104
"FeeRouterContract Address": feeRouterInstance.address,
111105
"BasicFeeHandler Address": basicFeeHandlerInstance.address,
112106
"DynamicFeeHandler Address": dynamicFeeHandlerInstance.address,
@@ -173,32 +167,52 @@ module.exports = async function (deployer, network) {
173167
);
174168
}
175169

176-
for (const generic of currentNetworkConfig.permissionedGeneric) {
177-
await Utils.setupGeneric(
178-
deployer,
179-
generic,
180-
bridgeInstance,
181-
permissionedGenericHandlerInstance
182-
);
183-
await Utils.setupFee(
184-
networksConfig,
185-
feeRouterInstance,
186-
dynamicFeeHandlerInstance,
187-
basicFeeHandlerInstance,
188-
percentageFeeHandlerInstance,
189-
generic
170+
// check if permissioned generic handler should be deployed
171+
if (currentNetworkConfig.permissionedGeneric.length > 0) {
172+
const permissionedGenericHandlerInstance = await deployer.deploy(
173+
PermissionedGenericHandlerContract,
174+
bridgeInstance.address
190175
);
191176

192-
console.log(
193-
"-------------------------------------------------------------------------------"
194-
);
195-
console.log("Generic contract address:", "\t", generic.address);
196-
console.log("ResourceID:", "\t", generic.resourceID);
197-
console.log(
198-
"-------------------------------------------------------------------------------"
199-
);
177+
for (const generic of currentNetworkConfig.permissionedGeneric) {
178+
await Utils.setupGeneric(
179+
deployer,
180+
generic,
181+
bridgeInstance,
182+
permissionedGenericHandlerInstance
183+
);
184+
await Utils.setupFee(
185+
networksConfig,
186+
feeRouterInstance,
187+
dynamicFeeHandlerInstance,
188+
basicFeeHandlerInstance,
189+
percentageFeeHandlerInstance,
190+
generic
191+
);
192+
193+
console.log(
194+
"-------------------------------------------------------------------------------"
195+
);
196+
console.log(
197+
"Permissioned generic handler address:",
198+
"\t",
199+
permissionedGenericHandlerInstance.address
200+
);
201+
console.log(
202+
"Generic contract address:",
203+
"\t", generic.address
204+
);
205+
console.log(
206+
"ResourceID:",
207+
"\t", generic.resourceID
208+
);
209+
console.log(
210+
"-------------------------------------------------------------------------------"
211+
);
212+
}
200213
}
201214

215+
202216
// set MPC address
203217
if (currentNetworkConfig.MPCAddress)
204218
await bridgeInstance.endKeygen(currentNetworkConfig.MPCAddress);

migrations/3_deploy_permissionlessGenericHandler.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,38 @@ const PermissionlessGenericHandlerContract = artifacts.require(
1010
);
1111
const FeeRouterContract = artifacts.require("FeeHandlerRouter");
1212
const BasicFeeHandlerContract = artifacts.require("BasicFeeHandler");
13-
const DynamicFeeHandlerContract = artifacts.require("DynamicERC20FeeHandlerEVM");
1413
const PercentageFeeHandler = artifacts.require("PercentageERC20FeeHandlerEVM");
14+
const DynamicGenericFeeHandlerEVMContract = artifacts.require("DynamicGenericFeeHandlerEVM");
1515

1616
module.exports = async function (deployer, network) {
1717
const networksConfig = Utils.getNetworksConfig();
1818
// trim suffix from network name and fetch current network config
1919
const currentNetworkName = network.split("-")[0];
2020
const currentNetworkConfig = networksConfig[currentNetworkName];
2121
delete networksConfig[currentNetworkName];
22-
22+
if (
23+
currentNetworkConfig.permissionlessGeneric &&
24+
currentNetworkConfig.permissionlessGeneric.resourceID
25+
) {
2326
// fetch deployed contracts addresses
2427
const bridgeInstance = await BridgeContract.deployed();
2528
const feeRouterInstance = await FeeRouterContract.deployed();
2629
const basicFeeHandlerInstance = await BasicFeeHandlerContract.deployed();
2730
const percentageFeeHandlerInstance = await PercentageFeeHandler.deployed();
28-
const dynamicFeeHandlerInstance =
29-
await DynamicFeeHandlerContract.deployed();
3031

3132
// deploy generic handler
3233
const permissionlessGenericHandlerInstance = await deployer.deploy(
3334
PermissionlessGenericHandlerContract,
3435
bridgeInstance.address
3536
);
3637

38+
// deploy generic dynamic fee handler
39+
const dynamicFeeHandlerInstance = await deployer.deploy(
40+
DynamicGenericFeeHandlerEVMContract,
41+
bridgeInstance.address,
42+
feeRouterInstance.address
43+
)
44+
3745
console.log(
3846
"-------------------------------------------------------------------------------"
3947
);
@@ -52,10 +60,6 @@ module.exports = async function (deployer, network) {
5260
);
5361

5462
// setup permissionless generic handler
55-
if (
56-
currentNetworkConfig.permissionlessGeneric &&
57-
currentNetworkConfig.permissionlessGeneric.resourceID
58-
) {
5963
const genericHandlerSetResourceData =
6064
Helpers.constructGenericHandlerSetResourceData(
6165
Helpers.blankFunctionSig,

0 commit comments

Comments
 (0)