-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from bgd-labs/feat/zksync
feat: Add zkSync adapter
- Loading branch information
Showing
68 changed files
with
856 additions
and
721 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ broadcast/ | |
|
||
input.json | ||
compressedArtifacts.zip | ||
zkout/ |
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
Submodule aave-helpers
deleted from
2e1710
Submodule openzeppelin-contracts
updated
16 files
+1 −1 | .github/actions/setup/action.yml | |
+13 −0 | CHANGELOG.md | |
+21 −10 | contracts/metatx/ERC2771Context.sol | |
+19 −0 | contracts/mocks/Base64Dirty.sol | |
+6 −1 | contracts/mocks/ERC2771ContextMock.sol | |
+1 −1 | contracts/package.json | |
+1 −1 | contracts/token/ERC20/extensions/ERC20Permit.sol | |
+1 −1 | contracts/token/ERC20/extensions/IERC20Permit.sol | |
+19 −10 | contracts/utils/Base64.sol | |
+5 −1 | contracts/utils/Context.sol | |
+17 −3 | contracts/utils/Multicall.sol | |
+0 −15 | docs/modules/ROOT/pages/wizard.adoc | |
+2 −2 | package-lock.json | |
+1 −1 | package.json | |
+54 −1 | test/metatx/ERC2771Context.test.js | |
+11 −1 | test/utils/Base64.test.js |
Submodule solidity-utils
added at
9e1215
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
solidity-utils/=lib/aave-helpers/lib/solidity-utils/src/ | ||
ds-test/=lib/aave-helpers/lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/aave-helpers/lib/forge-std/src/ | ||
fx-portal/=lib/fx-portal/contracts/ | ||
nitro-contracts/=lib/nitro-contracts/src/ | ||
solidity-utils/=lib/solidity-utils/src/ | ||
forge-std/=lib/solidity-utils/lib/forge-std/src/ | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/ | ||
aave-helpers/=lib/aave-helpers/src/ | ||
aave-address-book/=lib/aave-helpers/lib/aave-address-book/src/ |
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,84 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import './BaseAdapterScript.sol'; | ||
import {ZkSyncAdapter} from '../../src/contracts/adapters/zkSync/ZkSyncAdapter.sol'; | ||
import {ZkSyncAdapterTestnet} from '../contract_extensions/ZkSyncAdapterTestnet.sol'; | ||
|
||
library ZkSyncAdapterDeploymentHelper { | ||
struct ZkSyncAdapterArgs { | ||
BaseAdapterArgs baseArgs; | ||
address bridgeHub; | ||
address refundAddress; | ||
} | ||
|
||
function getAdapterCode( | ||
ZkSyncAdapterArgs memory zkSyncArgs | ||
) internal pure returns (bytes memory) { | ||
bytes memory creationCode = zkSyncArgs.baseArgs.isTestnet | ||
? type(ZkSyncAdapterTestnet).creationCode | ||
: type(ZkSyncAdapter).creationCode; | ||
|
||
return | ||
abi.encodePacked( | ||
creationCode, | ||
abi.encode( | ||
zkSyncArgs.baseArgs.crossChainController, | ||
zkSyncArgs.bridgeHub, | ||
zkSyncArgs.refundAddress, | ||
zkSyncArgs.baseArgs.providerGasLimit, | ||
zkSyncArgs.baseArgs.trustedRemotes | ||
) | ||
); | ||
} | ||
} | ||
|
||
abstract contract BaseZkSyncAdapter is BaseAdapterScript { | ||
function BRIDGE_HUB() internal view virtual returns (address); | ||
|
||
function REFUND_ADDRESS() internal view virtual returns (address) { | ||
return address(0); | ||
} | ||
|
||
function _getAdapterByteCode( | ||
BaseAdapterArgs memory baseArgs | ||
) internal view override returns (bytes memory) { | ||
require(BRIDGE_HUB() != address(0), 'Invalid BRIDGE_HUB'); | ||
|
||
return | ||
ZkSyncAdapterDeploymentHelper.getAdapterCode( | ||
ZkSyncAdapterDeploymentHelper.ZkSyncAdapterArgs({ | ||
baseArgs: baseArgs, | ||
bridgeHub: BRIDGE_HUB(), | ||
refundAddress: REFUND_ADDRESS() | ||
}) | ||
); | ||
} | ||
|
||
function _deployWithoutCreate2(BaseAdapterArgs memory baseArgs) internal returns (address) { | ||
require(BRIDGE_HUB() != address(0), 'Invalid BRIDGE_HUB'); | ||
if (isTestnet()) { | ||
return | ||
address( | ||
new ZkSyncAdapterTestnet( | ||
baseArgs.crossChainController, | ||
BRIDGE_HUB(), | ||
REFUND_ADDRESS(), | ||
baseArgs.providerGasLimit, | ||
baseArgs.trustedRemotes | ||
) | ||
); | ||
} else { | ||
return | ||
address( | ||
new ZkSyncAdapter( | ||
baseArgs.crossChainController, | ||
BRIDGE_HUB(), | ||
REFUND_ADDRESS(), | ||
baseArgs.providerGasLimit, | ||
baseArgs.trustedRemotes | ||
) | ||
); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import {ChainIds, TestNetChainIds} from 'aave-helpers/ChainIds.sol'; | ||
import {Create2Utils} from 'aave-helpers/ScriptUtils.sol'; | ||
import {ChainIds, TestNetChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; | ||
|
||
abstract contract BaseScript { | ||
function TRANSACTION_NETWORK() internal view virtual returns (uint256); | ||
|
||
// Should only implement as: | ||
// return Create2Utils.create2Deploy(keccak256(abi.encode(salt)), byteCode); | ||
function _deployByteCode( | ||
bytes memory byteCode, | ||
string memory salt | ||
) internal virtual returns (address) { | ||
return Create2Utils.create2Deploy(keccak256(abi.encode(salt)), byteCode); | ||
} | ||
) internal virtual returns (address); | ||
|
||
// Should only implement as: | ||
// return Create2Utils.computeCreate2Address(salt, adapterCode); | ||
function _computeByteCodeAddress( | ||
bytes memory byteCode, | ||
string memory salt | ||
) internal virtual returns (address); | ||
} |
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
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
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,25 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.8; | ||
|
||
import {TestNetChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; | ||
import {IZkSyncAdapter, ZkSyncAdapter} from '../../src/contracts/adapters/zkSync/ZkSyncAdapter.sol'; | ||
|
||
contract ZkSyncAdapterTestnet is ZkSyncAdapter { | ||
constructor( | ||
address crossChainController, | ||
address mailBox, | ||
address refundAddress, | ||
uint256 providerGasLimit, | ||
TrustedRemotesConfig[] memory trustedRemotes | ||
) ZkSyncAdapter(crossChainController, mailBox, refundAddress, providerGasLimit, trustedRemotes) {} | ||
|
||
/// @inheritdoc IZkSyncAdapter | ||
function isDestinationChainIdSupported(uint256 chainId) public pure override returns (bool) { | ||
return chainId == TestNetChainIds.ZK_SYNC_SEPOLIA; | ||
} | ||
|
||
/// @inheritdoc IZkSyncAdapter | ||
function getOriginChainId() public pure override returns (uint256) { | ||
return TestNetChainIds.ETHEREUM_SEPOLIA; | ||
} | ||
} |
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
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
Oops, something went wrong.