Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2531 from 0xProject/feat/erc20-bridge-sampler/dev…
Browse files Browse the repository at this point in the history
…-utils-as-param

ERC20BridgeSampler: Pass in `DevUtils` address as a constructor arg
  • Loading branch information
dorothy-zbornak authored Mar 30, 2020
2 parents 7ca4aa0 + 3626774 commit 350feed
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
9 changes: 9 additions & 0 deletions contracts/erc20-bridge-sampler/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "1.6.0",
"changes": [
{
"note": "Pass in `DevUtils` address as a constructor parameter",
"pr": 2531
}
]
},
{
"timestamp": 1583220306,
"version": "1.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ contract ERC20BridgeSampler is
/// @dev Default gas limit for liquidity provider calls.
uint256 constant internal DEFAULT_CALL_GAS = 200e3; // 200k

address private _devUtilsAddress;

constructor(address devUtilsAddress) public {
_devUtilsAddress = devUtilsAddress;
}

/// @dev Call multiple public functions on this contract in a single transaction.
/// @param callDatas ABI-encoded call data for each function call.
/// @return callResults ABI-encoded results data for each call.
Expand Down Expand Up @@ -87,6 +93,7 @@ contract ERC20BridgeSampler is
returns (uint256[] memory orderFillableTakerAssetAmounts)
{
orderFillableTakerAssetAmounts = new uint256[](orders.length);
address devUtilsAddress = _devUtilsAddress;
for (uint256 i = 0; i != orders.length; i++) {
// Ignore orders with no signature or empty maker/taker amounts.
if (orderSignatures[i].length == 0 ||
Expand All @@ -97,11 +104,11 @@ contract ERC20BridgeSampler is
}
// solhint-disable indent
(bool didSucceed, bytes memory resultData) =
_getDevUtilsAddress()
devUtilsAddress
.staticcall
.gas(DEV_UTILS_CALL_GAS)
(abi.encodeWithSelector(
IDevUtils(_getDevUtilsAddress()).getOrderRelevantState.selector,
IDevUtils(devUtilsAddress).getOrderRelevantState.selector,
orders[i],
orderSignatures[i]
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ contract TestERC20BridgeSampler is

uint8 private constant MAX_ORDER_STATUS = uint8(LibOrder.OrderStatus.CANCELLED) + 1;

constructor() public {
constructor() public ERC20BridgeSampler(address(this)) {
uniswap = new TestERC20BridgeSamplerUniswapExchangeFactory();
eth2Dai = new TestERC20BridgeSamplerEth2Dai();
kyber = new TestERC20BridgeSamplerKyberNetwork();
Expand All @@ -327,6 +327,7 @@ contract TestERC20BridgeSampler is
bytes memory
)
public
pure
returns (
LibOrder.OrderInfo memory orderInfo,
uint256 fillableTakerAssetAmount,
Expand Down Expand Up @@ -357,15 +358,6 @@ contract TestERC20BridgeSampler is
return LibDeterministicQuotes.getDeterministicTokenDecimals(tokenAddress);
}

// Overriden to point to a this contract.
function _getDevUtilsAddress()
internal
view
returns (address devUtilAddress)
{
return address(this);
}

// Overriden to point to a custom contract.
function _getEth2DaiAddress()
internal
Expand Down
9 changes: 9 additions & 0 deletions contracts/integrations/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "2.5.2",
"changes": [
{
"note": "Update `ERC20BridgeSampler` tests",
"pr": 2531
}
]
},
{
"timestamp": 1583220306,
"version": "2.5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { artifacts, ERC20BridgeSamplerContract } from '@0x/contracts-erc20-bridge-sampler';
import { blockchainTests, describe, expect, toBaseUnitAmount } from '@0x/contracts-test-utils';
import { blockchainTests, constants, describe, expect, toBaseUnitAmount } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';

blockchainTests.fork.resets('Mainnet Sampler Tests', env => {
Expand All @@ -10,6 +10,7 @@ blockchainTests.fork.resets('Mainnet Sampler Tests', env => {
env.provider,
{ ...env.txDefaults, from: '0x6cc5f688a315f3dc28a7781717a9a798a59fda7b' },
{},
constants.NULL_ADDRESS,
);
});

Expand Down

0 comments on commit 350feed

Please sign in to comment.