remove fill-scenarios

This commit is contained in:
xianny 2019-10-01 17:08:51 -07:00 committed by fabioberger
parent 9544d317a0
commit 24c3aefb6f
13 changed files with 0 additions and 1198 deletions

View File

@ -32,6 +32,5 @@ contracts: ['contracts']
@0x/json-schemas: ['packages/json-schemas'] @0x/json-schemas: ['packages/json-schemas']
@0x/ethereum-types: ['ethereum-types'] @0x/ethereum-types: ['ethereum-types']
@0x/connect: ['packages/connect'] @0x/connect: ['packages/connect']
@0x/fill-scenarios: ['packages/fill-scenarios']
@0x/testnet-faucets: ['packages/testnet-faucets'] @0x/testnet-faucets: ['packages/testnet-faucets']
@0x/monorepo-scripts: ['packages/monorepo-scripts'] @0x/monorepo-scripts: ['packages/monorepo-scripts']

View File

@ -93,7 +93,6 @@ These packages are all under development. See [/contracts/README.md](/contracts/
| [`@0x/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0x/assert.svg)](https://www.npmjs.com/package/@0x/assert) | Type and schema assertions used by our packages | | [`@0x/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0x/assert.svg)](https://www.npmjs.com/package/@0x/assert) | Type and schema assertions used by our packages |
| [`@0x/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0x/base-contract.svg)](https://www.npmjs.com/package/@0x/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts | | [`@0x/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0x/base-contract.svg)](https://www.npmjs.com/package/@0x/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
| [`@0x/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0x/dev-utils.svg)](https://www.npmjs.com/package/@0x/dev-utils) | Dev utils to be shared across 0x packages | | [`@0x/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0x/dev-utils.svg)](https://www.npmjs.com/package/@0x/dev-utils) | Dev utils to be shared across 0x packages |
| [`@0x/fill-scenarios`](/packages/fill-scenarios) | [![npm](https://img.shields.io/npm/v/@0x/fill-scenarios.svg)](https://www.npmjs.com/package/@0x/fill-scenarios) | 0x order fill scenario generator |
#### Private Packages #### Private Packages

View File

@ -1,10 +0,0 @@
# Blacklist all files
.*
*
# Whitelist lib
!lib/**/*
# Blacklist tests and publish scripts
/lib/test/*
/lib/monorepo_scripts/
# Package specific ignore

View File

@ -1,529 +0,0 @@
[
{
"version": "3.1.0-beta.0",
"changes": [
{
"note": "Use new `Order` structure with `domain` field",
"pr": 1742
},
{
"note": "Use arbitrary fee tokens instead of ZRX (ZEIP-28)",
"pr": 1819
}
]
},
{
"timestamp": 1568744790,
"version": "3.0.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1567521715,
"version": "3.0.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1566446343,
"version": "3.0.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1565296576,
"version": "3.0.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1564604963,
"version": "3.0.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563957393,
"version": "3.0.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563193019,
"version": "3.0.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563047529,
"version": "3.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563006338,
"version": "3.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1558712885,
"version": "3.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.8",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "3.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.5",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1554997931
},
{
"timestamp": 1553183790,
"version": "3.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1553091633,
"version": "3.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1551479279,
"version": "3.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1551220833,
"version": "3.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.0",
"changes": [
{
"note": "Update provider params to type SupportedProvider which outlines all supported providers",
"pr": 1627
}
],
"timestamp": 1551130135
},
{
"timestamp": 1549733923,
"version": "2.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.3",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1549547375
},
{
"timestamp": 1549504360,
"version": "2.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1549452781,
"version": "2.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.0",
"changes": [
{
"note": "Upgrade the bignumber.js to v8.0.2",
"pr": 1517
}
],
"timestamp": 1549373905
},
{
"timestamp": 1547561734,
"version": "1.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1547225310,
"version": "1.1.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.0",
"changes": [
{
"note": "Add support for MultiAssetProxy",
"pr": 1363
}
],
"timestamp": 1547040760
},
{
"version": "1.0.16",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1544739608
},
{
"version": "1.0.15",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1544570656
},
{
"timestamp": 1543401373,
"version": "1.0.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542821676,
"version": "1.0.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542208198,
"version": "1.0.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542134075,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.9",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1541740904
},
{
"version": "1.0.8",
"changes": [
{
"note": "Updated to use new @0xproject/contract-artifacts and @0xproject/abi-gen-wrappers packages",
"pr": 1105
}
],
"timestamp": 1539871071
},
{
"version": "1.0.7",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1538693146
},
{
"timestamp": 1538157789,
"version": "1.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537907159,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537875740,
"version": "1.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1537541580,
"version": "1.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.2",
"changes": [
{
"note": "Drastically reduce the bundle size by removing unused parts of included contract artifacts."
}
],
"timestamp": 1537369748
},
{
"timestamp": 1536142250,
"version": "1.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.1-rc.5",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1535377027
},
{
"version": "1.0.1-rc.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1535133899
},
{
"version": "1.0.1-rc.3",
"changes": [
{
"note": "Updated to use latest orderFactory interface, fixed `feeRecipient` spelling error in public interface",
"pr": 936
},
{
"note": "Dependencies updated"
}
],
"timestamp": 1534210131
},
{
"version": "1.0.1-rc.2",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1532619515
},
{
"version": "1.0.1-rc.1",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1532605697
},
{
"timestamp": 1532357734,
"version": "1.0.0",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1532043000,
"version": "1.0.0-rc.1",
"changes": [
{
"note": "Make fill-scenarios compatible with V2 of 0x protocol",
"pr": 656
}
]
},
{
"timestamp": 1531919263,
"version": "0.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1529397769,
"version": "0.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1527616612,
"version": "0.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1527008544,
"version": "0.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1527008544,
"version": "0.0.1",
"changes": [
{
"note": "Move FillScenarios out of 0x.js",
"pr": 579
}
]
}
]

View File

@ -1,231 +0,0 @@
<!--
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
## v3.0.19 - _September 17, 2019_
* Dependencies updated
## v3.0.18 - _September 3, 2019_
* Dependencies updated
## v3.0.17 - _August 22, 2019_
* Dependencies updated
## v3.0.16 - _August 8, 2019_
* Dependencies updated
## v3.0.15 - _July 31, 2019_
* Dependencies updated
## v3.0.14 - _July 24, 2019_
* Dependencies updated
## v3.0.13 - _July 15, 2019_
* Dependencies updated
## v3.0.12 - _July 13, 2019_
* Dependencies updated
## v3.0.11 - _July 13, 2019_
* Dependencies updated
## v3.0.10 - _May 24, 2019_
* Dependencies updated
## v3.0.9 - _May 15, 2019_
* Dependencies updated
## v3.0.8 - _May 14, 2019_
* Dependencies updated
## v3.0.6 - _May 10, 2019_
* Dependencies updated
## v3.0.5 - _April 11, 2019_
* Dependencies updated
## v3.0.4 - _March 21, 2019_
* Dependencies updated
## v3.0.3 - _March 20, 2019_
* Dependencies updated
## v3.0.2 - _March 1, 2019_
* Dependencies updated
## v3.0.1 - _February 26, 2019_
* Dependencies updated
## v3.0.0 - _February 25, 2019_
* Update provider params to type SupportedProvider which outlines all supported providers (#1627)
## v2.0.4 - _February 9, 2019_
* Dependencies updated
## v2.0.3 - _February 7, 2019_
* Dependencies updated
## v2.0.2 - _February 7, 2019_
* Dependencies updated
## v2.0.1 - _February 6, 2019_
* Dependencies updated
## v2.0.0 - _February 5, 2019_
* Upgrade the bignumber.js to v8.0.2 (#1517)
## v1.1.2 - _January 15, 2019_
* Dependencies updated
## v1.1.1 - _January 11, 2019_
* Dependencies updated
## v1.1.0 - _January 9, 2019_
* Add support for MultiAssetProxy (#1363)
## v1.0.16 - _December 13, 2018_
* Dependencies updated
## v1.0.15 - _December 11, 2018_
* Dependencies updated
## v1.0.14 - _November 28, 2018_
* Dependencies updated
## v1.0.13 - _November 21, 2018_
* Dependencies updated
## v1.0.12 - _November 14, 2018_
* Dependencies updated
## v1.0.11 - _November 13, 2018_
* Dependencies updated
## v1.0.10 - _November 12, 2018_
* Dependencies updated
## v1.0.9 - _November 9, 2018_
* Dependencies updated
## v1.0.8 - _October 18, 2018_
* Updated to use new @0xproject/contract-artifacts and @0xproject/abi-gen-wrappers packages (#1105)
## v1.0.7 - _October 4, 2018_
* Dependencies updated
## v1.0.6 - _September 28, 2018_
* Dependencies updated
## v1.0.5 - _September 25, 2018_
* Dependencies updated
## v1.0.4 - _September 25, 2018_
* Dependencies updated
## v1.0.3 - _September 21, 2018_
* Dependencies updated
## v1.0.2 - _September 19, 2018_
* Drastically reduce the bundle size by removing unused parts of included contract artifacts.
## v1.0.1 - _September 5, 2018_
* Dependencies updated
## v1.0.1-rc.5 - _August 27, 2018_
* Dependencies updated
## v1.0.1-rc.4 - _August 24, 2018_
* Dependencies updated
## v1.0.1-rc.3 - _August 14, 2018_
* Updated to use latest orderFactory interface, fixed `feeRecipient` spelling error in public interface (#936)
* Dependencies updated
## v1.0.1-rc.2 - _July 26, 2018_
* Dependencies updated
## v1.0.1-rc.1 - _July 26, 2018_
* Dependencies updated
## v1.0.0 - _July 23, 2018_
* Dependencies updated
## v1.0.0-rc.1 - _July 19, 2018_
* Make fill-scenarios compatible with V2 of 0x protocol (#656)
## v0.0.6 - _July 18, 2018_
* Dependencies updated
## v0.0.5 - _July 9, 2018_
* Dependencies updated
## v0.0.4 - _June 19, 2018_
* Dependencies updated
## v0.0.3 - _May 29, 2018_
* Dependencies updated
## v0.0.2 - _May 22, 2018_
* Dependencies updated
## v0.0.1 - _May 22, 2018_
* Move FillScenarios out of 0x.js (#579)

View File

@ -1,63 +0,0 @@
## @0x/fill-scenarios
0x order fill scenario generator
## Installation
```bash
yarn add @0x/fill-scenarios
```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```json
"compilerOptions": {
"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
}
```
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0x/fill-scenarios yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/fill-scenarios yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```

View File

@ -1,46 +0,0 @@
{
"name": "@0x/fill-scenarios",
"version": "3.0.19",
"description": "0x order fill scenario generator",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "yarn tsc -b",
"build:ci": "yarn build",
"clean": "shx rm -rf lib src/generated_contract_wrappers",
"lint": "tslint --format stylish --project .",
"fix": "tslint --format stylish --fix --project ."
},
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md",
"devDependencies": {
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"make-promises-safe": "^1.1.0",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^5.3.2",
"@0x/base-contract": "^5.4.0",
"@0x/order-utils": "^8.4.0",
"@0x/types": "^2.4.3",
"@0x/typescript-typings": "^4.3.0",
"@0x/utils": "^4.5.2",
"@0x/web3-wrapper": "^6.0.13",
"ethereum-types": "^2.1.6",
"ethers": "~4.0.4",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -1,5 +0,0 @@
export const constants = {
AWAIT_TRANSACTION_MINED_MS: 0,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
NULL_BYTES: '0x',
};

View File

@ -1,299 +0,0 @@
import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } from '@0x/abi-gen-wrappers';
import { assetDataUtils } from '@0x/order-utils';
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
import { Order, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';
import * as _ from 'lodash';
import { constants } from './constants';
export class FillScenarios {
private readonly _web3Wrapper: Web3Wrapper;
private readonly _userAddresses: string[];
private readonly _coinbase: string;
private readonly _exchangeAddress: string;
private readonly _erc20ProxyAddress: string;
private readonly _erc721ProxyAddress: string;
constructor(
supportedProvider: SupportedProvider,
userAddresses: string[],
exchangeAddress: string,
erc20ProxyAddress: string,
erc721ProxyAddress: string,
) {
this._web3Wrapper = new Web3Wrapper(supportedProvider);
this._userAddresses = userAddresses;
this._coinbase = userAddresses[0];
this._exchangeAddress = exchangeAddress;
this._erc20ProxyAddress = erc20ProxyAddress;
this._erc721ProxyAddress = erc721ProxyAddress;
}
public async createFillableSignedOrderAsync(
makerAssetData: string,
takerAssetData: string,
makerAddress: string,
takerAddress: string,
fillableAmount: BigNumber,
expirationTimeSeconds?: BigNumber,
): Promise<SignedOrder> {
return this.createAsymmetricFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
fillableAmount,
expirationTimeSeconds,
);
}
public async createFillableSignedOrderWithFeesAsync(
makerAssetData: string,
takerAssetData: string,
makerFeeAssetData: string,
takerFeeAssetData: string,
makerFee: BigNumber,
takerFee: BigNumber,
makerAddress: string,
takerAddress: string,
fillableAmount: BigNumber,
feeRecipientAddress: string,
expirationTimeSeconds?: BigNumber,
senderAddress?: string,
): Promise<SignedOrder> {
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
makerFeeAssetData,
takerFeeAssetData,
makerFee,
takerFee,
makerAddress,
takerAddress,
fillableAmount,
fillableAmount,
feeRecipientAddress,
expirationTimeSeconds,
senderAddress,
);
}
public async createAsymmetricFillableSignedOrderAsync(
makerAssetData: string,
takerAssetData: string,
makerAddress: string,
takerAddress: string,
makerFillableAmount: BigNumber,
takerFillableAmount: BigNumber,
expirationTimeSeconds?: BigNumber,
): Promise<SignedOrder> {
const makerFeeAssetData = constants.NULL_BYTES;
const takerFeeAssetData = constants.NULL_BYTES;
const makerFee = new BigNumber(0);
const takerFee = new BigNumber(0);
const feeRecipientAddress = constants.NULL_ADDRESS;
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
makerFeeAssetData,
takerFeeAssetData,
makerFee,
takerFee,
makerAddress,
takerAddress,
makerFillableAmount,
takerFillableAmount,
feeRecipientAddress,
expirationTimeSeconds,
);
}
public async createPartiallyFilledSignedOrderAsync(
makerAssetData: string,
takerAssetData: string,
takerAddress: string,
fillableAmount: BigNumber,
partialFillAmount: BigNumber,
): Promise<SignedOrder> {
const [makerAddress] = this._userAddresses;
const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
fillableAmount,
);
const exchangeInstance = new ExchangeContract(
signedOrder.exchangeAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
const order = _.omit(signedOrder, ['signature']) as Order;
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
order,
partialFillAmount,
signedOrder.signature,
{ from: takerAddress },
);
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
return signedOrder;
}
private async _createAsymmetricFillableSignedOrderWithFeesAsync(
makerAssetData: string,
takerAssetData: string,
makerFeeAssetData: string,
takerFeeAssetData: string,
makerFee: BigNumber,
takerFee: BigNumber,
makerAddress: string,
takerAddress: string,
makerFillableAmount: BigNumber,
takerFillableAmount: BigNumber,
feeRecipientAddress: string,
expirationTimeSeconds?: BigNumber,
senderAddress?: string,
): Promise<SignedOrder> {
await this._increaseBalanceAndAllowanceWithAssetDataAsync(makerAssetData, makerAddress, makerFillableAmount);
await this._increaseBalanceAndAllowanceWithAssetDataAsync(takerAssetData, takerAddress, takerFillableAmount);
// Fees
await Promise.all([
this._increaseERC20BalanceAndAllowanceAsync(makerFeeAssetData, makerAddress, makerFee),
this._increaseERC20BalanceAndAllowanceAsync(takerFeeAssetData, takerAddress, takerFee),
]);
const _senderAddress = senderAddress ? senderAddress : constants.NULL_ADDRESS;
const signedOrder = await orderFactory.createSignedOrderAsync(
this._web3Wrapper.getProvider(),
makerAddress,
makerFillableAmount,
makerAssetData,
takerFillableAmount,
takerAssetData,
this._exchangeAddress,
{
takerAddress,
senderAddress: _senderAddress,
makerFeeAssetData,
takerFeeAssetData,
makerFee,
takerFee,
feeRecipientAddress,
expirationTimeSeconds,
},
);
return signedOrder;
}
private async _increaseERC721BalanceAndAllowanceAsync(
tokenAddress: string,
address: string,
tokenId: BigNumber,
): Promise<void> {
await this._increaseERC721BalanceAsync(tokenAddress, address, tokenId);
await this._increaseERC721AllowanceAsync(tokenAddress, address, tokenId);
}
private async _increaseERC721AllowanceAsync(
tokenAddress: string,
address: string,
tokenId: BigNumber,
): Promise<void> {
const erc721Token = new DummyERC721TokenContract(
tokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
const txHash = await erc721Token.approve.sendTransactionAsync(this._erc721ProxyAddress, tokenId, {
from: address,
});
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
}
private async _increaseERC721BalanceAsync(
tokenAddress: string,
address: string,
tokenId: BigNumber,
): Promise<void> {
const erc721Token = new DummyERC721TokenContract(
tokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
try {
const currentOwner = await erc721Token.ownerOf.callAsync(tokenId);
if (currentOwner !== address) {
throw new Error(`Token ${tokenAddress}:${tokenId} is already owner by ${currentOwner}`);
}
} catch (err) {
const txHash = await erc721Token.mint.sendTransactionAsync(address, tokenId, { from: this._coinbase });
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
}
}
private async _increaseERC20BalanceAndAllowanceAsync(
tokenAddress: string,
address: string,
amount: BigNumber,
): Promise<void> {
if (amount.isZero() || address === constants.NULL_ADDRESS) {
return; // noop
}
await Promise.all([
this._increaseERC20BalanceAsync(tokenAddress, address, amount),
this._increaseERC20AllowanceAsync(tokenAddress, address, amount),
]);
}
private async _increaseERC20BalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
const erc20Token = new DummyERC20TokenContract(
tokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
const txHash = await erc20Token.transfer.sendTransactionAsync(address, amount, {
from: this._coinbase,
});
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
}
private async _increaseERC20AllowanceAsync(
tokenAddress: string,
address: string,
amount: BigNumber,
): Promise<void> {
const erc20Token = new DummyERC20TokenContract(
tokenAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
const oldMakerAllowance = await erc20Token.allowance.callAsync(address, this._erc20ProxyAddress);
const newMakerAllowance = oldMakerAllowance.plus(amount);
const txHash = await erc20Token.approve.sendTransactionAsync(this._erc20ProxyAddress, newMakerAllowance, {
from: address,
});
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
}
private async _increaseBalanceAndAllowanceWithAssetDataAsync(
assetData: string,
userAddress: string,
amount: BigNumber,
): Promise<void> {
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
if (assetDataUtils.isERC20AssetData(decodedAssetData)) {
await this._increaseERC20BalanceAndAllowanceAsync(decodedAssetData.tokenAddress, userAddress, amount);
} else if (assetDataUtils.isERC721AssetData(decodedAssetData)) {
await this._increaseERC721BalanceAndAllowanceAsync(
decodedAssetData.tokenAddress,
userAddress,
decodedAssetData.tokenId,
);
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) {
const amountsElement = decodedAssetData.amounts[index];
const totalAmount = amount.times(amountsElement);
await this._increaseBalanceAndAllowanceWithAssetDataAsync(
nestedAssetDataElement,
userAddress,
totalAmount,
);
}
}
}
}

View File

@ -1 +0,0 @@
export { FillScenarios } from './fill_scenarios';

View File

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
}

View File

@ -1,3 +0,0 @@
{
"extends": ["@0x/tslint-config"]
}

View File

@ -46,7 +46,6 @@
{ "path": "./packages/contracts-gen" }, { "path": "./packages/contracts-gen" },
{ "path": "./packages/dev-utils" }, { "path": "./packages/dev-utils" },
{ "path": "./packages/ethereum-types" }, { "path": "./packages/ethereum-types" },
{ "path": "./packages/fill-scenarios" },
{ "path": "./packages/json-schemas" }, { "path": "./packages/json-schemas" },
{ "path": "./packages/migrations" }, { "path": "./packages/migrations" },
{ "path": "./packages/monorepo-scripts" }, { "path": "./packages/monorepo-scripts" },