aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-24 04:53:27 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-28 04:05:23 +0800
commit9d9cab1711f2d5c77376056affc1d7287211c18d (patch)
tree695c3934b2cfb8726fc8472fc5ddb57c94ce5a86 /packages/contracts
parentfe8f2d8d898e9909636366c9ceee37a5e9481573 (diff)
downloaddexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar.gz
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar.bz2
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar.lz
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar.xz
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.tar.zst
dexon-sol-tools-9d9cab1711f2d5c77376056affc1d7287211c18d.zip
Fix build by using local events types
Diffstat (limited to 'packages/contracts')
-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
7 files changed, 72 insertions, 13 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';