aboutsummaryrefslogtreecommitdiffstats
path: root/packages/base-contract
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base-contract')
-rw-r--r--packages/base-contract/.npmignore1
-rw-r--r--packages/base-contract/README.md9
-rw-r--r--packages/base-contract/package.json6
-rw-r--r--packages/base-contract/src/index.ts13
-rw-r--r--packages/base-contract/tsconfig.json6
5 files changed, 14 insertions, 21 deletions
diff --git a/packages/base-contract/.npmignore b/packages/base-contract/.npmignore
index ad5ffcd56..24e65ad5b 100644
--- a/packages/base-contract/.npmignore
+++ b/packages/base-contract/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/scripts/
/src/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/base-contract/README.md b/packages/base-contract/README.md
index fa2f3da10..a689d0130 100644
--- a/packages/base-contract/README.md
+++ b/packages/base-contract/README.md
@@ -10,11 +10,10 @@ yarn add @0xproject/base-contract
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
- "./node_modules/ethers-typescript-typings/index.d.ts"
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Usage
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index 4e0260417..e9015713c 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -32,11 +32,9 @@
"dependencies": {
"@0xproject/types": "^0.4.1",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"ethers-contracts": "^2.2.1",
- "ethers-typescript-typings": "^0.0.4",
- "lodash": "^4.17.4",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "lodash": "^4.17.4"
},
"publishConfig": {
"access": "public"
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index cc1e16a13..961da8842 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -1,16 +1,15 @@
-import { TxData, TxDataPayable } from '@0xproject/types';
+import { ContractAbi, DataItem, TxData, TxDataPayable } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
export class BaseContract {
protected _ethersInterface: ethersContracts.Interface;
protected _web3Wrapper: Web3Wrapper;
- public abi: Web3.ContractAbi;
+ public abi: ContractAbi;
public address: string;
protected static _transformABIData(
- abis: Web3.DataItem[],
+ abis: DataItem[],
values: any[],
transformation: (type: string, value: any) => any,
): any {
@@ -46,20 +45,20 @@ export class BaseContract {
// 2. Global config passed in at library instantiation
// 3. Gas estimate calculation + safety margin
const removeUndefinedProperties = _.pickBy;
- const txDataWithDefaults = {
+ const txDataWithDefaults = ({
to: this.address,
...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()),
...removeUndefinedProperties(txData as any),
// HACK: TS can't prove that T is spreadable.
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
- };
+ } as any) as TxData;
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
const estimatedGas = await estimateGasAsync(txData);
txDataWithDefaults.gas = estimatedGas;
}
return txDataWithDefaults;
}
- constructor(web3Wrapper: Web3Wrapper, abi: Web3.ContractAbi, address: string) {
+ constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
this._web3Wrapper = web3Wrapper;
this.abi = abi;
this.address = address;
diff --git a/packages/base-contract/tsconfig.json b/packages/base-contract/tsconfig.json
index 8114d99cd..c56d255d5 100644
--- a/packages/base-contract/tsconfig.json
+++ b/packages/base-contract/tsconfig.json
@@ -3,9 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*"]
}