Skip to content

Commit 7057a54

Browse files
committed
hotfix: fixed sonar issue
1 parent 0760427 commit 7057a54

File tree

1 file changed

+37
-55
lines changed

1 file changed

+37
-55
lines changed

bridge/hardhat/script/changeOwner.js

+37-55
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function main() {
88

99
let newWalletAddress = null;
1010

11-
switch (network){
11+
switch (network) {
1212
case "rsktestnet":
1313
newWalletAddress = '0x51591ec8f296ef3e4deebe32c392c706aef42133';
1414
break;
@@ -20,11 +20,6 @@ async function main() {
2020
break;
2121
}
2222

23-
if (newWalletAddress === null) {
24-
console.log('No new owner founded');
25-
return;
26-
}
27-
2823
const Bridge = await deployments.get('BridgeV3');
2924
const BridgeProxy = await deployments.get('BridgeProxy');
3025

@@ -51,72 +46,59 @@ async function main() {
5146
console.log('Current Bridge Owner: ', bridgeOwner);
5247
console.log('List of multisig owners: ', multiSigOwners);
5348

54-
if(!multiSigOwners.includes(deployer)) {
55-
console.log('You should be a owner in the multisig wallet to perform this transaction');
49+
if (!multiSigOwners.includes(deployer) || newWalletAddress === null) {
50+
console.log('You should be a owner in the multisig wallet to perform this transaction and the new ' +
51+
'wallet should exists');
5652
return;
5753
}
5854

59-
if (bridgeOwner === MultiSigWallet.address) {
60-
const changeBridgeOwnerMethod = bridge.methods
61-
.transferOwnership(newWalletAddress);
62-
await changeBridgeOwnerMethod.call({ from: MultiSigWallet.address });
63-
await multiSigContract.methods.submitTransaction(
64-
BridgeProxy.address,
65-
0,
66-
changeBridgeOwnerMethod.encodeABI()
67-
).send({ from: deployer, gasLimit: 3000000 });
55+
try {
56+
if (bridgeOwner === MultiSigWallet.address) {
57+
const changeBridgeOwnerMethod = bridge.methods
58+
.transferOwnership(newWalletAddress);
59+
await changeBridgeOwnerMethod.call({from: MultiSigWallet.address});
60+
await multiSigContract.methods.submitTransaction(
61+
BridgeProxy.address,
62+
0,
63+
changeBridgeOwnerMethod.encodeABI()
64+
).send({from: deployer, gasLimit: 3000000});
6865

69-
const newOwner = await bridge.methods.owner().call();
66+
const newOwner = await bridge.methods.owner().call();
7067

71-
if(newOwner.toLowerCase() === newWalletAddress.toLowerCase()) {
7268
console.log('Bridge owner changed successfully, the new owner now is: ', newOwner);
73-
} else {
74-
console.log('Error changing the bridge owner, owner is: ', newOwner);
7569
}
76-
} else {
77-
console.log('Multisig is not the bridge owner');
78-
}
7970

80-
if (federationOwner === MultiSigWallet.address) {
81-
const changeFederationOwnerMethod = federation.methods
82-
.transferOwnership(newWalletAddress);
83-
await changeFederationOwnerMethod.call({ from: MultiSigWallet.address });
84-
await multiSigContract.methods.submitTransaction(
85-
FederationProxy.address,
86-
0,
87-
changeFederationOwnerMethod.encodeABI()
88-
).send({ from: deployer, gasLimit: 3000000 });
71+
if (federationOwner === MultiSigWallet.address) {
72+
const changeFederationOwnerMethod = federation.methods
73+
.transferOwnership(newWalletAddress);
74+
await changeFederationOwnerMethod.call({from: MultiSigWallet.address});
75+
await multiSigContract.methods.submitTransaction(
76+
FederationProxy.address,
77+
0,
78+
changeFederationOwnerMethod.encodeABI()
79+
).send({from: deployer, gasLimit: 3000000});
8980

90-
const newOwner = await federation.methods.owner().call();
81+
const newOwner = await federation.methods.owner().call();
9182

92-
if(newOwner.toLowerCase() === newWalletAddress.toLowerCase()) {
9383
console.log('Federation owner changed successfully, the new owner now is: ', newOwner);
94-
} else {
95-
console.log('Error changing the federation owner, owner is: ', newOwner);
9684
}
97-
} else {
98-
console.log('Multisig is not the Federation owner');
99-
}
10085

101-
if (allowTokensOwner === MultiSigWallet.address) {
102-
const changeAllowTokensOwnerMethod = allowTokens.methods
103-
.transferOwnership(newWalletAddress);
104-
await changeAllowTokensOwnerMethod.call({ from: MultiSigWallet.address });
105-
await multiSigContract.methods.submitTransaction(
106-
AllowTokensProxy.address,
107-
0,
108-
changeAllowTokensOwnerMethod.encodeABI()
109-
).send({ from: deployer, gasLimit: 3000000 });
86+
if (allowTokensOwner === MultiSigWallet.address) {
87+
const changeAllowTokensOwnerMethod = allowTokens.methods
88+
.transferOwnership(newWalletAddress);
89+
await changeAllowTokensOwnerMethod.call({from: MultiSigWallet.address});
90+
await multiSigContract.methods.submitTransaction(
91+
AllowTokensProxy.address,
92+
0,
93+
changeAllowTokensOwnerMethod.encodeABI()
94+
).send({from: deployer, gasLimit: 3000000});
11095

111-
const newOwner = await allowTokens.methods.owner().call();
96+
const newOwner = await allowTokens.methods.owner().call();
11297

113-
if(newOwner.toLowerCase() === newWalletAddress.toLowerCase()) {
11498
console.log('Allow Tokens owner changed successfully, the new owner now is: ', newOwner);
115-
} else {
116-
console.log('Error changing the Allow Tokens owner, owner is: ', newOwner);
11799
}
118-
} else {
119-
console.log('Multisig is not the Allow tokens owner');
100+
} catch (err) {
101+
throw new Error(err);
120102
}
121103
}
122104

0 commit comments

Comments
 (0)