-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Base contracts to generate aDI adapter payloads (#285)
* feat: Add Base contracts to generate aDI adapter payloads * fix: start on adi base tests * fix: added first version of diffs for adi * fix: fixed compilation errors. Receivers configs generated * fix: added receiver adapter diffs * fix: getting forwarder adapters * fix: Added initial e2e tests * fix: add correct cli version * fix: diffs showing correct changes * fix: explicit import * fix: src lowercase path * fix: moved execution logic to parent contracts * fix: fixed test * fix: add natspec * fix: fixed interfaces
- Loading branch information
Showing
20 changed files
with
1,298 additions
and
16 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions
30
diffs/adi_test_adi_diffs_before_adi_test_adi_diffs_after.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Raw diff | ||
|
||
```json | ||
{ | ||
"forwarderAdaptersByChain": { | ||
"1": { | ||
"0xDA4B6024aA06f7565BBcAaD9B8bE24C3c229AAb5": { | ||
"from": "0x2a323be63e08E08536Fc3b5d8C6f24825e68895e", | ||
"to": null | ||
}, | ||
"0x7FAE7765abB4c8f778d57337bB720d0BC53057e3": { | ||
"from": null, | ||
"to": "0x8410d9BD353b420ebA8C48ff1B0518426C280FCC" | ||
} | ||
} | ||
}, | ||
"receiverAdaptersByChain": { | ||
"1": { | ||
"0xDA4B6024aA06f7565BBcAaD9B8bE24C3c229AAb5": { | ||
"from": true, | ||
"to": null | ||
}, | ||
"0x7FAE7765abB4c8f778d57337bB720d0BC53057e3": { | ||
"from": null, | ||
"to": true | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IProposalGenericExecutor} from '../interfaces/IProposalGenericExecutor.sol'; | ||
import './BaseReceiverAdaptersUpdate.sol'; | ||
import './BaseForwarderAdaptersUpdate.sol'; | ||
|
||
/** | ||
* @title Base payload aDI and bridge adapters update | ||
* @author BGD Labs @bgdlabs | ||
*/ | ||
abstract contract BaseAdaptersUpdate is | ||
BaseReceiverAdaptersUpdate, | ||
BaseForwarderAdaptersUpdate, | ||
IProposalGenericExecutor | ||
{ | ||
address public immutable CROSS_CHAIN_CONTROLLER; | ||
|
||
/** | ||
* @param crossChainController address of the CCC of the network where payload will be deployed | ||
*/ | ||
constructor(address crossChainController) { | ||
CROSS_CHAIN_CONTROLLER = crossChainController; | ||
} | ||
|
||
function execute() public override { | ||
executeReceiversUpdate(CROSS_CHAIN_CONTROLLER); | ||
|
||
executeForwardersUpdate(CROSS_CHAIN_CONTROLLER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IBaseForwarderAdaptersUpdate, ICrossChainForwarder} from './interfaces/IBaseForwarderAdaptersUpdate.sol'; | ||
|
||
/** | ||
* @title Base forwarder payload. It has the methods to update the forwarder bridge adapters. | ||
* @author BGD Labs @bgdlabs | ||
*/ | ||
abstract contract BaseForwarderAdaptersUpdate is IBaseForwarderAdaptersUpdate { | ||
/// @inheritdoc IBaseForwarderAdaptersUpdate | ||
function getForwarderBridgeAdaptersToRemove() | ||
public | ||
view | ||
virtual | ||
returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) | ||
{ | ||
return new ICrossChainForwarder.BridgeAdapterToDisable[](0); | ||
} | ||
|
||
/// @inheritdoc IBaseForwarderAdaptersUpdate | ||
function getForwarderBridgeAdaptersToEnable() | ||
public | ||
view | ||
virtual | ||
returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) | ||
{ | ||
return new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](0); | ||
} | ||
|
||
/// @inheritdoc IBaseForwarderAdaptersUpdate | ||
function executeForwardersUpdate(address crossChainController) public virtual { | ||
// remove forwarding adapters | ||
ICrossChainForwarder.BridgeAdapterToDisable[] | ||
memory forwardersToRemove = getForwarderBridgeAdaptersToRemove(); | ||
if (forwardersToRemove.length != 0) { | ||
ICrossChainForwarder(crossChainController).disableBridgeAdapters(forwardersToRemove); | ||
} | ||
|
||
// add forwarding adapters | ||
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] | ||
memory forwardersToEnable = getForwarderBridgeAdaptersToEnable(); | ||
if (forwardersToEnable.length != 0) { | ||
ICrossChainForwarder(crossChainController).enableBridgeAdapters(forwardersToEnable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IBaseReceiverAdaptersUpdate, ICrossChainReceiver} from './interfaces/IBaseReceiverAdaptersUpdate.sol'; | ||
|
||
/** | ||
* @title Base receiver payload. It has the methods to update the receiver bridge adapters. | ||
* @author BGD Labs @bgdlabs | ||
*/ | ||
abstract contract BaseReceiverAdaptersUpdate is IBaseReceiverAdaptersUpdate { | ||
/// @inheritdoc IBaseReceiverAdaptersUpdate | ||
function getReceiverBridgeAdaptersToRemove() | ||
public | ||
view | ||
virtual | ||
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) | ||
{ | ||
// remove old Receiver bridge adapter | ||
return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); | ||
} | ||
|
||
/// @inheritdoc IBaseReceiverAdaptersUpdate | ||
function getReceiverBridgeAdaptersToAllow() | ||
public | ||
view | ||
virtual | ||
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) | ||
{ | ||
return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); | ||
} | ||
|
||
/// @inheritdoc IBaseReceiverAdaptersUpdate | ||
function executeReceiversUpdate(address crossChainController) public virtual { | ||
// remove old Receiver bridge adapter | ||
ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] | ||
memory receiversToRemove = getReceiverBridgeAdaptersToRemove(); | ||
if (receiversToRemove.length != 0) { | ||
ICrossChainReceiver(crossChainController).disallowReceiverBridgeAdapters(receiversToRemove); | ||
} | ||
|
||
// add receiver adapters | ||
ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] | ||
memory receiversToAllow = getReceiverBridgeAdaptersToAllow(); | ||
if (receiversToAllow.length != 0) { | ||
ICrossChainReceiver(crossChainController).allowReceiverBridgeAdapters(receiversToAllow); | ||
} | ||
} | ||
} |
Oops, something went wrong.
8ff94a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foundry report
Build log
Test success 🌈