diff options
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/package.json | 10 | ||||
-rw-r--r-- | packages/utils/src/abi_decoder.ts | 19 | ||||
-rw-r--r-- | packages/utils/src/monorepo_scripts/postpublish.ts | 8 |
3 files changed, 22 insertions, 15 deletions
diff --git a/packages/utils/package.json b/packages/utils/package.json index 28a967a35..4568352e1 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -9,15 +9,14 @@ "types": "lib/src/index.d.ts", "scripts": { "watch_without_deps": "tsc -w", - "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", - "clean": "shx rm -rf lib scripts", + "build": "tsc", + "clean": "shx rm -rf lib", + "lint": "tslint --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", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", - "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", - "lint": "tslint --project .", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js" + "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info" }, "license": "Apache-2.0", "repository": { @@ -29,7 +28,6 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/utils/README.md", "devDependencies": { - "@0xproject/monorepo-scripts": "^1.0.5", "@0xproject/tslint-config": "^1.0.5", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index cc05321ab..265eb105e 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -15,12 +15,25 @@ import * as _ from 'lodash'; import { addressUtils } from './address_utils'; import { BigNumber } from './configured_bignumber'; +/** + * AbiDecoder allows you to decode event logs given a set of supplied contract ABI's. It takes the contract's event + * signature from the ABI and attempts to decode the logs using it. + */ export class AbiDecoder { private readonly _methodIds: { [signatureHash: string]: { [numIndexedArgs: number]: EventAbi } } = {}; + /** + * Instantiate an AbiDecoder + * @param abiArrays An array of contract ABI's + * @return AbiDecoder instance + */ constructor(abiArrays: AbiDefinition[][]) { _.forEach(abiArrays, this.addABI.bind(this)); } - // This method can only decode logs from the 0x & ERC20 smart contracts + /** + * Attempt to decode a log given the ABI's the AbiDecoder knows about. + * @param log The log to attempt to decode + * @return The decoded log if the requisite ABI was available. Otherwise the log unaltered. + */ public tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { const methodId = log.topics[0]; const numIndexedArgs = log.topics.length - 1; @@ -75,6 +88,10 @@ export class AbiDecoder { }; } } + /** + * Add additional ABI definitions to the AbiDecoder + * @param abiArray An array of ABI definitions to add to the AbiDecoder + */ public addABI(abiArray: AbiDefinition[]): void { if (_.isUndefined(abiArray)) { return; diff --git a/packages/utils/src/monorepo_scripts/postpublish.ts b/packages/utils/src/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/utils/src/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); |