fixed rebase issues
This commit is contained in:
committed by
Noah Khamliche
parent
17e81432f1
commit
7267420874
@@ -11,7 +11,6 @@ import * as BootstrapFeature from '../test/generated-artifacts/BootstrapFeature.
|
||||
import * as BridgeAdapter from '../test/generated-artifacts/BridgeAdapter.json';
|
||||
import * as BridgeProtocols from '../test/generated-artifacts/BridgeProtocols.json';
|
||||
import * as CurveLiquidityProvider from '../test/generated-artifacts/CurveLiquidityProvider.json';
|
||||
import * as EpFundRecoveryFeature from '../test/generated-artifacts/EpFundRecoveryFeature.json';
|
||||
import * as FeeCollector from '../test/generated-artifacts/FeeCollector.json';
|
||||
import * as FeeCollectorController from '../test/generated-artifacts/FeeCollectorController.json';
|
||||
import * as FillQuoteTransformer from '../test/generated-artifacts/FillQuoteTransformer.json';
|
||||
@@ -22,14 +21,15 @@ import * as FixinReentrancyGuard from '../test/generated-artifacts/FixinReentran
|
||||
import * as FixinTokenSpender from '../test/generated-artifacts/FixinTokenSpender.json';
|
||||
import * as FlashWallet from '../test/generated-artifacts/FlashWallet.json';
|
||||
import * as FullMigration from '../test/generated-artifacts/FullMigration.json';
|
||||
import * as FundRecoveryFeature from '../test/generated-artifacts/FundRecoveryFeature.json';
|
||||
import * as IBatchFillNativeOrdersFeature from '../test/generated-artifacts/IBatchFillNativeOrdersFeature.json';
|
||||
import * as IBootstrapFeature from '../test/generated-artifacts/IBootstrapFeature.json';
|
||||
import * as IBridgeAdapter from '../test/generated-artifacts/IBridgeAdapter.json';
|
||||
import * as IEpFundRecoveryFeature from '../test/generated-artifacts/IEpFundRecoveryFeature.json';
|
||||
import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json';
|
||||
import * as IERC20Transformer from '../test/generated-artifacts/IERC20Transformer.json';
|
||||
import * as IFeature from '../test/generated-artifacts/IFeature.json';
|
||||
import * as IFlashWallet from '../test/generated-artifacts/IFlashWallet.json';
|
||||
import * as IFundRecoveryFeature from '../test/generated-artifacts/IFundRecoveryFeature.json';
|
||||
import * as ILiquidityProvider from '../test/generated-artifacts/ILiquidityProvider.json';
|
||||
import * as ILiquidityProviderFeature from '../test/generated-artifacts/ILiquidityProviderFeature.json';
|
||||
import * as ILiquidityProviderSandbox from '../test/generated-artifacts/ILiquidityProviderSandbox.json';
|
||||
@@ -135,6 +135,7 @@ import * as TestFillQuoteTransformerHost from '../test/generated-artifacts/TestF
|
||||
import * as TestFixinProtocolFees from '../test/generated-artifacts/TestFixinProtocolFees.json';
|
||||
import * as TestFixinTokenSpender from '../test/generated-artifacts/TestFixinTokenSpender.json';
|
||||
import * as TestFullMigration from '../test/generated-artifacts/TestFullMigration.json';
|
||||
import * as TestFundRecoveryFeature from '../test/generated-artifacts/TestFundRecoveryFeature.json';
|
||||
import * as TestInitialMigration from '../test/generated-artifacts/TestInitialMigration.json';
|
||||
import * as TestLibNativeOrder from '../test/generated-artifacts/TestLibNativeOrder.json';
|
||||
import * as TestLibSignature from '../test/generated-artifacts/TestLibSignature.json';
|
||||
@@ -200,7 +201,7 @@ export const artifacts = {
|
||||
TransformerDeployer: TransformerDeployer as ContractArtifact,
|
||||
BatchFillNativeOrdersFeature: BatchFillNativeOrdersFeature as ContractArtifact,
|
||||
BootstrapFeature: BootstrapFeature as ContractArtifact,
|
||||
EpFundRecoveryFeature: EpFundRecoveryFeature as ContractArtifact,
|
||||
FundRecoveryFeature: FundRecoveryFeature as ContractArtifact,
|
||||
LiquidityProviderFeature: LiquidityProviderFeature as ContractArtifact,
|
||||
MetaTransactionsFeature: MetaTransactionsFeature as ContractArtifact,
|
||||
NativeOrdersFeature: NativeOrdersFeature as ContractArtifact,
|
||||
@@ -213,8 +214,8 @@ export const artifacts = {
|
||||
UniswapV3Feature: UniswapV3Feature as ContractArtifact,
|
||||
IBatchFillNativeOrdersFeature: IBatchFillNativeOrdersFeature as ContractArtifact,
|
||||
IBootstrapFeature: IBootstrapFeature as ContractArtifact,
|
||||
IEpFundRecoveryFeature: IEpFundRecoveryFeature as ContractArtifact,
|
||||
IFeature: IFeature as ContractArtifact,
|
||||
IFundRecoveryFeature: IFundRecoveryFeature as ContractArtifact,
|
||||
ILiquidityProviderFeature: ILiquidityProviderFeature as ContractArtifact,
|
||||
IMetaTransactionsFeature: IMetaTransactionsFeature as ContractArtifact,
|
||||
IMultiplexFeature: IMultiplexFeature as ContractArtifact,
|
||||
@@ -314,6 +315,7 @@ export const artifacts = {
|
||||
TestFixinProtocolFees: TestFixinProtocolFees as ContractArtifact,
|
||||
TestFixinTokenSpender: TestFixinTokenSpender as ContractArtifact,
|
||||
TestFullMigration: TestFullMigration as ContractArtifact,
|
||||
TestFundRecoveryFeature: TestFundRecoveryFeature as ContractArtifact,
|
||||
TestInitialMigration: TestInitialMigration as ContractArtifact,
|
||||
TestLibNativeOrder: TestLibNativeOrder as ContractArtifact,
|
||||
TestLibSignature: TestLibSignature as ContractArtifact,
|
||||
|
@@ -0,0 +1,126 @@
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
getRandomPortion,
|
||||
provider,
|
||||
randomAddress,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BigNumber, hexUtils } from '@0x/utils';
|
||||
import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import { IOwnableFeatureContract, IZeroExContract, LiquidityProviderFeatureContract } from '../../src/wrappers';
|
||||
import {TestWethContract} from '../wrappers';
|
||||
import { artifacts } from '../artifacts';
|
||||
import { abis } from '../utils/abis';
|
||||
import { fullMigrateAsync } from '../utils/migration';
|
||||
import { TestInitialMigrationContract } from '../generated-wrappers/test_initial_migration';
|
||||
import { FundRecoveryFeatureContract } from '../generated-wrappers/fund_recovery_feature';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Address } from '@0x/utils/lib/src/abi_encoder';
|
||||
|
||||
blockchainTests('FundRecovery', async env => {
|
||||
|
||||
let owner: string;
|
||||
let designatedAddress: string;
|
||||
let testAddress: string;
|
||||
let zeroEx: IZeroExContract;
|
||||
let token: DummyERC20TokenContract;
|
||||
let weth: TestWethContract;
|
||||
let feature: FundRecoveryFeatureContract;
|
||||
|
||||
before(async () => {
|
||||
env.blockchainLifecycle.startAsync();
|
||||
const ZERO_EX_EXCHANGE_PROXY = '0xdef1c0ded9bec7f1a1670819833240f027b25eff';
|
||||
[owner, designatedAddress, testAddress] = await env.getAccountAddressesAsync();
|
||||
|
||||
console.log(owner);
|
||||
//EP Migration
|
||||
zeroEx = await fullMigrateAsync(owner, env.provider, env.txDefaults, {});
|
||||
|
||||
//deploy dummy erc20 token
|
||||
token = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
|
||||
erc20Artifacts.DummyERC20Token,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
erc20Artifacts,
|
||||
constants.DUMMY_TOKEN_NAME,
|
||||
constants.DUMMY_TOKEN_SYMBOL,
|
||||
constants.DUMMY_TOKEN_DECIMALS,
|
||||
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
|
||||
|
||||
);
|
||||
|
||||
await token.setBalance(zeroEx.address, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync();
|
||||
const bal = await token.balanceOf(ZERO_EX_EXCHANGE_PROXY).callAsync();
|
||||
|
||||
weth = await TestWethContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestWeth,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
await weth.mint(zeroEx.address, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync();
|
||||
await weth.mint(ZERO_EX_EXCHANGE_PROXY, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync();
|
||||
const balweth = await weth.balanceOf(zeroEx.address).callAsync();
|
||||
|
||||
//CREATE CONTRACT AND DEPLOY FEATURE
|
||||
feature = new FundRecoveryFeatureContract(zeroEx.address, env.provider, env.txDefaults, abis);
|
||||
const featureImpl = await FundRecoveryFeatureContract.deployFrom0xArtifactAsync(
|
||||
artifacts.FundRecoveryFeature,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts
|
||||
);
|
||||
|
||||
await new IOwnableFeatureContract(zeroEx.address, env.provider, env.txDefaults, abis)
|
||||
.migrate(featureImpl.address, featureImpl.migrate().getABIEncodedTransactionData(), owner)
|
||||
.awaitTransactionSuccessAsync();
|
||||
|
||||
});
|
||||
blockchainTests.resets('Should delegatecall `transferTrappedTokensTo` from the exchange proxy', () => {
|
||||
const ETH_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
||||
const ZERO_EX_EXCHANGE_PROXY = '0xdef1c0ded9bec7f1a1670819833240f027b25eff';
|
||||
it('Tranfers an arbitrary ERC-20 Token', async () => {
|
||||
const amountOut = Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18);
|
||||
const designatedAddressBalance = await token.balanceOf(designatedAddress).callAsync();
|
||||
const epBalance = await token.balanceOf(zeroEx.address).callAsync();
|
||||
await zeroEx.transferTrappedTokensTo(token.address, amountOut, designatedAddress).awaitTransactionSuccessAsync({ from: owner });
|
||||
const epBalanceNew = await token.balanceOf(zeroEx.address).callAsync();
|
||||
const designatedAddressBalanceAferTransfer = await token.balanceOf(designatedAddress).callAsync();
|
||||
expect(designatedAddressBalanceAferTransfer.c![0]).to.equal(amountOut.c![0]);
|
||||
});
|
||||
it('Amount -1 transfers entire balance', async () => {
|
||||
const designatedAddressBalance = await token.balanceOf(designatedAddress).callAsync();
|
||||
const balanceOwner = await token.balanceOf(zeroEx.address).callAsync();
|
||||
const tx = await zeroEx.transferTrappedTokensTo(token.address, constants.MAX_UINT256 , designatedAddress).awaitTransactionSuccessAsync({ from: owner });
|
||||
const balanceNew = await token.balanceOf(zeroEx.address).callAsync();
|
||||
const designatedAddressBalanceAferTransfer = await token.balanceOf(designatedAddress).callAsync();
|
||||
expect(balanceNew.c![0]).to.equal(0);
|
||||
expect(designatedAddressBalanceAferTransfer.c![0]).to.equal(balanceOwner.c![0]);
|
||||
});
|
||||
it('Transfers ETH ', async () => {
|
||||
//connect to mainnet contract address
|
||||
const zrxContractMainnet = new IZeroExContract(ZERO_EX_EXCHANGE_PROXY, env.provider, env.txDefaults);
|
||||
//await weth.withdraw(wethBal);
|
||||
const bal = await env.web3Wrapper.getBalanceInWeiAsync(zrxContractMainnet.address);
|
||||
//const designatedAddressBalance = await token.balanceOf(designatedAddress).callAsync();
|
||||
const tx = await zrxContractMainnet.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, constants.MAX_UINT256 , designatedAddress).awaitTransactionSuccessAsync({ from: owner });
|
||||
//const bal2 = await env.web3Wrapper.getBalanceInWeiAsync(zrxContractMainnet.address);
|
||||
const designatedAddressBalance = await env.web3Wrapper.getBalanceInWeiAsync(zrxContractMainnet.address);
|
||||
|
||||
|
||||
});
|
||||
it('Feature `transferTrappedTokensTo` can only be called by owner', async () => {
|
||||
//need to be able to change caller context.
|
||||
const zrxContractMainnet = new IZeroExContract(ZERO_EX_EXCHANGE_PROXY, env.provider, env.txDefaults);
|
||||
const tx = await zrxContractMainnet.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, constants.MAX_UINT256 , designatedAddress).awaitTransactionSuccessAsync({ from: owner });
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
@@ -9,7 +9,6 @@ export * from '../test/generated-wrappers/bootstrap_feature';
|
||||
export * from '../test/generated-wrappers/bridge_adapter';
|
||||
export * from '../test/generated-wrappers/bridge_protocols';
|
||||
export * from '../test/generated-wrappers/curve_liquidity_provider';
|
||||
export * from '../test/generated-wrappers/ep_fund_recovery_feature';
|
||||
export * from '../test/generated-wrappers/fee_collector';
|
||||
export * from '../test/generated-wrappers/fee_collector_controller';
|
||||
export * from '../test/generated-wrappers/fill_quote_transformer';
|
||||
@@ -20,14 +19,15 @@ export * from '../test/generated-wrappers/fixin_reentrancy_guard';
|
||||
export * from '../test/generated-wrappers/fixin_token_spender';
|
||||
export * from '../test/generated-wrappers/flash_wallet';
|
||||
export * from '../test/generated-wrappers/full_migration';
|
||||
export * from '../test/generated-wrappers/fund_recovery_feature';
|
||||
export * from '../test/generated-wrappers/i_batch_fill_native_orders_feature';
|
||||
export * from '../test/generated-wrappers/i_bootstrap_feature';
|
||||
export * from '../test/generated-wrappers/i_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/i_ep_fund_recovery_feature';
|
||||
export * from '../test/generated-wrappers/i_erc20_bridge';
|
||||
export * from '../test/generated-wrappers/i_erc20_transformer';
|
||||
export * from '../test/generated-wrappers/i_feature';
|
||||
export * from '../test/generated-wrappers/i_flash_wallet';
|
||||
export * from '../test/generated-wrappers/i_fund_recovery_feature';
|
||||
export * from '../test/generated-wrappers/i_liquidity_provider';
|
||||
export * from '../test/generated-wrappers/i_liquidity_provider_feature';
|
||||
export * from '../test/generated-wrappers/i_liquidity_provider_sandbox';
|
||||
@@ -133,6 +133,7 @@ export * from '../test/generated-wrappers/test_fill_quote_transformer_host';
|
||||
export * from '../test/generated-wrappers/test_fixin_protocol_fees';
|
||||
export * from '../test/generated-wrappers/test_fixin_token_spender';
|
||||
export * from '../test/generated-wrappers/test_full_migration';
|
||||
export * from '../test/generated-wrappers/test_fund_recovery_feature';
|
||||
export * from '../test/generated-wrappers/test_initial_migration';
|
||||
export * from '../test/generated-wrappers/test_lib_native_order';
|
||||
export * from '../test/generated-wrappers/test_lib_signature';
|
||||
|
Reference in New Issue
Block a user