Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 076fc37

Browse files
Matija PetrunićMakMuftic
andauthored
Restrict retry to be only callable by allowed address (#625)
Co-authored-by: mace <[email protected]>
1 parent 1f15e88 commit 076fc37

File tree

4 files changed

+20
-41
lines changed

4 files changed

+20
-41
lines changed

contracts/Bridge.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,12 @@ contract Bridge is Pausable, Context {
381381

382382
/**
383383
@notice This method is used to trigger the process for retrying failed deposits on the MPC side.
384+
@notice Only callable by address that has the right to call the specific function,
385+
which is mapped in {functionAccess} in AccessControlSegregator contract.
384386
@param txHash Transaction hash which contains deposit that should be retried
385387
@notice This is not applicable for failed executions on {GenericHandler}
386388
*/
387-
function retry(string memory txHash) external {
389+
function retry(string memory txHash) external onlyAllowed {
388390
emit Retry(txHash);
389391
}
390392

test/contractBridge/admin.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ contract('Bridge - [admin]', async (accounts) => {
2323
const someAddress = "0xcafecafecafecafecafecafecafecafecafecafe";
2424
const nullAddress = "0x0000000000000000000000000000000000000000";
2525
const topologyHash = "549f715f5b06809ada23145c2dc548db";
26+
const txHash = "0x59d881e01ca682130e550e3576b6de760951fb45b1d5dd81342132f57920bbfa";
2627

2728
const bytes32 = "0x0";
2829
let ADMIN_ROLE;
@@ -241,4 +242,18 @@ contract('Bridge - [admin]', async (accounts) => {
241242
await assertOnlyAdmin(BridgeInstance.adminChangeAccessControl, someAddress)
242243
})
243244

245+
// Retry
246+
247+
it('Should require admin role to retry deposit', async () => {
248+
await assertOnlyAdmin(BridgeInstance.retry, txHash);
249+
});
250+
251+
it('Should successfully emit Retry event', async () => {
252+
const eventTx = await BridgeInstance.retry(txHash);
253+
254+
TruffleAssert.eventEmitted(eventTx, 'Retry', (event) => {
255+
return event.txHash === txHash
256+
});
257+
});
258+
244259
});

test/contractBridge/publicMethods.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/helpers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ const deployBridge = async (domainID, admin) => {
236236
"0x6ba6db6b", // startKeygen
237237
"0xd2e5fae9", // endKeygen
238238
"0xd8236744", // refreshKey
239+
"0x366b4885", // retry
239240

240241
],
241-
Array(13).fill(admin)
242+
Array(14).fill(admin)
242243
)
243244
return await BridgeContract.new(domainID, accessControlInstance.address);
244245
}

0 commit comments

Comments
 (0)