Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
first pass at including doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xianny committed Jul 30, 2019
1 parent 46384ce commit fe579be
Show file tree
Hide file tree
Showing 30 changed files with 4,332 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/abi-gen-templates/contract.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export enum {{contractName}}Events {
// tslint:disable-next-line:class-name
export class {{contractName}}Contract extends BaseContract {
{{#each methods}}
{{#if this.devdoc.details}}
/**
* {{formatDocstringForMethodTs this.devdoc.details}}
*/
{{/if}}
{{#this.constant}}
{{> call contractName=../contractName}}
{{/this.constant}}
Expand Down
12 changes: 12 additions & 0 deletions packages/abi-gen-templates/partials/callAsync.handlebars
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Calls the method
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
{{#if devdoc.return}}
* @returns {{devdoc.return}}
{{/if}}
*/
async callAsync(
{{> typed_params inputs=inputs}}
callData: Partial<CallData> = {},
Expand Down Expand Up @@ -34,6 +41,11 @@ async callAsync(
// tslint:enable boolean-naming
return result;
},

/**
* Returns the ABI encoded transaction data
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
*/
getABIEncodedTransactionData(
{{> typed_params inputs=inputs}}
): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#each inputs}}
{{#if (getDocstringForParamTs name ../docstrings)}}
* @param {{name}} {{getDocstringForParamTs name ../docstrings}}
{{/if}}
{{/each}}
19 changes: 19 additions & 0 deletions packages/abi-gen-templates/partials/tx.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
public {{languageSpecificName}} = {
/**
* Sends the transaction
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @returns The hash of the transaction
*/
async sendTransactionAsync(
{{> typed_params inputs=inputs}}
txData?: Partial<TxData> | undefined,
Expand Down Expand Up @@ -27,6 +33,13 @@ public {{languageSpecificName}} = {
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
},
/**
* Sends the transaction and wait for it to succeed
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @param pollingIntervalMs Interval at which to poll for success
* @returns A promise that resolves when the transaction is successful
*/
awaitTransactionSuccessAsync(
{{> typed_params inputs=inputs}}
txData?: Partial<TxData>,
Expand Down Expand Up @@ -54,6 +67,12 @@ public {{languageSpecificName}} = {
})(),
);
},
/**
* Estimate gas to send the transaction
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
* @param txData Additional data for transaction
* @returns The hash of the transaction
*/
async estimateGasAsync(
{{> typed_params inputs=inputs}}
txData?: Partial<TxData> | undefined,
Expand Down
5 changes: 5 additions & 0 deletions packages/abi-gen-wrappers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ yarn lint
```bash
yarn test
```

### Reading Documentation

Documentation for this package is generated by TypeDoc, using the Solidity source code for 0x contracts. Each contract corresponds to one global-level module, which contains relevant enums and interfaces for its events and structs. Most significantly, each module exports a class, `<ContractName>Contract`, e.g. `ExchangeContract`, which implements helper methods for all the functions defined in the corresponding contract.
A convention to note is that these contract-specific helper methods are defined as _object literals_, which are separated from methods in the generated documentation. Each contract method has a number of sub-methods, e.g. `sendTransactionAsync`, or `estimateGasAsync`, which are documented separately. This is an example of an expected method call signature: `exchangeContractInstance.fillOrder.sendTransactionAsync(...arguments)`.
3 changes: 2 additions & 1 deletion packages/abi-gen-wrappers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"prettier": "prettier --write src/**/* --config ../../.prettierrc",
"prettier_contract_wrappers": "prettier --write src/generated-wrappers/* --config ../../.prettierrc",
"clean": "shx rm -rf lib src/generated-wrappers",
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers",
"docs": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --out generated_docs ./src/generated-wrappers/*"
},
"config": {
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IAssetProxy|IValidator|IWallet|MultiAssetProxy|OrderValidator|WETH9|ZRXToken|Coordinator|CoordinatorRegistry|EthBalanceChecker).json"
Expand Down
Loading

0 comments on commit fe579be

Please sign in to comment.