From 642a2cf165abe527bba015b3a923d9624d1b1a3d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 14 Mar 2018 16:36:00 +0100 Subject: Added doc json generation and uploading to Web3Wrapper package --- packages/web3-wrapper/README.md | 2 +- packages/web3-wrapper/package.json | 14 +++++++++++++- packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/README.md b/packages/web3-wrapper/README.md index 0d5defb1e..244e20708 100644 --- a/packages/web3-wrapper/README.md +++ b/packages/web3-wrapper/README.md @@ -1,6 +1,6 @@ ## @0xproject/web3-wrapper -Wrapped version of web3 with a nicer interface that is used across 0x projects and packages +Wrapped version of web3 with a nicer interface that is used across 0x projects and packages. Visit [the docs](0xproject.com/docs/web3_wrapper). ## Installation diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 6e569b993..ae7ba8b26 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -8,7 +8,18 @@ "build:watch": "tsc -w", "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", "clean": "shx rm -rf lib scripts", - "lint": "tslint --project . 'src/**/*.ts'" + "lint": "tslint --project . 'src/**/*.ts'", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", + "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" + }, + "config": { + "postpublish": { + "docPublishConfigs": { + "extraFileIncludes": ["../types/src/index.ts"], + "s3BucketPath": "s3://web3-wrapper-docs-json/", + "s3StagingBucketPath": "s3://staging-web3-wrapper-docs-json/" + } + } }, "license": "Apache-2.0", "repository": { @@ -27,6 +38,7 @@ "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.8.0", + "typedoc": "0xProject/typedoc", "typescript": "2.7.1" }, "dependencies": { diff --git a/packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts b/packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts new file mode 100644 index 000000000..e732ac8eb --- /dev/null +++ b/packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts @@ -0,0 +1,8 @@ +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.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); -- cgit From d7bf003d511321ec6cb8814cb1549c46b4efba86 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 16 Mar 2018 16:56:53 +0100 Subject: Refactor all docJSON's to reside within the same S3 bucket under different folders --- packages/web3-wrapper/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index ae7ba8b26..9b41f1de6 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -16,8 +16,8 @@ "postpublish": { "docPublishConfigs": { "extraFileIncludes": ["../types/src/index.ts"], - "s3BucketPath": "s3://web3-wrapper-docs-json/", - "s3StagingBucketPath": "s3://staging-web3-wrapper-docs-json/" + "s3BucketPath": "s3://doc-jsons/web3-wrapper/", + "s3StagingBucketPath": "s3://staging-doc-jsons/web3-wrapper/" } } }, -- cgit From 644deee8b5ac16526e046b74e3a2ab41a50b6727 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Sun, 18 Mar 2018 15:08:37 +0100 Subject: Standardize all doc commands and add `docs:stage` shortcut --- packages/web3-wrapper/package.json | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 9b41f1de6..58f3f1083 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -9,6 +9,7 @@ "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", "clean": "shx rm -rf lib scripts", "lint": "tslint --project . 'src/**/*.ts'", + "docs:stage": "yarn build && node ./scripts/stagedocs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" }, -- cgit From db8be4a66eeb9b3ae51da01291b0bf86a92c6e3f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 12:00:22 +0000 Subject: Rename `stagedocs.ts` file to `stage_docs.ts` in keeping with our file naming conventions. `postpublish.ts` is the only exception and this is because it is dictated by Lerna --- packages/web3-wrapper/package.json | 2 +- packages/web3-wrapper/src/monorepo_scripts/stage_docs.ts | 8 ++++++++ packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts | 8 -------- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 packages/web3-wrapper/src/monorepo_scripts/stage_docs.ts delete mode 100644 packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index a244b5fa9..176f796c8 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -9,7 +9,7 @@ "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", "clean": "shx rm -rf lib scripts", "lint": "tslint --project . 'src/**/*.ts'", - "docs:stage": "yarn build && node ./scripts/stagedocs.js", + "docs:stage": "yarn build && node ./scripts/stage_docs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" }, diff --git a/packages/web3-wrapper/src/monorepo_scripts/stage_docs.ts b/packages/web3-wrapper/src/monorepo_scripts/stage_docs.ts new file mode 100644 index 000000000..e732ac8eb --- /dev/null +++ b/packages/web3-wrapper/src/monorepo_scripts/stage_docs.ts @@ -0,0 +1,8 @@ +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.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts b/packages/web3-wrapper/src/monorepo_scripts/stagedocs.ts deleted file mode 100644 index e732ac8eb..000000000 --- a/packages/web3-wrapper/src/monorepo_scripts/stagedocs.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.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); -- cgit From 9991ddecc28f562539645a27c12707fc43f811ca Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 21:39:08 +0000 Subject: Fix var name typo --- packages/web3-wrapper/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 02d5e4f7b..6cd068be1 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -141,8 +141,8 @@ export class Web3Wrapper { return gas; } public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise { - const rawCalllResult = await promisify(this._web3.eth.call)(callData, defaultBlock); - return rawCalllResult; + const rawCallResult = await promisify(this._web3.eth.call)(callData, defaultBlock); + return rawCallResult; } public async sendTransactionAsync(txData: Web3.TxData): Promise { const txHash = await promisify(this._web3.eth.sendTransaction)(txData); -- cgit From 4f76bb2a12e7741be4fbed0455e53de798efa12e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 21:39:41 +0000 Subject: Remove duplicate method --- packages/web3-wrapper/src/index.ts | 3 --- 1 file changed, 3 deletions(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 6cd068be1..e508c4f5b 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -54,9 +54,6 @@ export class Web3Wrapper { } return transactionReceipt; } - public getCurrentProvider(): Web3.Provider { - return this._web3.currentProvider; - } public toWei(ethAmount: BigNumber): BigNumber { const balanceWei = this._web3.toWei(ethAmount, 'ether'); return balanceWei; -- cgit From 647bc5a63ecccdcaaad5390d5c7dd5a8d3d07996 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 21:41:21 +0000 Subject: Rename method for clarity --- packages/web3-wrapper/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index e508c4f5b..975649a75 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -70,7 +70,7 @@ export class Web3Wrapper { const codeIsEmpty = /^0x0{0,40}$/i.test(code); return !codeIsEmpty; } - public async signTransactionAsync(address: string, message: string): Promise { + public async signMessageAsync(address: string, message: string): Promise { const signData = await promisify(this._web3.eth.sign)(address, message); return signData; } -- cgit From 6693540f432d5004339799de5a18c66eabbd12cc Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 21:41:36 +0000 Subject: Add changelog entry --- packages/web3-wrapper/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 5f6523209..9fbc9021c 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.4.0 _TBD_ + + * Rename `signTransactionAsync` to `signMessageAsync` for clarity (#465) + ## v0.3.0 _March 18, 2018_ * Add `web3Wrapper.takeSnapshotAsync`, `web3Wrapper.revertSnapshotAsync`, `web3Wrapper.mineBlockAsync`, `web3Wrapper.increaseTimeAsync` (#426) -- cgit From 3cd7bce0a3a3c49858917122970a0a6e283fba37 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 21:41:59 +0000 Subject: Add DocComments to Web3Wrapper --- packages/web3-wrapper/src/index.ts | 133 ++++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 975649a75..895df509a 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -3,12 +3,25 @@ import { BigNumber, promisify } from '@0xproject/utils'; import * as _ from 'lodash'; import * as Web3 from 'web3'; +/** + * A wrapper around the Web3.js 0.x library that provides a consistent, clean promise-based interface. + */ export class Web3Wrapper { - // This is here purely to reliably distinguish it from other objects in runtime (like BigNumber.isBigNumber) + /** + * This is here purely to reliably distinguish it from other objects in runtime + * Similar to: BigNumber.isBigNumber + */ public isZeroExWeb3Wrapper = true; private _web3: Web3; private _defaults: Partial; private _jsonRpcRequestId: number; + /** + * Instantiates a new Web3Wrapper. + * @param provider The Web3 provider instance you would like the Web3Wrapper to use for interacting with + * the Ethereum network. + * @param defaults Override TxData defaults sent with RPC requests to the backing Ethereum node. + * @return An instance of the Web3Wrapper class. + */ constructor(provider: Web3.Provider, defaults?: Partial) { if (_.isUndefined((provider as any).sendAsync)) { // Web3@1.0 provider doesn't support synchronous http requests, @@ -21,32 +34,69 @@ export class Web3Wrapper { this._defaults = defaults || {}; this._jsonRpcRequestId = 0; } + /** + * Get the contract defaults set to the Web3Wrapper instance + * @return TxData defaults (e.g gas, gasPrice, nonce, etc...) + */ public getContractDefaults(): Partial { return this._defaults; } + /** + * Retrieve the Web3 provider + * @return Web3 provider instance + */ public getProvider(): Web3.Provider { return this._web3.currentProvider; } + /** + * Update the used Web3 provider + * @param provider The new Web3 provider to be set + */ public setProvider(provider: Web3.Provider) { this._web3.setProvider(provider); } + /** + * Check if an address is a valid Ethereum address + * @param address Address to check + * @returns Whether the address is a valid Ethereum address + */ public isAddress(address: string): boolean { return this._web3.isAddress(address); } + /** + * Check whether an address is available through the backing provider. This can be + * useful if you want to know whether a user can sign messages or transactions from + * a given Ethereum address. + * @param senderAddress Address to check availability for + * @returns Whether the address is available through the provider. + */ public async isSenderAddressAvailableAsync(senderAddress: string): Promise { const addresses = await this.getAvailableAddressesAsync(); const normalizedAddress = senderAddress.toLowerCase(); return _.includes(addresses, normalizedAddress); } + /** + * Fetch the backing Ethereum node's version string e.g `MetaMask/v4.2.0` + * @returns Ethereum node's version string + */ public async getNodeVersionAsync(): Promise { const nodeVersion = await promisify(this._web3.version.getNode)(); return nodeVersion; } + /** + * Fetches the networkId of the backing Ethereum node + * @returns The networkId + */ public async getNetworkIdAsync(): Promise { const networkIdStr = await promisify(this._web3.version.getNetwork)(); const networkId = _.parseInt(networkIdStr); return networkId; } + /** + * Retrieves the transaction receipt for a given transaction hash + * @param txHash Transaction hash + * @returns The transaction receipt, including it's status (0: failed, 1: succeeded or undefined: not found) + */ public async getTransactionReceiptAsync(txHash: string): Promise { const transactionReceipt = await promisify(this._web3.eth.getTransactionReceipt)(txHash); if (!_.isNull(transactionReceipt)) { @@ -54,57 +104,117 @@ export class Web3Wrapper { } return transactionReceipt; } + /** + * Convert an Ether amount from ETH to Wei + * @param ethAmount Amount of Ether to convert to wei + * @returns Amount in wei + */ public toWei(ethAmount: BigNumber): BigNumber { const balanceWei = this._web3.toWei(ethAmount, 'ether'); return balanceWei; } + /** + * Retrieves an accounts Ether balance in wei + * @param owner Account whose balance you wish to check + * @returns Balance in wei + */ public async getBalanceInWeiAsync(owner: string): Promise { let balanceInWei = await promisify(this._web3.eth.getBalance)(owner); // Rewrap in a new BigNumber balanceInWei = new BigNumber(balanceInWei); return balanceInWei; } + /** + * Check if a contract exists at a given address + * @param address Account address to check + * @returns Whether or not contract code was found at the supplied address + */ public async doesContractExistAtAddressAsync(address: string): Promise { const code = await promisify(this._web3.eth.getCode)(address); // Regex matches 0x0, 0x00, 0x in order to accommodate poorly implemented clients const codeIsEmpty = /^0x0{0,40}$/i.test(code); return !codeIsEmpty; } + /** + * Sign a message with a specific address's private key (`eth_sign`) + * @param address Address of signer + * @param message Message to sign + * @returns Signature string (might be VRS or RSV depending on the Signer) + */ public async signMessageAsync(address: string, message: string): Promise { const signData = await promisify(this._web3.eth.sign)(address, message); return signData; } + /** + * Fetches the latest blockNumber + * @returns Block number + */ public async getBlockNumberAsync(): Promise { const blockNumber = await promisify(this._web3.eth.getBlockNumber)(); return blockNumber; } + /** + * Fetch a specific Ethereum block + * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) + * @returns The requested block without transaction data + */ public async getBlockAsync(blockParam: string | Web3.BlockParam): Promise { const block = await promisify(this._web3.eth.getBlock)(blockParam); return block; } + /** + * Fetch a block's timestamp + * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) + * @returns The timestamp the block was mined + */ public async getBlockTimestampAsync(blockParam: string | Web3.BlockParam): Promise { const { timestamp } = await this.getBlockAsync(blockParam); return timestamp; } + /** + * Retrieve the user addresses available through the provider + * @returns Available user addresses + */ public async getAvailableAddressesAsync(): Promise { const addresses = await promisify(this._web3.eth.getAccounts)(); const normalizedAddresses = _.map(addresses, address => address.toLowerCase()); return normalizedAddresses; } + /** + * Take a snapshot of the blockchain state on a TestRPC/Ganache local node + * @returns The snapshot Id. This can be used to revert to this snapshot + */ public async takeSnapshotAsync(): Promise { const snapshotId = Number(await this._sendRawPayloadAsync({ method: 'evm_snapshot', params: [] })); return snapshotId; } + /** + * Revert the blockchain state to a previous snapshot state on TestRPC/Ganache local node + * @param snapshotId snapshot Id to revert to + * @returns Whether the revert was successful + */ public async revertSnapshotAsync(snapshotId: number): Promise { const didRevert = await this._sendRawPayloadAsync({ method: 'evm_revert', params: [snapshotId] }); return didRevert; } + /** + * Mine a block on a TestRPC/Ganache local node + */ public async mineBlockAsync(): Promise { await this._sendRawPayloadAsync({ method: 'evm_mine', params: [] }); } + /** + * Increase the next blocks timestamp on TestRPC/Ganache local node + * @param timeDelta Amount of time to add in seconds + */ public async increaseTimeAsync(timeDelta: number): Promise { await this._sendRawPayloadAsync({ method: 'evm_increaseTime', params: [timeDelta] }); } + /** + * Retrieve smart contract logs for a given filter + * @param filter Parameters by which to filter which logs to retrieve + * @returns The corresponding log entries + */ public async getLogsAsync(filter: Web3.FilterObject): Promise { let fromBlock = filter.fromBlock; if (_.isNumber(fromBlock)) { @@ -129,18 +239,39 @@ export class Web3Wrapper { const formattedLogs = _.map(rawLogs, this._formatLog.bind(this)); return formattedLogs; } + /** + * Get a Web3 contract factory instance for a given ABI + * @param abi Smart contract ABI + * @returns Web3 contract factory which can create Web3 Contract instances for the supplied ABI + */ public getContractFromAbi(abi: Web3.ContractAbi): Web3.Contract { const web3Contract = this._web3.eth.contract(abi); return web3Contract; } + /** + * Calculate the estimated gas cost for a given transaction + * @param txData Transaction data + * @returns Estimated gas cost + */ public async estimateGasAsync(txData: Partial): Promise { const gas = await promisify(this._web3.eth.estimateGas)(txData); return gas; } + /** + * Call a smart contract method at a given block height + * @param callData Call data + * @param defaultBlock Block height at which to make the call + * @returns The raw call result + */ public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise { const rawCallResult = await promisify(this._web3.eth.call)(callData, defaultBlock); return rawCallResult; } + /** + * Send a transaction + * @param txData Transaction data + * @returns Transaction hash + */ public async sendTransactionAsync(txData: Web3.TxData): Promise { const txHash = await promisify(this._web3.eth.sendTransaction)(txData); return txHash; -- cgit From 6a410b03ff644ed46b4ae1e6f8bf81203deb1663 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 22:17:39 +0000 Subject: Improve comments --- packages/web3-wrapper/src/index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 895df509a..2ce2580ee 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -8,8 +8,7 @@ import * as Web3 from 'web3'; */ export class Web3Wrapper { /** - * This is here purely to reliably distinguish it from other objects in runtime - * Similar to: BigNumber.isBigNumber + * Flag to check if this instance is of type Web3Wrapper */ public isZeroExWeb3Wrapper = true; private _web3: Web3; @@ -18,7 +17,7 @@ export class Web3Wrapper { /** * Instantiates a new Web3Wrapper. * @param provider The Web3 provider instance you would like the Web3Wrapper to use for interacting with - * the Ethereum network. + * the backing Ethereum node. * @param defaults Override TxData defaults sent with RPC requests to the backing Ethereum node. * @return An instance of the Web3Wrapper class. */ @@ -76,7 +75,7 @@ export class Web3Wrapper { return _.includes(addresses, normalizedAddress); } /** - * Fetch the backing Ethereum node's version string e.g `MetaMask/v4.2.0` + * Fetch the backing Ethereum node's version string (e.g `MetaMask/v4.2.0`) * @returns Ethereum node's version string */ public async getNodeVersionAsync(): Promise { @@ -85,7 +84,7 @@ export class Web3Wrapper { } /** * Fetches the networkId of the backing Ethereum node - * @returns The networkId + * @returns The network id */ public async getNetworkIdAsync(): Promise { const networkIdStr = await promisify(this._web3.version.getNetwork)(); @@ -126,7 +125,7 @@ export class Web3Wrapper { } /** * Check if a contract exists at a given address - * @param address Account address to check + * @param address Address to which to check * @returns Whether or not contract code was found at the supplied address */ public async doesContractExistAtAddressAsync(address: string): Promise { @@ -146,7 +145,7 @@ export class Web3Wrapper { return signData; } /** - * Fetches the latest blockNumber + * Fetches the latest block number * @returns Block number */ public async getBlockNumberAsync(): Promise { @@ -165,14 +164,14 @@ export class Web3Wrapper { /** * Fetch a block's timestamp * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) - * @returns The timestamp the block was mined + * @returns The block's timestamp */ public async getBlockTimestampAsync(blockParam: string | Web3.BlockParam): Promise { const { timestamp } = await this.getBlockAsync(blockParam); return timestamp; } /** - * Retrieve the user addresses available through the provider + * Retrieve the user addresses available through the backing provider * @returns Available user addresses */ public async getAvailableAddressesAsync(): Promise { @@ -182,7 +181,7 @@ export class Web3Wrapper { } /** * Take a snapshot of the blockchain state on a TestRPC/Ganache local node - * @returns The snapshot Id. This can be used to revert to this snapshot + * @returns The snapshot id. This can be used to revert to this snapshot */ public async takeSnapshotAsync(): Promise { const snapshotId = Number(await this._sendRawPayloadAsync({ method: 'evm_snapshot', params: [] })); @@ -190,7 +189,7 @@ export class Web3Wrapper { } /** * Revert the blockchain state to a previous snapshot state on TestRPC/Ganache local node - * @param snapshotId snapshot Id to revert to + * @param snapshotId snapshot id to revert to * @returns Whether the revert was successful */ public async revertSnapshotAsync(snapshotId: number): Promise { @@ -242,7 +241,7 @@ export class Web3Wrapper { /** * Get a Web3 contract factory instance for a given ABI * @param abi Smart contract ABI - * @returns Web3 contract factory which can create Web3 Contract instances for the supplied ABI + * @returns Web3 contract factory which can create Web3 Contract instances from the supplied ABI */ public getContractFromAbi(abi: Web3.ContractAbi): Web3.Contract { const web3Contract = this._web3.eth.contract(abi); @@ -260,7 +259,7 @@ export class Web3Wrapper { /** * Call a smart contract method at a given block height * @param callData Call data - * @param defaultBlock Block height at which to make the call + * @param defaultBlock Block height at which to make the call. Defaults to `latest` * @returns The raw call result */ public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise { -- cgit From 38f716bd77c46e55ad117cfef8cb42474e61a7c0 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 22:24:26 +0000 Subject: Make docs link more discoverable in README, move docs out of README --- packages/web3-wrapper/README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/README.md b/packages/web3-wrapper/README.md index 244e20708..c63982703 100644 --- a/packages/web3-wrapper/README.md +++ b/packages/web3-wrapper/README.md @@ -1,6 +1,8 @@ ## @0xproject/web3-wrapper -Wrapped version of web3 with a nicer interface that is used across 0x projects and packages. Visit [the docs](0xproject.com/docs/web3_wrapper). +Wrapped version of web3 with a nicer interface that is used across 0x projects and packages. + +### Read the [ Documentation](0xproject.com/docs/web3_wrapper). ## Installation @@ -16,16 +18,6 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol ] ``` -## Usage - -```typescript -import {Web3Wrapper} from '@0xproject/web3-wrapper'; - -const web3 = ...; -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); -``` - ## Contributing We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. -- cgit From 07fa01528b5b5febf6852fb439a41c0e892cf830 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 21 Mar 2018 12:32:53 +0000 Subject: Move usage out of README and add add link to docs --- packages/web3-wrapper/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/README.md b/packages/web3-wrapper/README.md index c63982703..1fed11407 100644 --- a/packages/web3-wrapper/README.md +++ b/packages/web3-wrapper/README.md @@ -2,7 +2,7 @@ Wrapped version of web3 with a nicer interface that is used across 0x projects and packages. -### Read the [ Documentation](0xproject.com/docs/web3_wrapper). +### Read the [Documentation](0xproject.com/docs/web3_wrapper). ## Installation -- cgit