diff --git a/contracts/zero-ex/compiler.json b/contracts/zero-ex/compiler.json index 7b38881a7a..62f35ce7bf 100644 --- a/contracts/zero-ex/compiler.json +++ b/contracts/zero-ex/compiler.json @@ -115,6 +115,8 @@ "./contracts/src/transformers/bridges/BridgeProtocols.sol", "./contracts/src/transformers/bridges/CeloBridgeAdapter.sol", "./contracts/src/transformers/bridges/EthereumBridgeAdapter.sol", + "./contracts/src/transformers/bridges/EthereumBridgeAdapterGroup1.sol", + "./contracts/src/transformers/bridges/EthereumBridgeAdapterV2.sol", "./contracts/src/transformers/bridges/FantomBridgeAdapter.sol", "./contracts/src/transformers/bridges/IBridgeAdapter.sol", "./contracts/src/transformers/bridges/OptimismBridgeAdapter.sol", diff --git a/contracts/zero-ex/contracts/deps/forge-std b/contracts/zero-ex/contracts/deps/forge-std index 1680d7fb3e..2a2ce3692b 160000 --- a/contracts/zero-ex/contracts/deps/forge-std +++ b/contracts/zero-ex/contracts/deps/forge-std @@ -1 +1 @@ -Subproject commit 1680d7fb3e00b7b197a7336e7c88e838c7e6a3ec +Subproject commit 2a2ce3692b8c1523b29de3ec9d961ee9fbbc43a6 diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterGroup1.sol b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterGroup1.sol index ead5f04185..5f7117313a 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterGroup1.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterGroup1.sol @@ -45,7 +45,7 @@ import "./mixins/MixinUniswapV2.sol"; import "./mixins/MixinUniswapV3.sol"; import "./mixins/MixinZeroExBridge.sol"; -contract EthereumBridgeAdapter is +contract EthereumBridgeAdapterGroup1 is AbstractBridgeAdapter(1, "Ethereum"), MixinAaveV2, MixinBalancer, diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterV2.sol b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterV2.sol index 9f938f0665..58db3e1984 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterV2.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapterV2.sol @@ -19,15 +19,27 @@ */ pragma solidity ^0.6.5; +pragma experimental ABIEncoderV2; import "./EthereumBridgeAdapterGroup1.sol"; import "./IBridgeAdapter.sol"; -contract EthereumBridgeAdapterV2 is AbstractBridgeAdapter(1, "Ethereum") { +contract EthereumBridgeAdapterV2 is IBridgeAdapter { IBridgeAdapter private immutable adapter1; uint256 private constant ADAPTER_1_LENGTH = 33; constructor(IEtherTokenV06 weth) public { - adapter1 = EthereumBridgeAdapterGroup1(weth); + uint256 expectedChainId = 1; + string memory expectedChainName = "Ethereum"; + uint256 chainId; + assembly { + chainId := chainid() + } + // Allow testing on Ganache + if (chainId != expectedChainId && chainId != 1337) { + revert(string(abi.encodePacked(expectedChainName, "BridgeAdapter.constructor: wrong chain ID"))); + } + + adapter1 = new EthereumBridgeAdapterGroup1(weth); } function trade( @@ -42,11 +54,10 @@ contract EthereumBridgeAdapterV2 is AbstractBridgeAdapter(1, "Ethereum") { } } - function isSupportedSource(bytes32 source) external returns (bool isSupported) { - uint128 protocolId = uint128(uint256(order.source) >> 128); + function isSupportedSource(bytes32 source) external override returns (bool isSupported) { + uint128 protocolId = uint128(uint256(source) >> 128); if (protocolId < ADAPTER_1_LENGTH) { return adapter1.isSupportedSource(source); } - } } \ No newline at end of file diff --git a/contracts/zero-ex/package.json b/contracts/zero-ex/package.json index 752bacecf0..427f2f05fa 100644 --- a/contracts/zero-ex/package.json +++ b/contracts/zero-ex/package.json @@ -43,7 +43,7 @@ "config": { "publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature,AvalancheBridgeAdapter,BSCBridgeAdapter,CeloBridgeAdapter,EthereumBridgeAdapter,FantomBridgeAdapter,OptimismBridgeAdapter,PolygonBridgeAdapter", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "abis": "./test/generated-artifacts/@(AbstractBridgeAdapter|AffiliateFeeTransformer|AvalancheBridgeAdapter|BSCBridgeAdapter|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeProtocols|CeloBridgeAdapter|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|EthereumBridgeAdapter|FantomBridgeAdapter|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2Batch|MixinBancor|MixinBancorV3|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinGMX|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinPlatypus|MixinShell|MixinSolidly|MixinSynthetix|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OptimismBridgeAdapter|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PolygonBridgeAdapter|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json" + "abis": "./test/generated-artifacts/@(AbstractBridgeAdapter|AffiliateFeeTransformer|AvalancheBridgeAdapter|BSCBridgeAdapter|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeProtocols|CeloBridgeAdapter|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|EthereumBridgeAdapter|EthereumBridgeAdapterGroup1|EthereumBridgeAdapterV2|FantomBridgeAdapter|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2Batch|MixinBancor|MixinBancorV3|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinGMX|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinPlatypus|MixinShell|MixinSolidly|MixinSynthetix|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OptimismBridgeAdapter|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PolygonBridgeAdapter|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json" }, "repository": { "type": "git", diff --git a/contracts/zero-ex/test/artifacts.ts b/contracts/zero-ex/test/artifacts.ts index 8449d5231b..8a36b64f42 100644 --- a/contracts/zero-ex/test/artifacts.ts +++ b/contracts/zero-ex/test/artifacts.ts @@ -18,6 +18,8 @@ import * as ERC1155OrdersFeature from '../test/generated-artifacts/ERC1155Orders import * as ERC165Feature from '../test/generated-artifacts/ERC165Feature.json'; import * as ERC721OrdersFeature from '../test/generated-artifacts/ERC721OrdersFeature.json'; import * as EthereumBridgeAdapter from '../test/generated-artifacts/EthereumBridgeAdapter.json'; +import * as EthereumBridgeAdapterGroup1 from '../test/generated-artifacts/EthereumBridgeAdapterGroup1.json'; +import * as EthereumBridgeAdapterV2 from '../test/generated-artifacts/EthereumBridgeAdapterV2.json'; import * as FantomBridgeAdapter from '../test/generated-artifacts/FantomBridgeAdapter.json'; import * as FeeCollector from '../test/generated-artifacts/FeeCollector.json'; import * as FeeCollectorController from '../test/generated-artifacts/FeeCollectorController.json'; @@ -322,6 +324,8 @@ export const artifacts = { BridgeProtocols: BridgeProtocols as ContractArtifact, CeloBridgeAdapter: CeloBridgeAdapter as ContractArtifact, EthereumBridgeAdapter: EthereumBridgeAdapter as ContractArtifact, + EthereumBridgeAdapterGroup1: EthereumBridgeAdapterGroup1 as ContractArtifact, + EthereumBridgeAdapterV2: EthereumBridgeAdapterV2 as ContractArtifact, FantomBridgeAdapter: FantomBridgeAdapter as ContractArtifact, IBridgeAdapter: IBridgeAdapter as ContractArtifact, OptimismBridgeAdapter: OptimismBridgeAdapter as ContractArtifact, diff --git a/contracts/zero-ex/test/wrappers.ts b/contracts/zero-ex/test/wrappers.ts index 5f0cd5bb96..523d40d658 100644 --- a/contracts/zero-ex/test/wrappers.ts +++ b/contracts/zero-ex/test/wrappers.ts @@ -16,6 +16,8 @@ export * from '../test/generated-wrappers/erc1155_orders_feature'; export * from '../test/generated-wrappers/erc165_feature'; export * from '../test/generated-wrappers/erc721_orders_feature'; export * from '../test/generated-wrappers/ethereum_bridge_adapter'; +export * from '../test/generated-wrappers/ethereum_bridge_adapter_group1'; +export * from '../test/generated-wrappers/ethereum_bridge_adapter_v2'; export * from '../test/generated-wrappers/fantom_bridge_adapter'; export * from '../test/generated-wrappers/fee_collector'; export * from '../test/generated-wrappers/fee_collector_controller'; diff --git a/contracts/zero-ex/tsconfig.json b/contracts/zero-ex/tsconfig.json index 47b0d733a8..70f40bae2e 100644 --- a/contracts/zero-ex/tsconfig.json +++ b/contracts/zero-ex/tsconfig.json @@ -55,6 +55,8 @@ "test/generated-artifacts/ERC165Feature.json", "test/generated-artifacts/ERC721OrdersFeature.json", "test/generated-artifacts/EthereumBridgeAdapter.json", + "test/generated-artifacts/EthereumBridgeAdapterGroup1.json", + "test/generated-artifacts/EthereumBridgeAdapterV2.json", "test/generated-artifacts/FantomBridgeAdapter.json", "test/generated-artifacts/FeeCollector.json", "test/generated-artifacts/FeeCollectorController.json",