aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/contracts/contract_templates/contract.handlebars18
-rw-r--r--packages/contracts/contract_templates/partials/event.handlebars5
-rw-r--r--packages/contracts/globals.d.ts28
-rw-r--r--packages/contracts/package.json3
-rw-r--r--packages/contracts/test/exchange/core.ts17
-rw-r--r--packages/contracts/test/exchange/helpers.ts7
-rw-r--r--packages/contracts/test/exchange/wrapper.ts7
-rw-r--r--yarn.lock10
8 files changed, 72 insertions, 23 deletions
diff --git a/packages/contracts/contract_templates/contract.handlebars b/packages/contracts/contract_templates/contract.handlebars
index afb9708e9..84b0696b1 100644
--- a/packages/contracts/contract_templates/contract.handlebars
+++ b/packages/contracts/contract_templates/contract.handlebars
@@ -10,6 +10,24 @@ import * as Web3 from 'web3';
import {BaseContract} from './base_contract';
+{{#if events}}
+export type {{contractName}}ContractEventArgs =
+{{#each events}}
+ | {{name}}ContractEventArgs{{#if @last}};{{/if}}
+{{/each}}
+
+export enum {{contractName}}Events {
+ {{#each events}}
+ {{name}} = '{{name}}',
+ {{/each}}
+}
+
+{{#each events}}
+{{> event}}
+
+{{/each}}
+{{/if}}
+
export class {{contractName}}Contract extends BaseContract {
{{#each methods}}
{{#this.constant}}
diff --git a/packages/contracts/contract_templates/partials/event.handlebars b/packages/contracts/contract_templates/partials/event.handlebars
new file mode 100644
index 000000000..3c6100e4f
--- /dev/null
+++ b/packages/contracts/contract_templates/partials/event.handlebars
@@ -0,0 +1,5 @@
+export interface {{name}}ContractEventArgs {
+ {{#each inputs}}
+ {{name}}: {{#returnType type components}}{{/returnType}};
+ {{/each}}
+}
diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts
index 0e6586a4b..fe39fb11d 100644
--- a/packages/contracts/globals.d.ts
+++ b/packages/contracts/globals.d.ts
@@ -32,3 +32,31 @@ declare module 'ethereumjs-abi' {
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
const methodID: (name: string, types: string[]) => Buffer;
}
+
+declare module 'ethers-contracts' {
+ export interface TransactionDescription {
+ name: string;
+ signature: string;
+ sighash: string;
+ data: string;
+ }
+ export interface CallDescription extends TransactionDescription {
+ parse: (...args: any[]) => any;
+ }
+ export interface FunctionDescription {
+ (...params: any[]): TransactionDescription | CallDescription;
+ inputs: { names: string[]; types: string[] };
+ outputs: { names: string[]; types: string[] };
+ }
+ export interface EventDescription {
+ inputs: { names: string[]; types: string[] };
+ signature: string;
+ topic: string;
+ }
+ // tslint:disable-next-line:max-classes-per-file
+ export class Interface {
+ public functions: { [functionName: string]: FunctionDescription };
+ public events: { [eventName: string]: EventDescription };
+ constructor(abi: any);
+ }
+}
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 0a3a6fc84..f35ba73c2 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -17,7 +17,7 @@
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
"clean": "shx rm -rf ./lib",
- "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated",
+ "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend web3",
"migrate": "node ../deployer/lib/src/cli.js migrate",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"test:circleci": "yarn test"
@@ -72,6 +72,7 @@
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",
+ "ethers-contracts": "^2.2.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"request": "^2.81.0",
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 9cfc68418..1997a1f11 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -1,12 +1,4 @@
-import {
- LogCancelContractEventArgs,
- LogErrorContractEventArgs,
- LogFillContractEventArgs,
- LogWithDecodedArgs,
- SignedOrder,
- TransactionReceiptWithDecodedLogs,
- ZeroEx,
-} from '0x.js';
+import { LogWithDecodedArgs, SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -15,7 +7,12 @@ import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
-import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
+import {
+ ExchangeContract,
+ LogCancelContractEventArgs,
+ LogErrorContractEventArgs,
+ LogFillContractEventArgs,
+} from '../../src/contract_wrappers/generated/exchange';
import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy';
import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index 5fe00225e..9030af4c6 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -5,7 +5,12 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
-import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
+import {
+ ExchangeContract,
+ LogCancelContractEventArgs,
+ LogErrorContractEventArgs,
+ LogFillContractEventArgs,
+} from '../../src/contract_wrappers/generated/exchange';
import { constants } from '../../util/constants';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
import { OrderFactory } from '../../util/order_factory';
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index bf5a89222..5b1b76deb 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -7,7 +7,12 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
-import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
+import {
+ ExchangeContract,
+ LogCancelContractEventArgs,
+ LogErrorContractEventArgs,
+ LogFillContractEventArgs,
+} from '../../src/contract_wrappers/generated/exchange';
import { TokenRegistryContract } from '../../src/contract_wrappers/generated/token_registry';
import { TokenTransferProxyContract } from '../../src/contract_wrappers/generated/token_transfer_proxy';
import { Balances } from '../../util/balances';
diff --git a/yarn.lock b/yarn.lock
index f48310c91..ddcaa3f9e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10,12 +10,6 @@
version "4.0.3"
resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-4.0.3.tgz#e8ce5f28c3025a01c6af7fc6d944494903a9e348"
-"@types/bignumber.js@^5.0.0":
- version "5.0.0"
- resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-5.0.0.tgz#d9f1a378509f3010a3255e9cc822ad0eeb4ab969"
- dependencies:
- bignumber.js "*"
-
"@types/bintrees@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/bintrees/-/bintrees-1.0.2.tgz#0dfdce4eeebdf90427bd35b0e79dc248b3d157a6"
@@ -1289,10 +1283,6 @@ big.js@^3.1.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
-bignumber.js@*, bignumber.js@^6.0.0:
- version "6.0.0"
- resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-6.0.0.tgz#bbfa047644609a5af093e9cbd83b0461fa3f6002"
-
"bignumber.js@git+https://github.com/debris/bignumber.js#master":
version "2.0.7"
resolved "git+https://github.com/debris/bignumber.js#c7a38de919ed75e6fb6ba38051986e294b328df9"