aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/utils')
-rw-r--r--packages/utils/CHANGELOG.json18
-rw-r--r--packages/utils/CHANGELOG.md10
-rw-r--r--packages/utils/README.md12
-rw-r--r--packages/utils/package.json15
-rw-r--r--packages/utils/src/abi_decoder.ts10
-rw-r--r--packages/utils/src/configured_bignumber.ts23
-rw-r--r--packages/utils/src/sign_typed_data_utils.ts2
-rw-r--r--packages/utils/tslint.json2
8 files changed, 71 insertions, 21 deletions
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index 237ebeecc..6c9da5f37 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "2.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ],
+ "timestamp": 1541740904
+ },
+ {
+ "timestamp": 1539871071,
+ "version": "2.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538693146,
"version": "2.0.2",
"changes": [
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md
index fa731ecf0..4fdd13d9c 100644
--- a/packages/utils/CHANGELOG.md
+++ b/packages/utils/CHANGELOG.md
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.4 - _November 9, 2018_
+
+ * Dependencies updated
+
+## v2.0.3 - _October 18, 2018_
+
+ * Dependencies updated
+
## v2.0.2 - _October 4, 2018_
* Dependencies updated
@@ -41,7 +49,7 @@ CHANGELOG
* Dependencies updated
-## v1.0.5 - _August 13, 2018_
+## v1.0.5 - _August 14, 2018_
* Increased BigNumber decimal precision from 20 to 78 (#807)
* Store different ABIs for events with same function signature and different amount of indexed arguments (#933)
diff --git a/packages/utils/README.md b/packages/utils/README.md
index c9a2f5846..0b15f00c5 100644
--- a/packages/utils/README.md
+++ b/packages/utils/README.md
@@ -1,25 +1,25 @@
-## @0xproject/utils
+## @0x/utils
Utils to be shared across 0x projects and packages
## Installation
```bash
-yarn add @0xproject/utils
+yarn add @0x/utils
```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```json
"compilerOptions": {
- "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+ "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
}
```
## Usage
```javascript
-import { addressUtils, bigNumberConfigs, classUtils, intervalUtils, promisify } from '@0xproject/utils';
+import { addressUtils, bigNumberConfigs, classUtils, intervalUtils, promisify } from '@0x/utils';
```
## Troubleshooting
@@ -62,13 +62,13 @@ yarn install
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
-PKG=@0xproject/utils yarn build
+PKG=@0x/utils yarn build
```
Or continuously rebuild on change:
```bash
-PKG=@0xproject/utils yarn watch
+PKG=@0x/utils yarn watch
```
### Clean
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 20b0f0c86..24c2496b0 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,6 +1,6 @@
{
- "name": "@0xproject/utils",
- "version": "2.0.2",
+ "name": "@0x/utils",
+ "version": "2.0.4",
"engines": {
"node": ">=6.12"
},
@@ -11,7 +11,7 @@
"build": "tsc -b",
"build:ci": "yarn build",
"clean": "shx rm -rf lib",
- "lint": "tslint --project .",
+ "lint": "tslint --format stylish --project .",
"test": "yarn run_mocha",
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
@@ -28,12 +28,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/utils/README.md",
"devDependencies": {
- "@0xproject/tslint-config": "^1.0.8",
+ "@0x/tslint-config": "^1.0.10",
"@types/detect-node": "2.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
- "copyfiles": "^2.0.0",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
@@ -42,13 +41,13 @@
"typescript": "3.0.1"
},
"dependencies": {
- "@0xproject/types": "^1.1.4",
- "@0xproject/typescript-typings": "^3.0.2",
+ "@0x/types": "^1.2.1",
+ "@0x/typescript-typings": "^3.0.4",
"@types/node": "*",
"abortcontroller-polyfill": "^1.1.9",
"bignumber.js": "~4.1.0",
"detect-node": "2.0.3",
- "ethereum-types": "^1.0.11",
+ "ethereum-types": "^1.1.2",
"ethereumjs-util": "^5.1.1",
"ethers": "~4.0.4",
"isomorphic-fetch": "^2.2.1",
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index ac3e54efb..2da46db35 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -9,7 +9,7 @@ import {
RawLog,
SolidityTypes,
} from 'ethereum-types';
-import { ethers } from 'ethers';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { addressUtils } from './address_utils';
@@ -99,11 +99,13 @@ export class AbiDecoder {
const ethersInterface = new ethers.utils.Interface(abiArray);
_.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) {
- const topic = ethersInterface.events[abi.name].topic;
- const numIndexedArgs = _.reduce(abi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0);
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ const eventAbi = abi as EventAbi;
+ const topic = ethersInterface.events[eventAbi.name].topic;
+ const numIndexedArgs = _.reduce(eventAbi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0);
this._methodIds[topic] = {
...this._methodIds[topic],
- [numIndexedArgs]: abi,
+ [numIndexedArgs]: eventAbi,
};
}
});
diff --git a/packages/utils/src/configured_bignumber.ts b/packages/utils/src/configured_bignumber.ts
index 2b22b6938..34b57d303 100644
--- a/packages/utils/src/configured_bignumber.ts
+++ b/packages/utils/src/configured_bignumber.ts
@@ -11,4 +11,27 @@ BigNumber.config({
DECIMAL_PLACES: 78,
});
+// Set a debug print function for NodeJS
+// Upstream issue: https://github.com/MikeMcl/bignumber.js/issues/188
+import isNode = require('detect-node');
+if (isNode) {
+ // Dynamically load a NodeJS specific module.
+ // Typescript requires all imports to be global, so we need to use
+ // `const` here and disable the tslint warning.
+ // tslint:disable-next-line: no-var-requires
+ const util = require('util');
+
+ // Set a custom util.inspect function
+ // HACK: We add a function to the BigNumber class by assigning to the
+ // prototype. The function name is a symbol provided by Node.
+ (BigNumber.prototype as any)[util.inspect.custom] = function(): string {
+ // HACK: When executed, `this` will refer to the BigNumber instance.
+ // This is also why we need a function expression instead of an
+ // arrow function, as the latter does not have a `this`.
+ // Return the readable string representation
+ // tslint:disable-next-line: no-invalid-this
+ return this.toString();
+ };
+}
+
export { BigNumber };
diff --git a/packages/utils/src/sign_typed_data_utils.ts b/packages/utils/src/sign_typed_data_utils.ts
index cd5bcb42f..6963b9084 100644
--- a/packages/utils/src/sign_typed_data_utils.ts
+++ b/packages/utils/src/sign_typed_data_utils.ts
@@ -2,7 +2,7 @@ import * as ethUtil from 'ethereumjs-util';
import * as ethers from 'ethers';
import * as _ from 'lodash';
-import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0xproject/types';
+import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
export const signTypedDataUtils = {
/**
diff --git a/packages/utils/tslint.json b/packages/utils/tslint.json
index ffaefe83a..dd9053357 100644
--- a/packages/utils/tslint.json
+++ b/packages/utils/tslint.json
@@ -1,3 +1,3 @@
{
- "extends": ["@0xproject/tslint-config"]
+ "extends": ["@0x/tslint-config"]
}