From 427a29145d90070e8c67753e7f76c7b88322eefb Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 15 May 2018 11:13:01 +0200 Subject: Support all opcodes in a trace parser --- packages/utils/src/log_utils.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/utils') diff --git a/packages/utils/src/log_utils.ts b/packages/utils/src/log_utils.ts index d0f0e34c9..87f8479b5 100644 --- a/packages/utils/src/log_utils.ts +++ b/packages/utils/src/log_utils.ts @@ -2,4 +2,7 @@ export const logUtils = { log(...args: any[]): void { console.log(...args); // tslint:disable-line:no-console }, + warn(...args: any[]): void { + console.warn(...args); // tslint:disable-line:no-console + }, }; -- cgit v1.2.3 From b86248f13fcb8f326098252beee6ca557e0175e7 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 15 May 2018 11:29:52 +0200 Subject: Add CHANGELOG entries --- packages/utils/CHANGELOG.json | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'packages/utils') diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index d3c7da7b9..f447bdd1c 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.7.0", + "changes": [ + { + "note": "Add logUtils.warn", + "pr": 589 + } + ] + }, { "timestamp": 1525477860, "version": "0.6.1", -- cgit v1.2.3 From f8c628b0c7b750e1096dcc507190525feb8bd572 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 22 May 2018 10:16:38 -0700 Subject: Updated CHANGELOGS --- packages/utils/CHANGELOG.json | 9 +++++++++ packages/utils/CHANGELOG.md | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/utils') diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index f447bdd1c..616a17d62 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1527009133, + "version": "0.6.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "version": "0.7.0", "changes": [ diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 92e466b17..0c01bf4f1 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,7 +5,11 @@ Edit the package's CHANGELOG.json file only. CHANGELOG -## v0.6.1 - _May 5, 2018_ +## v0.6.2 - _May 22, 2018_ + + * Dependencies updated + +## v0.6.1 - _May 4, 2018_ * Dependencies updated -- cgit v1.2.3 From 84a1b5612de3b22bbe6b8b01a997234771d98005 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 22 May 2018 10:26:47 -0700 Subject: Publish - 0x.js@0.38.0 - @0xproject/abi-gen@0.3.0 - @0xproject/assert@0.2.10 - @0xproject/base-contract@0.3.2 - @0xproject/connect@0.6.13 - @0xproject/contract-wrappers@0.0.2 - contracts@2.1.29 - @0xproject/dev-utils@0.4.2 - @0xproject/fill-scenarios@0.0.2 - @0xproject/json-schemas@0.7.24 - @0xproject/metacoin@0.0.7 - @0xproject/migrations@0.0.6 - @0xproject/monorepo-scripts@0.1.20 - @0xproject/order-utils@0.0.5 - @0xproject/order-watcher@0.0.2 - @0xproject/react-docs-example@0.0.12 - @0xproject/react-docs@0.0.12 - @0xproject/react-shared@0.1.7 - @0xproject/sol-compiler@0.5.0 - @0xproject/sol-cov@0.0.11 - @0xproject/sol-resolver@0.0.5 - @0xproject/sra-report@0.1.0 - @0xproject/subproviders@0.10.2 - @0xproject/testnet-faucets@1.0.30 - @0xproject/tslint-config@0.4.18 - @0xproject/types@0.7.0 - @0xproject/typescript-typings@0.3.2 - @0xproject/utils@0.6.2 - @0xproject/web3-wrapper@0.6.4 - @0xproject/website@0.0.33 --- packages/utils/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/utils') diff --git a/packages/utils/package.json b/packages/utils/package.json index 66dc682fa..99d3d9256 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/utils", - "version": "0.6.1", + "version": "0.6.2", "engines": { "node": ">=6.12" }, @@ -24,8 +24,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/utils/README.md", "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.19", - "@0xproject/tslint-config": "^0.4.17", + "@0xproject/monorepo-scripts": "^0.1.20", + "@0xproject/tslint-config": "^0.4.18", "@types/lodash": "4.14.104", "copyfiles": "^1.2.0", "make-promises-safe": "^1.1.0", @@ -35,8 +35,8 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/types": "^0.6.3", - "@0xproject/typescript-typings": "^0.3.1", + "@0xproject/types": "^0.7.0", + "@0xproject/typescript-typings": "^0.3.2", "@types/node": "^8.0.53", "bignumber.js": "~4.1.0", "ethers": "^3.0.15", -- cgit v1.2.3 From 83c37c6a7a320326975c8afd9d49a42c9afcefd4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 22 May 2018 11:05:24 -0700 Subject: Address feedback --- packages/utils/package.json | 1 + packages/utils/src/abi_decoder.ts | 13 ++----------- packages/utils/src/address_utils.ts | 5 +++++ 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'packages/utils') diff --git a/packages/utils/package.json b/packages/utils/package.json index 99d3d9256..24551dd93 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -38,6 +38,7 @@ "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@types/node": "^8.0.53", + "ethereumjs-util": "^5.1.1", "bignumber.js": "~4.1.0", "ethers": "^3.0.15", "js-sha3": "^0.7.0", diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index c78bfa343..d2d8364ca 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -12,21 +12,12 @@ import { import * as ethers from 'ethers'; import * as _ from 'lodash'; +import { addressUtils } from './address_utils'; import { BigNumber } from './configured_bignumber'; export class AbiDecoder { private _savedABIs: AbiDefinition[] = []; private _methodIds: { [signatureHash: string]: EventAbi } = {}; - private static _padZeros(address: string): string { - let formatted = address; - if (_.startsWith(formatted, '0x')) { - formatted = formatted.slice(2); - } - - const addressLength = 40; - formatted = _.padStart(formatted, addressLength, '0'); - return `0x${formatted}`; - } constructor(abiArrays: AbiDefinition[][]) { _.forEach(abiArrays, this.addABI.bind(this)); } @@ -56,7 +47,7 @@ export class AbiDecoder { } if (param.type === SolidityTypes.Address) { const baseHex = 16; - value = AbiDecoder._padZeros(new BigNumber(value).toString(baseHex)); + value = addressUtils.padZeros(new BigNumber(value).toString(baseHex)); } else if (param.type === SolidityTypes.Uint256 || param.type === SolidityTypes.Uint) { value = new BigNumber(value); } else if (param.type === SolidityTypes.Uint8) { diff --git a/packages/utils/src/address_utils.ts b/packages/utils/src/address_utils.ts index e25bde249..cc43bd477 100644 --- a/packages/utils/src/address_utils.ts +++ b/packages/utils/src/address_utils.ts @@ -1,4 +1,6 @@ +import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util'; import * as jsSHA3 from 'js-sha3'; +import * as _ from 'lodash'; const BASIC_ADDRESS_REGEX = /^(0x)?[0-9a-f]{40}$/i; const SAME_CASE_ADDRESS_REGEX = /^(0x)?([0-9a-f]{40}|[0-9A-F]{40})$/; @@ -38,4 +40,7 @@ export const addressUtils = { return isValidChecksummedAddress; } }, + padZeros(address: string): string { + return addHexPrefix(_.padStart(stripHexPrefix(address), 40, '0')); + }, }; -- cgit v1.2.3 From c9aef166495c0a1b1c34db01226602375c0b3547 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 23 May 2018 10:39:56 -0700 Subject: Fix linter issues --- packages/utils/src/address_utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/utils') diff --git a/packages/utils/src/address_utils.ts b/packages/utils/src/address_utils.ts index cc43bd477..1fc960408 100644 --- a/packages/utils/src/address_utils.ts +++ b/packages/utils/src/address_utils.ts @@ -4,6 +4,7 @@ import * as _ from 'lodash'; const BASIC_ADDRESS_REGEX = /^(0x)?[0-9a-f]{40}$/i; const SAME_CASE_ADDRESS_REGEX = /^(0x)?([0-9a-f]{40}|[0-9A-F]{40})$/; +const ADDRESS_LENGTH = 40; export const addressUtils = { isChecksumAddress(address: string): boolean { @@ -11,8 +12,7 @@ export const addressUtils = { const unprefixedAddress = address.replace('0x', ''); const addressHash = jsSHA3.keccak256(unprefixedAddress.toLowerCase()); - const addressLength = 40; - for (let i = 0; i < addressLength; i++) { + for (let i = 0; i < ADDRESS_LENGTH; i++) { // The nth letter should be uppercase if the nth digit of casemap is 1 const hexBase = 16; const lowercaseRange = 7; @@ -41,6 +41,6 @@ export const addressUtils = { } }, padZeros(address: string): string { - return addHexPrefix(_.padStart(stripHexPrefix(address), 40, '0')); + return addHexPrefix(_.padStart(stripHexPrefix(address), ADDRESS_LENGTH, '0')); }, }; -- cgit v1.2.3