Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/move-features-over-from-zrx-buyer
This commit is contained in:
commit
dbf5be6c21
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -1 +1,5 @@
|
|||||||
*.sol linguist-language=Solidity
|
*.sol linguist-language=Solidity
|
||||||
|
|
||||||
|
# Automatically collapse generated files in GitHub.
|
||||||
|
packages/contract-artifacts/artifacts/*json linguist-generated
|
||||||
|
packages/abi-gen-wrappers/wrappers/*.ts liguist-generated
|
||||||
|
24
.gitignore
vendored
24
.gitignore
vendored
@ -79,30 +79,14 @@ packages/react-docs/example/public/bundle*
|
|||||||
packages/testnet-faucets/server/
|
packages/testnet-faucets/server/
|
||||||
|
|
||||||
# generated contract artifacts/
|
# generated contract artifacts/
|
||||||
|
packages/contracts/generated-artifacts/
|
||||||
packages/sol-cov/test/fixtures/artifacts/
|
packages/sol-cov/test/fixtures/artifacts/
|
||||||
packages/metacoin/artifacts/
|
packages/metacoin/artifacts/
|
||||||
packages/order-watcher/test/artifacts/
|
|
||||||
packages/contract-wrappers/test/artifacts/
|
|
||||||
packages/contract-wrappers/src/artifacts/
|
|
||||||
packages/order-watcher/src/artifacts/
|
|
||||||
packages/0x.js/src/artifacts/
|
|
||||||
packages/order-utils/src/artifacts/
|
|
||||||
|
|
||||||
# unstable generated contract artifacts:
|
# generated contract wrappers
|
||||||
packages/migrations/artifacts/development/
|
packages/abi-gen-wrappers/wrappers
|
||||||
|
packages/contracts/generated-wrappers/
|
||||||
# generated contract watcher
|
|
||||||
packages/0x.js/src/generated_contract_wrappers/
|
|
||||||
packages/contracts/generated_contract_wrappers/
|
|
||||||
packages/contract-wrappers/src/contract_wrappers/generated/
|
|
||||||
packages/metacoin/src/contract_wrappers
|
packages/metacoin/src/contract_wrappers
|
||||||
packages/fill-scenarios/src/generated_contract_wrappers/
|
|
||||||
packages/order-watcher/src/generated_contract_wrappers/
|
|
||||||
packages/order-utils/src/generated_contract_wrappers/
|
|
||||||
packages/migrations/src/1.0.0/contract_wrappers
|
|
||||||
packages/migrations/src/2.0.0-testnet/contract_wrappers
|
|
||||||
packages/migrations/src/2.0.0/contract_wrappers
|
|
||||||
packages/migrations/src/development/contract_wrappers
|
|
||||||
|
|
||||||
# solc-bin in sol-compiler
|
# solc-bin in sol-compiler
|
||||||
packages/sol-compiler/solc_bin/
|
packages/sol-compiler/solc_bin/
|
||||||
|
@ -1,27 +1,12 @@
|
|||||||
lib
|
lib
|
||||||
.nyc_output
|
.nyc_output
|
||||||
/packages/contract-wrappers/src/contract_wrappers/generated/
|
/packages/contracts/generated-wrappers
|
||||||
|
/packages/contracts/generated-artifacts
|
||||||
|
/packages/abi-gen-wrappers/src/generated-wrappers
|
||||||
|
/packages/contract-artifacts/artifacts
|
||||||
/packages/metacoin/src/contract_wrappers
|
/packages/metacoin/src/contract_wrappers
|
||||||
/packages/0x.js/src/generated_contract_wrappers/
|
|
||||||
/packages/contracts/generated_contract_wrappers/
|
|
||||||
/packages/fill-scenarios/src/generated_contract_wrappers/
|
|
||||||
/packages/order-watcher/src/generated_contract_wrappers/
|
|
||||||
/packages/order-utils/src/generated_contract_wrappers/
|
|
||||||
/packages/migrations/src/1.0.0/contract_wrappers
|
|
||||||
/packages/migrations/src/2.0.0-testnet/contract_wrappers
|
|
||||||
/packages/migrations/src/2.0.0/contract_wrappers
|
|
||||||
/packages/0x.js/src/artifacts
|
|
||||||
/packages/contracts/src/artifacts
|
|
||||||
/packages/contract-wrappers/src/artifacts
|
|
||||||
/packages/order-watcher/src/artifacts
|
|
||||||
/packages/metacoin/artifacts
|
/packages/metacoin/artifacts
|
||||||
/packages/sra-spec/public/
|
/packages/sra-spec/public/
|
||||||
/packages/contract-wrappers/test/artifacts
|
|
||||||
/packages/order-watcher/test/artifacts
|
|
||||||
/packages/migrations/artifacts/1.0.0
|
|
||||||
/packages/migrations/artifacts/2.0.0-testnet
|
|
||||||
/packages/migrations/artifacts/2.0.0
|
|
||||||
/packages/migrations/artifacts/development
|
|
||||||
package.json
|
package.json
|
||||||
scripts/postpublish_utils.js
|
scripts/postpublish_utils.js
|
||||||
packages/sol-cov/test/fixtures/artifacts
|
packages/sol-cov/test/fixtures/artifacts
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
"report_coverage": "lcov-result-merger './{packages/*/coverage/lcov.info,python-packages/*/.coverage}' | coveralls",
|
"report_coverage": "lcov-result-merger './{packages/*/coverage/lcov.info,python-packages/*/.coverage}' | coveralls",
|
||||||
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||||
"test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js",
|
"test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||||
"test:publish:circleci:comment": "HACK(albrow) We need an automated way to login to npm and echo+sleep piped to stdin was the only way I could find to do it.",
|
|
||||||
"test:publish:circleci": "yarn npm-cli-login -u test -p test -e test@example.com -r http://localhost:4873 && IS_LOCAL_PUBLISH=true run-s script:publish test:installation:local",
|
"test:publish:circleci": "yarn npm-cli-login -u test -p test -e test@example.com -r http://localhost:4873 && IS_LOCAL_PUBLISH=true run-s script:publish test:installation:local",
|
||||||
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish",
|
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish",
|
||||||
"run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish",
|
"run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish",
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
"note":
|
"note":
|
||||||
"Removed `SignerType` (including `SignerType.Metamask`). Please use the `MetamaskSubprovider` to wrap `web3.currentProvider`.",
|
"Removed `SignerType` (including `SignerType.Metamask`). Please use the `MetamaskSubprovider` to wrap `web3.currentProvider`.",
|
||||||
"pr": 1102
|
"pr": 1102
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Updated to use new modularized artifacts and the latest version of @0xproject/contract-wrappers",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Make web3-provider-engine types a 'dependency' so it's available to users of the library",
|
||||||
|
"pr": 1105
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -42,7 +42,9 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@0xproject/contract-addresses": "^1.0.0",
|
||||||
"@0xproject/abi-gen": "^1.0.13",
|
"@0xproject/abi-gen": "^1.0.13",
|
||||||
|
"@0xproject/abi-gen-wrappers": "^1.0.0",
|
||||||
"@0xproject/dev-utils": "^1.0.12",
|
"@0xproject/dev-utils": "^1.0.12",
|
||||||
"@0xproject/migrations": "^1.0.14",
|
"@0xproject/migrations": "^1.0.14",
|
||||||
"@0xproject/monorepo-scripts": "^1.0.11",
|
"@0xproject/monorepo-scripts": "^1.0.11",
|
||||||
@ -51,7 +53,6 @@
|
|||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"@types/sinon": "^2.2.2",
|
"@types/sinon": "^2.2.2",
|
||||||
"@types/web3-provider-engine": "^14.0.0",
|
|
||||||
"awesome-typescript-loader": "^5.2.1",
|
"awesome-typescript-loader": "^5.2.1",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
@ -83,6 +84,7 @@
|
|||||||
"@0xproject/typescript-typings": "^3.0.2",
|
"@0xproject/typescript-typings": "^3.0.2",
|
||||||
"@0xproject/utils": "^2.0.2",
|
"@0xproject/utils": "^2.0.2",
|
||||||
"@0xproject/web3-wrapper": "^3.0.3",
|
"@0xproject/web3-wrapper": "^3.0.3",
|
||||||
|
"@types/web3-provider-engine": "^14.0.0",
|
||||||
"ethereum-types": "^1.0.11",
|
"ethereum-types": "^1.0.11",
|
||||||
"ethers": "~4.0.4",
|
"ethers": "~4.0.4",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
|
6
packages/0x.js/src/globals.d.ts
vendored
6
packages/0x.js/src/globals.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
declare module '*.json' {
|
|
||||||
const json: any;
|
|
||||||
/* tslint:disable */
|
|
||||||
export default json;
|
|
||||||
/* tslint:enable */
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
export { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
|
|
||||||
export { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils';
|
export { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -18,6 +20,16 @@ export {
|
|||||||
TransactionOpts,
|
TransactionOpts,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
OrderInfo,
|
OrderInfo,
|
||||||
|
EventCallback,
|
||||||
|
DecodedLogEvent,
|
||||||
|
TransactionEncoder,
|
||||||
|
BalanceAndAllowance,
|
||||||
|
OrderAndTraderInfo,
|
||||||
|
TraderInfo,
|
||||||
|
ValidateOrderFillableOpts,
|
||||||
|
} from '@0xproject/contract-wrappers';
|
||||||
|
|
||||||
|
export {
|
||||||
WETH9Events,
|
WETH9Events,
|
||||||
WETH9WithdrawalEventArgs,
|
WETH9WithdrawalEventArgs,
|
||||||
WETH9ApprovalEventArgs,
|
WETH9ApprovalEventArgs,
|
||||||
@ -38,16 +50,9 @@ export {
|
|||||||
ExchangeSignatureValidatorApprovalEventArgs,
|
ExchangeSignatureValidatorApprovalEventArgs,
|
||||||
ExchangeFillEventArgs,
|
ExchangeFillEventArgs,
|
||||||
ExchangeCancelEventArgs,
|
ExchangeCancelEventArgs,
|
||||||
ExchangeEvents,
|
|
||||||
EventCallback,
|
|
||||||
DecodedLogEvent,
|
|
||||||
ExchangeEventArgs,
|
ExchangeEventArgs,
|
||||||
TransactionEncoder,
|
ExchangeEvents,
|
||||||
BalanceAndAllowance,
|
} from '@0xproject/abi-gen-wrappers';
|
||||||
OrderAndTraderInfo,
|
|
||||||
TraderInfo,
|
|
||||||
ValidateOrderFillableOpts,
|
|
||||||
} from '@0xproject/contract-wrappers';
|
|
||||||
|
|
||||||
export { OrderWatcher, OnOrderStateChangeCallback, OrderWatcherConfig } from '@0xproject/order-watcher';
|
export { OrderWatcher, OnOrderStateChangeCallback, OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||||
|
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*", "./test/**/*"]
|
"include": ["./src/**/*"]
|
||||||
}
|
}
|
||||||
|
11
packages/abi-gen-wrappers/CHANGELOG.json
Normal file
11
packages/abi-gen-wrappers/CHANGELOG.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"pr": 1105,
|
||||||
|
"note": "Initial release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
73
packages/abi-gen-wrappers/README.md
Normal file
73
packages/abi-gen-wrappers/README.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
## @0xproject/abi-gen-wrappers
|
||||||
|
|
||||||
|
Low-level 0x smart contract wrappers generated using @0xproject/abi-gen. These
|
||||||
|
low-level wrappers are imported by other packages in the 0x monorepo and
|
||||||
|
application developers are not expected to import this package directly.
|
||||||
|
|
||||||
|
You may also be interested in the
|
||||||
|
[@0xproject/contract-wrappers](../contract-wrappers/README.md) package which
|
||||||
|
includes some higher-level features.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add @0xproject/abi-gen-wrappers
|
||||||
|
```
|
||||||
|
|
||||||
|
**Import**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import * as wrappers from '@0xproject/abi-gen-wrappers';
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var wrappers = require('@0xproject/abi-gen-wrappers');
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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=@0xproject/abi-gen-wrappers yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clean
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn test
|
||||||
|
```
|
41
packages/abi-gen-wrappers/package.json
Normal file
41
packages/abi-gen-wrappers/package.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "@0xproject/abi-gen-wrappers",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
|
"description": "Low-level 0x smart contract wrappers generated using @0xproject/abi-gen",
|
||||||
|
"main": "lib/src/index.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "yarn pre_build && tsc -b",
|
||||||
|
"build:ci": "yarn build",
|
||||||
|
"pre_build": "yarn generate_contract_wrappers",
|
||||||
|
"clean": "shx rm -rf lib wrappers",
|
||||||
|
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|ZRXToken).json"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
||||||
|
"devDependencies": {
|
||||||
|
"@0xproject/abi-gen": "^1.0.12",
|
||||||
|
"shx": "^0.2.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@0xproject/base-contract": "^3.0.1"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
649
packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts
Normal file
649
packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts
Normal file
@ -0,0 +1,649 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type ERC20ProxyEventArgs =
|
||||||
|
| ERC20ProxyAuthorizedAddressAddedEventArgs
|
||||||
|
| ERC20ProxyAuthorizedAddressRemovedEventArgs;
|
||||||
|
|
||||||
|
export enum ERC20ProxyEvents {
|
||||||
|
AuthorizedAddressAdded = 'AuthorizedAddressAdded',
|
||||||
|
AuthorizedAddressRemoved = 'AuthorizedAddressRemoved',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC20ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs {
|
||||||
|
target: string;
|
||||||
|
caller: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC20ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs {
|
||||||
|
target: string;
|
||||||
|
caller: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ERC20ProxyContract extends BaseContract {
|
||||||
|
public addAuthorizedAddress = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.addAuthorizedAddress.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'addAuthorizedAddress(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addAuthorizedAddress;
|
||||||
|
const encodedData = ethersFunction.encode([target
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'addAuthorizedAddress'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public authorities = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'authorities(uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorities;
|
||||||
|
const encodedData = ethersFunction.encode([index_0
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'authorities'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public removeAuthorizedAddress = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.removeAuthorizedAddress.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'removeAuthorizedAddress(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddress;
|
||||||
|
const encodedData = ethersFunction.encode([target
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddress'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public owner = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'owner()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public removeAuthorizedAddressAtIndex = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target,
|
||||||
|
index
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'removeAuthorizedAddressAtIndex(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddressAtIndex;
|
||||||
|
const encodedData = ethersFunction.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddressAtIndex'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getProxyId = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'getProxyId()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getProxyId;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getProxyId'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public authorized = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'authorized(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorized;
|
||||||
|
const encodedData = ethersFunction.encode([index_0
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'authorized'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getAuthorizedAddresses = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string[]
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'getAuthorizedAddresses()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuthorizedAddresses;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getAuthorizedAddresses'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferOwnership = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferOwnership.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
newOwner
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
newOwner: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
newOwner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20ProxyContract;
|
||||||
|
const functionSignature = 'transferOwnership(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership;
|
||||||
|
const encodedData = ethersFunction.encode([newOwner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC20ProxyContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC20ProxyContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`ERC20Proxy successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ERC20ProxyContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('ERC20Proxy', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
556
packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts
Normal file
556
packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts
Normal file
@ -0,0 +1,556 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type ERC20TokenEventArgs =
|
||||||
|
| ERC20TokenTransferEventArgs
|
||||||
|
| ERC20TokenApprovalEventArgs;
|
||||||
|
|
||||||
|
export enum ERC20TokenEvents {
|
||||||
|
Transfer = 'Transfer',
|
||||||
|
Approval = 'Approval',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC20TokenTransferEventArgs extends DecodedLogArgs {
|
||||||
|
_from: string;
|
||||||
|
_to: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_spender: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ERC20TokenContract extends BaseContract {
|
||||||
|
public approve = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.approve.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_spender,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'approve(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
|
||||||
|
const encodedData = ethersFunction.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public totalSupply = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'totalSupply()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferFrom = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferFrom.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'transferFrom(address,address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public balanceOf = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'balanceOf(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
|
||||||
|
const encodedData = ethersFunction.encode([_owner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transfer = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transfer.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'transfer(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer;
|
||||||
|
const encodedData = ethersFunction.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public allowance = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
_spender: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC20TokenContract;
|
||||||
|
const functionSignature = 'allowance(address,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner,
|
||||||
|
_spender
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner,
|
||||||
|
_spender
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner,
|
||||||
|
_spender
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance;
|
||||||
|
const encodedData = ethersFunction.encode([_owner,
|
||||||
|
_spender
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC20TokenContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC20TokenContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ERC20TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('ERC20Token', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
649
packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts
Normal file
649
packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts
Normal file
@ -0,0 +1,649 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type ERC721ProxyEventArgs =
|
||||||
|
| ERC721ProxyAuthorizedAddressAddedEventArgs
|
||||||
|
| ERC721ProxyAuthorizedAddressRemovedEventArgs;
|
||||||
|
|
||||||
|
export enum ERC721ProxyEvents {
|
||||||
|
AuthorizedAddressAdded = 'AuthorizedAddressAdded',
|
||||||
|
AuthorizedAddressRemoved = 'AuthorizedAddressRemoved',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC721ProxyAuthorizedAddressAddedEventArgs extends DecodedLogArgs {
|
||||||
|
target: string;
|
||||||
|
caller: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC721ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogArgs {
|
||||||
|
target: string;
|
||||||
|
caller: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ERC721ProxyContract extends BaseContract {
|
||||||
|
public addAuthorizedAddress = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.addAuthorizedAddress.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('addAuthorizedAddress(address)').functions.addAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'addAuthorizedAddress(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.addAuthorizedAddress;
|
||||||
|
const encodedData = ethersFunction.encode([target
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'addAuthorizedAddress'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public authorities = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'authorities(uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorities;
|
||||||
|
const encodedData = ethersFunction.encode([index_0
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'authorities'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public removeAuthorizedAddress = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.removeAuthorizedAddress.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddress(address)').functions.removeAuthorizedAddress.encode([target
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'removeAuthorizedAddress(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddress;
|
||||||
|
const encodedData = ethersFunction.encode([target
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddress'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public owner = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'owner()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public removeAuthorizedAddressAtIndex = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
target,
|
||||||
|
index
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('removeAuthorizedAddressAtIndex(address,uint256)').inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('removeAuthorizedAddressAtIndex(address,uint256)').functions.removeAuthorizedAddressAtIndex.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
index: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'removeAuthorizedAddressAtIndex(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target,
|
||||||
|
index
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
index
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.removeAuthorizedAddressAtIndex;
|
||||||
|
const encodedData = ethersFunction.encode([target,
|
||||||
|
index
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'removeAuthorizedAddressAtIndex'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getProxyId = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'getProxyId()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getProxyId;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getProxyId'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public authorized = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'authorized(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.authorized;
|
||||||
|
const encodedData = ethersFunction.encode([index_0
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'authorized'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getAuthorizedAddresses = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string[]
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'getAuthorizedAddresses()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuthorizedAddresses;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getAuthorizedAddresses'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferOwnership = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferOwnership.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
newOwner
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
newOwner: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
newOwner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721ProxyContract;
|
||||||
|
const functionSignature = 'transferOwnership(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership;
|
||||||
|
const encodedData = ethersFunction.encode([newOwner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC721ProxyContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC721ProxyContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`ERC721Proxy successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ERC721ProxyContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('ERC721Proxy', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
893
packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts
Normal file
893
packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts
Normal file
@ -0,0 +1,893 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type ERC721TokenEventArgs =
|
||||||
|
| ERC721TokenTransferEventArgs
|
||||||
|
| ERC721TokenApprovalEventArgs
|
||||||
|
| ERC721TokenApprovalForAllEventArgs;
|
||||||
|
|
||||||
|
export enum ERC721TokenEvents {
|
||||||
|
Transfer = 'Transfer',
|
||||||
|
Approval = 'Approval',
|
||||||
|
ApprovalForAll = 'ApprovalForAll',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC721TokenTransferEventArgs extends DecodedLogArgs {
|
||||||
|
_from: string;
|
||||||
|
_to: string;
|
||||||
|
_tokenId: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC721TokenApprovalEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_approved: string;
|
||||||
|
_tokenId: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ERC721TokenApprovalForAllEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_operator: string;
|
||||||
|
_approved: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ERC721TokenContract extends BaseContract {
|
||||||
|
public getApproved = {
|
||||||
|
async callAsync(
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'getApproved(uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getApproved;
|
||||||
|
const encodedData = ethersFunction.encode([_tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getApproved'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public approve = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_approved: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_approved,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.approve.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_approved,
|
||||||
|
_tokenId
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_approved: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_approved,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_approved: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_approved,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_approved: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'approve(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_approved,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
|
||||||
|
const encodedData = ethersFunction.encode([_approved,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferFrom = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferFrom.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'transferFrom(address,address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public safeTransferFrom1 = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.safeTransferFrom1.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'safeTransferFrom(address,address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public ownerOf = {
|
||||||
|
async callAsync(
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'ownerOf(uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.ownerOf;
|
||||||
|
const encodedData = ethersFunction.encode([_tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'ownerOf'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public balanceOf = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'balanceOf(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
|
||||||
|
const encodedData = ethersFunction.encode([_owner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public setApprovalForAll = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_operator: string,
|
||||||
|
_approved: boolean,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
|
||||||
|
[_operator,
|
||||||
|
_approved
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.setApprovalForAll.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_operator,
|
||||||
|
_approved
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_operator: string,
|
||||||
|
_approved: boolean,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
|
||||||
|
[_operator,
|
||||||
|
_approved
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_operator: string,
|
||||||
|
_approved: boolean,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('setApprovalForAll(address,bool)').inputs;
|
||||||
|
[_operator,
|
||||||
|
_approved
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('setApprovalForAll(address,bool)').functions.setApprovalForAll.encode([_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_operator: string,
|
||||||
|
_approved: boolean,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'setApprovalForAll(address,bool)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_operator,
|
||||||
|
_approved
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.setApprovalForAll;
|
||||||
|
const encodedData = ethersFunction.encode([_operator,
|
||||||
|
_approved
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'setApprovalForAll'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public safeTransferFrom2 = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
_data: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.safeTransferFrom2.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
_data: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
_data: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('safeTransferFrom(address,address,uint256,bytes)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('safeTransferFrom(address,address,uint256,bytes)').functions.safeTransferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_tokenId: BigNumber,
|
||||||
|
_data: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'safeTransferFrom(address,address,uint256,bytes)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.safeTransferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([_from,
|
||||||
|
_to,
|
||||||
|
_tokenId,
|
||||||
|
_data
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'safeTransferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public isApprovedForAll = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
_operator: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ERC721TokenContract;
|
||||||
|
const functionSignature = 'isApprovedForAll(address,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner,
|
||||||
|
_operator
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner,
|
||||||
|
_operator
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner,
|
||||||
|
_operator
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isApprovedForAll;
|
||||||
|
const encodedData = ethersFunction.encode([_owner,
|
||||||
|
_operator
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'isApprovedForAll'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC721TokenContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ERC721TokenContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`ERC721Token successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ERC721TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('ERC721Token', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
3072
packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts
Normal file
3072
packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts
Normal file
File diff suppressed because it is too large
Load Diff
730
packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts
Normal file
730
packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts
Normal file
@ -0,0 +1,730 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ForwarderContract extends BaseContract {
|
||||||
|
public marketBuyOrdersWithEth = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
makerAssetFillAmount: BigNumber,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
txData: Partial<TxDataPayable> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.marketBuyOrdersWithEth.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
makerAssetFillAmount: BigNumber,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
makerAssetFillAmount: BigNumber,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)').functions.marketBuyOrdersWithEth.encode([orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
makerAssetFillAmount: BigNumber,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}]
|
||||||
|
> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const functionSignature = 'marketBuyOrdersWithEth(tuple[],uint256,bytes[],tuple[],bytes[],uint256,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketBuyOrdersWithEth;
|
||||||
|
const encodedData = ethersFunction.encode([orders,
|
||||||
|
makerAssetFillAmount,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'marketBuyOrdersWithEth'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public withdrawAsset = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
assetData: string,
|
||||||
|
amount: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs;
|
||||||
|
[assetData,
|
||||||
|
amount
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.withdrawAsset.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
assetData,
|
||||||
|
amount
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
assetData: string,
|
||||||
|
amount: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs;
|
||||||
|
[assetData,
|
||||||
|
amount
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
assetData: string,
|
||||||
|
amount: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('withdrawAsset(bytes,uint256)').inputs;
|
||||||
|
[assetData,
|
||||||
|
amount
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('withdrawAsset(bytes,uint256)').functions.withdrawAsset.encode([assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
assetData: string,
|
||||||
|
amount: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const functionSignature = 'withdrawAsset(bytes,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[assetData,
|
||||||
|
amount
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.withdrawAsset;
|
||||||
|
const encodedData = ethersFunction.encode([assetData,
|
||||||
|
amount
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'withdrawAsset'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public owner = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const functionSignature = 'owner()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.owner;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'owner'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public marketSellOrdersWithEth = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
txData: Partial<TxDataPayable> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.marketSellOrdersWithEth.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').inputs;
|
||||||
|
[orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)').functions.marketSellOrdersWithEth.encode([orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
signatures: string[],
|
||||||
|
feeOrders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
feeSignatures: string[],
|
||||||
|
feePercentage: BigNumber,
|
||||||
|
feeRecipient: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[{makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}, {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber}]
|
||||||
|
> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const functionSignature = 'marketSellOrdersWithEth(tuple[],bytes[],tuple[],bytes[],uint256,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.marketSellOrdersWithEth;
|
||||||
|
const encodedData = ethersFunction.encode([orders,
|
||||||
|
signatures,
|
||||||
|
feeOrders,
|
||||||
|
feeSignatures,
|
||||||
|
feePercentage,
|
||||||
|
feeRecipient
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'marketSellOrdersWithEth'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferOwnership = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferOwnership.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
newOwner
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
newOwner: string,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
newOwner: string,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferOwnership(address)').functions.transferOwnership.encode([newOwner
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
newOwner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as ForwarderContract;
|
||||||
|
const functionSignature = 'transferOwnership(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[newOwner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [newOwner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [newOwner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferOwnership;
|
||||||
|
const encodedData = ethersFunction.encode([newOwner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferOwnership'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
_zrxAssetData: string,
|
||||||
|
_wethAssetData: string,
|
||||||
|
): Promise<ForwarderContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ForwarderContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange,
|
||||||
|
_zrxAssetData,
|
||||||
|
_wethAssetData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
_zrxAssetData: string,
|
||||||
|
_wethAssetData: string,
|
||||||
|
): Promise<ForwarderContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[_exchange,
|
||||||
|
_zrxAssetData,
|
||||||
|
_wethAssetData
|
||||||
|
] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[_exchange,
|
||||||
|
_zrxAssetData,
|
||||||
|
_wethAssetData
|
||||||
|
],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, [_exchange,
|
||||||
|
_zrxAssetData,
|
||||||
|
_wethAssetData
|
||||||
|
]);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`Forwarder successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ForwarderContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [_exchange,
|
||||||
|
_zrxAssetData,
|
||||||
|
_wethAssetData
|
||||||
|
];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('Forwarder', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
108
packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts
Normal file
108
packages/abi-gen-wrappers/src/generated-wrappers/i_validator.ts
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class IValidatorContract extends BaseContract {
|
||||||
|
public isValidSignature = {
|
||||||
|
async callAsync(
|
||||||
|
hash: string,
|
||||||
|
signerAddress: string,
|
||||||
|
signature: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as IValidatorContract;
|
||||||
|
const functionSignature = 'isValidSignature(bytes32,address,bytes)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[hash,
|
||||||
|
signerAddress,
|
||||||
|
signature
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [hash,
|
||||||
|
signerAddress,
|
||||||
|
signature
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [hash,
|
||||||
|
signerAddress,
|
||||||
|
signature
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isValidSignature;
|
||||||
|
const encodedData = ethersFunction.encode([hash,
|
||||||
|
signerAddress,
|
||||||
|
signature
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'isValidSignature'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<IValidatorContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<IValidatorContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new IValidatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('IValidator', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
103
packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts
Normal file
103
packages/abi-gen-wrappers/src/generated-wrappers/i_wallet.ts
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class IWalletContract extends BaseContract {
|
||||||
|
public isValidSignature = {
|
||||||
|
async callAsync(
|
||||||
|
hash: string,
|
||||||
|
signature: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as IWalletContract;
|
||||||
|
const functionSignature = 'isValidSignature(bytes32,bytes)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[hash,
|
||||||
|
signature
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [hash,
|
||||||
|
signature
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [hash,
|
||||||
|
signature
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.isValidSignature;
|
||||||
|
const encodedData = ethersFunction.encode([hash,
|
||||||
|
signature
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'isValidSignature'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<IWalletContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<IWalletContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new IWalletContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('IWallet', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
@ -0,0 +1,357 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class OrderValidatorContract extends BaseContract {
|
||||||
|
public getOrderAndTraderInfo = {
|
||||||
|
async callAsync(
|
||||||
|
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||||
|
takerAddress: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}]
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getOrderAndTraderInfo({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[order,
|
||||||
|
takerAddress
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [order,
|
||||||
|
takerAddress
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [order,
|
||||||
|
takerAddress
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrderAndTraderInfo;
|
||||||
|
const encodedData = ethersFunction.encode([order,
|
||||||
|
takerAddress
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getOrderAndTraderInfo'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getBalanceAndAllowance = {
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
assetData: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[BigNumber, BigNumber]
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getBalanceAndAllowance(address,bytes)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target,
|
||||||
|
assetData
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
assetData
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
assetData
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getBalanceAndAllowance;
|
||||||
|
const encodedData = ethersFunction.encode([target,
|
||||||
|
assetData
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getBalanceAndAllowance'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getOrdersAndTradersInfo = {
|
||||||
|
async callAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
takerAddresses: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>]
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getOrdersAndTradersInfo(tuple[],address[])';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[orders,
|
||||||
|
takerAddresses
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
takerAddresses
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
takerAddresses
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getOrdersAndTradersInfo;
|
||||||
|
const encodedData = ethersFunction.encode([orders,
|
||||||
|
takerAddresses
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getOrdersAndTradersInfo'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getTradersInfo = {
|
||||||
|
async callAsync(
|
||||||
|
orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
|
||||||
|
takerAddresses: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getTradersInfo(tuple[],address[])';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[orders,
|
||||||
|
takerAddresses
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [orders,
|
||||||
|
takerAddresses
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [orders,
|
||||||
|
takerAddresses
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTradersInfo;
|
||||||
|
const encodedData = ethersFunction.encode([orders,
|
||||||
|
takerAddresses
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getTradersInfo'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getERC721TokenOwner = {
|
||||||
|
async callAsync(
|
||||||
|
token: string,
|
||||||
|
tokenId: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getERC721TokenOwner(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[token,
|
||||||
|
tokenId
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [token,
|
||||||
|
tokenId
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [token,
|
||||||
|
tokenId
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getERC721TokenOwner;
|
||||||
|
const encodedData = ethersFunction.encode([token,
|
||||||
|
tokenId
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getERC721TokenOwner'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getBalancesAndAllowances = {
|
||||||
|
async callAsync(
|
||||||
|
target: string,
|
||||||
|
assetData: string[],
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<[BigNumber[], BigNumber[]]
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getBalancesAndAllowances(address,bytes[])';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[target,
|
||||||
|
assetData
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [target,
|
||||||
|
assetData
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [target,
|
||||||
|
assetData
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getBalancesAndAllowances;
|
||||||
|
const encodedData = ethersFunction.encode([target,
|
||||||
|
assetData
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getBalancesAndAllowances'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public getTraderInfo = {
|
||||||
|
async callAsync(
|
||||||
|
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||||
|
takerAddress: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}
|
||||||
|
> {
|
||||||
|
const self = this as any as OrderValidatorContract;
|
||||||
|
const functionSignature = 'getTraderInfo({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[order,
|
||||||
|
takerAddress
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [order,
|
||||||
|
takerAddress
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [order,
|
||||||
|
takerAddress
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getTraderInfo;
|
||||||
|
const encodedData = ethersFunction.encode([order,
|
||||||
|
takerAddress
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'getTraderInfo'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
_zrxAssetData: string,
|
||||||
|
): Promise<OrderValidatorContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange,
|
||||||
|
_zrxAssetData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
_exchange: string,
|
||||||
|
_zrxAssetData: string,
|
||||||
|
): Promise<OrderValidatorContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[_exchange,
|
||||||
|
_zrxAssetData
|
||||||
|
] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[_exchange,
|
||||||
|
_zrxAssetData
|
||||||
|
],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, [_exchange,
|
||||||
|
_zrxAssetData
|
||||||
|
]);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new OrderValidatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [_exchange,
|
||||||
|
_zrxAssetData
|
||||||
|
];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('OrderValidator', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
835
packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts
Normal file
835
packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts
Normal file
@ -0,0 +1,835 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type WETH9EventArgs =
|
||||||
|
| WETH9ApprovalEventArgs
|
||||||
|
| WETH9TransferEventArgs
|
||||||
|
| WETH9DepositEventArgs
|
||||||
|
| WETH9WithdrawalEventArgs;
|
||||||
|
|
||||||
|
export enum WETH9Events {
|
||||||
|
Approval = 'Approval',
|
||||||
|
Transfer = 'Transfer',
|
||||||
|
Deposit = 'Deposit',
|
||||||
|
Withdrawal = 'Withdrawal',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WETH9ApprovalEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_spender: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WETH9TransferEventArgs extends DecodedLogArgs {
|
||||||
|
_from: string;
|
||||||
|
_to: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WETH9DepositEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WETH9WithdrawalEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class WETH9Contract extends BaseContract {
|
||||||
|
public name = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'name()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public approve = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
guy: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[guy,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.approve.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
guy,
|
||||||
|
wad
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
guy: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[guy,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
guy: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[guy,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
guy: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'approve(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[guy,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
|
||||||
|
const encodedData = ethersFunction.encode([guy,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public totalSupply = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'totalSupply()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferFrom = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
src: string,
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferFrom.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
src: string,
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
src: string,
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
src: string,
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'transferFrom(address,address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([src,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public withdraw = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
||||||
|
[wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [wad
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.withdraw.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
wad
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
||||||
|
[wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
wad: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
||||||
|
[wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw.encode([wad
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
wad: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'withdraw(uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [wad
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.withdraw;
|
||||||
|
const encodedData = ethersFunction.encode([wad
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'withdraw'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public decimals = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<number
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'decimals()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.decimals;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'decimals'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public balanceOf = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'balanceOf(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
|
||||||
|
const encodedData = ethersFunction.encode([index_0
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public symbol = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'symbol()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transfer = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transfer.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
dst,
|
||||||
|
wad
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'transfer(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[dst,
|
||||||
|
wad
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer;
|
||||||
|
const encodedData = ethersFunction.encode([dst,
|
||||||
|
wad
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public deposit = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
txData: Partial<TxDataPayable> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('deposit()').inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const encodedData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.deposit.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('deposit()').inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
): string {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const inputAbi = self._lookupAbi('deposit()').inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('deposit()').functions.deposit.encode([]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<void
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'deposit()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.deposit;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'deposit'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public allowance = {
|
||||||
|
async callAsync(
|
||||||
|
index_0: string,
|
||||||
|
index_1: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as WETH9Contract;
|
||||||
|
const functionSignature = 'allowance(address,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[index_0,
|
||||||
|
index_1
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [index_0,
|
||||||
|
index_1
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [index_0,
|
||||||
|
index_1
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance;
|
||||||
|
const encodedData = ethersFunction.encode([index_0,
|
||||||
|
index_1
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<WETH9Contract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return WETH9Contract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<WETH9Contract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`WETH9 successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new WETH9Contract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('WETH9', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
646
packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts
Normal file
646
packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts
Normal file
@ -0,0 +1,646 @@
|
|||||||
|
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||||
|
// tslint:disable:no-unused-variable
|
||||||
|
// tslint:disable:no-unbound-method
|
||||||
|
import { BaseContract } from '@0xproject/base-contract';
|
||||||
|
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||||
|
import { BigNumber, classUtils, logUtils } from '@0xproject/utils';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
|
export type ZRXTokenEventArgs =
|
||||||
|
| ZRXTokenTransferEventArgs
|
||||||
|
| ZRXTokenApprovalEventArgs;
|
||||||
|
|
||||||
|
export enum ZRXTokenEvents {
|
||||||
|
Transfer = 'Transfer',
|
||||||
|
Approval = 'Approval',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ZRXTokenTransferEventArgs extends DecodedLogArgs {
|
||||||
|
_from: string;
|
||||||
|
_to: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ZRXTokenApprovalEventArgs extends DecodedLogArgs {
|
||||||
|
_owner: string;
|
||||||
|
_spender: string;
|
||||||
|
_value: BigNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
// tslint:disable:no-parameter-reassignment
|
||||||
|
// tslint:disable-next-line:class-name
|
||||||
|
export class ZRXTokenContract extends BaseContract {
|
||||||
|
public name = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'name()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.name;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'name'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public approve = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.approve.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_spender,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('approve(address,uint256)').functions.approve.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_spender: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'approve(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_spender,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.approve;
|
||||||
|
const encodedData = ethersFunction.encode([_spender,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'approve'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public totalSupply = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'totalSupply()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.totalSupply;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'totalSupply'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transferFrom = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transferFrom.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transferFrom(address,address,uint256)').functions.transferFrom.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_from: string,
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'transferFrom(address,address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transferFrom;
|
||||||
|
const encodedData = ethersFunction.encode([_from,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transferFrom'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public decimals = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<number
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'decimals()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.decimals;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'decimals'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public balanceOf = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'balanceOf(address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.balanceOf;
|
||||||
|
const encodedData = ethersFunction.encode([_owner
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'balanceOf'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public symbol = {
|
||||||
|
async callAsync(
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<string
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'symbol()';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, []);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.symbol;
|
||||||
|
const encodedData = ethersFunction.encode([]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'symbol'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public transfer = {
|
||||||
|
async sendTransactionAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
self.transfer.estimateGasAsync.bind(
|
||||||
|
self,
|
||||||
|
_to,
|
||||||
|
_value
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
return txHash;
|
||||||
|
},
|
||||||
|
async estimateGasAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
txData: Partial<TxData> = {},
|
||||||
|
): Promise<number> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...txData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
|
return gas;
|
||||||
|
},
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
): string {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString);
|
||||||
|
const abiEncodedTransactionData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
async callAsync(
|
||||||
|
_to: string,
|
||||||
|
_value: BigNumber,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<boolean
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'transfer(address,uint256)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_to,
|
||||||
|
_value
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.transfer;
|
||||||
|
const encodedData = ethersFunction.encode([_to,
|
||||||
|
_value
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'transfer'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public allowance = {
|
||||||
|
async callAsync(
|
||||||
|
_owner: string,
|
||||||
|
_spender: string,
|
||||||
|
callData: Partial<CallData> = {},
|
||||||
|
defaultBlock?: BlockParam,
|
||||||
|
): Promise<BigNumber
|
||||||
|
> {
|
||||||
|
const self = this as any as ZRXTokenContract;
|
||||||
|
const functionSignature = 'allowance(address,address)';
|
||||||
|
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||||
|
[_owner,
|
||||||
|
_spender
|
||||||
|
] = BaseContract._formatABIDataItemList(inputAbi, [_owner,
|
||||||
|
_spender
|
||||||
|
], BaseContract._bigNumberToString.bind(self));
|
||||||
|
BaseContract.strictArgumentEncodingCheck(inputAbi, [_owner,
|
||||||
|
_spender
|
||||||
|
]);
|
||||||
|
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.allowance;
|
||||||
|
const encodedData = ethersFunction.encode([_owner,
|
||||||
|
_spender
|
||||||
|
]);
|
||||||
|
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{
|
||||||
|
to: self.address,
|
||||||
|
...callData,
|
||||||
|
data: encodedData,
|
||||||
|
},
|
||||||
|
self._web3Wrapper.getContractDefaults(),
|
||||||
|
);
|
||||||
|
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||||
|
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||||
|
let resultArray = ethersFunction.decode(rawCallResult);
|
||||||
|
const outputAbi = (_.find(self.abi, {name: 'allowance'}) as MethodAbi).outputs;
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||||
|
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||||
|
return resultArray[0];
|
||||||
|
},
|
||||||
|
};
|
||||||
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
artifact: ContractArtifact,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ZRXTokenContract> {
|
||||||
|
if (_.isUndefined(artifact.compilerOutput)) {
|
||||||
|
throw new Error('Compiler output not found in the artifact file');
|
||||||
|
}
|
||||||
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
|
const abi = artifact.compilerOutput.abi;
|
||||||
|
return ZRXTokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||||
|
}
|
||||||
|
public static async deployAsync(
|
||||||
|
bytecode: string,
|
||||||
|
abi: ContractAbi,
|
||||||
|
provider: Provider,
|
||||||
|
txDefaults: Partial<TxData>,
|
||||||
|
): Promise<ZRXTokenContract> {
|
||||||
|
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||||
|
[] = BaseContract._formatABIDataItemList(
|
||||||
|
constructorAbi.inputs,
|
||||||
|
[],
|
||||||
|
BaseContract._bigNumberToString,
|
||||||
|
);
|
||||||
|
const iface = new ethers.utils.Interface(abi);
|
||||||
|
const deployInfo = iface.deployFunction;
|
||||||
|
const txData = deployInfo.encode(bytecode, []);
|
||||||
|
const web3Wrapper = new Web3Wrapper(provider);
|
||||||
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
|
{data: txData},
|
||||||
|
txDefaults,
|
||||||
|
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||||
|
);
|
||||||
|
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
logUtils.log(`ZRXToken successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
|
const contractInstance = new ZRXTokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||||
|
contractInstance.constructorArgs = [];
|
||||||
|
return contractInstance;
|
||||||
|
}
|
||||||
|
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||||
|
super('ZRXToken', abi, address, provider, txDefaults);
|
||||||
|
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||||
|
}
|
||||||
|
} // tslint:disable:max-file-line-count
|
||||||
|
// tslint:enable:no-unbound-method
|
14
packages/abi-gen-wrappers/src/index.ts
Normal file
14
packages/abi-gen-wrappers/src/index.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export * from './generated-wrappers/asset_proxy_owner';
|
||||||
|
export * from './generated-wrappers/dummy_erc20_token';
|
||||||
|
export * from './generated-wrappers/dummy_erc721_token';
|
||||||
|
export * from './generated-wrappers/erc20_proxy';
|
||||||
|
export * from './generated-wrappers/erc20_token';
|
||||||
|
export * from './generated-wrappers/erc721_proxy';
|
||||||
|
export * from './generated-wrappers/erc721_token';
|
||||||
|
export * from './generated-wrappers/exchange';
|
||||||
|
export * from './generated-wrappers/forwarder';
|
||||||
|
export * from './generated-wrappers/i_validator';
|
||||||
|
export * from './generated-wrappers/i_wallet';
|
||||||
|
export * from './generated-wrappers/order_validator';
|
||||||
|
export * from './generated-wrappers/weth9';
|
||||||
|
export * from './generated-wrappers/zrx_token';
|
8
packages/abi-gen-wrappers/tsconfig.json
Normal file
8
packages/abi-gen-wrappers/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
@ -54,7 +54,6 @@
|
|||||||
"@types/tmp": "^0.0.33",
|
"@types/tmp": "^0.0.33",
|
||||||
"@types/yargs": "^10.0.0",
|
"@types/yargs": "^10.0.0",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"copyfiles": "^2.0.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/valid-url": "^1.0.2",
|
"@types/valid-url": "^1.0.2",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"copyfiles": "^2.0.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
{
|
{
|
||||||
"note": "Export `BuyQuoteInfo` type",
|
"note": "Export `BuyQuoteInfo` type",
|
||||||
"pr": 1131
|
"pr": 1131
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Updated to use new modularized artifacts and the latest version of @0xproject/contract-wrappers",
|
||||||
|
"pr": 1105
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch_without_deps": "tsc -w",
|
"build": "yarn tsc -b",
|
||||||
|
"build:ci": "yarn build",
|
||||||
"lint": "tslint --project .",
|
"lint": "tslint --project .",
|
||||||
"test": "yarn run_mocha",
|
"test": "yarn run_mocha",
|
||||||
"rebuild_and_test": "run-s clean build test",
|
"rebuild_and_test": "run-s clean build test",
|
||||||
@ -16,10 +17,7 @@
|
|||||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||||
"test:circleci": "yarn test:coverage",
|
"test:circleci": "yarn test:coverage",
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||||
"clean": "shx rm -rf lib test_temp scripts",
|
"clean": "shx rm -rf lib test_temp"
|
||||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
|
||||||
"build:ci": "yarn build",
|
|
||||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"postpublish": {
|
"postpublish": {
|
||||||
@ -58,7 +56,6 @@
|
|||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^2.0.1",
|
"chai-bignumber": "^2.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
|
@ -283,13 +283,13 @@ export class AssetBuyer {
|
|||||||
* Will throw if WETH does not exist for the current network.
|
* Will throw if WETH does not exist for the current network.
|
||||||
*/
|
*/
|
||||||
private _getEtherTokenAssetDataOrThrow(): string {
|
private _getEtherTokenAssetDataOrThrow(): string {
|
||||||
return assetDataUtils.getEtherTokenAssetDataOrThrow(this._contractWrappers);
|
return assetDataUtils.getEtherTokenAssetData(this._contractWrappers);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the assetData that represents the ZRX token.
|
* Get the assetData that represents the ZRX token.
|
||||||
* Will throw if ZRX does not exist for the current network.
|
* Will throw if ZRX does not exist for the current network.
|
||||||
*/
|
*/
|
||||||
private _getZrxTokenAssetDataOrThrow(): string {
|
private _getZrxTokenAssetDataOrThrow(): string {
|
||||||
return assetDataUtils.getZrxTokenAssetDataOrThrow(this._contractWrappers);
|
return this._contractWrappers.exchange.getZRXAssetData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,11 @@ import { ContractWrappers } from '@0xproject/contract-wrappers';
|
|||||||
import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils';
|
import { assetDataUtils as sharedAssetDataUtils } from '@0xproject/order-utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { AssetBuyerError } from '../types';
|
|
||||||
|
|
||||||
export const assetDataUtils = {
|
export const assetDataUtils = {
|
||||||
...sharedAssetDataUtils,
|
...sharedAssetDataUtils,
|
||||||
getEtherTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string {
|
getEtherTokenAssetData(contractWrappers: ContractWrappers): string {
|
||||||
const etherTokenAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists();
|
const etherTokenAddress = contractWrappers.forwarder.etherTokenAddress;
|
||||||
if (_.isUndefined(etherTokenAddressIfExists)) {
|
const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddress);
|
||||||
throw new Error(AssetBuyerError.NoEtherTokenContractFound);
|
|
||||||
}
|
|
||||||
const etherTokenAssetData = sharedAssetDataUtils.encodeERC20AssetData(etherTokenAddressIfExists);
|
|
||||||
return etherTokenAssetData;
|
return etherTokenAssetData;
|
||||||
},
|
},
|
||||||
getZrxTokenAssetDataOrThrow(contractWrappers: ContractWrappers): string {
|
|
||||||
let zrxTokenAssetData: string;
|
|
||||||
try {
|
|
||||||
zrxTokenAssetData = contractWrappers.exchange.getZRXAssetData();
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error(AssetBuyerError.NoZrxTokenContractFound);
|
|
||||||
}
|
|
||||||
return zrxTokenAssetData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
"@0xproject/tslint-config": "^1.0.8",
|
"@0xproject/tslint-config": "^1.0.8",
|
||||||
"@types/lodash": "4.14.104",
|
"@types/lodash": "4.14.104",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"copyfiles": "^2.0.0",
|
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
|
11
packages/contract-addresses/CHANGELOG.json
Normal file
11
packages/contract-addresses/CHANGELOG.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"pr": 1105,
|
||||||
|
"note": "Initial release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
69
packages/contract-addresses/README.md
Normal file
69
packages/contract-addresses/README.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
## @0xproject/contract-addresses
|
||||||
|
|
||||||
|
A tiny utility library for getting known deployed contract addresses for a
|
||||||
|
particular network.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add @0xproject/contract-addresses
|
||||||
|
```
|
||||||
|
|
||||||
|
**Import**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { getContractAddressesForNetworkOrThrow } from '@0xproject/contract-addresses';
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var getContractAddressesForNetworkOrThrow = require('@0xproject/contract-addresses')
|
||||||
|
.getContractAddressesForNetworkOrThrow;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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=@0xproject/contract-addresses yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clean
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn test
|
||||||
|
```
|
37
packages/contract-addresses/package.json
Normal file
37
packages/contract-addresses/package.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name": "@0xproject/contract-addresses",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
|
"description": "Used to get known addresses of deployed 0x contracts",
|
||||||
|
"main": "lib/src/index.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "yarn tsc -b",
|
||||||
|
"build:ci": "yarn build",
|
||||||
|
"clean": "shx rm -rf lib"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-addresses/README.md",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/lodash": "4.14.104",
|
||||||
|
"typescript": "3.0.1",
|
||||||
|
"shx": "^0.2.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": "^4.17.5"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
66
packages/contract-addresses/src/index.ts
Normal file
66
packages/contract-addresses/src/index.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
export interface ContractAddresses {
|
||||||
|
erc20Proxy: string;
|
||||||
|
erc721Proxy: string;
|
||||||
|
zrxToken: string;
|
||||||
|
etherToken: string;
|
||||||
|
exchange: string;
|
||||||
|
assetProxyOwner: string;
|
||||||
|
forwarder: string;
|
||||||
|
orderValidator: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum NetworkId {
|
||||||
|
Mainnet = 1,
|
||||||
|
Ropsten = 3,
|
||||||
|
Kovan = 42,
|
||||||
|
}
|
||||||
|
|
||||||
|
const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||||
|
1: {
|
||||||
|
erc20Proxy: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e',
|
||||||
|
erc721Proxy: '0x208e41fb445f1bb1b6780d58356e81405f3e6127',
|
||||||
|
zrxToken: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||||
|
etherToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
|
exchange: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
|
||||||
|
assetProxyOwner: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6',
|
||||||
|
forwarder: '0x7afc2d5107af94c462a194d2c21b5bdd238709d6',
|
||||||
|
orderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138',
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
erc20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa',
|
||||||
|
erc721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4',
|
||||||
|
zrxToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00',
|
||||||
|
etherToken: '0xc778417e063141139fce010982780140aa0cd5ab',
|
||||||
|
exchange: '0x4530c0483a1633c7a1c97d2c53721caff2caaaaf',
|
||||||
|
assetProxyOwner: '0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b',
|
||||||
|
forwarder: '0x3983e204b12b3c02fb0638caf2cd406a62e0ead3',
|
||||||
|
orderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f',
|
||||||
|
},
|
||||||
|
42: {
|
||||||
|
erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e',
|
||||||
|
erc721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821',
|
||||||
|
zrxToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa',
|
||||||
|
etherToken: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
|
||||||
|
exchange: '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
|
||||||
|
assetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8',
|
||||||
|
forwarder: '0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8',
|
||||||
|
orderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get addresses of contracts that have been deployed to either the
|
||||||
|
* Ethereum mainnet or a supported testnet. Throws if there are no known
|
||||||
|
* contracts deployed on the corresponding network.
|
||||||
|
* @param networkId The desired networkId.
|
||||||
|
* @returns The set of addresses for contracts which have been deployed on the
|
||||||
|
* given networkId.
|
||||||
|
*/
|
||||||
|
export function getContractAddressesForNetworkOrThrow(networkId: NetworkId): ContractAddresses {
|
||||||
|
if (_.isUndefined(networkToAddresses[networkId])) {
|
||||||
|
throw new Error(`Unknown network id (${networkId}). No known 0x contracts have been deployed on this network.`);
|
||||||
|
}
|
||||||
|
return networkToAddresses[networkId];
|
||||||
|
}
|
8
packages/contract-addresses/tsconfig.json
Normal file
8
packages/contract-addresses/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
3
packages/contract-addresses/tslint.json
Normal file
3
packages/contract-addresses/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0xproject/tslint-config"]
|
||||||
|
}
|
11
packages/contract-artifacts/CHANGELOG.json
Normal file
11
packages/contract-artifacts/CHANGELOG.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"pr": 1105,
|
||||||
|
"note": "Initial release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
67
packages/contract-artifacts/README.md
Normal file
67
packages/contract-artifacts/README.md
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
## @0xproject/contract-artifacts
|
||||||
|
|
||||||
|
Smart contract compilation artifacts for the latest version of the 0x Protocol.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add @0xproject/contract-artifacts
|
||||||
|
```
|
||||||
|
|
||||||
|
**Import**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import * as artifacts from '@0xproject/contract-artifacts';
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var artifacts = require('@0xproject/contract-artifacts');
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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=@0xproject/contract-artifacts yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Clean
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn test
|
||||||
|
```
|
@ -695,30 +695,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[[\"0x257619b7155d247e43c8b6d90c8c17278ae481f0\",\"0x5ee2a00f8f01d099451844af7f894f26a57fcbf2\",\"0x894d623e0e0e8ed12c4a73dada999e275684a37d\"],[\"0x2240dab907db71e64d3e0dba4800c83b5c502d4e\",\"0x208e41fb445f1bb1b6780d58356e81405f3e6127\"],\"2\",\"1209600\"]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[[\"0x9df8137872ac09a8fee71d0da5c7539923fb9bf0\",\"0xcf34d44db312d188789f43a63d11cf2bebb4da15\",\"0x73fd50f2a6beac9cdac9fe87ef68a18edc415831\"],[\"0xb1408f4c245a23c31b98d2c626777d4c0d766caa\",\"0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4\"],\"1\",\"0\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0x2c824d2882baa668e0d5202b1e7f2922278703f8",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[[\"0x9df8137872ac09a8fee71d0da5c7539923fb9bf0\",\"0xcf34d44db312d188789f43a63d11cf2bebb4da15\",\"0x73fd50f2a6beac9cdac9fe87ef68a18edc415831\"],[\"0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e\",\"0x2a9127c745688a165106c11cd4d647d2220af821\"],\"1\",\"0\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x34d402f14d58e001d8efbe6585051bf9706aa064",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[[\"0x9df8137872ac09a8fee71d0da5c7539923fb9bf0\",\"0xcf34d44db312d188789f43a63d11cf2bebb4da15\",\"0x73fd50f2a6beac9cdac9fe87ef68a18edc415831\"],[\"0x1dc4c1cefef38a777b15aa20260a54e584b16c48\",\"0x1d7022f5b17d2f8b695918fb48fa1089c9f85401\"],\"1\",\"0\"]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -324,22 +324,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"3": {
|
|
||||||
"address": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0x Protocol Token\",\"ZRX\",\"18\",\"1000000000000000000000000000\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0x Protocol Token\",\"ZRX\",\"18\",\"1000000000000000000000000000\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x Protocol Token\",\"ZRX\",\"18\",\"115792089237316195423570985008687907853269984665640564039457584007913129639935\"]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -191,26 +191,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -191,26 +191,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0x2a9127c745688a165106c11cd4d647d2220af821",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1972,26 +1972,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0xf47261b0000000000000000000000000ff67881f8d12f372d91baae9752eb3631ff0ed00\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0x35dd2932454449b14cee11a94d3674a936d5d7b2",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x48bacb9266a570d521063ef5dd96e61686dbe788",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0xf47261b0000000000000000000000000871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c\"]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -444,30 +444,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x4f833a24e1f95d70f028921e27040ca56e09ab0b\",\"0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498\",\"0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\"]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x4530c0483a1633c7a1c97d2c53721caff2caaaaf\",\"0xf47261b0000000000000000000000000ff67881f8d12f372d91baae9752eb3631ff0ed00\",\"0xf47261b0000000000000000000000000c778417e063141139fce010982780140aa0cd5ab\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x35dd2932454449b14cee11a94d3674a936d5d7b2\",\"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa\",\"0xf47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0xb69e673309512a9d726f87304c6984054f87a93b",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x0b1ba0af832d7c05fd64161e0db78e85978e8082\",\"0xf47261b0000000000000000000000000871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c\",\"0xf47261b00000000000000000000000000000000000000000000000000000000000000000\"]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -568,30 +568,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0x9463e518dea6810309563c81d5266c1b1d149138",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x4f833a24e1f95d70f028921e27040ca56e09ab0b\",\"0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498\"]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0x90431a90516ab49af23a0530e04e8c7836e7122f",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x4530c0483a1633c7a1c97d2c53721caff2caaaaf\",\"0xf47261b0000000000000000000000000ff67881f8d12f372d91baae9752eb3631ff0ed00\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x35dd2932454449b14cee11a94d3674a936d5d7b2\",\"0xf47261b00000000000000000000000002002d3812f58e35f0ea1ffbf80a75a38c32175fa\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0xe86bb98fcf9bff3512c74589b78fb168200cc546",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs":
|
|
||||||
"[\"0x48bacb9266a570d521063ef5dd96e61686dbe788\",\"0xf47261b0000000000000000000000000871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c\"]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -289,26 +289,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0xc778417e063141139fce010982780140aa0cd5ab",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -223,26 +223,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"networks": {
|
"networks": {}
|
||||||
"1": {
|
|
||||||
"address": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"address": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0x Protocol Token\",\"ZRX\",\"18\",\"1000000000000000000000000000\"]"
|
|
||||||
},
|
|
||||||
"42": {
|
|
||||||
"address": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[\"0x Protocol Token\",\"ZRX\",\"18\",\"1000000000000000000000000000\"]"
|
|
||||||
},
|
|
||||||
"50": {
|
|
||||||
"address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c",
|
|
||||||
"links": {},
|
|
||||||
"constructorArgs": "[]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
33
packages/contract-artifacts/package.json
Normal file
33
packages/contract-artifacts/package.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "@0xproject/contract-artifacts",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.12"
|
||||||
|
},
|
||||||
|
"description": "0x smart contract compilation artifacts",
|
||||||
|
"main": "lib/src/index.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "yarn tsc -b",
|
||||||
|
"build:ci": "yarn build",
|
||||||
|
"clean": "shx rm -rf lib"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||||
|
},
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-artifacts/README.md",
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "3.0.1",
|
||||||
|
"shx": "^0.2.2"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
31
packages/contract-artifacts/src/index.ts
Normal file
31
packages/contract-artifacts/src/index.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import * as AssetProxyOwner from '../artifacts/AssetProxyOwner.json';
|
||||||
|
import * as DummyERC20Token from '../artifacts/DummyERC20Token.json';
|
||||||
|
import * as DummyERC721Token from '../artifacts/DummyERC721Token.json';
|
||||||
|
import * as ERC20Proxy from '../artifacts/ERC20Proxy.json';
|
||||||
|
import * as ERC20Token from '../artifacts/ERC20Token.json';
|
||||||
|
import * as ERC721Proxy from '../artifacts/ERC721Proxy.json';
|
||||||
|
import * as ERC721Token from '../artifacts/ERC721Token.json';
|
||||||
|
import * as Exchange from '../artifacts/Exchange.json';
|
||||||
|
import * as Forwarder from '../artifacts/Forwarder.json';
|
||||||
|
import * as IValidator from '../artifacts/IValidator.json';
|
||||||
|
import * as IWallet from '../artifacts/IWallet.json';
|
||||||
|
import * as OrderValidator from '../artifacts/OrderValidator.json';
|
||||||
|
import * as WETH9 from '../artifacts/WETH9.json';
|
||||||
|
import * as ZRXToken from '../artifacts/ZRXToken.json';
|
||||||
|
|
||||||
|
export {
|
||||||
|
AssetProxyOwner,
|
||||||
|
DummyERC20Token,
|
||||||
|
DummyERC721Token,
|
||||||
|
ERC20Proxy,
|
||||||
|
ERC20Token,
|
||||||
|
ERC721Proxy,
|
||||||
|
ERC721Token,
|
||||||
|
Exchange,
|
||||||
|
Forwarder,
|
||||||
|
IValidator,
|
||||||
|
IWallet,
|
||||||
|
OrderValidator,
|
||||||
|
WETH9,
|
||||||
|
ZRXToken,
|
||||||
|
};
|
25
packages/contract-artifacts/tsconfig.json
Normal file
25
packages/contract-artifacts/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": ".",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"],
|
||||||
|
"files": [
|
||||||
|
"./artifacts/AssetProxyOwner.json",
|
||||||
|
"./artifacts/DummyERC20Token.json",
|
||||||
|
"./artifacts/DummyERC721Token.json",
|
||||||
|
"./artifacts/ERC20Proxy.json",
|
||||||
|
"./artifacts/ERC20Token.json",
|
||||||
|
"./artifacts/ERC721Proxy.json",
|
||||||
|
"./artifacts/ERC721Token.json",
|
||||||
|
"./artifacts/Exchange.json",
|
||||||
|
"./artifacts/Forwarder.json",
|
||||||
|
"./artifacts/IValidator.json",
|
||||||
|
"./artifacts/IWallet.json",
|
||||||
|
"./artifacts/OrderValidator.json",
|
||||||
|
"./artifacts/WETH9.json",
|
||||||
|
"./artifacts/ZRXToken.json"
|
||||||
|
]
|
||||||
|
}
|
3
packages/contract-artifacts/tslint.json
Normal file
3
packages/contract-artifacts/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0xproject/tslint-config"]
|
||||||
|
}
|
@ -1,9 +1,42 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"version": "2.1.0",
|
"version": "3.0.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
{
|
{
|
||||||
"note": "Add optional validation to the forwarder wrapper methods"
|
"note": "Add optional validation to the forwarder wrapper methods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Updated to use new modularized artifacts.",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Top-level `ContractWrappers` class has a new optional `contractAddresses` parameter.",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Default contract addresses are no longer stored in artifacts and are instead loaded from the `@0xproject/contract-addresses` package.",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Most contract addresses are now defined at instantiation time and are available as properties (e.g., `exchangeWrapper.address`) instead of methods (e.g., `exchangeWrapper.getContractAddress()`).",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Removed `setProvider` method in top-level `ContractWrapper` class and added new `unsubscribeAll` method.",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Some properties and methods have been renamed. For example, some methods that previously could throw no longer can, and so their names have been updated accordingly.",
|
||||||
|
"pr": 1105
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note":
|
||||||
|
"Removed ContractNotFound errors. Checking for this error was somewhat ineffecient. Relevant methods/functions now return the default error from web3-wrapper, which we feel provides enough information.",
|
||||||
|
"pr": 1105
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -11,24 +11,19 @@
|
|||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn pre_build && tsc -b",
|
"build": "tsc -b",
|
||||||
"build:ci": "yarn build",
|
"build:ci": "yarn build",
|
||||||
"pre_build": "run-s update_artifacts generate_contract_wrappers copy_artifacts",
|
|
||||||
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder|OrderValidator).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
|
|
||||||
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
|
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
|
||||||
"test:circleci": "run-s test:coverage",
|
"test:circleci": "run-s test:coverage",
|
||||||
"test": "yarn run_mocha",
|
"test": "yarn run_mocha",
|
||||||
"rebuild_and_test": "run-s build test",
|
"rebuild_and_test": "run-s build test",
|
||||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||||
"update_artifacts": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-trimmed/$i.json src/artifacts; done;",
|
"clean": "shx rm -rf _bundles lib test_temp generated_docs",
|
||||||
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
|
||||||
"clean": "shx rm -rf _bundles lib test_temp test/artifacts src/contract_wrappers/generated src/artifacts generated_docs",
|
|
||||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"contracts_v2": "AssetProxyOwner Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken Forwarder OrderValidator DummyERC20Token DummyERC721Token",
|
|
||||||
"postpublish": {
|
"postpublish": {
|
||||||
"assets": []
|
"assets": []
|
||||||
}
|
}
|
||||||
@ -42,7 +37,6 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/abi-gen": "^1.0.13",
|
|
||||||
"@0xproject/dev-utils": "^1.0.12",
|
"@0xproject/dev-utils": "^1.0.12",
|
||||||
"@0xproject/migrations": "^1.0.14",
|
"@0xproject/migrations": "^1.0.14",
|
||||||
"@0xproject/subproviders": "^2.0.7",
|
"@0xproject/subproviders": "^2.0.7",
|
||||||
@ -56,7 +50,6 @@
|
|||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^2.0.1",
|
"chai-bignumber": "^2.0.1",
|
||||||
"copyfiles": "^2.0.0",
|
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^4.1.0",
|
"mocha": "^4.1.0",
|
||||||
@ -72,8 +65,10 @@
|
|||||||
"web3-provider-engine": "14.0.6"
|
"web3-provider-engine": "14.0.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@0xproject/abi-gen-wrappers": "^1.0.0",
|
||||||
"@0xproject/assert": "^1.0.13",
|
"@0xproject/assert": "^1.0.13",
|
||||||
"@0xproject/base-contract": "^3.0.1",
|
"@0xproject/contract-addresses": "^1.0.0",
|
||||||
|
"@0xproject/contract-artifacts": "^1.0.0",
|
||||||
"@0xproject/fill-scenarios": "^1.0.7",
|
"@0xproject/fill-scenarios": "^1.0.7",
|
||||||
"@0xproject/json-schemas": "^1.0.7",
|
"@0xproject/json-schemas": "^1.0.7",
|
||||||
"@0xproject/order-utils": "^1.0.7",
|
"@0xproject/order-utils": "^1.0.7",
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import { ContractArtifact } from 'ethereum-types';
|
|
||||||
|
|
||||||
import * as DummyERC20Token from './artifacts/DummyERC20Token.json';
|
|
||||||
import * as DummyERC721Token from './artifacts/DummyERC721Token.json';
|
|
||||||
import * as ERC20Proxy from './artifacts/ERC20Proxy.json';
|
|
||||||
import * as ERC20Token from './artifacts/ERC20Token.json';
|
|
||||||
import * as ERC721Proxy from './artifacts/ERC721Proxy.json';
|
|
||||||
import * as ERC721Token from './artifacts/ERC721Token.json';
|
|
||||||
import * as Exchange from './artifacts/Exchange.json';
|
|
||||||
import * as Forwarder from './artifacts/Forwarder.json';
|
|
||||||
import * as OrderValidator from './artifacts/OrderValidator.json';
|
|
||||||
import * as EtherToken from './artifacts/WETH9.json';
|
|
||||||
import * as ZRXToken from './artifacts/ZRXToken.json';
|
|
||||||
|
|
||||||
export const artifacts = {
|
|
||||||
ZRXToken: (ZRXToken as any) as ContractArtifact,
|
|
||||||
DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
|
|
||||||
DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
|
|
||||||
ERC20Token: (ERC20Token as any) as ContractArtifact,
|
|
||||||
ERC721Token: (ERC721Token as any) as ContractArtifact,
|
|
||||||
Exchange: (Exchange as any) as ContractArtifact,
|
|
||||||
EtherToken: (EtherToken as any) as ContractArtifact,
|
|
||||||
ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
|
|
||||||
ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
|
|
||||||
Forwarder: (Forwarder as any) as ContractArtifact,
|
|
||||||
OrderValidator: (OrderValidator as any) as ContractArtifact,
|
|
||||||
};
|
|
@ -1,10 +1,17 @@
|
|||||||
|
import {
|
||||||
|
ERC20Proxy,
|
||||||
|
ERC20Token,
|
||||||
|
ERC721Proxy,
|
||||||
|
ERC721Token,
|
||||||
|
Exchange,
|
||||||
|
Forwarder,
|
||||||
|
OrderValidator,
|
||||||
|
WETH9,
|
||||||
|
} from '@0xproject/contract-artifacts';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { Provider } from 'ethereum-types';
|
import { Provider } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
|
|
||||||
import { artifacts } from './artifacts';
|
|
||||||
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
||||||
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
||||||
import { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
|
import { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
|
||||||
@ -14,10 +21,11 @@ import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
|||||||
import { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper';
|
import { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper';
|
||||||
import { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper';
|
import { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper';
|
||||||
import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema';
|
import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema';
|
||||||
import { contractWrappersPrivateNetworkConfigSchema } from './schemas/contract_wrappers_private_network_config_schema';
|
|
||||||
import { contractWrappersPublicNetworkConfigSchema } from './schemas/contract_wrappers_public_network_config_schema';
|
|
||||||
import { ContractWrappersConfig } from './types';
|
import { ContractWrappersConfig } from './types';
|
||||||
import { assert } from './utils/assert';
|
import { assert } from './utils/assert';
|
||||||
|
import { constants } from './utils/constants';
|
||||||
|
import { _getDefaultContractAddresses } from './utils/contract_addresses';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol.
|
* The ContractWrappers class contains smart contract wrappers helpful when building on 0x protocol.
|
||||||
*/
|
*/
|
||||||
@ -61,35 +69,39 @@ export class ContractWrappers {
|
|||||||
private readonly _web3Wrapper: Web3Wrapper;
|
private readonly _web3Wrapper: Web3Wrapper;
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ContractWrappers instance.
|
* Instantiates a new ContractWrappers instance.
|
||||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
* @param provider The Provider instance you would like the contract-wrappers library to use for interacting with
|
||||||
* the Ethereum network.
|
* the Ethereum network.
|
||||||
* @param config The configuration object. Look up the type for the description.
|
* @param config The configuration object. Look up the type for the description.
|
||||||
* @return An instance of the ContractWrappers class.
|
* @return An instance of the ContractWrappers class.
|
||||||
*/
|
*/
|
||||||
constructor(provider: Provider, config: ContractWrappersConfig) {
|
constructor(provider: Provider, config: ContractWrappersConfig) {
|
||||||
assert.isWeb3Provider('provider', provider);
|
assert.isWeb3Provider('provider', provider);
|
||||||
assert.doesConformToSchema('config', config, ContractWrappersConfigSchema, [
|
assert.doesConformToSchema('config', config, ContractWrappersConfigSchema);
|
||||||
contractWrappersPrivateNetworkConfigSchema,
|
|
||||||
contractWrappersPublicNetworkConfigSchema,
|
|
||||||
]);
|
|
||||||
const artifactJSONs = _.values(artifacts);
|
|
||||||
const abiArrays = _.map(artifactJSONs, artifact => artifact.compilerOutput.abi);
|
|
||||||
const txDefaults = {
|
const txDefaults = {
|
||||||
gasPrice: config.gasPrice,
|
gasPrice: config.gasPrice,
|
||||||
};
|
};
|
||||||
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||||
_.forEach(abiArrays, abi => {
|
const artifactsArray = [
|
||||||
this._web3Wrapper.abiDecoder.addABI(abi);
|
ERC20Proxy,
|
||||||
|
ERC20Token,
|
||||||
|
ERC721Proxy,
|
||||||
|
ERC721Token,
|
||||||
|
Exchange,
|
||||||
|
Forwarder,
|
||||||
|
OrderValidator,
|
||||||
|
WETH9,
|
||||||
|
];
|
||||||
|
_.forEach(artifactsArray, artifact => {
|
||||||
|
this._web3Wrapper.abiDecoder.addABI(artifact.compilerOutput.abi);
|
||||||
});
|
});
|
||||||
const blockPollingIntervalMs = _.isUndefined(config.blockPollingIntervalMs)
|
const blockPollingIntervalMs = _.isUndefined(config.blockPollingIntervalMs)
|
||||||
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
|
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
|
||||||
: config.blockPollingIntervalMs;
|
: config.blockPollingIntervalMs;
|
||||||
this.erc20Proxy = new ERC20ProxyWrapper(this._web3Wrapper, config.networkId, config.erc20ProxyContractAddress);
|
const contractAddresses = _.isUndefined(config.contractAddresses)
|
||||||
this.erc721Proxy = new ERC721ProxyWrapper(
|
? _getDefaultContractAddresses(config.networkId)
|
||||||
this._web3Wrapper,
|
: config.contractAddresses;
|
||||||
config.networkId,
|
this.erc20Proxy = new ERC20ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc20Proxy);
|
||||||
config.erc721ProxyContractAddress,
|
this.erc721Proxy = new ERC721ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc721Proxy);
|
||||||
);
|
|
||||||
this.erc20Token = new ERC20TokenWrapper(
|
this.erc20Token = new ERC20TokenWrapper(
|
||||||
this._web3Wrapper,
|
this._web3Wrapper,
|
||||||
config.networkId,
|
config.networkId,
|
||||||
@ -113,37 +125,34 @@ export class ContractWrappers {
|
|||||||
config.networkId,
|
config.networkId,
|
||||||
this.erc20Token,
|
this.erc20Token,
|
||||||
this.erc721Token,
|
this.erc721Token,
|
||||||
config.exchangeContractAddress,
|
contractAddresses.exchange,
|
||||||
config.zrxContractAddress,
|
contractAddresses.zrxToken,
|
||||||
blockPollingIntervalMs,
|
blockPollingIntervalMs,
|
||||||
);
|
);
|
||||||
this.forwarder = new ForwarderWrapper(
|
this.forwarder = new ForwarderWrapper(
|
||||||
this._web3Wrapper,
|
this._web3Wrapper,
|
||||||
config.networkId,
|
config.networkId,
|
||||||
config.forwarderContractAddress,
|
contractAddresses.forwarder,
|
||||||
config.zrxContractAddress,
|
contractAddresses.zrxToken,
|
||||||
|
contractAddresses.etherToken,
|
||||||
|
);
|
||||||
|
this.orderValidator = new OrderValidatorWrapper(
|
||||||
|
this._web3Wrapper,
|
||||||
|
config.networkId,
|
||||||
|
contractAddresses.orderValidator,
|
||||||
);
|
);
|
||||||
this.orderValidator = new OrderValidatorWrapper(this._web3Wrapper, config.networkId);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
* Unsubscribes from all subscriptions for all contracts.
|
||||||
* subscriptions so you will need to re-subscribe to all events relevant to your app after this call.
|
|
||||||
* @param provider The Web3Provider you would like the 0x.js library to use from now on.
|
|
||||||
* @param networkId The id of the network your provider is connected to
|
|
||||||
*/
|
*/
|
||||||
public setProvider(provider: Provider, networkId: number): void {
|
public unsubscribeAll(): void {
|
||||||
this._web3Wrapper.setProvider(provider);
|
this.exchange.unsubscribeAll();
|
||||||
(this.exchange as any)._invalidateContractInstances();
|
this.erc20Token.unsubscribeAll();
|
||||||
(this.exchange as any)._setNetworkId(networkId);
|
this.erc721Token.unsubscribeAll();
|
||||||
(this.erc20Token as any)._invalidateContractInstances();
|
this.etherToken.unsubscribeAll();
|
||||||
(this.erc20Token as any)._setNetworkId(networkId);
|
|
||||||
(this.erc20Proxy as any)._invalidateContractInstance();
|
|
||||||
(this.erc20Proxy as any)._setNetworkId(networkId);
|
|
||||||
(this.etherToken as any)._invalidateContractInstance();
|
|
||||||
(this.etherToken as any)._setNetworkId(networkId);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the provider instance currently used by 0x.js
|
* Get the provider instance currently used by contract-wrappers
|
||||||
* @return Web3 provider instance
|
* @return Web3 provider instance
|
||||||
*/
|
*/
|
||||||
public getProvider(): Provider {
|
public getProvider(): Provider {
|
||||||
|
@ -3,7 +3,6 @@ import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import {
|
import {
|
||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
ContractAbi,
|
ContractAbi,
|
||||||
ContractArtifact,
|
|
||||||
FilterObject,
|
FilterObject,
|
||||||
LogEntry,
|
LogEntry,
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
@ -24,22 +23,10 @@ import {
|
|||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
import { filterUtils } from '../utils/filter_utils';
|
import { filterUtils } from '../utils/filter_utils';
|
||||||
|
|
||||||
const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {
|
|
||||||
[contractName: string]: ContractWrappersError;
|
|
||||||
} = {
|
|
||||||
ZRX: ContractWrappersError.ZRXContractDoesNotExist,
|
|
||||||
EtherToken: ContractWrappersError.EtherTokenContractDoesNotExist,
|
|
||||||
ERC20Token: ContractWrappersError.ERC20TokenContractDoesNotExist,
|
|
||||||
ERC20Proxy: ContractWrappersError.ERC20ProxyContractDoesNotExist,
|
|
||||||
ERC721Token: ContractWrappersError.ERC721TokenContractDoesNotExist,
|
|
||||||
ERC721Proxy: ContractWrappersError.ERC721ProxyContractDoesNotExist,
|
|
||||||
Exchange: ContractWrappersError.ExchangeContractDoesNotExist,
|
|
||||||
};
|
|
||||||
|
|
||||||
export abstract class ContractWrapper {
|
export abstract class ContractWrapper {
|
||||||
public abstract abi: ContractAbi;
|
public abstract abi: ContractAbi;
|
||||||
protected _web3Wrapper: Web3Wrapper;
|
|
||||||
protected _networkId: number;
|
protected _networkId: number;
|
||||||
|
protected _web3Wrapper: Web3Wrapper;
|
||||||
private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined;
|
private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined;
|
||||||
private _blockPollingIntervalMs: number;
|
private _blockPollingIntervalMs: number;
|
||||||
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
|
||||||
@ -124,40 +111,6 @@ export abstract class ContractWrapper {
|
|||||||
const logWithDecodedArgs = abiDecoder.tryToDecodeLogOrNoop(log);
|
const logWithDecodedArgs = abiDecoder.tryToDecodeLogOrNoop(log);
|
||||||
return logWithDecodedArgs;
|
return logWithDecodedArgs;
|
||||||
}
|
}
|
||||||
protected async _getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifact: ContractArtifact,
|
|
||||||
addressIfExists?: string,
|
|
||||||
): Promise<[ContractAbi, string]> {
|
|
||||||
let contractAddress: string;
|
|
||||||
if (_.isUndefined(addressIfExists)) {
|
|
||||||
if (_.isUndefined(artifact.networks[this._networkId])) {
|
|
||||||
throw new Error(ContractWrappersError.ContractNotDeployedOnNetwork);
|
|
||||||
}
|
|
||||||
contractAddress = artifact.networks[this._networkId].address.toLowerCase();
|
|
||||||
} else {
|
|
||||||
contractAddress = addressIfExists;
|
|
||||||
}
|
|
||||||
const doesContractExist = await this._web3Wrapper.doesContractExistAtAddressAsync(contractAddress);
|
|
||||||
if (!doesContractExist) {
|
|
||||||
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contractName]);
|
|
||||||
}
|
|
||||||
const abiAndAddress: [ContractAbi, string] = [artifact.compilerOutput.abi, contractAddress];
|
|
||||||
return abiAndAddress;
|
|
||||||
}
|
|
||||||
protected _getContractAddress(artifact: ContractArtifact, addressIfExists?: string): string {
|
|
||||||
if (_.isUndefined(addressIfExists)) {
|
|
||||||
if (_.isUndefined(artifact.networks[this._networkId])) {
|
|
||||||
throw new Error(ContractWrappersError.ContractNotDeployedOnNetwork);
|
|
||||||
}
|
|
||||||
const contractAddress = artifact.networks[this._networkId].address;
|
|
||||||
if (_.isUndefined(contractAddress)) {
|
|
||||||
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contractName]);
|
|
||||||
}
|
|
||||||
return contractAddress;
|
|
||||||
} else {
|
|
||||||
return addressIfExists;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void {
|
private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void {
|
||||||
const log: LogEntry = marshaller.unmarshalLog(rawLog);
|
const log: LogEntry = marshaller.unmarshalLog(rawLog);
|
||||||
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
|
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
|
||||||
@ -222,14 +175,6 @@ export abstract class ContractWrapper {
|
|||||||
});
|
});
|
||||||
return logs as RawLogEntry[];
|
return logs as RawLogEntry[];
|
||||||
}
|
}
|
||||||
// HACK: This should be a package-scoped method (which doesn't exist in TS)
|
|
||||||
// We don't want this method available in the public interface for all classes
|
|
||||||
// who inherit from ContractWrapper, and it is only used by the internal implementation
|
|
||||||
// of those higher classes.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _setNetworkId(networkId: number): void {
|
|
||||||
this._networkId = networkId;
|
|
||||||
}
|
|
||||||
private _stopBlockAndLogStream(): void {
|
private _stopBlockAndLogStream(): void {
|
||||||
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||||
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
||||||
|
@ -1,38 +1,39 @@
|
|||||||
|
import { ERC20ProxyContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { ERC20Proxy } from '@0xproject/contract-artifacts';
|
||||||
import { AssetProxyId } from '@0xproject/types';
|
import { AssetProxyId } from '@0xproject/types';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { ContractAbi } from 'ethereum-types';
|
import { ContractAbi } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC20ProxyContract } from './generated/erc20_proxy';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes the functionality related to interacting with the ERC20Proxy contract.
|
* This class includes the functionality related to interacting with the ERC20Proxy contract.
|
||||||
*/
|
*/
|
||||||
export class ERC20ProxyWrapper extends ContractWrapper {
|
export class ERC20ProxyWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
public abi: ContractAbi = ERC20Proxy.compilerOutput.abi;
|
||||||
|
public address: string;
|
||||||
private _erc20ProxyContractIfExists?: ERC20ProxyContract;
|
private _erc20ProxyContractIfExists?: ERC20ProxyContract;
|
||||||
private _contractAddressIfExists?: string;
|
|
||||||
/**
|
/**
|
||||||
* Instantiate ERC20ProxyWrapper
|
* Instantiate ERC20ProxyWrapper
|
||||||
* @param web3Wrapper Web3Wrapper instance to use
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
* @param networkId Desired networkId
|
* @param networkId Desired networkId
|
||||||
* @param contractAddressIfExists The contract address to use. This is usually pulled from
|
* @param address The address of the ERC20Proxy contract. If undefined, will
|
||||||
* the artifacts but needs to be specified when using with your own custom testnet.
|
* default to the known address corresponding to the networkId.
|
||||||
*/
|
*/
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).erc20Proxy : address;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the 4 bytes ID of this asset proxy
|
* Get the 4 bytes ID of this asset proxy
|
||||||
* @return Proxy id
|
* @return Proxy id
|
||||||
*/
|
*/
|
||||||
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
||||||
const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
|
const ERC20ProxyContractInstance = this._getERC20ProxyContract();
|
||||||
const proxyId = (await ERC20ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
const proxyId = (await ERC20ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
||||||
return proxyId;
|
return proxyId;
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
|||||||
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
|
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
|
||||||
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
|
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
|
||||||
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
|
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
|
||||||
const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
|
const ERC20ProxyContractInstance = this._getERC20ProxyContract();
|
||||||
const isAuthorized = await ERC20ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
|
const isAuthorized = await ERC20ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
|
||||||
return isAuthorized;
|
return isAuthorized;
|
||||||
}
|
}
|
||||||
@ -53,36 +54,17 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
|||||||
* @return The list of authorized addresses.
|
* @return The list of authorized addresses.
|
||||||
*/
|
*/
|
||||||
public async getAuthorizedAddressesAsync(): Promise<string[]> {
|
public async getAuthorizedAddressesAsync(): Promise<string[]> {
|
||||||
const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
|
const ERC20ProxyContractInstance = this._getERC20ProxyContract();
|
||||||
const authorizedAddresses = await ERC20ProxyContractInstance.getAuthorizedAddresses.callAsync();
|
const authorizedAddresses = await ERC20ProxyContractInstance.getAuthorizedAddresses.callAsync();
|
||||||
return authorizedAddresses;
|
return authorizedAddresses;
|
||||||
}
|
}
|
||||||
/**
|
private _getERC20ProxyContract(): ERC20ProxyContract {
|
||||||
* Retrieves the Ethereum address of the ERC20Proxy contract deployed on the network
|
|
||||||
* that the user-passed web3 provider is connected to.
|
|
||||||
* @returns The Ethereum address of the ERC20Proxy contract being used.
|
|
||||||
*/
|
|
||||||
public getContractAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.ERC20Proxy, this._contractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstance(): void {
|
|
||||||
delete this._erc20ProxyContractIfExists;
|
|
||||||
}
|
|
||||||
private async _getERC20ProxyContractAsync(): Promise<ERC20ProxyContract> {
|
|
||||||
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
|
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
|
||||||
return this._erc20ProxyContractIfExists;
|
return this._erc20ProxyContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.ERC20Proxy,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
const contractInstance = new ERC20ProxyContract(
|
const contractInstance = new ERC20ProxyContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
this.address,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { ERC20Token } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
||||||
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
||||||
import {
|
import {
|
||||||
@ -20,7 +21,6 @@ import { constants } from '../utils/constants';
|
|||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC20ProxyWrapper } from './erc20_proxy_wrapper';
|
import { ERC20ProxyWrapper } from './erc20_proxy_wrapper';
|
||||||
import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from './generated/erc20_token';
|
|
||||||
|
|
||||||
const removeUndefinedProperties = _.pickBy;
|
const removeUndefinedProperties = _.pickBy;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ const removeUndefinedProperties = _.pickBy;
|
|||||||
* to the 0x ERC20 Proxy smart contract.
|
* to the 0x ERC20 Proxy smart contract.
|
||||||
*/
|
*/
|
||||||
export class ERC20TokenWrapper extends ContractWrapper {
|
export class ERC20TokenWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.ERC20Token.compilerOutput.abi;
|
public abi: ContractAbi = ERC20Token.compilerOutput.abi;
|
||||||
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
public UNLIMITED_ALLOWANCE_IN_BASE_UNITS = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
|
||||||
private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
private _tokenContractsByAddress: { [address: string]: ERC20TokenContract };
|
||||||
private _erc20ProxyWrapper: ERC20ProxyWrapper;
|
private _erc20ProxyWrapper: ERC20ProxyWrapper;
|
||||||
@ -189,7 +189,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts: MethodOpts = {},
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc20ProxyWrapper.address;
|
||||||
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, methodOpts);
|
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, methodOpts);
|
||||||
return allowanceInBaseUnits;
|
return allowanceInBaseUnits;
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
amountInBaseUnits: BigNumber,
|
amountInBaseUnits: BigNumber,
|
||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc20ProxyWrapper.address;
|
||||||
const txHash = await this.setAllowanceAsync(
|
const txHash = await this.setAllowanceAsync(
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
@ -373,7 +373,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ERC20Token.compilerOutput.abi,
|
ERC20Token.compilerOutput.abi,
|
||||||
callback,
|
callback,
|
||||||
isVerbose,
|
isVerbose,
|
||||||
);
|
);
|
||||||
@ -418,30 +418,19 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ERC20Token.compilerOutput.abi,
|
ERC20Token.compilerOutput.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstances(): void {
|
|
||||||
this.unsubscribeAll();
|
|
||||||
this._tokenContractsByAddress = {};
|
|
||||||
}
|
|
||||||
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
|
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
||||||
if (!_.isUndefined(tokenContract)) {
|
if (!_.isUndefined(tokenContract)) {
|
||||||
return tokenContract;
|
return tokenContract;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.ERC20Token,
|
|
||||||
normalizedTokenAddress,
|
|
||||||
);
|
|
||||||
const contractInstance = new ERC20TokenContract(
|
const contractInstance = new ERC20TokenContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
normalizedTokenAddress,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,38 +1,39 @@
|
|||||||
|
import { ERC721ProxyContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { ERC721Proxy } from '@0xproject/contract-artifacts';
|
||||||
import { AssetProxyId } from '@0xproject/types';
|
import { AssetProxyId } from '@0xproject/types';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { ContractAbi } from 'ethereum-types';
|
import { ContractAbi } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC721ProxyContract } from './generated/erc721_proxy';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes the functionality related to interacting with the ERC721Proxy contract.
|
* This class includes the functionality related to interacting with the ERC721Proxy contract.
|
||||||
*/
|
*/
|
||||||
export class ERC721ProxyWrapper extends ContractWrapper {
|
export class ERC721ProxyWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.ERC20Proxy.compilerOutput.abi;
|
public abi: ContractAbi = ERC721Proxy.compilerOutput.abi;
|
||||||
|
public address: string;
|
||||||
private _erc721ProxyContractIfExists?: ERC721ProxyContract;
|
private _erc721ProxyContractIfExists?: ERC721ProxyContract;
|
||||||
private _contractAddressIfExists?: string;
|
|
||||||
/**
|
/**
|
||||||
* Instantiate ERC721ProxyWrapper
|
* Instantiate ERC721ProxyWrapper
|
||||||
* @param web3Wrapper Web3Wrapper instance to use
|
* @param web3Wrapper Web3Wrapper instance to use
|
||||||
* @param networkId Desired networkId
|
* @param networkId Desired networkId
|
||||||
* @param contractAddressIfExists The contract address to use. This is usually pulled from
|
* @param address The address of the ERC721Proxy contract. If undefined,
|
||||||
* the artifacts but needs to be specified when using with your own custom testnet.
|
* will default to the known address corresponding to the networkId.
|
||||||
*/
|
*/
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).erc721Proxy : address;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the 4 bytes ID of this asset proxy
|
* Get the 4 bytes ID of this asset proxy
|
||||||
* @return Proxy id
|
* @return Proxy id
|
||||||
*/
|
*/
|
||||||
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
public async getProxyIdAsync(): Promise<AssetProxyId> {
|
||||||
const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync();
|
const ERC721ProxyContractInstance = await this._getERC721ProxyContract();
|
||||||
const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
|
||||||
return proxyId;
|
return proxyId;
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
|||||||
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
|
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
|
||||||
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
|
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
|
||||||
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
|
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
|
||||||
const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync();
|
const ERC721ProxyContractInstance = await this._getERC721ProxyContract();
|
||||||
const isAuthorized = await ERC721ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
|
const isAuthorized = await ERC721ProxyContractInstance.authorized.callAsync(normalizedExchangeContractAddress);
|
||||||
return isAuthorized;
|
return isAuthorized;
|
||||||
}
|
}
|
||||||
@ -53,36 +54,17 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
|||||||
* @return The list of authorized addresses.
|
* @return The list of authorized addresses.
|
||||||
*/
|
*/
|
||||||
public async getAuthorizedAddressesAsync(): Promise<string[]> {
|
public async getAuthorizedAddressesAsync(): Promise<string[]> {
|
||||||
const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync();
|
const ERC721ProxyContractInstance = await this._getERC721ProxyContract();
|
||||||
const authorizedAddresses = await ERC721ProxyContractInstance.getAuthorizedAddresses.callAsync();
|
const authorizedAddresses = await ERC721ProxyContractInstance.getAuthorizedAddresses.callAsync();
|
||||||
return authorizedAddresses;
|
return authorizedAddresses;
|
||||||
}
|
}
|
||||||
/**
|
private _getERC721ProxyContract(): ERC721ProxyContract {
|
||||||
* Retrieves the Ethereum address of the ERC721Proxy contract deployed on the network
|
|
||||||
* that the user-passed web3 provider is connected to.
|
|
||||||
* @returns The Ethereum address of the ERC721Proxy contract being used.
|
|
||||||
*/
|
|
||||||
public getContractAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.ERC721Proxy, this._contractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstance(): void {
|
|
||||||
delete this._erc721ProxyContractIfExists;
|
|
||||||
}
|
|
||||||
private async _getERC721ProxyContractAsync(): Promise<ERC721ProxyContract> {
|
|
||||||
if (!_.isUndefined(this._erc721ProxyContractIfExists)) {
|
if (!_.isUndefined(this._erc721ProxyContractIfExists)) {
|
||||||
return this._erc721ProxyContractIfExists;
|
return this._erc721ProxyContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.ERC721Proxy,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
const contractInstance = new ERC721ProxyContract(
|
const contractInstance = new ERC721ProxyContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
this.address,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import { ERC721TokenContract, ERC721TokenEventArgs, ERC721TokenEvents } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { ERC721Token } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
||||||
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
||||||
import {
|
import {
|
||||||
@ -20,7 +21,6 @@ import { constants } from '../utils/constants';
|
|||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
|
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
|
||||||
import { ERC721TokenContract, ERC721TokenEventArgs, ERC721TokenEvents } from './generated/erc721_token';
|
|
||||||
|
|
||||||
const removeUndefinedProperties = _.pickBy;
|
const removeUndefinedProperties = _.pickBy;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ const removeUndefinedProperties = _.pickBy;
|
|||||||
* to the 0x ERC721 Proxy smart contract.
|
* to the 0x ERC721 Proxy smart contract.
|
||||||
*/
|
*/
|
||||||
export class ERC721TokenWrapper extends ContractWrapper {
|
export class ERC721TokenWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.ERC721Token.compilerOutput.abi;
|
public abi: ContractAbi = ERC721Token.compilerOutput.abi;
|
||||||
private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
private _tokenContractsByAddress: { [address: string]: ERC721TokenContract };
|
||||||
private _erc721ProxyWrapper: ERC721ProxyWrapper;
|
private _erc721ProxyWrapper: ERC721ProxyWrapper;
|
||||||
/**
|
/**
|
||||||
@ -150,7 +150,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts: MethodOpts = {},
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.address;
|
||||||
const isProxyApprovedForAll = await this.isApprovedForAllAsync(
|
const isProxyApprovedForAll = await this.isApprovedForAllAsync(
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
ownerAddress,
|
ownerAddress,
|
||||||
@ -199,7 +199,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
tokenId: BigNumber,
|
tokenId: BigNumber,
|
||||||
methodOpts: MethodOpts = {},
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.address;
|
||||||
const approvedAddress = await this.getApprovedIfExistsAsync(tokenAddress, tokenId, methodOpts);
|
const approvedAddress = await this.getApprovedIfExistsAsync(tokenAddress, tokenId, methodOpts);
|
||||||
const isProxyApproved = approvedAddress === proxyAddress;
|
const isProxyApproved = approvedAddress === proxyAddress;
|
||||||
return isProxyApproved;
|
return isProxyApproved;
|
||||||
@ -260,7 +260,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
isApproved: boolean,
|
isApproved: boolean,
|
||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.address;
|
||||||
const txHash = await this.setApprovalForAllAsync(tokenAddress, ownerAddress, proxyAddress, isApproved, txOpts);
|
const txHash = await this.setApprovalForAllAsync(tokenAddress, ownerAddress, proxyAddress, isApproved, txOpts);
|
||||||
return txHash;
|
return txHash;
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
tokenId: BigNumber,
|
tokenId: BigNumber,
|
||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.address;
|
||||||
const txHash = await this.setApprovalAsync(tokenAddress, proxyAddress, tokenId, txOpts);
|
const txHash = await this.setApprovalAsync(tokenAddress, proxyAddress, tokenId, txOpts);
|
||||||
return txHash;
|
return txHash;
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ERC721Token.compilerOutput.abi,
|
ERC721Token.compilerOutput.abi,
|
||||||
callback,
|
callback,
|
||||||
isVerbose,
|
isVerbose,
|
||||||
);
|
);
|
||||||
@ -445,30 +445,19 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.ERC721Token.compilerOutput.abi,
|
ERC721Token.compilerOutput.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstances(): void {
|
|
||||||
this.unsubscribeAll();
|
|
||||||
this._tokenContractsByAddress = {};
|
|
||||||
}
|
|
||||||
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC721TokenContract> {
|
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC721TokenContract> {
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
||||||
if (!_.isUndefined(tokenContract)) {
|
if (!_.isUndefined(tokenContract)) {
|
||||||
return tokenContract;
|
return tokenContract;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.ERC721Token,
|
|
||||||
normalizedTokenAddress,
|
|
||||||
);
|
|
||||||
const contractInstance = new ERC721TokenContract(
|
const contractInstance = new ERC721TokenContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
normalizedTokenAddress,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
import { WETH9Contract, WETH9EventArgs, WETH9Events } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { WETH9 } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { BlockRange, ContractWrappersError, EventCallback, IndexedFilterValues, TransactionOpts } from '../types';
|
import { BlockRange, ContractWrappersError, EventCallback, IndexedFilterValues, TransactionOpts } from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC20TokenWrapper } from './erc20_token_wrapper';
|
import { ERC20TokenWrapper } from './erc20_token_wrapper';
|
||||||
import { WETH9Contract, WETH9EventArgs, WETH9Events } from './generated/weth9';
|
|
||||||
|
|
||||||
const removeUndefinedProperties = _.pickBy;
|
const removeUndefinedProperties = _.pickBy;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ const removeUndefinedProperties = _.pickBy;
|
|||||||
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
|
* The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back.
|
||||||
*/
|
*/
|
||||||
export class EtherTokenWrapper extends ContractWrapper {
|
export class EtherTokenWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.EtherToken.compilerOutput.abi;
|
public abi: ContractAbi = WETH9.compilerOutput.abi;
|
||||||
private _etherTokenContractsByAddress: {
|
private _etherTokenContractsByAddress: {
|
||||||
[address: string]: WETH9Contract;
|
[address: string]: WETH9Contract;
|
||||||
} = {};
|
} = {};
|
||||||
@ -142,7 +142,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.EtherToken.compilerOutput.abi,
|
WETH9.compilerOutput.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
normalizedEtherTokenAddress,
|
normalizedEtherTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.EtherToken.compilerOutput.abi,
|
WETH9.compilerOutput.abi,
|
||||||
callback,
|
callback,
|
||||||
isVerbose,
|
isVerbose,
|
||||||
);
|
);
|
||||||
@ -192,36 +192,14 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
public unsubscribeAll(): void {
|
public unsubscribeAll(): void {
|
||||||
super._unsubscribeAll();
|
super._unsubscribeAll();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Retrieves the Ethereum address of the EtherToken contract deployed on the network
|
|
||||||
* that the user-passed web3 provider is connected to. If it's not Kovan, Ropsten, Rinkeby, Mainnet or TestRPC
|
|
||||||
* (networkId: 50), it will return undefined (e.g a private network).
|
|
||||||
* @returns The Ethereum address of the EtherToken contract or undefined.
|
|
||||||
*/
|
|
||||||
public getContractAddressIfExists(): string | undefined {
|
|
||||||
const networkSpecificArtifact = artifacts.EtherToken.networks[this._networkId];
|
|
||||||
const contractAddressIfExists = _.isUndefined(networkSpecificArtifact)
|
|
||||||
? undefined
|
|
||||||
: networkSpecificArtifact.address;
|
|
||||||
return contractAddressIfExists;
|
|
||||||
}
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstance(): void {
|
|
||||||
this.unsubscribeAll();
|
|
||||||
this._etherTokenContractsByAddress = {};
|
|
||||||
}
|
|
||||||
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<WETH9Contract> {
|
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<WETH9Contract> {
|
||||||
let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
|
let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
|
||||||
if (!_.isUndefined(etherTokenContract)) {
|
if (!_.isUndefined(etherTokenContract)) {
|
||||||
return etherTokenContract;
|
return etherTokenContract;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.EtherToken,
|
|
||||||
etherTokenAddress,
|
|
||||||
);
|
|
||||||
const contractInstance = new WETH9Contract(
|
const contractInstance = new WETH9Contract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
etherTokenAddress,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { Exchange } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import {
|
import {
|
||||||
assetDataUtils,
|
assetDataUtils,
|
||||||
@ -11,7 +13,6 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import { BlockParamLiteral, ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
import { BlockParamLiteral, ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { AssetBalanceAndProxyAllowanceFetcher } from '../fetchers/asset_balance_and_proxy_allowance_fetcher';
|
import { AssetBalanceAndProxyAllowanceFetcher } from '../fetchers/asset_balance_and_proxy_allowance_fetcher';
|
||||||
import { OrderFilledCancelledFetcher } from '../fetchers/order_filled_cancelled_fetcher';
|
import { OrderFilledCancelledFetcher } from '../fetchers/order_filled_cancelled_fetcher';
|
||||||
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
||||||
@ -24,54 +25,58 @@ import {
|
|||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
MethodOpts,
|
MethodOpts,
|
||||||
OrderInfo,
|
OrderInfo,
|
||||||
OrderStatus,
|
|
||||||
OrderTransactionOpts,
|
OrderTransactionOpts,
|
||||||
ValidateOrderFillableOpts,
|
ValidateOrderFillableOpts,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
import { decorators } from '../utils/decorators';
|
import { decorators } from '../utils/decorators';
|
||||||
import { TransactionEncoder } from '../utils/transaction_encoder';
|
import { TransactionEncoder } from '../utils/transaction_encoder';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ERC20TokenWrapper } from './erc20_token_wrapper';
|
import { ERC20TokenWrapper } from './erc20_token_wrapper';
|
||||||
import { ERC721TokenWrapper } from './erc721_token_wrapper';
|
import { ERC721TokenWrapper } from './erc721_token_wrapper';
|
||||||
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to calling methods, sending transactions and subscribing to
|
* This class includes all the functionality related to calling methods, sending transactions and subscribing to
|
||||||
* events of the 0x V2 Exchange smart contract.
|
* events of the 0x V2 Exchange smart contract.
|
||||||
*/
|
*/
|
||||||
export class ExchangeWrapper extends ContractWrapper {
|
export class ExchangeWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.Exchange.compilerOutput.abi;
|
public abi: ContractAbi = Exchange.compilerOutput.abi;
|
||||||
|
public address: string;
|
||||||
|
public zrxTokenAddress: string;
|
||||||
private _exchangeContractIfExists?: ExchangeContract;
|
private _exchangeContractIfExists?: ExchangeContract;
|
||||||
private _erc721TokenWrapper: ERC721TokenWrapper;
|
private _erc721TokenWrapper: ERC721TokenWrapper;
|
||||||
private _erc20TokenWrapper: ERC20TokenWrapper;
|
private _erc20TokenWrapper: ERC20TokenWrapper;
|
||||||
private _contractAddressIfExists?: string;
|
|
||||||
private _zrxContractAddressIfExists?: string;
|
|
||||||
/**
|
/**
|
||||||
* Instantiate ExchangeWrapper
|
* Instantiate ExchangeWrapper
|
||||||
* @param web3Wrapper Web3Wrapper instance to use
|
* @param web3Wrapper Web3Wrapper instance to use.
|
||||||
* @param networkId Desired networkId
|
* @param networkId Desired networkId.
|
||||||
* @param contractAddressIfExists The exchange contract address to use. This is usually pulled from
|
* @param erc20TokenWrapper ERC20TokenWrapper instance to use.
|
||||||
* the artifacts but needs to be specified when using with your own custom testnet.
|
* @param erc721TokenWrapper ERC721TokenWrapper instance to use.
|
||||||
* @param zrxContractAddressIfExists The ZRXToken contract address to use. This is usually pulled from
|
* @param address The address of the Exchange contract. If undefined, will
|
||||||
* the artifacts but needs to be specified when using with your own custom testnet.
|
* default to the known address corresponding to the networkId.
|
||||||
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions
|
* @param zrxTokenAddress The address of the ZRXToken contract. If
|
||||||
|
* undefined, will default to the known address corresponding to the
|
||||||
|
* networkId.
|
||||||
|
* @param blockPollingIntervalMs The block polling interval to use for active subscriptions.
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
erc20TokenWrapper: ERC20TokenWrapper,
|
erc20TokenWrapper: ERC20TokenWrapper,
|
||||||
erc721TokenWrapper: ERC721TokenWrapper,
|
erc721TokenWrapper: ERC721TokenWrapper,
|
||||||
contractAddressIfExists?: string,
|
address?: string,
|
||||||
zrxContractAddressIfExists?: string,
|
zrxTokenAddress?: string,
|
||||||
blockPollingIntervalMs?: number,
|
blockPollingIntervalMs?: number,
|
||||||
) {
|
) {
|
||||||
super(web3Wrapper, networkId, blockPollingIntervalMs);
|
super(web3Wrapper, networkId, blockPollingIntervalMs);
|
||||||
this._erc20TokenWrapper = erc20TokenWrapper;
|
this._erc20TokenWrapper = erc20TokenWrapper;
|
||||||
this._erc721TokenWrapper = erc721TokenWrapper;
|
this._erc721TokenWrapper = erc721TokenWrapper;
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||||
this._zrxContractAddressIfExists = zrxContractAddressIfExists;
|
this.zrxTokenAddress = _.isUndefined(zrxTokenAddress)
|
||||||
|
? _getDefaultContractAddresses(networkId).zrxToken
|
||||||
|
: zrxTokenAddress;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve the address of an asset proxy by signature.
|
* Retrieve the address of an asset proxy by signature.
|
||||||
@ -1051,12 +1056,11 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
assert.isFunction('callback', callback);
|
assert.isFunction('callback', callback);
|
||||||
const exchangeContractAddress = this.getContractAddress();
|
|
||||||
const subscriptionToken = this._subscribe<ArgsType>(
|
const subscriptionToken = this._subscribe<ArgsType>(
|
||||||
exchangeContractAddress,
|
this.address,
|
||||||
eventName,
|
eventName,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.Exchange.compilerOutput.abi,
|
Exchange.compilerOutput.abi,
|
||||||
callback,
|
callback,
|
||||||
isVerbose,
|
isVerbose,
|
||||||
);
|
);
|
||||||
@ -1091,13 +1095,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
||||||
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
const exchangeContractAddress = this.getContractAddress();
|
|
||||||
const logs = await this._getLogsAsync<ArgsType>(
|
const logs = await this._getLogsAsync<ArgsType>(
|
||||||
exchangeContractAddress,
|
this.address,
|
||||||
eventName,
|
eventName,
|
||||||
blockRange,
|
blockRange,
|
||||||
indexFilterValues,
|
indexFilterValues,
|
||||||
artifacts.Exchange.compilerOutput.abi,
|
Exchange.compilerOutput.abi,
|
||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
@ -1159,30 +1162,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
this.getZRXAssetData(),
|
this.getZRXAssetData(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Retrieves the Ethereum address of the Exchange contract deployed on the network
|
|
||||||
* that the user-passed web3 provider is connected to.
|
|
||||||
* @returns The Ethereum address of the Exchange contract being used.
|
|
||||||
*/
|
|
||||||
public getContractAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.Exchange, this._contractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the ZRX token address used by the exchange contract.
|
|
||||||
* @return Address of ZRX token
|
|
||||||
*/
|
|
||||||
public getZRXTokenAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.ZRXToken, this._zrxContractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Returns the ZRX asset data used by the exchange contract.
|
* Returns the ZRX asset data used by the exchange contract.
|
||||||
* @return ZRX asset data
|
* @return ZRX asset data
|
||||||
*/
|
*/
|
||||||
public getZRXAssetData(): string {
|
public getZRXAssetData(): string {
|
||||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
const zrxAssetData = assetDataUtils.encodeERC20AssetData(this.zrxTokenAddress);
|
||||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
|
||||||
return zrxAssetData;
|
return zrxAssetData;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -1195,23 +1180,14 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
const encoder = new TransactionEncoder(exchangeInstance);
|
const encoder = new TransactionEncoder(exchangeInstance);
|
||||||
return encoder;
|
return encoder;
|
||||||
}
|
}
|
||||||
// tslint:disable:no-unused-variable
|
|
||||||
private _invalidateContractInstances(): void {
|
|
||||||
this.unsubscribeAll();
|
|
||||||
delete this._exchangeContractIfExists;
|
|
||||||
}
|
|
||||||
// tslint:enable:no-unused-variable
|
// tslint:enable:no-unused-variable
|
||||||
private async _getExchangeContractAsync(): Promise<ExchangeContract> {
|
private async _getExchangeContractAsync(): Promise<ExchangeContract> {
|
||||||
if (!_.isUndefined(this._exchangeContractIfExists)) {
|
if (!_.isUndefined(this._exchangeContractIfExists)) {
|
||||||
return this._exchangeContractIfExists;
|
return this._exchangeContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.Exchange,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
const contractInstance = new ExchangeContract(
|
const contractInstance = new ExchangeContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
this.address,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ForwarderContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { Forwarder } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { AssetProxyId, SignedOrder } from '@0xproject/types';
|
import { AssetProxyId, SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
@ -5,36 +7,56 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import { ContractAbi } from 'ethereum-types';
|
import { ContractAbi } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
|
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
|
||||||
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
||||||
import { OrderTransactionOpts } from '../types';
|
import { OrderTransactionOpts } from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
import { calldataOptimizationUtils } from '../utils/calldata_optimization_utils';
|
import { calldataOptimizationUtils } from '../utils/calldata_optimization_utils';
|
||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
import { decorators } from '../utils/decorators';
|
import { decorators } from '../utils/decorators';
|
||||||
import { utils } from '../utils/utils';
|
import { utils } from '../utils/utils';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { ForwarderContract } from './generated/forwarder';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes the functionality related to interacting with the Forwarder contract.
|
* This class includes the functionality related to interacting with the Forwarder contract.
|
||||||
*/
|
*/
|
||||||
export class ForwarderWrapper extends ContractWrapper {
|
export class ForwarderWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.Forwarder.compilerOutput.abi;
|
public abi: ContractAbi = Forwarder.compilerOutput.abi;
|
||||||
|
public address: string;
|
||||||
|
public zrxTokenAddress: string;
|
||||||
|
public etherTokenAddress: string;
|
||||||
private _forwarderContractIfExists?: ForwarderContract;
|
private _forwarderContractIfExists?: ForwarderContract;
|
||||||
private _contractAddressIfExists?: string;
|
|
||||||
private _zrxContractAddressIfExists?: string;
|
/**
|
||||||
|
* Instantiate ForwarderWrapper
|
||||||
|
* @param web3Wrapper Web3Wrapper instance to use.
|
||||||
|
* @param networkId Desired networkId.
|
||||||
|
* @param address The address of the Exchange contract. If undefined, will
|
||||||
|
* default to the known address corresponding to the networkId.
|
||||||
|
* @param zrxTokenAddress The address of the ZRXToken contract. If
|
||||||
|
* undefined, will default to the known address corresponding to the
|
||||||
|
* networkId.
|
||||||
|
* @param etherTokenAddress The address of a WETH (Ether token) contract. If
|
||||||
|
* undefined, will default to the known address corresponding to the
|
||||||
|
* networkId.
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
web3Wrapper: Web3Wrapper,
|
web3Wrapper: Web3Wrapper,
|
||||||
networkId: number,
|
networkId: number,
|
||||||
contractAddressIfExists?: string,
|
address?: string,
|
||||||
zrxContractAddressIfExists?: string,
|
zrxTokenAddress?: string,
|
||||||
|
etherTokenAddress?: string,
|
||||||
) {
|
) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
this._contractAddressIfExists = contractAddressIfExists;
|
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||||
this._zrxContractAddressIfExists = zrxContractAddressIfExists;
|
this.zrxTokenAddress = _.isUndefined(zrxTokenAddress)
|
||||||
|
? _getDefaultContractAddresses(networkId).zrxToken
|
||||||
|
: zrxTokenAddress;
|
||||||
|
this.etherTokenAddress = _.isUndefined(etherTokenAddress)
|
||||||
|
? _getDefaultContractAddresses(networkId).etherToken
|
||||||
|
: etherTokenAddress;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
|
* Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
|
||||||
@ -73,12 +95,8 @@ export class ForwarderWrapper extends ContractWrapper {
|
|||||||
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
|
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
|
||||||
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
||||||
// other assertions
|
// other assertions
|
||||||
assert.ordersCanBeUsedForForwarderContract(signedOrders, this.getEtherTokenAddress());
|
assert.ordersCanBeUsedForForwarderContract(signedOrders, this.etherTokenAddress);
|
||||||
assert.feeOrdersCanBeUsedForForwarderContract(
|
assert.feeOrdersCanBeUsedForForwarderContract(signedFeeOrders, this.zrxTokenAddress, this.etherTokenAddress);
|
||||||
signedFeeOrders,
|
|
||||||
this.getZRXTokenAddress(),
|
|
||||||
this.getEtherTokenAddress(),
|
|
||||||
);
|
|
||||||
// format feePercentage
|
// format feePercentage
|
||||||
const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
|
const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
|
||||||
// lowercase input addresses
|
// lowercase input addresses
|
||||||
@ -165,12 +183,8 @@ export class ForwarderWrapper extends ContractWrapper {
|
|||||||
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
|
assert.isETHAddressHex('feeRecipientAddress', feeRecipientAddress);
|
||||||
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
||||||
// other assertions
|
// other assertions
|
||||||
assert.ordersCanBeUsedForForwarderContract(signedOrders, this.getEtherTokenAddress());
|
assert.ordersCanBeUsedForForwarderContract(signedOrders, this.etherTokenAddress);
|
||||||
assert.feeOrdersCanBeUsedForForwarderContract(
|
assert.feeOrdersCanBeUsedForForwarderContract(signedFeeOrders, this.zrxTokenAddress, this.etherTokenAddress);
|
||||||
signedFeeOrders,
|
|
||||||
this.getZRXTokenAddress(),
|
|
||||||
this.getEtherTokenAddress(),
|
|
||||||
);
|
|
||||||
// format feePercentage
|
// format feePercentage
|
||||||
const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
|
const formattedFeePercentage = utils.numberPercentageToEtherTokenAmountPercentage(feePercentage);
|
||||||
// lowercase input addresses
|
// lowercase input addresses
|
||||||
@ -220,48 +234,13 @@ export class ForwarderWrapper extends ContractWrapper {
|
|||||||
);
|
);
|
||||||
return txHash;
|
return txHash;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Retrieves the Ethereum address of the Forwarder contract deployed on the network
|
|
||||||
* that the user-passed web3 provider is connected to.
|
|
||||||
* @returns The Ethereum address of the Forwarder contract being used.
|
|
||||||
*/
|
|
||||||
public getContractAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.Forwarder, this._contractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the ZRX token address used by the forwarder contract.
|
|
||||||
* @return Address of ZRX token
|
|
||||||
*/
|
|
||||||
public getZRXTokenAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.ZRXToken, this._zrxContractAddressIfExists);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the Ether token address used by the forwarder contract.
|
|
||||||
* @return Address of Ether token
|
|
||||||
*/
|
|
||||||
public getEtherTokenAddress(): string {
|
|
||||||
const contractAddress = this._getContractAddress(artifacts.EtherToken);
|
|
||||||
return contractAddress;
|
|
||||||
}
|
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstance(): void {
|
|
||||||
delete this._forwarderContractIfExists;
|
|
||||||
}
|
|
||||||
private async _getForwarderContractAsync(): Promise<ForwarderContract> {
|
private async _getForwarderContractAsync(): Promise<ForwarderContract> {
|
||||||
if (!_.isUndefined(this._forwarderContractIfExists)) {
|
if (!_.isUndefined(this._forwarderContractIfExists)) {
|
||||||
return this._forwarderContractIfExists;
|
return this._forwarderContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
|
||||||
artifacts.Forwarder,
|
|
||||||
this._contractAddressIfExists,
|
|
||||||
);
|
|
||||||
const contractInstance = new ForwarderContract(
|
const contractInstance = new ForwarderContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
this.address,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { OrderValidatorContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { OrderValidator } from '@0xproject/contract-artifacts';
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { SignedOrder } from '@0xproject/types';
|
import { SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
@ -5,26 +7,29 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|||||||
import { ContractAbi } from 'ethereum-types';
|
import { ContractAbi } from 'ethereum-types';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { artifacts } from '../artifacts';
|
|
||||||
import { BalanceAndAllowance, OrderAndTraderInfo, TraderInfo } from '../types';
|
import { BalanceAndAllowance, OrderAndTraderInfo, TraderInfo } from '../types';
|
||||||
import { assert } from '../utils/assert';
|
import { assert } from '../utils/assert';
|
||||||
|
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||||
|
|
||||||
import { ContractWrapper } from './contract_wrapper';
|
import { ContractWrapper } from './contract_wrapper';
|
||||||
import { OrderValidatorContract } from './generated/order_validator';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes the functionality related to interacting with the OrderValidator contract.
|
* This class includes the functionality related to interacting with the OrderValidator contract.
|
||||||
*/
|
*/
|
||||||
export class OrderValidatorWrapper extends ContractWrapper {
|
export class OrderValidatorWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.OrderValidator.compilerOutput.abi;
|
public abi: ContractAbi = OrderValidator.compilerOutput.abi;
|
||||||
|
public address: string;
|
||||||
private _orderValidatorContractIfExists?: OrderValidatorContract;
|
private _orderValidatorContractIfExists?: OrderValidatorContract;
|
||||||
/**
|
/**
|
||||||
* Instantiate OrderValidatorWrapper
|
* Instantiate OrderValidatorWrapper
|
||||||
* @param web3Wrapper Web3Wrapper instance to use
|
* @param web3Wrapper Web3Wrapper instance to use.
|
||||||
* @param networkId Desired networkId
|
* @param networkId Desired networkId.
|
||||||
|
* @param address The address of the OrderValidator contract. If undefined,
|
||||||
|
* will default to the known address corresponding to the networkId.
|
||||||
*/
|
*/
|
||||||
constructor(web3Wrapper: Web3Wrapper, networkId: number) {
|
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||||
super(web3Wrapper, networkId);
|
super(web3Wrapper, networkId);
|
||||||
|
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get an object conforming to OrderAndTraderInfo containing on-chain information of the provided order and address
|
* Get an object conforming to OrderAndTraderInfo containing on-chain information of the provided order and address
|
||||||
@ -164,20 +169,13 @@ export class OrderValidatorWrapper extends ContractWrapper {
|
|||||||
const result = await OrderValidatorContractInstance.getERC721TokenOwner.callAsync(tokenAddress, tokenId);
|
const result = await OrderValidatorContractInstance.getERC721TokenOwner.callAsync(tokenAddress, tokenId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
|
|
||||||
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
private _invalidateContractInstance(): void {
|
|
||||||
delete this._orderValidatorContractIfExists;
|
|
||||||
}
|
|
||||||
private async _getOrderValidatorContractAsync(): Promise<OrderValidatorContract> {
|
private async _getOrderValidatorContractAsync(): Promise<OrderValidatorContract> {
|
||||||
if (!_.isUndefined(this._orderValidatorContractIfExists)) {
|
if (!_.isUndefined(this._orderValidatorContractIfExists)) {
|
||||||
return this._orderValidatorContractIfExists;
|
return this._orderValidatorContractIfExists;
|
||||||
}
|
}
|
||||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(artifacts.OrderValidator);
|
|
||||||
const contractInstance = new OrderValidatorContract(
|
const contractInstance = new OrderValidatorContract(
|
||||||
abi,
|
this.abi,
|
||||||
address,
|
this.address,
|
||||||
this._web3Wrapper.getProvider(),
|
this._web3Wrapper.getProvider(),
|
||||||
this._web3Wrapper.getContractDefaults(),
|
this._web3Wrapper.getContractDefaults(),
|
||||||
);
|
);
|
||||||
|
6
packages/contract-wrappers/src/globals.d.ts
vendored
6
packages/contract-wrappers/src/globals.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
declare module '*.json' {
|
|
||||||
const json: any;
|
|
||||||
/* tslint:disable */
|
|
||||||
export default json;
|
|
||||||
/* tslint:enable */
|
|
||||||
}
|
|
@ -1,3 +1,30 @@
|
|||||||
|
export { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
|
|
||||||
|
export {
|
||||||
|
WETH9Events,
|
||||||
|
WETH9WithdrawalEventArgs,
|
||||||
|
WETH9ApprovalEventArgs,
|
||||||
|
WETH9EventArgs,
|
||||||
|
WETH9DepositEventArgs,
|
||||||
|
WETH9TransferEventArgs,
|
||||||
|
ERC20TokenTransferEventArgs,
|
||||||
|
ERC20TokenApprovalEventArgs,
|
||||||
|
ERC20TokenEvents,
|
||||||
|
ERC20TokenEventArgs,
|
||||||
|
ERC721TokenApprovalEventArgs,
|
||||||
|
ERC721TokenApprovalForAllEventArgs,
|
||||||
|
ERC721TokenTransferEventArgs,
|
||||||
|
ERC721TokenEvents,
|
||||||
|
ERC721TokenEventArgs,
|
||||||
|
ExchangeCancelUpToEventArgs,
|
||||||
|
ExchangeAssetProxyRegisteredEventArgs,
|
||||||
|
ExchangeSignatureValidatorApprovalEventArgs,
|
||||||
|
ExchangeFillEventArgs,
|
||||||
|
ExchangeCancelEventArgs,
|
||||||
|
ExchangeEventArgs,
|
||||||
|
ExchangeEvents,
|
||||||
|
} from '@0xproject/abi-gen-wrappers';
|
||||||
|
|
||||||
export { ContractWrappers } from './contract_wrappers';
|
export { ContractWrappers } from './contract_wrappers';
|
||||||
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
||||||
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
|
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
|
||||||
@ -54,40 +81,6 @@ export {
|
|||||||
StateMutability,
|
StateMutability,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
|
|
||||||
export {
|
|
||||||
WETH9Events,
|
|
||||||
WETH9WithdrawalEventArgs,
|
|
||||||
WETH9ApprovalEventArgs,
|
|
||||||
WETH9EventArgs,
|
|
||||||
WETH9DepositEventArgs,
|
|
||||||
WETH9TransferEventArgs,
|
|
||||||
} from './contract_wrappers/generated/weth9';
|
|
||||||
|
|
||||||
export {
|
|
||||||
ERC20TokenTransferEventArgs,
|
|
||||||
ERC20TokenApprovalEventArgs,
|
|
||||||
ERC20TokenEvents,
|
|
||||||
ERC20TokenEventArgs,
|
|
||||||
} from './contract_wrappers/generated/erc20_token';
|
|
||||||
|
|
||||||
export {
|
|
||||||
ERC721TokenApprovalEventArgs,
|
|
||||||
ERC721TokenApprovalForAllEventArgs,
|
|
||||||
ERC721TokenTransferEventArgs,
|
|
||||||
ERC721TokenEvents,
|
|
||||||
ERC721TokenEventArgs,
|
|
||||||
} from './contract_wrappers/generated/erc721_token';
|
|
||||||
|
|
||||||
export {
|
|
||||||
ExchangeCancelUpToEventArgs,
|
|
||||||
ExchangeAssetProxyRegisteredEventArgs,
|
|
||||||
ExchangeSignatureValidatorApprovalEventArgs,
|
|
||||||
ExchangeFillEventArgs,
|
|
||||||
ExchangeCancelEventArgs,
|
|
||||||
ExchangeEventArgs,
|
|
||||||
ExchangeEvents,
|
|
||||||
} from './contract_wrappers/generated/exchange';
|
|
||||||
|
|
||||||
export { AbstractBalanceAndProxyAllowanceFetcher, AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
|
export { AbstractBalanceAndProxyAllowanceFetcher, AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
|
||||||
|
|
||||||
export { AssetBalanceAndProxyAllowanceFetcher } from './fetchers/asset_balance_and_proxy_allowance_fetcher';
|
export { AssetBalanceAndProxyAllowanceFetcher } from './fetchers/asset_balance_and_proxy_allowance_fetcher';
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
export const ContractWrappersConfigSchema = {
|
export const ContractWrappersConfigSchema = {
|
||||||
id: '/ContractWrappersConfig',
|
id: '/ContractWrappersConfig',
|
||||||
oneOf: [{ $ref: '/ZeroExContractPrivateNetworkConfig' }, { $ref: '/ZeroExContractPublicNetworkConfig' }],
|
properties: {
|
||||||
|
networkId: {
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
gasPrice: { $ref: '/numberSchema' },
|
||||||
|
contractAddresses: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
erc20Proxy: { $ref: '/addressSchema' },
|
||||||
|
erc721Proxy: { $ref: '/addressSchema' },
|
||||||
|
zrxToken: { $ref: '/addressSchema' },
|
||||||
|
etherToken: { $ref: '/addressSchema' },
|
||||||
|
exchange: { $ref: '/addressSchema' },
|
||||||
|
assetProxyOwner: { $ref: '/addressSchema' },
|
||||||
|
forwarder: { $ref: '/addressSchema' },
|
||||||
|
orderValidator: { $ref: '/addressSchema' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
blockPollingIntervalMs: { type: 'number' },
|
||||||
|
},
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
required: ['networkId'],
|
||||||
};
|
};
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
export const contractWrappersPrivateNetworkConfigSchema = {
|
|
||||||
id: '/ZeroExContractPrivateNetworkConfig',
|
|
||||||
properties: {
|
|
||||||
networkId: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 1,
|
|
||||||
},
|
|
||||||
gasPrice: { $ref: '/numberSchema' },
|
|
||||||
zrxContractAddress: { $ref: '/addressSchema' },
|
|
||||||
exchangeContractAddress: { $ref: '/addressSchema' },
|
|
||||||
erc20ProxyContractAddress: { $ref: '/addressSchema' },
|
|
||||||
erc721ProxyContractAddress: { $ref: '/addressSchema' },
|
|
||||||
blockPollingIntervalMs: { type: 'number' },
|
|
||||||
orderWatcherConfig: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
pollingIntervalMs: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
numConfirmations: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
type: 'object',
|
|
||||||
required: [
|
|
||||||
'networkId',
|
|
||||||
'zrxContractAddress',
|
|
||||||
'exchangeContractAddress',
|
|
||||||
'erc20ProxyContractAddress',
|
|
||||||
'erc721ProxyContractAddress',
|
|
||||||
],
|
|
||||||
};
|
|
@ -1,44 +0,0 @@
|
|||||||
const networkNameToId: { [networkName: string]: number } = {
|
|
||||||
mainnet: 1,
|
|
||||||
ropsten: 3,
|
|
||||||
rinkeby: 4,
|
|
||||||
kovan: 42,
|
|
||||||
ganache: 50,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const contractWrappersPublicNetworkConfigSchema = {
|
|
||||||
id: '/ZeroExContractPublicNetworkConfig',
|
|
||||||
properties: {
|
|
||||||
networkId: {
|
|
||||||
type: 'number',
|
|
||||||
enum: [
|
|
||||||
networkNameToId.mainnet,
|
|
||||||
networkNameToId.kovan,
|
|
||||||
networkNameToId.ropsten,
|
|
||||||
networkNameToId.rinkeby,
|
|
||||||
networkNameToId.ganache,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
gasPrice: { $ref: '/numberSchema' },
|
|
||||||
zrxContractAddress: { $ref: '/addressSchema' },
|
|
||||||
exchangeContractAddress: { $ref: '/addressSchema' },
|
|
||||||
erc20ProxyContractAddress: { $ref: '/addressSchema' },
|
|
||||||
erc721ProxyContractAddress: { $ref: '/addressSchema' },
|
|
||||||
blockPollingIntervalMs: { type: 'number' },
|
|
||||||
orderWatcherConfig: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
pollingIntervalMs: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
numConfirmations: {
|
|
||||||
type: 'number',
|
|
||||||
minimum: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
type: 'object',
|
|
||||||
required: ['networkId'],
|
|
||||||
};
|
|
@ -1,25 +1,24 @@
|
|||||||
|
import {
|
||||||
|
ERC20TokenEventArgs,
|
||||||
|
ERC20TokenEvents,
|
||||||
|
ERC721TokenEventArgs,
|
||||||
|
ERC721TokenEvents,
|
||||||
|
ExchangeEventArgs,
|
||||||
|
ExchangeEvents,
|
||||||
|
WETH9EventArgs,
|
||||||
|
WETH9Events,
|
||||||
|
} from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
|
import { OrderState, SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
import { OrderState, SignedOrder } from '@0xproject/types';
|
|
||||||
import { BlockParam, ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
|
import { BlockParam, ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
|
||||||
|
|
||||||
import { ERC20TokenEventArgs, ERC20TokenEvents } from './contract_wrappers/generated/erc20_token';
|
|
||||||
import { ERC721TokenEventArgs, ERC721TokenEvents } from './contract_wrappers/generated/erc721_token';
|
|
||||||
import { ExchangeEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
|
|
||||||
import { WETH9EventArgs, WETH9Events } from './contract_wrappers/generated/weth9';
|
|
||||||
|
|
||||||
export enum ExchangeWrapperError {
|
export enum ExchangeWrapperError {
|
||||||
AssetDataMismatch = 'ASSET_DATA_MISMATCH',
|
AssetDataMismatch = 'ASSET_DATA_MISMATCH',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ContractWrappersError {
|
export enum ContractWrappersError {
|
||||||
ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
EtherTokenContractDoesNotExist = 'ETHER_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ERC20ProxyContractDoesNotExist = 'ERC20_PROXY_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ERC721ProxyContractDoesNotExist = 'ERC721_PROXY_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ERC20TokenContractDoesNotExist = 'ERC20_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ERC721TokenContractDoesNotExist = 'ERC721_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
|
||||||
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
|
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
|
||||||
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
|
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
|
||||||
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
|
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
|
||||||
@ -105,22 +104,13 @@ export type SyncMethod = (...args: any[]) => any;
|
|||||||
/**
|
/**
|
||||||
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
||||||
* gasPrice: Gas price to use with every transaction
|
* gasPrice: Gas price to use with every transaction
|
||||||
* exchangeContractAddress: The address of an exchange contract to use
|
* contractAddresses: The address of all contracts to use. Defaults to the known addresses based on networkId.
|
||||||
* zrxContractAddress: The address of the ZRX contract to use
|
|
||||||
* erc20ProxyContractAddress: The address of the erc20 token transfer proxy contract to use
|
|
||||||
* erc721ProxyContractAddress: The address of the erc721 token transfer proxy contract to use
|
|
||||||
* forwarderContractAddress: The address of the forwarder contract to use
|
|
||||||
* orderWatcherConfig: All the configs related to the orderWatcher
|
|
||||||
* blockPollingIntervalMs: The interval to use for block polling in event watching methods (defaults to 1000)
|
* blockPollingIntervalMs: The interval to use for block polling in event watching methods (defaults to 1000)
|
||||||
*/
|
*/
|
||||||
export interface ContractWrappersConfig {
|
export interface ContractWrappersConfig {
|
||||||
networkId: number;
|
networkId: number;
|
||||||
gasPrice?: BigNumber;
|
gasPrice?: BigNumber;
|
||||||
exchangeContractAddress?: string;
|
contractAddresses?: ContractAddresses;
|
||||||
zrxContractAddress?: string;
|
|
||||||
erc20ProxyContractAddress?: string;
|
|
||||||
erc721ProxyContractAddress?: string;
|
|
||||||
forwarderContractAddress?: string;
|
|
||||||
blockPollingIntervalMs?: number;
|
blockPollingIntervalMs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
packages/contract-wrappers/src/utils/contract_addresses.ts
Normal file
15
packages/contract-wrappers/src/utils/contract_addresses.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { ContractAddresses, getContractAddressesForNetworkOrThrow, NetworkId } from '@0xproject/contract-addresses';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default contract addresses for the given networkId or throws with
|
||||||
|
* a context-specific error message if the networkId is not recognized.
|
||||||
|
*/
|
||||||
|
export function _getDefaultContractAddresses(networkId: number): ContractAddresses {
|
||||||
|
if (!(networkId in NetworkId)) {
|
||||||
|
throw new Error(
|
||||||
|
`No default contract addresses found for the given network id (${networkId}). If you want to use ContractWrappers on this network, you must manually pass in the contract address(es) to the constructor.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return getContractAddressesForNetworkOrThrow(networkId);
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
|
import { ExchangeContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
|
||||||
import { schemas } from '@0xproject/json-schemas';
|
import { schemas } from '@0xproject/json-schemas';
|
||||||
import { eip712Utils } from '@0xproject/order-utils';
|
import { eip712Utils } from '@0xproject/order-utils';
|
||||||
import { Order, SignedOrder } from '@0xproject/types';
|
import { Order, SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber, signTypedDataUtils } from '@0xproject/utils';
|
import { BigNumber, signTypedDataUtils } from '@0xproject/utils';
|
||||||
import _ = require('lodash');
|
import _ = require('lodash');
|
||||||
|
|
||||||
import { ExchangeContract } from '../contract_wrappers/generated/exchange';
|
|
||||||
|
|
||||||
import { assert } from './assert';
|
import { assert } from './assert';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import { web3Factory } from '@0xproject/dev-utils';
|
|
||||||
|
|
||||||
import { ContractWrappers } from '../src';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
|
||||||
import { constants } from './utils/constants';
|
|
||||||
|
|
||||||
chaiSetup.configure();
|
|
||||||
|
|
||||||
// Those tests are slower cause they're talking to a remote node
|
|
||||||
const TIMEOUT = 10000;
|
|
||||||
|
|
||||||
// TODO: Re-enable those tests after final kovan and ropsten deployments are done.
|
|
||||||
describe.skip('Artifacts', () => {
|
|
||||||
describe('contracts are deployed on kovan', () => {
|
|
||||||
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
|
||||||
const provider = web3Factory.getRpcProvider({ rpcUrl: kovanRpcUrl });
|
|
||||||
const config = {
|
|
||||||
networkId: constants.KOVAN_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const contractWrappers = new ContractWrappers(provider, config);
|
|
||||||
it('erc20 proxy contract is deployed', async () => {
|
|
||||||
await (contractWrappers.erc20Proxy as any)._getTokenTransferProxyContractAsync();
|
|
||||||
}).timeout(TIMEOUT);
|
|
||||||
it('erc721 proxy contract is deployed', async () => {
|
|
||||||
await (contractWrappers.erc721Proxy as any)._getTokenTransferProxyContractAsync();
|
|
||||||
}).timeout(TIMEOUT);
|
|
||||||
});
|
|
||||||
describe('contracts are deployed on ropsten', () => {
|
|
||||||
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
|
|
||||||
const provider = web3Factory.getRpcProvider({ rpcUrl: ropstenRpcUrl });
|
|
||||||
const config = {
|
|
||||||
networkId: constants.ROPSTEN_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const contractWrappers = new ContractWrappers(provider, config);
|
|
||||||
it('erc20 proxy contract is deployed', async () => {
|
|
||||||
await (contractWrappers.erc20Proxy as any)._getTokenTransferProxyContractAsync();
|
|
||||||
}).timeout(TIMEOUT);
|
|
||||||
it('erc721 proxy contract is deployed', async () => {
|
|
||||||
await (contractWrappers.erc721Proxy as any)._getTokenTransferProxyContractAsync();
|
|
||||||
}).timeout(TIMEOUT);
|
|
||||||
});
|
|
||||||
});
|
|
@ -4,6 +4,7 @@ import { ContractWrappers } from '../src';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { provider } from './utils/web3_wrapper';
|
import { provider } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@ -11,10 +12,13 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
describe('ERC20ProxyWrapper', () => {
|
describe('ERC20ProxyWrapper', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
});
|
});
|
||||||
describe('#isAuthorizedAsync', () => {
|
describe('#isAuthorizedAsync', () => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
||||||
import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
|
import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
|
||||||
import { DoneCallback } from '@0xproject/types';
|
import { DoneCallback } from '@0xproject/types';
|
||||||
@ -10,16 +11,17 @@ import {
|
|||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
BlockRange,
|
BlockRange,
|
||||||
ContractWrappers,
|
ContractWrappers,
|
||||||
|
ContractWrappersConfig,
|
||||||
ContractWrappersError,
|
ContractWrappersError,
|
||||||
|
DecodedLogEvent,
|
||||||
ERC20TokenApprovalEventArgs,
|
ERC20TokenApprovalEventArgs,
|
||||||
ERC20TokenEvents,
|
ERC20TokenEvents,
|
||||||
ERC20TokenTransferEventArgs,
|
ERC20TokenTransferEventArgs,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
import { DecodedLogEvent } from '../src/types';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -29,14 +31,20 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|||||||
|
|
||||||
describe('ERC20Wrapper', () => {
|
describe('ERC20Wrapper', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
|
let contractAddresses: ContractAddresses;
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let tokens: string[];
|
let tokens: string[];
|
||||||
let coinbase: string;
|
let coinbase: string;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
const config = {
|
let config: ContractWrappersConfig;
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
contractAddresses = await migrateOnceAsync();
|
||||||
|
config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
tokens = tokenUtils.getDummyERC20TokenAddresses();
|
tokens = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
@ -72,19 +80,6 @@ describe('ERC20Wrapper', () => {
|
|||||||
contractWrappers.erc20Token.transferAsync(tokenAddress, fromAddress, toAddress, transferAmount),
|
contractWrappers.erc20Token.transferAsync(tokenAddress, fromAddress, toAddress, transferAmount),
|
||||||
).to.be.rejectedWith(ContractWrappersError.InsufficientBalanceForTransfer);
|
).to.be.rejectedWith(ContractWrappersError.InsufficientBalanceForTransfer);
|
||||||
});
|
});
|
||||||
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
|
|
||||||
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
|
|
||||||
const fromAddress = coinbase;
|
|
||||||
const toAddress = coinbase;
|
|
||||||
return expect(
|
|
||||||
contractWrappers.erc20Token.transferAsync(
|
|
||||||
nonExistentTokenAddress,
|
|
||||||
fromAddress,
|
|
||||||
toAddress,
|
|
||||||
transferAmount,
|
|
||||||
),
|
|
||||||
).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('#transferFromAsync', () => {
|
describe('#transferFromAsync', () => {
|
||||||
let tokenAddress: string;
|
let tokenAddress: string;
|
||||||
@ -189,19 +184,6 @@ describe('ERC20Wrapper', () => {
|
|||||||
const postBalance = await contractWrappers.erc20Token.getBalanceAsync(tokenAddress, toAddress);
|
const postBalance = await contractWrappers.erc20Token.getBalanceAsync(tokenAddress, toAddress);
|
||||||
return expect(postBalance).to.be.bignumber.equal(transferAmount);
|
return expect(postBalance).to.be.bignumber.equal(transferAmount);
|
||||||
});
|
});
|
||||||
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
|
|
||||||
const fromAddress = coinbase;
|
|
||||||
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
|
|
||||||
return expect(
|
|
||||||
contractWrappers.erc20Token.transferFromAsync(
|
|
||||||
nonExistentTokenAddress,
|
|
||||||
fromAddress,
|
|
||||||
toAddress,
|
|
||||||
senderAddress,
|
|
||||||
new BigNumber(42),
|
|
||||||
),
|
|
||||||
).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('#getBalanceAsync', () => {
|
describe('#getBalanceAsync', () => {
|
||||||
describe('With provider with accounts', () => {
|
describe('With provider with accounts', () => {
|
||||||
@ -212,13 +194,6 @@ describe('ERC20Wrapper', () => {
|
|||||||
const expectedBalance = new BigNumber('1000000000000000000000000000');
|
const expectedBalance = new BigNumber('1000000000000000000000000000');
|
||||||
return expect(balance).to.be.bignumber.equal(expectedBalance);
|
return expect(balance).to.be.bignumber.equal(expectedBalance);
|
||||||
});
|
});
|
||||||
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
|
|
||||||
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
|
|
||||||
const ownerAddress = coinbase;
|
|
||||||
return expect(
|
|
||||||
contractWrappers.erc20Token.getBalanceAsync(nonExistentTokenAddress, ownerAddress),
|
|
||||||
).to.be.rejectedWith(ContractWrappersError.ERC20TokenContractDoesNotExist);
|
|
||||||
});
|
|
||||||
it('should return a balance of 0 for a non-existent owner address', async () => {
|
it('should return a balance of 0 for a non-existent owner address', async () => {
|
||||||
const tokenAddress = tokens[0];
|
const tokenAddress = tokens[0];
|
||||||
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
|
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
|
||||||
@ -294,7 +269,7 @@ describe('ERC20Wrapper', () => {
|
|||||||
});
|
});
|
||||||
it('should reduce the gas cost for transfers including tokens with unlimited allowance support', async () => {
|
it('should reduce the gas cost for transfers including tokens with unlimited allowance support', async () => {
|
||||||
const transferAmount = new BigNumber(5);
|
const transferAmount = new BigNumber(5);
|
||||||
const zrxAddress = tokenUtils.getProtocolTokenAddress();
|
const zrxAddress = contractAddresses.zrxToken;
|
||||||
const [, userWithNormalAllowance, userWithUnlimitedAllowance] = userAddresses;
|
const [, userWithNormalAllowance, userWithUnlimitedAllowance] = userAddresses;
|
||||||
await contractWrappers.erc20Token.setAllowanceAsync(
|
await contractWrappers.erc20Token.setAllowanceAsync(
|
||||||
zrxAddress,
|
zrxAddress,
|
||||||
@ -525,7 +500,7 @@ describe('ERC20Wrapper', () => {
|
|||||||
);
|
);
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
it('Outstanding subscriptions are cancelled when contractWrappers.setProvider called', (done: DoneCallback) => {
|
it('Outstanding subscriptions are cancelled when contractWrappers.unsubscribeAll called', (done: DoneCallback) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
||||||
(_logEvent: DecodedLogEvent<ERC20TokenApprovalEventArgs>) => {
|
(_logEvent: DecodedLogEvent<ERC20TokenApprovalEventArgs>) => {
|
||||||
@ -539,7 +514,7 @@ describe('ERC20Wrapper', () => {
|
|||||||
callbackNeverToBeCalled,
|
callbackNeverToBeCalled,
|
||||||
);
|
);
|
||||||
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
||||||
contractWrappers.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
contractWrappers.unsubscribeAll();
|
||||||
contractWrappers.erc20Token.subscribe(
|
contractWrappers.erc20Token.subscribe(
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
ERC20TokenEvents.Transfer,
|
ERC20TokenEvents.Transfer,
|
||||||
@ -588,7 +563,7 @@ describe('ERC20Wrapper', () => {
|
|||||||
let txHash: string;
|
let txHash: string;
|
||||||
before(() => {
|
before(() => {
|
||||||
tokenAddress = tokens[0];
|
tokenAddress = tokens[0];
|
||||||
tokenTransferProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
|
tokenTransferProxyAddress = contractWrappers.erc20Proxy.address;
|
||||||
});
|
});
|
||||||
it('should get logs with decoded args emitted by Approval', async () => {
|
it('should get logs with decoded args emitted by Approval', async () => {
|
||||||
txHash = await contractWrappers.erc20Token.setUnlimitedProxyAllowanceAsync(tokenAddress, coinbase);
|
txHash = await contractWrappers.erc20Token.setUnlimitedProxyAllowanceAsync(tokenAddress, coinbase);
|
||||||
|
@ -4,6 +4,7 @@ import { ContractWrappers } from '../src';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { provider } from './utils/web3_wrapper';
|
import { provider } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@ -11,10 +12,13 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
describe('ERC721ProxyWrapper', () => {
|
describe('ERC721ProxyWrapper', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
});
|
});
|
||||||
describe('#isAuthorizedAsync', () => {
|
describe('#isAuthorizedAsync', () => {
|
||||||
|
@ -10,16 +10,18 @@ import {
|
|||||||
BlockParamLiteral,
|
BlockParamLiteral,
|
||||||
BlockRange,
|
BlockRange,
|
||||||
ContractWrappers,
|
ContractWrappers,
|
||||||
|
ContractWrappersConfig,
|
||||||
ContractWrappersError,
|
ContractWrappersError,
|
||||||
|
DecodedLogEvent,
|
||||||
ERC721TokenApprovalEventArgs,
|
ERC721TokenApprovalEventArgs,
|
||||||
ERC721TokenApprovalForAllEventArgs,
|
ERC721TokenApprovalForAllEventArgs,
|
||||||
ERC721TokenEvents,
|
ERC721TokenEvents,
|
||||||
ERC721TokenTransferEventArgs,
|
ERC721TokenTransferEventArgs,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
import { DecodedLogEvent } from '../src/types';
|
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -37,10 +39,15 @@ describe('ERC721Wrapper', () => {
|
|||||||
let operatorAddress: string;
|
let operatorAddress: string;
|
||||||
let approvedAddress: string;
|
let approvedAddress: string;
|
||||||
let receiverAddress: string;
|
let receiverAddress: string;
|
||||||
const config = {
|
let config: ContractWrappersConfig;
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
|
config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
tokens = tokenUtils.getDummyERC721TokenAddresses();
|
tokens = tokenUtils.getDummyERC721TokenAddresses();
|
||||||
@ -108,12 +115,6 @@ describe('ERC721Wrapper', () => {
|
|||||||
tokenCount = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, ownerAddress);
|
tokenCount = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, ownerAddress);
|
||||||
expect(tokenCount).to.be.bignumber.equal(1);
|
expect(tokenCount).to.be.bignumber.equal(1);
|
||||||
});
|
});
|
||||||
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
|
|
||||||
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
|
|
||||||
return expect(
|
|
||||||
contractWrappers.erc721Token.getTokenCountAsync(nonExistentTokenAddress, ownerAddress),
|
|
||||||
).to.be.rejectedWith(ContractWrappersError.ERC721TokenContractDoesNotExist);
|
|
||||||
});
|
|
||||||
it('should return a balance of 0 for a non-existent owner address', async () => {
|
it('should return a balance of 0 for a non-existent owner address', async () => {
|
||||||
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
|
const nonExistentOwner = '0x198c6ad858f213fb31b6fe809e25040e6b964593';
|
||||||
const balance = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, nonExistentOwner);
|
const balance = await contractWrappers.erc721Token.getTokenCountAsync(tokenAddress, nonExistentOwner);
|
||||||
@ -142,13 +143,6 @@ describe('ERC721Wrapper', () => {
|
|||||||
const tokenOwner = await contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, tokenId);
|
const tokenOwner = await contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, tokenId);
|
||||||
expect(tokenOwner).to.be.bignumber.equal(ownerAddress);
|
expect(tokenOwner).to.be.bignumber.equal(ownerAddress);
|
||||||
});
|
});
|
||||||
it('should throw a CONTRACT_DOES_NOT_EXIST error for a non-existent token contract', async () => {
|
|
||||||
const nonExistentTokenAddress = '0x9dd402f14d67e001d8efbe6583e51bf9706aa065';
|
|
||||||
const fakeTokenId = new BigNumber(42);
|
|
||||||
return expect(
|
|
||||||
contractWrappers.erc721Token.getOwnerOfAsync(nonExistentTokenAddress, fakeTokenId),
|
|
||||||
).to.be.rejectedWith(ContractWrappersError.ERC721TokenContractDoesNotExist);
|
|
||||||
});
|
|
||||||
it('should return undefined not 0 for a non-existent ERC721', async () => {
|
it('should return undefined not 0 for a non-existent ERC721', async () => {
|
||||||
const fakeTokenId = new BigNumber(42);
|
const fakeTokenId = new BigNumber(42);
|
||||||
return expect(contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, fakeTokenId)).to.be.rejectedWith(
|
return expect(contractWrappers.erc721Token.getOwnerOfAsync(tokenAddress, fakeTokenId)).to.be.rejectedWith(
|
||||||
@ -319,7 +313,7 @@ describe('ERC721Wrapper', () => {
|
|||||||
);
|
);
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
it('Outstanding subscriptions are cancelled when contractWrappers.setProvider called', (done: DoneCallback) => {
|
it('Outstanding subscriptions are cancelled when contractWrappers.unsubscribeAll called', (done: DoneCallback) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
||||||
(logEvent: DecodedLogEvent<ERC721TokenApprovalEventArgs>) => {
|
(logEvent: DecodedLogEvent<ERC721TokenApprovalEventArgs>) => {
|
||||||
@ -333,7 +327,7 @@ describe('ERC721Wrapper', () => {
|
|||||||
callbackNeverToBeCalled,
|
callbackNeverToBeCalled,
|
||||||
);
|
);
|
||||||
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
||||||
contractWrappers.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
contractWrappers.unsubscribeAll();
|
||||||
contractWrappers.erc721Token.subscribe(
|
contractWrappers.erc721Token.subscribe(
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
ERC721TokenEvents.Approval,
|
ERC721TokenEvents.Approval,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
||||||
import { DoneCallback } from '@0xproject/types';
|
import { DoneCallback } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
@ -16,12 +17,11 @@ import {
|
|||||||
WETH9TransferEventArgs,
|
WETH9TransferEventArgs,
|
||||||
WETH9WithdrawalEventArgs,
|
WETH9WithdrawalEventArgs,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
import { DecodedLogEvent } from '../src/types';
|
import { DecodedLogEvent } from '../src/types';
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@ -36,6 +36,7 @@ const MAX_REASONABLE_GAS_COST_IN_WEI = 62517;
|
|||||||
|
|
||||||
describe('EtherTokenWrapper', () => {
|
describe('EtherTokenWrapper', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
|
let contractAddresses: ContractAddresses;
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let addressWithETH: string;
|
let addressWithETH: string;
|
||||||
let wethContractAddress: string;
|
let wethContractAddress: string;
|
||||||
@ -43,19 +44,22 @@ describe('EtherTokenWrapper', () => {
|
|||||||
const decimalPlaces = 7;
|
const decimalPlaces = 7;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
const gasPrice = new BigNumber(1);
|
const gasPrice = new BigNumber(1);
|
||||||
const zeroExConfig = {
|
|
||||||
gasPrice,
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
const transferAmount = new BigNumber(42);
|
const transferAmount = new BigNumber(42);
|
||||||
const allowanceAmount = new BigNumber(42);
|
const allowanceAmount = new BigNumber(42);
|
||||||
const depositAmount = new BigNumber(42);
|
const depositAmount = new BigNumber(42);
|
||||||
const withdrawalAmount = new BigNumber(42);
|
const withdrawalAmount = new BigNumber(42);
|
||||||
before(async () => {
|
before(async () => {
|
||||||
contractWrappers = new ContractWrappers(provider, zeroExConfig);
|
contractAddresses = await migrateOnceAsync();
|
||||||
|
const config = {
|
||||||
|
gasPrice,
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
addressWithETH = userAddresses[0];
|
addressWithETH = userAddresses[0];
|
||||||
wethContractAddress = contractWrappers.etherToken.getContractAddressIfExists() as string;
|
wethContractAddress = contractAddresses.etherToken;
|
||||||
depositWeiAmount = Web3Wrapper.toWei(new BigNumber(5));
|
depositWeiAmount = Web3Wrapper.toWei(new BigNumber(5));
|
||||||
addressWithoutFunds = userAddresses[1];
|
addressWithoutFunds = userAddresses[1];
|
||||||
});
|
});
|
||||||
@ -67,7 +71,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
});
|
});
|
||||||
describe('#getContractAddressIfExists', async () => {
|
describe('#getContractAddressIfExists', async () => {
|
||||||
it('should return contract address if connected to a known network', () => {
|
it('should return contract address if connected to a known network', () => {
|
||||||
const contractAddressIfExists = contractWrappers.etherToken.getContractAddressIfExists();
|
const contractAddressIfExists = contractAddresses.etherToken;
|
||||||
expect(contractAddressIfExists).to.not.be.undefined();
|
expect(contractAddressIfExists).to.not.be.undefined();
|
||||||
});
|
});
|
||||||
it('should throw if connected to a private network and contract addresses are not specified', () => {
|
it('should throw if connected to a private network and contract addresses are not specified', () => {
|
||||||
@ -172,7 +176,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
const indexFilterValues = {};
|
const indexFilterValues = {};
|
||||||
let etherTokenAddress: string;
|
let etherTokenAddress: string;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
etherTokenAddress = tokenUtils.getWethTokenAddress();
|
etherTokenAddress = contractAddresses.etherToken;
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
contractWrappers.etherToken.unsubscribeAll();
|
contractWrappers.etherToken.unsubscribeAll();
|
||||||
@ -279,7 +283,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
await contractWrappers.etherToken.withdrawAsync(etherTokenAddress, withdrawalAmount, addressWithETH);
|
await contractWrappers.etherToken.withdrawAsync(etherTokenAddress, withdrawalAmount, addressWithETH);
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
it('should cancel outstanding subscriptions when ZeroEx.setProvider is called', (done: DoneCallback) => {
|
it('should cancel outstanding subscriptions when contractWrappers.unsubscribeAll is called', (done: DoneCallback) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
||||||
(_logEvent: DecodedLogEvent<WETH9ApprovalEventArgs>) => {
|
(_logEvent: DecodedLogEvent<WETH9ApprovalEventArgs>) => {
|
||||||
@ -293,7 +297,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
callbackNeverToBeCalled,
|
callbackNeverToBeCalled,
|
||||||
);
|
);
|
||||||
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
const callbackToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)();
|
||||||
contractWrappers.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
contractWrappers.unsubscribeAll();
|
||||||
await contractWrappers.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
|
await contractWrappers.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
|
||||||
contractWrappers.etherToken.subscribe(
|
contractWrappers.etherToken.subscribe(
|
||||||
etherTokenAddress,
|
etherTokenAddress,
|
||||||
@ -341,8 +345,8 @@ describe('EtherTokenWrapper', () => {
|
|||||||
let txHash: string;
|
let txHash: string;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
addressWithETH = userAddresses[0];
|
addressWithETH = userAddresses[0];
|
||||||
etherTokenAddress = tokenUtils.getWethTokenAddress();
|
etherTokenAddress = contractAddresses.etherToken;
|
||||||
erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
|
erc20ProxyAddress = contractWrappers.erc20Proxy.address;
|
||||||
// Start the block range after all migrations to avoid unexpected logs
|
// Start the block range after all migrations to avoid unexpected logs
|
||||||
const currentBlock: number = await web3Wrapper.getBlockNumberAsync();
|
const currentBlock: number = await web3Wrapper.getBlockNumberAsync();
|
||||||
const fromBlock = currentBlock + 1;
|
const fromBlock = currentBlock + 1;
|
||||||
|
@ -12,6 +12,7 @@ import { DecodedLogEvent } from '../src/types';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -27,37 +28,38 @@ describe('ExchangeWrapper', () => {
|
|||||||
let exchangeContractAddress: string;
|
let exchangeContractAddress: string;
|
||||||
let makerTokenAddress: string;
|
let makerTokenAddress: string;
|
||||||
let takerTokenAddress: string;
|
let takerTokenAddress: string;
|
||||||
let coinbase: string;
|
|
||||||
let makerAddress: string;
|
let makerAddress: string;
|
||||||
let anotherMakerAddress: string;
|
let anotherMakerAddress: string;
|
||||||
let takerAddress: string;
|
let takerAddress: string;
|
||||||
let makerAssetData: string;
|
let makerAssetData: string;
|
||||||
let takerAssetData: string;
|
let takerAssetData: string;
|
||||||
let feeRecipient: string;
|
|
||||||
let txHash: string;
|
let txHash: string;
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
const takerTokenFillAmount = new BigNumber(5);
|
const takerTokenFillAmount = new BigNumber(5);
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
let anotherSignedOrder: SignedOrder;
|
let anotherSignedOrder: SignedOrder;
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
blockPollingIntervalMs: 0,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
exchangeContractAddress = contractWrappers.exchange.address;
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
zrxTokenAddress = contractWrappers.exchange.zrxTokenAddress;
|
||||||
fillScenarios = new FillScenarios(
|
fillScenarios = new FillScenarios(
|
||||||
provider,
|
provider,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
zrxTokenAddress,
|
zrxTokenAddress,
|
||||||
exchangeContractAddress,
|
exchangeContractAddress,
|
||||||
contractWrappers.erc20Proxy.getContractAddress(),
|
contractWrappers.erc20Proxy.address,
|
||||||
contractWrappers.erc721Proxy.getContractAddress(),
|
contractWrappers.erc721Proxy.address,
|
||||||
);
|
);
|
||||||
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
[, makerAddress, takerAddress, , anotherMakerAddress] = userAddresses;
|
||||||
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
[makerAssetData, takerAssetData] = [
|
[makerAssetData, takerAssetData] = [
|
||||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||||
@ -329,11 +331,11 @@ describe('ExchangeWrapper', () => {
|
|||||||
it('should fill or kill a valid order', async () => {
|
it('should fill or kill a valid order', async () => {
|
||||||
const erc20ProxyId = await contractWrappers.erc20Proxy.getProxyIdAsync();
|
const erc20ProxyId = await contractWrappers.erc20Proxy.getProxyIdAsync();
|
||||||
const erc20ProxyAddressById = await contractWrappers.exchange.getAssetProxyBySignatureAsync(erc20ProxyId);
|
const erc20ProxyAddressById = await contractWrappers.exchange.getAssetProxyBySignatureAsync(erc20ProxyId);
|
||||||
const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
|
const erc20ProxyAddress = contractWrappers.erc20Proxy.address;
|
||||||
expect(erc20ProxyAddressById).to.be.equal(erc20ProxyAddress);
|
expect(erc20ProxyAddressById).to.be.equal(erc20ProxyAddress);
|
||||||
const erc721ProxyId = await contractWrappers.erc721Proxy.getProxyIdAsync();
|
const erc721ProxyId = await contractWrappers.erc721Proxy.getProxyIdAsync();
|
||||||
const erc721ProxyAddressById = await contractWrappers.exchange.getAssetProxyBySignatureAsync(erc721ProxyId);
|
const erc721ProxyAddressById = await contractWrappers.exchange.getAssetProxyBySignatureAsync(erc721ProxyId);
|
||||||
const erc721ProxyAddress = contractWrappers.erc721Proxy.getContractAddress();
|
const erc721ProxyAddress = contractWrappers.erc721Proxy.address;
|
||||||
expect(erc721ProxyAddressById).to.be.equal(erc721ProxyAddress);
|
expect(erc721ProxyAddressById).to.be.equal(erc721ProxyAddress);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -408,7 +410,7 @@ describe('ExchangeWrapper', () => {
|
|||||||
await contractWrappers.exchange.cancelOrderAsync(signedOrder);
|
await contractWrappers.exchange.cancelOrderAsync(signedOrder);
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
it('Outstanding subscriptions are cancelled when contractWrappers.setProvider called', (done: DoneCallback) => {
|
it('Outstanding subscriptions are cancelled when contractWrappers.unsubscribeAll called', (done: DoneCallback) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
const callbackNeverToBeCalled = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
||||||
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
|
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
|
||||||
@ -417,7 +419,7 @@ describe('ExchangeWrapper', () => {
|
|||||||
);
|
);
|
||||||
contractWrappers.exchange.subscribe(ExchangeEvents.Fill, indexFilterValues, callbackNeverToBeCalled);
|
contractWrappers.exchange.subscribe(ExchangeEvents.Fill, indexFilterValues, callbackNeverToBeCalled);
|
||||||
|
|
||||||
contractWrappers.setProvider(provider, constants.TESTRPC_NETWORK_ID);
|
contractWrappers.unsubscribeAll();
|
||||||
|
|
||||||
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)(
|
||||||
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
|
(logEvent: DecodedLogEvent<ExchangeFillEventArgs>) => {
|
||||||
@ -454,13 +456,6 @@ describe('ExchangeWrapper', () => {
|
|||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#getZRXTokenAddressAsync', () => {
|
|
||||||
it('gets the same token as is in token registry', () => {
|
|
||||||
const zrxAddressFromExchangeWrapper = contractWrappers.exchange.getZRXTokenAddress();
|
|
||||||
const zrxAddress = tokenUtils.getProtocolTokenAddress();
|
|
||||||
expect(zrxAddressFromExchangeWrapper).to.equal(zrxAddress);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('#getLogsAsync', () => {
|
describe('#getLogsAsync', () => {
|
||||||
const blockRange = {
|
const blockRange = {
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
|
@ -10,6 +10,7 @@ import { ContractWrappers, OrderStatus } from '../src';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -19,21 +20,14 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|||||||
|
|
||||||
// tslint:disable:custom-no-magic-numbers
|
// tslint:disable:custom-no-magic-numbers
|
||||||
describe('ForwarderWrapper', () => {
|
describe('ForwarderWrapper', () => {
|
||||||
const contractWrappersConfig = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
blockPollingIntervalMs: 0,
|
|
||||||
};
|
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
let fillScenarios: FillScenarios;
|
let fillScenarios: FillScenarios;
|
||||||
let exchangeContractAddress: string;
|
let exchangeContractAddress: string;
|
||||||
let zrxTokenAddress: string;
|
let zrxTokenAddress: string;
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let coinbase: string;
|
|
||||||
let makerAddress: string;
|
let makerAddress: string;
|
||||||
let takerAddress: string;
|
let takerAddress: string;
|
||||||
let feeRecipient: string;
|
|
||||||
let anotherMakerAddress: string;
|
|
||||||
let makerTokenAddress: string;
|
let makerTokenAddress: string;
|
||||||
let takerTokenAddress: string;
|
let takerTokenAddress: string;
|
||||||
let makerAssetData: string;
|
let makerAssetData: string;
|
||||||
@ -41,22 +35,28 @@ describe('ForwarderWrapper', () => {
|
|||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
let anotherSignedOrder: SignedOrder;
|
let anotherSignedOrder: SignedOrder;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
contractWrappers = new ContractWrappers(provider, contractWrappersConfig);
|
const config = {
|
||||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
|
exchangeContractAddress = contractWrappers.exchange.address;
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
zrxTokenAddress = contractWrappers.exchange.zrxTokenAddress;
|
||||||
fillScenarios = new FillScenarios(
|
fillScenarios = new FillScenarios(
|
||||||
provider,
|
provider,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
zrxTokenAddress,
|
zrxTokenAddress,
|
||||||
exchangeContractAddress,
|
exchangeContractAddress,
|
||||||
contractWrappers.erc20Proxy.getContractAddress(),
|
contractWrappers.erc20Proxy.address,
|
||||||
contractWrappers.erc721Proxy.getContractAddress(),
|
contractWrappers.erc721Proxy.address,
|
||||||
);
|
);
|
||||||
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
[, makerAddress, takerAddress] = userAddresses;
|
||||||
[makerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
[makerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
takerTokenAddress = tokenUtils.getWethTokenAddress();
|
takerTokenAddress = contractWrappers.forwarder.etherTokenAddress;
|
||||||
[makerAssetData, takerAssetData] = [
|
[makerAssetData, takerAssetData] = [
|
||||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||||
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
||||||
|
@ -1,17 +1,6 @@
|
|||||||
import { devConstants } from '@0xproject/dev-utils';
|
before('set up mocha', async function(): Promise<void> {
|
||||||
import { runV2MigrationsAsync } from '@0xproject/migrations';
|
|
||||||
|
|
||||||
import { provider } from './utils/web3_wrapper';
|
|
||||||
|
|
||||||
before('migrate contracts', async function(): Promise<void> {
|
|
||||||
// HACK: Since the migrations take longer then our global mocha timeout limit
|
// HACK: Since the migrations take longer then our global mocha timeout limit
|
||||||
// we manually increase it for this before hook.
|
// we manually increase it for this before hook.
|
||||||
const mochaTestTimeoutMs = 50000;
|
const mochaTestTimeoutMs = 50000;
|
||||||
this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
|
this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
|
||||||
const txDefaults = {
|
|
||||||
gas: devConstants.GAS_LIMIT,
|
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
|
||||||
};
|
|
||||||
const artifactsDir = `src/artifacts`;
|
|
||||||
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
|
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||||
import { FillScenarios } from '@0xproject/fill-scenarios';
|
import { FillScenarios } from '@0xproject/fill-scenarios';
|
||||||
import { assetDataUtils } from '@0xproject/order-utils';
|
import { assetDataUtils } from '@0xproject/order-utils';
|
||||||
@ -12,6 +13,7 @@ import { OrderInfo, TraderInfo } from '../src/types';
|
|||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -20,10 +22,6 @@ const expect = chai.expect;
|
|||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
|
|
||||||
describe('OrderValidator', () => {
|
describe('OrderValidator', () => {
|
||||||
const contractWrappersConfig = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
blockPollingIntervalMs: 0,
|
|
||||||
};
|
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
let fillScenarios: FillScenarios;
|
let fillScenarios: FillScenarios;
|
||||||
@ -42,24 +40,32 @@ describe('OrderValidator', () => {
|
|||||||
let takerAssetData: string;
|
let takerAssetData: string;
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
let anotherSignedOrder: SignedOrder;
|
let anotherSignedOrder: SignedOrder;
|
||||||
|
let contractAddresses: ContractAddresses;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
contractAddresses = await migrateOnceAsync();
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
contractWrappers = new ContractWrappers(provider, contractWrappersConfig);
|
const config = {
|
||||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
|
exchangeContractAddress = contractWrappers.exchange.address;
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
zrxTokenAddress = contractWrappers.exchange.zrxTokenAddress;
|
||||||
zrxTokenAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
zrxTokenAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
||||||
fillScenarios = new FillScenarios(
|
fillScenarios = new FillScenarios(
|
||||||
provider,
|
provider,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
zrxTokenAddress,
|
zrxTokenAddress,
|
||||||
exchangeContractAddress,
|
exchangeContractAddress,
|
||||||
contractWrappers.erc20Proxy.getContractAddress(),
|
contractWrappers.erc20Proxy.address,
|
||||||
contractWrappers.erc721Proxy.getContractAddress(),
|
contractWrappers.erc721Proxy.address,
|
||||||
);
|
);
|
||||||
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
||||||
[makerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
[makerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
takerTokenAddress = tokenUtils.getWethTokenAddress();
|
takerTokenAddress = contractAddresses.etherToken;
|
||||||
[makerAssetData, takerAssetData] = [
|
[makerAssetData, takerAssetData] = [
|
||||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||||
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||||
import { FillScenarios } from '@0xproject/fill-scenarios';
|
import { FillScenarios } from '@0xproject/fill-scenarios';
|
||||||
import { runV2MigrationsAsync } from '@0xproject/migrations';
|
import { runMigrationsAsync } from '@0xproject/migrations';
|
||||||
import { assetDataUtils } from '@0xproject/order-utils';
|
import { assetDataUtils } from '@0xproject/order-utils';
|
||||||
import { SignedOrder } from '@0xproject/types';
|
import { SignedOrder } from '@0xproject/types';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
@ -20,28 +20,19 @@ const expect = chai.expect;
|
|||||||
describe('Revert Validation ExchangeWrapper', () => {
|
describe('Revert Validation ExchangeWrapper', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let zrxTokenAddress: string;
|
|
||||||
let fillScenarios: FillScenarios;
|
let fillScenarios: FillScenarios;
|
||||||
let exchangeContractAddress: string;
|
|
||||||
let makerTokenAddress: string;
|
let makerTokenAddress: string;
|
||||||
let takerTokenAddress: string;
|
let takerTokenAddress: string;
|
||||||
let coinbase: string;
|
|
||||||
let makerAddress: string;
|
let makerAddress: string;
|
||||||
let anotherMakerAddress: string;
|
|
||||||
let takerAddress: string;
|
let takerAddress: string;
|
||||||
let makerAssetData: string;
|
let makerAssetData: string;
|
||||||
let takerAssetData: string;
|
let takerAssetData: string;
|
||||||
let feeRecipient: string;
|
|
||||||
let txHash: string;
|
let txHash: string;
|
||||||
let blockchainLifecycle: BlockchainLifecycle;
|
let blockchainLifecycle: BlockchainLifecycle;
|
||||||
let web3Wrapper: Web3Wrapper;
|
let web3Wrapper: Web3Wrapper;
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
const takerTokenFillAmount = new BigNumber(5);
|
const takerTokenFillAmount = new BigNumber(5);
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
blockPollingIntervalMs: 0,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
// vmErrorsOnRPCResponse is useful for quick feedback and testing during development
|
// vmErrorsOnRPCResponse is useful for quick feedback and testing during development
|
||||||
// but is not the default behaviour in production. Here we ensure our failure cases
|
// but is not the default behaviour in production. Here we ensure our failure cases
|
||||||
@ -52,29 +43,31 @@ describe('Revert Validation ExchangeWrapper', () => {
|
|||||||
});
|
});
|
||||||
web3Wrapper = new Web3Wrapper(provider);
|
web3Wrapper = new Web3Wrapper(provider);
|
||||||
blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
|
// Re-deploy the artifacts in this provider, rather than in the default provider exposed in
|
||||||
|
// the beforeAll hook. This is due to the fact that the default provider enabled vmErrorsOnRPCResponse
|
||||||
|
// and we are explicity testing with vmErrorsOnRPCResponse disabled.
|
||||||
const txDefaults = {
|
const txDefaults = {
|
||||||
gas: devConstants.GAS_LIMIT,
|
gas: devConstants.GAS_LIMIT,
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||||
};
|
};
|
||||||
const artifactsDir = `src/artifacts`;
|
|
||||||
// Re-deploy the artifacts in this provider, rather than in the default provider exposed in
|
|
||||||
// the beforeAll hook. This is due to the fact that the default provider enabled vmErrorsOnRPCResponse
|
|
||||||
// and we are explicity testing with vmErrorsOnRPCResponse disabled.
|
|
||||||
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
|
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
|
const contractAddresses = await runMigrationsAsync(provider, txDefaults);
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
|
||||||
fillScenarios = new FillScenarios(
|
fillScenarios = new FillScenarios(
|
||||||
provider,
|
provider,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
zrxTokenAddress,
|
contractAddresses.zrxToken,
|
||||||
exchangeContractAddress,
|
contractAddresses.exchange,
|
||||||
contractWrappers.erc20Proxy.getContractAddress(),
|
contractAddresses.erc20Proxy,
|
||||||
contractWrappers.erc721Proxy.getContractAddress(),
|
contractAddresses.erc721Proxy,
|
||||||
);
|
);
|
||||||
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
[, makerAddress, takerAddress] = userAddresses;
|
||||||
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
[makerAssetData, takerAssetData] = [
|
[makerAssetData, takerAssetData] = [
|
||||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||||
@ -112,7 +105,7 @@ describe('Revert Validation ExchangeWrapper', () => {
|
|||||||
makerTokenBalance,
|
makerTokenBalance,
|
||||||
);
|
);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||||
expect(
|
return expect(
|
||||||
contractWrappers.exchange.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress, {
|
contractWrappers.exchange.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress, {
|
||||||
shouldValidate: true,
|
shouldValidate: true,
|
||||||
}),
|
}),
|
||||||
|
@ -4,11 +4,17 @@ import * as _ from 'lodash';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import * as Sinon from 'sinon';
|
import * as Sinon from 'sinon';
|
||||||
|
|
||||||
import { ContractWrappers, ERC20TokenApprovalEventArgs, ERC20TokenEvents } from '../src';
|
import {
|
||||||
import { DecodedLogEvent } from '../src/types';
|
ContractWrappers,
|
||||||
|
ContractWrappersConfig,
|
||||||
|
DecodedLogEvent,
|
||||||
|
ERC20TokenApprovalEventArgs,
|
||||||
|
ERC20TokenEvents,
|
||||||
|
} from '../src';
|
||||||
|
|
||||||
import { chaiSetup } from './utils/chai_setup';
|
import { chaiSetup } from './utils/chai_setup';
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -17,10 +23,14 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
|||||||
|
|
||||||
describe('SubscriptionTest', () => {
|
describe('SubscriptionTest', () => {
|
||||||
let contractWrappers: ContractWrappers;
|
let contractWrappers: ContractWrappers;
|
||||||
const config = {
|
let config: ContractWrappersConfig;
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
|
config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -9,6 +9,7 @@ import { ContractWrappers } from '../src';
|
|||||||
import { TransactionEncoder } from '../src/utils/transaction_encoder';
|
import { TransactionEncoder } from '../src/utils/transaction_encoder';
|
||||||
|
|
||||||
import { constants } from './utils/constants';
|
import { constants } from './utils/constants';
|
||||||
|
import { migrateOnceAsync } from './utils/migrate';
|
||||||
import { tokenUtils } from './utils/token_utils';
|
import { tokenUtils } from './utils/token_utils';
|
||||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||||
|
|
||||||
@ -31,23 +32,26 @@ describe('TransactionEncoder', () => {
|
|||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
const takerTokenFillAmount = new BigNumber(5);
|
const takerTokenFillAmount = new BigNumber(5);
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
const config = {
|
|
||||||
networkId: constants.TESTRPC_NETWORK_ID,
|
|
||||||
blockPollingIntervalMs: 0,
|
|
||||||
};
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
|
const contractAddresses = await migrateOnceAsync();
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
contractAddresses,
|
||||||
|
blockPollingIntervalMs: 10,
|
||||||
|
};
|
||||||
contractWrappers = new ContractWrappers(provider, config);
|
contractWrappers = new ContractWrappers(provider, config);
|
||||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
exchangeContractAddress = contractWrappers.exchange.address;
|
||||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||||
const zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
const zrxTokenAddress = contractWrappers.exchange.zrxTokenAddress;
|
||||||
fillScenarios = new FillScenarios(
|
fillScenarios = new FillScenarios(
|
||||||
provider,
|
provider,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
zrxTokenAddress,
|
zrxTokenAddress,
|
||||||
exchangeContractAddress,
|
exchangeContractAddress,
|
||||||
contractWrappers.erc20Proxy.getContractAddress(),
|
contractWrappers.erc20Proxy.address,
|
||||||
contractWrappers.erc721Proxy.getContractAddress(),
|
contractWrappers.erc721Proxy.address,
|
||||||
);
|
);
|
||||||
[coinbase, makerAddress, takerAddress, senderAddress] = userAddresses;
|
[coinbase, makerAddress, takerAddress, senderAddress] = userAddresses;
|
||||||
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
|
18
packages/contract-wrappers/test/utils/migrate.ts
Normal file
18
packages/contract-wrappers/test/utils/migrate.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { ContractAddresses } from '@0xproject/contract-addresses';
|
||||||
|
import { devConstants } from '@0xproject/dev-utils';
|
||||||
|
import { runMigrationsOnceAsync } from '@0xproject/migrations';
|
||||||
|
|
||||||
|
import { provider } from './web3_wrapper';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures and runs the migrations exactly once. Any subsequent times this is
|
||||||
|
* called, it returns the cached addresses.
|
||||||
|
* @returns The addresses of contracts that were deployed during the migrations.
|
||||||
|
*/
|
||||||
|
export async function migrateOnceAsync(): Promise<ContractAddresses> {
|
||||||
|
const txDefaults = {
|
||||||
|
gas: devConstants.GAS_LIMIT,
|
||||||
|
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||||
|
};
|
||||||
|
return runMigrationsOnceAsync(provider, txDefaults);
|
||||||
|
}
|
@ -1,14 +1,13 @@
|
|||||||
|
import { DummyERC721TokenContract } from '@0xproject/abi-gen-wrappers';
|
||||||
|
import { DummyERC721Token } from '@0xproject/contract-artifacts';
|
||||||
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
|
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
|
|
||||||
import { artifacts } from '../../src/artifacts';
|
|
||||||
import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_erc721_token';
|
|
||||||
|
|
||||||
import { constants } from './constants';
|
|
||||||
import { provider, txDefaults, web3Wrapper } from './web3_wrapper';
|
import { provider, txDefaults, web3Wrapper } from './web3_wrapper';
|
||||||
|
|
||||||
// Those addresses come from migrations. They're deterministic so it's relatively safe to hard-code them here.
|
// Those addresses come from migrations. They're deterministic so it's relatively safe to hard-code them here.
|
||||||
// Before we were fetching them from the TokenRegistry but now we can't as it's deprecated and removed.
|
// Before we were fetching them from the TokenRegistry but now we can't as it's deprecated and removed.
|
||||||
|
// TODO(albrow): Import these from the migrations package instead of hard-coding them.
|
||||||
const DUMMY_ERC_20_ADRESSES = [
|
const DUMMY_ERC_20_ADRESSES = [
|
||||||
'0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f',
|
'0x6dfff22588be9b3ef8cf0ad6dc9b84796f9fb45f',
|
||||||
'0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db',
|
'0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db',
|
||||||
@ -20,12 +19,6 @@ const DUMMY_ERC_20_ADRESSES = [
|
|||||||
const DUMMY_ERC_721_ADRESSES = ['0x131855dda0aaff096f6854854c55a4debf61077a'];
|
const DUMMY_ERC_721_ADRESSES = ['0x131855dda0aaff096f6854854c55a4debf61077a'];
|
||||||
|
|
||||||
export const tokenUtils = {
|
export const tokenUtils = {
|
||||||
getProtocolTokenAddress(): string {
|
|
||||||
return artifacts.ZRXToken.networks[constants.TESTRPC_NETWORK_ID].address;
|
|
||||||
},
|
|
||||||
getWethTokenAddress(): string {
|
|
||||||
return artifacts.EtherToken.networks[constants.TESTRPC_NETWORK_ID].address;
|
|
||||||
},
|
|
||||||
getDummyERC20TokenAddresses(): string[] {
|
getDummyERC20TokenAddresses(): string[] {
|
||||||
return DUMMY_ERC_20_ADRESSES;
|
return DUMMY_ERC_20_ADRESSES;
|
||||||
},
|
},
|
||||||
@ -33,12 +26,7 @@ export const tokenUtils = {
|
|||||||
return DUMMY_ERC_721_ADRESSES;
|
return DUMMY_ERC_721_ADRESSES;
|
||||||
},
|
},
|
||||||
async mintDummyERC721Async(address: string, tokenOwner: string): Promise<BigNumber> {
|
async mintDummyERC721Async(address: string, tokenOwner: string): Promise<BigNumber> {
|
||||||
const erc721 = new DummyERC721TokenContract(
|
const erc721 = new DummyERC721TokenContract(DummyERC721Token.compilerOutput.abi, address, provider, txDefaults);
|
||||||
artifacts.DummyERC721Token.compilerOutput.abi,
|
|
||||||
address,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
const tokenId = generatePseudoRandomSalt();
|
const tokenId = generatePseudoRandomSalt();
|
||||||
const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId);
|
const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId);
|
||||||
web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
|
3
packages/contracts/.solhintignore
Normal file
3
packages/contracts/.solhintignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
contracts/tokens/ZRXToken/ERC20Token_v1.sol
|
||||||
|
contracts/tokens/ZRXToken/Token_v1.sol
|
||||||
|
contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"artifactsDir": "../migrations/artifacts/development",
|
"artifactsDir": "./generated-artifacts",
|
||||||
"contractsDir": "src/",
|
"contractsDir": "./contracts",
|
||||||
"compilerSettings": {
|
"compilerSettings": {
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
@ -50,7 +50,6 @@
|
|||||||
"TestExchangeInternals",
|
"TestExchangeInternals",
|
||||||
"TestSignatureValidator",
|
"TestSignatureValidator",
|
||||||
"TestStaticCallReceiver",
|
"TestStaticCallReceiver",
|
||||||
"TokenRegistry",
|
|
||||||
"Validator",
|
"Validator",
|
||||||
"Wallet",
|
"Wallet",
|
||||||
"WETH9",
|
"WETH9",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user