aboutsummaryrefslogtreecommitdiffstats
path: root/packages/base-contract
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-03 07:13:16 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-03 07:13:16 +0800
commit343b922ec11a6108caaf3095e59be0e56d45ee4a (patch)
treead38a124853c4cd153f5a290a0dc461447f8c799 /packages/base-contract
parent6deb027bdf4e57f8918fd2413f0fdc55311508d3 (diff)
parentf1ecb8c5cb28a0a7ca6f7ad2ff11194091df62a4 (diff)
downloaddexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.gz
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.bz2
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.lz
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.xz
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.zst
dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.zip
Merge branch 'development' into feature/asset-buyer/improve-asset-buyer-manager
* development: (178 commits) Change cache key back to repo from repo-built Change the lint command back Merge build & install Remove deps cache all together Cache all nested node_modules directories Explicitly specify yarn cache folder Ignore linter issues Fix linter issue Separate deps and built caches Build tslint rules before running linter Cache yarn cache directory without node modules Run linter before prettier as it fails more often Add yarn cache path Split CI install and build steps Move bundle-size out of static tests and don't wait for a build with static tests Introduce a build:ci command that doesn't build webpack bundles Measure only one bundle size as they're the same Fix linter errors Fix no_website CI builds Check bundle size on CI ...
Diffstat (limited to 'packages/base-contract')
-rw-r--r--packages/base-contract/CHANGELOG.json32
-rw-r--r--packages/base-contract/CHANGELOG.md13
-rw-r--r--packages/base-contract/package.json13
-rw-r--r--packages/base-contract/src/index.ts22
4 files changed, 70 insertions, 10 deletions
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index 5f94afa43..92680729f 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,37 @@
[
{
+ "timestamp": 1538475601,
+ "version": "3.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Change the way we detect BN to work with the newest ethers.js",
+ "pr": 1069
+ },
+ {
+ "note": "Add baseContract._throwIfRevertWithReasonCallResult",
+ "pr": 1069
+ }
+ ],
+ "timestamp": 1538157789
+ },
+ {
+ "timestamp": 1537907159,
+ "version": "2.0.5",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1537875740,
"version": "2.0.4",
"changes": [
diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md
index b3f3b5619..90d7f3bc2 100644
--- a/packages/base-contract/CHANGELOG.md
+++ b/packages/base-contract/CHANGELOG.md
@@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v3.0.1 - _October 2, 2018_
+
+ * Dependencies updated
+
+## v3.0.0 - _September 28, 2018_
+
+ * Change the way we detect BN to work with the newest ethers.js (#1069)
+ * Add baseContract._throwIfRevertWithReasonCallResult (#1069)
+
+## v2.0.5 - _September 25, 2018_
+
+ * Dependencies updated
+
## v2.0.4 - _September 25, 2018_
* Dependencies updated
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index cd7f29114..e95a753e6 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/base-contract",
- "version": "2.0.4",
+ "version": "3.0.0",
"engines": {
"node": ">=6.12"
},
@@ -9,6 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
@@ -40,11 +41,11 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/typescript-typings": "^2.0.1",
- "@0xproject/utils": "^1.0.10",
- "@0xproject/web3-wrapper": "^3.0.0",
- "ethereum-types": "^1.0.7",
- "ethers": "3.0.22",
+ "@0xproject/typescript-typings": "^3.0.0",
+ "@0xproject/utils": "^2.0.0",
+ "@0xproject/web3-wrapper": "^3.0.2",
+ "ethereum-types": "^1.0.9",
+ "ethers": "4.0.0-beta.14",
"lodash": "^4.17.5"
},
"publishConfig": {
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index 12f974445..981e6fca6 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -20,6 +20,11 @@ export interface EthersInterfaceByFunctionSignature {
[key: string]: ethers.Interface;
}
+const REVERT_ERROR_SELECTOR = '08c379a0';
+const REVERT_ERROR_SELECTOR_OFFSET = 2;
+const REVERT_ERROR_SELECTOR_BYTES_LENGTH = 4;
+const REVERT_ERROR_SELECTOR_END = REVERT_ERROR_SELECTOR_OFFSET + REVERT_ERROR_SELECTOR_BYTES_LENGTH * 2;
+
export class BaseContract {
protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature;
protected _web3Wrapper: Web3Wrapper;
@@ -61,7 +66,7 @@ export class BaseContract {
}
}
protected static _bnToBigNumber(_type: string, value: any): any {
- return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value;
+ return _.isObject(value) && value._hex ? new BigNumber(value.toString()) : value;
}
protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
txData: T,
@@ -82,15 +87,24 @@ export class BaseContract {
}
return txDataWithDefaults;
}
+ protected static _throwIfRevertWithReasonCallResult(rawCallResult: string): void {
+ if (rawCallResult.slice(REVERT_ERROR_SELECTOR_OFFSET, REVERT_ERROR_SELECTOR_END) === REVERT_ERROR_SELECTOR) {
+ const revertReason = ethers.utils.defaultAbiCoder.decode(
+ ['string'],
+ ethers.utils.hexDataSlice(rawCallResult, REVERT_ERROR_SELECTOR_BYTES_LENGTH),
+ );
+ throw new Error(revertReason);
+ }
+ }
// Throws if the given arguments cannot be safely/correctly encoded based on
// the given inputAbi. An argument may not be considered safely encodeable
// if it overflows the corresponding Solidity type, there is a bug in the
// encoder, or the encoder performs unsafe type coercion.
public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): void {
- const coder = ethers.utils.AbiCoder.defaultCoder;
+ const coder = new ethers.AbiCoder();
const params = abiUtils.parseEthersParams(inputAbi);
- const rawEncoded = coder.encode(params.names, params.types, args);
- const rawDecoded = coder.decode(params.names, params.types, rawEncoded);
+ const rawEncoded = coder.encode(inputAbi, args);
+ const rawDecoded = coder.decode(inputAbi, rawEncoded);
for (let i = 0; i < rawDecoded.length; i++) {
const original = args[i];
const decoded = rawDecoded[i];