Upgrade to typescript v4.2.2 (#188)
* upgrade to typescript v4.2.2 * prettier; remove outdated test
This commit is contained in:
parent
525bc8197b
commit
7bf009fbf6
@ -76,7 +76,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -1,354 +0,0 @@
|
||||
import { ContractTxFunctionObj } from '@0x/contract-wrappers';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
expect,
|
||||
filterLogsToArguments,
|
||||
getRandomInteger,
|
||||
randomAddress,
|
||||
shortZip,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BigNumber, hexUtils, NULL_ADDRESS } from '@0x/utils';
|
||||
import { DecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DexForwarderBridgeCall, dexForwarderBridgeDataEncoder } from '../src/dex_forwarder_bridge';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import {
|
||||
TestDexForwarderBridgeBridgeTransferFromCalledEventArgs as BtfCalledEventArgs,
|
||||
TestDexForwarderBridgeContract,
|
||||
TestDexForwarderBridgeEvents as TestEvents,
|
||||
} from './wrappers';
|
||||
|
||||
const { ZERO_AMOUNT } = constants;
|
||||
|
||||
blockchainTests.resets('DexForwarderBridge unit tests', env => {
|
||||
let testContract: TestDexForwarderBridgeContract;
|
||||
let inputToken: string;
|
||||
let outputToken: string;
|
||||
const BRIDGE_SUCCESS = '0xdc1600f3';
|
||||
const BRIDGE_FAILURE = '0xffffffff';
|
||||
const BRIDGE_REVERT_ERROR = 'oopsie';
|
||||
const NOT_AUTHORIZED_REVERT = 'DexForwarderBridge/SENDER_NOT_AUTHORIZED';
|
||||
const DEFAULTS = {
|
||||
toAddress: randomAddress(),
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
testContract = await TestDexForwarderBridgeContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestDexForwarderBridge,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
// Create test tokens.
|
||||
[inputToken, outputToken] = [
|
||||
await callAndTransactAsync(testContract.createToken()),
|
||||
await callAndTransactAsync(testContract.createToken()),
|
||||
];
|
||||
await callAndTransactAsync(testContract.setAuthorized(env.txDefaults.from as string));
|
||||
});
|
||||
|
||||
async function callAndTransactAsync<TResult>(fnCall: ContractTxFunctionObj<TResult>): Promise<TResult> {
|
||||
const result = await fnCall.callAsync();
|
||||
await fnCall.awaitTransactionSuccessAsync({}, { shouldValidate: false });
|
||||
return result;
|
||||
}
|
||||
|
||||
function getRandomBridgeCall(
|
||||
bridgeAddress: string,
|
||||
fields: Partial<DexForwarderBridgeCall> = {},
|
||||
): DexForwarderBridgeCall {
|
||||
return {
|
||||
target: bridgeAddress,
|
||||
inputTokenAmount: getRandomInteger(1, '100e18'),
|
||||
outputTokenAmount: getRandomInteger(1, '100e18'),
|
||||
bridgeData: hexUtils.leftPad(inputToken),
|
||||
...fields,
|
||||
};
|
||||
}
|
||||
|
||||
describe('bridgeTransferFrom()', () => {
|
||||
let goodBridgeCalls: DexForwarderBridgeCall[];
|
||||
let revertingBridgeCall: DexForwarderBridgeCall;
|
||||
let failingBridgeCall: DexForwarderBridgeCall;
|
||||
let allBridgeCalls: DexForwarderBridgeCall[];
|
||||
let totalFillableOutputAmount: BigNumber;
|
||||
let totalFillableInputAmount: BigNumber;
|
||||
let recipientOutputBalance: BigNumber;
|
||||
|
||||
beforeEach(async () => {
|
||||
goodBridgeCalls = [];
|
||||
for (let i = 0; i < 4; ++i) {
|
||||
goodBridgeCalls.push(await createBridgeCallAsync({ returnCode: BRIDGE_SUCCESS }));
|
||||
}
|
||||
revertingBridgeCall = await createBridgeCallAsync({ revertError: BRIDGE_REVERT_ERROR });
|
||||
failingBridgeCall = await createBridgeCallAsync({ returnCode: BRIDGE_FAILURE });
|
||||
allBridgeCalls = _.shuffle([failingBridgeCall, revertingBridgeCall, ...goodBridgeCalls]);
|
||||
|
||||
totalFillableInputAmount = BigNumber.sum(...goodBridgeCalls.map(c => c.inputTokenAmount));
|
||||
totalFillableOutputAmount = BigNumber.sum(...goodBridgeCalls.map(c => c.outputTokenAmount));
|
||||
|
||||
// Grant the taker some output tokens.
|
||||
await testContract.setTokenBalance(
|
||||
outputToken,
|
||||
DEFAULTS.toAddress,
|
||||
(recipientOutputBalance = getRandomInteger(1, '100e18')),
|
||||
);
|
||||
});
|
||||
|
||||
async function setForwarderInputBalanceAsync(amount: BigNumber): Promise<void> {
|
||||
await testContract
|
||||
.setTokenBalance(inputToken, testContract.address, amount)
|
||||
.awaitTransactionSuccessAsync({}, { shouldValidate: false });
|
||||
}
|
||||
|
||||
async function createBridgeCallAsync(
|
||||
opts: Partial<{
|
||||
returnCode: string;
|
||||
revertError: string;
|
||||
callFields: Partial<DexForwarderBridgeCall>;
|
||||
outputFillAmount: BigNumber;
|
||||
}>,
|
||||
): Promise<DexForwarderBridgeCall> {
|
||||
const { returnCode, revertError, callFields, outputFillAmount } = {
|
||||
returnCode: BRIDGE_SUCCESS,
|
||||
revertError: '',
|
||||
...opts,
|
||||
};
|
||||
const bridge = await callAndTransactAsync(testContract.createBridge(returnCode, revertError));
|
||||
const call = getRandomBridgeCall(bridge, callFields);
|
||||
await testContract
|
||||
.setBridgeTransferAmount(call.target, outputFillAmount || call.outputTokenAmount)
|
||||
.awaitTransactionSuccessAsync({}, { shouldValidate: false });
|
||||
return call;
|
||||
}
|
||||
|
||||
async function callBridgeTransferFromAsync(opts: {
|
||||
bridgeData: string;
|
||||
sellAmount?: BigNumber;
|
||||
buyAmount?: BigNumber;
|
||||
}): Promise<DecodedLogs> {
|
||||
// Fund the forwarder with input tokens to sell.
|
||||
await setForwarderInputBalanceAsync(opts.sellAmount || totalFillableInputAmount);
|
||||
const call = testContract.bridgeTransferFrom(
|
||||
outputToken,
|
||||
testContract.address,
|
||||
DEFAULTS.toAddress,
|
||||
opts.buyAmount || totalFillableOutputAmount,
|
||||
opts.bridgeData,
|
||||
);
|
||||
const returnCode = await call.callAsync();
|
||||
if (returnCode !== BRIDGE_SUCCESS) {
|
||||
throw new Error('Expected BRIDGE_SUCCESS');
|
||||
}
|
||||
const receipt = await call.awaitTransactionSuccessAsync({}, { shouldValidate: false });
|
||||
// tslint:disable-next-line: no-unnecessary-type-assertion
|
||||
return receipt.logs as DecodedLogs;
|
||||
}
|
||||
|
||||
it('succeeds with no bridge calls and no input balance', async () => {
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls: [],
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
|
||||
});
|
||||
|
||||
it('succeeds with bridge calls and no input balance', async () => {
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls: allBridgeCalls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
|
||||
});
|
||||
|
||||
it('succeeds with no bridge calls and an input balance', async () => {
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls: [],
|
||||
});
|
||||
await callBridgeTransferFromAsync({
|
||||
bridgeData,
|
||||
sellAmount: new BigNumber(1),
|
||||
});
|
||||
});
|
||||
|
||||
it('succeeds if entire input token balance is not consumed', async () => {
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls: allBridgeCalls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({
|
||||
bridgeData,
|
||||
sellAmount: totalFillableInputAmount.plus(1),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails if not authorized', async () => {
|
||||
const calls = goodBridgeCalls.slice(0, 1);
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
await callAndTransactAsync(testContract.setAuthorized(NULL_ADDRESS));
|
||||
return expect(callBridgeTransferFromAsync({ bridgeData, sellAmount: new BigNumber(1) })).to.revertWith(
|
||||
NOT_AUTHORIZED_REVERT,
|
||||
);
|
||||
});
|
||||
|
||||
it('succeeds with one bridge call', async () => {
|
||||
const calls = goodBridgeCalls.slice(0, 1);
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData, sellAmount: calls[0].inputTokenAmount });
|
||||
});
|
||||
|
||||
it('succeeds with many bridge calls', async () => {
|
||||
const calls = goodBridgeCalls;
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData });
|
||||
});
|
||||
|
||||
it('swallows a failing bridge call', async () => {
|
||||
const calls = _.shuffle([...goodBridgeCalls, failingBridgeCall]);
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData });
|
||||
});
|
||||
|
||||
it('consumes input tokens for output tokens', async () => {
|
||||
const calls = allBridgeCalls;
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
await callBridgeTransferFromAsync({ bridgeData });
|
||||
const currentBridgeInputBalance = await testContract
|
||||
.balanceOf(inputToken, testContract.address)
|
||||
.callAsync();
|
||||
expect(currentBridgeInputBalance).to.bignumber.eq(0);
|
||||
const currentRecipientOutputBalance = await testContract
|
||||
.balanceOf(outputToken, DEFAULTS.toAddress)
|
||||
.callAsync();
|
||||
expect(currentRecipientOutputBalance).to.bignumber.eq(totalFillableOutputAmount);
|
||||
});
|
||||
|
||||
it("transfers only up to each call's input amount to each bridge", async () => {
|
||||
const calls = goodBridgeCalls;
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
const logs = await callBridgeTransferFromAsync({ bridgeData });
|
||||
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
|
||||
for (const [call, btf] of shortZip(goodBridgeCalls, btfs)) {
|
||||
expect(btf.inputTokenBalance).to.bignumber.eq(call.inputTokenAmount);
|
||||
}
|
||||
});
|
||||
|
||||
it('transfers only up to outstanding sell amount to each bridge', async () => {
|
||||
// Prepend an extra bridge call.
|
||||
const calls = [
|
||||
await createBridgeCallAsync({
|
||||
callFields: {
|
||||
inputTokenAmount: new BigNumber(1),
|
||||
outputTokenAmount: new BigNumber(1),
|
||||
},
|
||||
}),
|
||||
...goodBridgeCalls,
|
||||
];
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
const logs = await callBridgeTransferFromAsync({ bridgeData });
|
||||
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
|
||||
expect(btfs).to.be.length(goodBridgeCalls.length + 1);
|
||||
// The last call will receive 1 less token.
|
||||
const lastCall = calls.slice(-1)[0];
|
||||
const lastBtf = btfs.slice(-1)[0];
|
||||
expect(lastBtf.inputTokenBalance).to.bignumber.eq(lastCall.inputTokenAmount.minus(1));
|
||||
});
|
||||
|
||||
it('recoups funds from a bridge that fails', async () => {
|
||||
// Prepend a call that will take the whole input amount but will
|
||||
// fail.
|
||||
const badCall = await createBridgeCallAsync({
|
||||
callFields: { inputTokenAmount: totalFillableInputAmount },
|
||||
returnCode: BRIDGE_FAILURE,
|
||||
});
|
||||
const calls = [badCall, ...goodBridgeCalls];
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
const logs = await callBridgeTransferFromAsync({ bridgeData });
|
||||
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
|
||||
expect(btfs).to.be.length(goodBridgeCalls.length);
|
||||
});
|
||||
|
||||
it('recoups funds from a bridge that reverts', async () => {
|
||||
// Prepend a call that will take the whole input amount but will
|
||||
// revert.
|
||||
const badCall = await createBridgeCallAsync({
|
||||
callFields: { inputTokenAmount: totalFillableInputAmount },
|
||||
revertError: BRIDGE_REVERT_ERROR,
|
||||
});
|
||||
const calls = [badCall, ...goodBridgeCalls];
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
const logs = await callBridgeTransferFromAsync({ bridgeData });
|
||||
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
|
||||
expect(btfs).to.be.length(goodBridgeCalls.length);
|
||||
});
|
||||
|
||||
it('recoups funds from a bridge that under-pays', async () => {
|
||||
// Prepend a call that will take the whole input amount but will
|
||||
// underpay the output amount..
|
||||
const badCall = await createBridgeCallAsync({
|
||||
callFields: {
|
||||
inputTokenAmount: totalFillableInputAmount,
|
||||
outputTokenAmount: new BigNumber(2),
|
||||
},
|
||||
outputFillAmount: new BigNumber(1),
|
||||
});
|
||||
const calls = [badCall, ...goodBridgeCalls];
|
||||
const bridgeData = dexForwarderBridgeDataEncoder.encode({
|
||||
inputToken,
|
||||
calls,
|
||||
});
|
||||
const logs = await callBridgeTransferFromAsync({ bridgeData });
|
||||
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
|
||||
expect(btfs).to.be.length(goodBridgeCalls.length);
|
||||
});
|
||||
});
|
||||
|
||||
describe('executeBridgeCall()', () => {
|
||||
it('cannot be called externally', async () => {
|
||||
return expect(
|
||||
testContract
|
||||
.executeBridgeCall(
|
||||
randomAddress(),
|
||||
randomAddress(),
|
||||
randomAddress(),
|
||||
randomAddress(),
|
||||
new BigNumber(1),
|
||||
new BigNumber(1),
|
||||
constants.NULL_BYTES,
|
||||
)
|
||||
.callAsync(),
|
||||
).to.revertWith('DexForwarderBridge/ONLY_SELF');
|
||||
});
|
||||
});
|
||||
});
|
@ -81,7 +81,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -79,7 +79,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.21",
|
||||
|
@ -60,7 +60,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -77,7 +77,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -79,7 +79,7 @@
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18"
|
||||
|
@ -39,8 +39,8 @@ describe('EtherToken', () => {
|
||||
artifacts.WETH9,
|
||||
provider,
|
||||
{
|
||||
gasPrice,
|
||||
...txDefaults,
|
||||
gasPrice,
|
||||
},
|
||||
artifacts,
|
||||
);
|
||||
|
@ -81,7 +81,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18"
|
||||
|
@ -87,7 +87,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -77,7 +77,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -85,7 +85,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -12,12 +12,12 @@ export abstract class AbstractBalanceAndProxyAllowanceFetcher {
|
||||
* @param userAddress Ethereum address for which to fetch the balance
|
||||
* @return Balance amount in base units
|
||||
*/
|
||||
public abstract async getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
/**
|
||||
* Get the 0x asset proxy allowance of assetData for userAddress
|
||||
* @param assetData AssetData for which to fetch the allowance
|
||||
* @param userAddress Ethereum address for which to fetch the allowance
|
||||
* @return Allowance amount in base units
|
||||
*/
|
||||
public abstract async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
export abstract class AbstractBalanceAndProxyAllowanceLazyStore {
|
||||
public abstract async getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract setBalance(assetData: string, userAddress: string, balance: BigNumber): void;
|
||||
public abstract deleteBalance(assetData: string, userAddress: string): void;
|
||||
public abstract setProxyAllowance(assetData: string, userAddress: string, proxyAllowance: BigNumber): void;
|
||||
|
@ -11,5 +11,5 @@ export abstract class AbstractOrderFilledCancelledFetcher {
|
||||
* @param orderHash OrderHash of order we are interested in
|
||||
* @return FilledTakerAmount
|
||||
*/
|
||||
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
public abstract getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
export abstract class AbstractOrderFilledCancelledLazyStore {
|
||||
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
public abstract getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
public abstract setFilledTakerAmount(orderHash: string, balance: BigNumber): void;
|
||||
public abstract deleteFilledTakerAmount(orderHash: string): void;
|
||||
public abstract setIsCancelled(orderHash: string, isCancelled: boolean): void;
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
IsolatedExchangeFillEventArgs as FillEventArgs,
|
||||
} from '../wrappers';
|
||||
|
||||
export { Order } from '@0x/types';
|
||||
export interface AssetBalances {
|
||||
[assetData: string]: { [address: string]: BigNumber };
|
||||
}
|
||||
@ -27,7 +28,6 @@ export interface IsolatedExchangeEvents {
|
||||
transferFromCalls: DispatchTransferFromCallArgs[];
|
||||
}
|
||||
|
||||
export type Order = Order;
|
||||
export type Numberish = string | number | BigNumber;
|
||||
|
||||
export const DEFAULT_GOOD_SIGNATURE = createGoodSignature();
|
||||
|
@ -87,7 +87,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -90,7 +90,7 @@
|
||||
"solhint": "^1.4.1",
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/asset-swapper": "^6.3.0",
|
||||
|
@ -63,11 +63,9 @@ blockchainTests.fork('DevUtils dydx order validation tests', env => {
|
||||
let dai: ERC20TokenContract;
|
||||
let usdc: ERC20TokenContract;
|
||||
let devUtils: DevUtilsContract;
|
||||
let accountOwner: string;
|
||||
let minMarginRatio: number;
|
||||
|
||||
before(async () => {
|
||||
[accountOwner] = await env.getAccountAddressesAsync();
|
||||
dydx = new IDydxContract(DYDX_ADDRESS, env.provider, env.txDefaults);
|
||||
dai = new ERC20TokenContract(DAI_ADDRESS, env.provider, env.txDefaults);
|
||||
usdc = new ERC20TokenContract(USDC_ADDRESS, env.provider, env.txDefaults);
|
||||
|
@ -19,5 +19,5 @@ export function filterActorsByRole<TClass extends Constructor>(
|
||||
actors: Actor[],
|
||||
role: TClass,
|
||||
): Array<InstanceType<typeof role>> {
|
||||
return actors.filter(actor => actor.mixins.includes(role.name)) as InstanceType<typeof role>;
|
||||
return actors.filter(actor => actor.mixins.includes(role.name)) as Array<InstanceType<typeof role>>;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@
|
||||
"shx": "^0.2.2",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -84,7 +84,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -4,6 +4,7 @@ import { DecodedLogArgs, LogWithDecodedArgs } from 'ethereum-types';
|
||||
|
||||
import { constants as stakingConstants } from './constants';
|
||||
|
||||
export { Numberish } from '@0x/contracts-test-utils';
|
||||
// tslint:disable:max-classes-per-file
|
||||
|
||||
export interface StakingParams {
|
||||
@ -259,5 +260,3 @@ export class AggregatedStats {
|
||||
export interface AggregatedStatsByEpoch {
|
||||
[epoch: string]: AggregatedStats;
|
||||
}
|
||||
|
||||
export type Numberish = Numberish;
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
|
||||
blockchainTests.resets('Exchange Unit Tests', env => {
|
||||
// Addresses
|
||||
let nonOwner: string;
|
||||
let owner: string;
|
||||
let nonExchange: string;
|
||||
let exchange: string;
|
||||
@ -24,7 +23,7 @@ blockchainTests.resets('Exchange Unit Tests', env => {
|
||||
|
||||
before(async () => {
|
||||
// Set up addresses for testing.
|
||||
[nonOwner, owner, nonExchange, exchange, nonAuthority, authority] = await env.getAccountAddressesAsync();
|
||||
[, owner, nonExchange, exchange, nonAuthority, authority] = await env.getAccountAddressesAsync();
|
||||
|
||||
// Deploy the Exchange Manager contract.
|
||||
exchangeManager = await TestExchangeManagerContract.deployFrom0xArtifactAsync(
|
||||
|
@ -543,7 +543,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
const expectedPoolRewards = await calculatePoolRewardsAsync(INITIAL_BALANCE, pools);
|
||||
const [pool, reward] = _.sampleSize(shortZip(pools, expectedPoolRewards), 1)[0];
|
||||
return assertUnfinalizedPoolRewardsAsync(pool.poolId, {
|
||||
totalReward: (reward as any) as BigNumber,
|
||||
totalReward: reward,
|
||||
membersStake: pool.membersStake,
|
||||
});
|
||||
});
|
||||
|
@ -12,17 +12,13 @@ import * as _ from 'lodash';
|
||||
import { artifacts } from '../artifacts';
|
||||
import { TestCobbDouglasContract } from '../wrappers';
|
||||
|
||||
// tslint:disable: no-unnecessary-type-assertion
|
||||
blockchainTests('LibCobbDouglas unit tests', env => {
|
||||
const FUZZ_COUNT = 1024;
|
||||
const PRECISION = 15;
|
||||
|
||||
let testContract: TestCobbDouglasContract;
|
||||
let ownerAddress: string;
|
||||
let notOwnerAddress: string;
|
||||
|
||||
before(async () => {
|
||||
[ownerAddress, notOwnerAddress] = await env.getAccountAddressesAsync();
|
||||
testContract = await TestCobbDouglasContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestCobbDouglas,
|
||||
env.provider,
|
||||
@ -211,4 +207,3 @@ blockchainTests('LibCobbDouglas unit tests', env => {
|
||||
});
|
||||
});
|
||||
});
|
||||
// tslint:enable:no-unnecessary-type-assertion
|
||||
|
@ -39,7 +39,7 @@
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.21",
|
||||
|
@ -14,6 +14,6 @@ export function shortZip<T1, T2>(a: T1[], b: T2[]): Array<[T1, T2]> {
|
||||
export function replaceKeysDeep(obj: {}, mapKeys: (key: string) => string | void): _.Dictionary<{}> {
|
||||
return _.transform(obj, (result, value, key) => {
|
||||
const currentKey = mapKeys(key) || key;
|
||||
result[currentKey] = _.isObject(value) ? replaceKeysDeep(value, mapKeys) : value;
|
||||
result[currentKey] = _.isObject(value) ? replaceKeysDeep(value as {}, mapKeys) : (value as {});
|
||||
});
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ export class OrderFactory {
|
||||
): Promise<SignedOrder> {
|
||||
const fifteenMinutesInSeconds = 15 * 60;
|
||||
const currentBlockTimestamp = await getLatestBlockTimestampAsync();
|
||||
const order = ({
|
||||
const order = {
|
||||
takerAddress: constants.NULL_ADDRESS,
|
||||
senderAddress: constants.NULL_ADDRESS,
|
||||
expirationTimeSeconds: new BigNumber(currentBlockTimestamp).plus(fifteenMinutesInSeconds),
|
||||
salt: generatePseudoRandomSalt(),
|
||||
...this._defaultOrderParams,
|
||||
...customOrderParams,
|
||||
} as any) as Order;
|
||||
} as Order; // tslint:disable-line:no-object-literal-type-assertion
|
||||
const orderHashBuff = orderHashUtils.getOrderHashBuffer(order);
|
||||
const signature = signingUtils.signMessage(orderHashBuff, this._privateKey, signatureType);
|
||||
const signedOrder = {
|
||||
|
@ -30,7 +30,8 @@ export const orderUtils = {
|
||||
return cancel;
|
||||
},
|
||||
createOrderWithoutSignature(signedOrder: SignedOrder): Order {
|
||||
return _.omit(signedOrder, ['signature']) as Order;
|
||||
const { signature, ...order } = signedOrder;
|
||||
return order;
|
||||
},
|
||||
createBatchMatchOrders(signedOrdersLeft: SignedOrder[], signedOrdersRight: SignedOrder[]): BatchMatchOrder {
|
||||
return {
|
||||
|
@ -69,7 +69,7 @@
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -76,7 +76,7 @@
|
||||
"solhint": "^1.4.1",
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -79,7 +79,7 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
|
@ -9,7 +9,6 @@ blockchainTests.resets('CurveLiquidityProvider feature', env => {
|
||||
let sellToken: TestMintableERC20TokenContract;
|
||||
let buyToken: TestMintableERC20TokenContract;
|
||||
let testCurve: TestCurveContract;
|
||||
let owner: string;
|
||||
let taker: string;
|
||||
const RECIPIENT = hexUtils.random(20);
|
||||
const SELL_AMOUNT = getRandomInteger('1e6', '1e18');
|
||||
@ -24,7 +23,7 @@ blockchainTests.resets('CurveLiquidityProvider feature', env => {
|
||||
const { ZERO_AMOUNT } = constants;
|
||||
|
||||
before(async () => {
|
||||
[owner, taker] = await env.getAccountAddressesAsync();
|
||||
[, taker] = await env.getAccountAddressesAsync();
|
||||
[sellToken, buyToken] = await Promise.all(
|
||||
new Array(2)
|
||||
.fill(0)
|
||||
|
@ -15,7 +15,6 @@ blockchainTests.resets('MooniswapLiquidityProvider feature', env => {
|
||||
let buyToken: TestMintableERC20TokenContract;
|
||||
let weth: TestWethContract;
|
||||
let testMooniswap: TestMooniswapContract;
|
||||
let owner: string;
|
||||
let taker: string;
|
||||
let mooniswapData: string;
|
||||
const RECIPIENT = hexUtils.random(20);
|
||||
@ -25,7 +24,7 @@ blockchainTests.resets('MooniswapLiquidityProvider feature', env => {
|
||||
const BUY_AMOUNT = getRandomInteger('1e18', '10e18');
|
||||
|
||||
before(async () => {
|
||||
[owner, taker] = await env.getAccountAddressesAsync();
|
||||
[, taker] = await env.getAccountAddressesAsync();
|
||||
[sellToken, buyToken] = await Promise.all(
|
||||
new Array(2)
|
||||
.fill(0)
|
||||
|
@ -10,13 +10,12 @@ import {
|
||||
} from './wrappers';
|
||||
|
||||
blockchainTests.resets('PermissionlessTransformerDeployer', env => {
|
||||
let owner: string;
|
||||
let sender: string;
|
||||
let deployer: PermissionlessTransformerDeployerContract;
|
||||
const deployBytes = artifacts.TestPermissionlessTransformerDeployerTransformer.compilerOutput.evm.bytecode.object;
|
||||
|
||||
before(async () => {
|
||||
[owner, sender] = await env.getAccountAddressesAsync();
|
||||
[, sender] = await env.getAccountAddressesAsync();
|
||||
deployer = await PermissionlessTransformerDeployerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.PermissionlessTransformerDeployer,
|
||||
env.provider,
|
||||
|
@ -9,13 +9,12 @@ import {
|
||||
} from './wrappers';
|
||||
|
||||
blockchainTests.resets('TransformerDeployer', env => {
|
||||
let owner: string;
|
||||
let authority: string;
|
||||
let deployer: TransformerDeployerContract;
|
||||
const deployBytes = artifacts.TestTransformerDeployerTransformer.compilerOutput.evm.bytecode.object;
|
||||
|
||||
before(async () => {
|
||||
[owner, authority] = await env.getAccountAddressesAsync();
|
||||
[, authority] = await env.getAccountAddressesAsync();
|
||||
deployer = await TransformerDeployerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TransformerDeployer,
|
||||
env.provider,
|
||||
|
@ -77,7 +77,7 @@
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "~1.16.3",
|
||||
"source-map-support": "^0.5.6",
|
||||
"typescript": "3.0.1",
|
||||
"typescript": "4.2.2",
|
||||
"wsrun": "^2.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
|
@ -89,7 +89,6 @@
|
||||
"devDependencies": {
|
||||
"@0x/base-contract": "^6.2.18",
|
||||
"@0x/contracts-asset-proxy": "^3.7.8",
|
||||
"@0x/contracts-erc20": "^3.3.4",
|
||||
"@0x/contracts-exchange": "^3.2.27",
|
||||
"@0x/contracts-exchange-libs": "^4.3.26",
|
||||
"@0x/contracts-gen": "^2.0.32",
|
||||
@ -118,7 +117,7 @@
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typemoq": "^2.1.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -104,16 +104,14 @@ export const FEE_QUOTE_SOURCES = [ERC20BridgeSource.Uniswap, ERC20BridgeSource.U
|
||||
|
||||
// HACK(mzhu25): Limit and RFQ orders need to be treated as different sources
|
||||
// when computing the exchange proxy gas overhead.
|
||||
export const SOURCE_FLAGS: { [source in ERC20BridgeSource]: number } & {
|
||||
export const SOURCE_FLAGS: { [key in ERC20BridgeSource]: number } & {
|
||||
RfqOrder: number;
|
||||
LimitOrder: number;
|
||||
} = Object.assign(
|
||||
{},
|
||||
...['RfqOrder', 'LimitOrder', ...Object.values(ERC20BridgeSource)].map(
|
||||
(source: ERC20BridgeSource | 'RfqOrder' | 'LimitOrder', index) => ({
|
||||
[source]: source === ERC20BridgeSource.Native ? 0 : 1 << index,
|
||||
}),
|
||||
),
|
||||
...['RfqOrder', 'LimitOrder', ...Object.values(ERC20BridgeSource)].map((source, index) => ({
|
||||
[source]: source === ERC20BridgeSource.Native ? 0 : 1 << index,
|
||||
})),
|
||||
);
|
||||
|
||||
const MIRROR_WRAPPED_TOKENS = {
|
||||
|
@ -30,7 +30,7 @@
|
||||
"devDependencies": {
|
||||
"gitpkg": "https://github.com/0xProject/gitpkg.git",
|
||||
"shx": "^0.2.2",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -36,7 +36,7 @@
|
||||
"lodash": "^4.17.11",
|
||||
"mocha": "^6.2.0",
|
||||
"shx": "^0.2.2",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -48,7 +48,7 @@
|
||||
"mocha": "^6.2.0",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"private": true,
|
||||
"publishConfig": {
|
||||
|
@ -52,7 +52,7 @@
|
||||
"gitpkg": "https://github.com/0xProject/gitpkg.git",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1"
|
||||
"typescript": "4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.21",
|
||||
|
@ -62,7 +62,7 @@
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1",
|
||||
"typescript": "4.2.2",
|
||||
"web3-provider-engine": "14.0.6",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
|
@ -64,7 +64,7 @@
|
||||
"sinon": "^4.0.0",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1",
|
||||
"typescript": "4.2.2",
|
||||
"web3-provider-engine": "14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -142,7 +142,7 @@ export const eip712Utils = {
|
||||
_.omit(mtx, 'domain'),
|
||||
// tslint:disable-next-line: custom-no-magic-numbers
|
||||
v => (BigNumber.isBigNumber(v) ? v.toString(10) : v),
|
||||
) as EIP712Object,
|
||||
) as EIP712Object, // tslint:disable-line:no-unnecessary-type-assertion
|
||||
{
|
||||
...constants.MAINNET_EXCHANGE_PROXY_DOMAIN,
|
||||
...mtx.domain,
|
||||
|
@ -58,7 +58,7 @@
|
||||
"sinon": "^4.0.0",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "3.0.1",
|
||||
"typescript": "4.2.2",
|
||||
"web3-provider-engine": "14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -12338,14 +12338,15 @@ typeorm@0.2.7:
|
||||
yargonaut "^1.1.2"
|
||||
yargs "^11.1.0"
|
||||
|
||||
typescript@3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb"
|
||||
|
||||
typescript@3.7.x:
|
||||
version "3.7.5"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae"
|
||||
|
||||
typescript@4.2.2:
|
||||
version "4.2.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c"
|
||||
integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ==
|
||||
|
||||
typescript@^3.8.3:
|
||||
version "3.9.7"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
|
||||
|
Loading…
x
Reference in New Issue
Block a user