aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-24 02:18:31 +0800
committerGitHub <noreply@github.com>2018-03-24 02:18:31 +0800
commitf30353087f9c4ec4fa5e096a065c9749e1164984 (patch)
tree4d7968160890b5efa358593e743411c7b8652556 /packages/deployer
parent7ef6bd4b14b7502617c6929010d4a9991e1d577d (diff)
parentbed7d87b7ff64989051e6b2115a1c77e1e72ff55 (diff)
downloaddexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.gz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.bz2
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.lz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.xz
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.tar.zst
dexon-sol-tools-f30353087f9c4ec4fa5e096a065c9749e1164984.zip
Merge branch 'development' into feature/deployer-improvements
Diffstat (limited to 'packages/deployer')
-rw-r--r--packages/deployer/README.md62
-rw-r--r--packages/deployer/package.json16
-rw-r--r--packages/deployer/src/compiler.ts6
-rw-r--r--packages/deployer/src/deployer.ts16
-rw-r--r--packages/deployer/src/monorepo_scripts/stage_docs.ts8
5 files changed, 56 insertions, 52 deletions
diff --git a/packages/deployer/README.md b/packages/deployer/README.md
index 9abcfa6fe..8fe82f59e 100644
--- a/packages/deployer/README.md
+++ b/packages/deployer/README.md
@@ -2,66 +2,34 @@
This repository contains a CLI tool that facilitates compiling and deployment of smart contracts.
+### Read the [Documentation](0xproject.com/docs/deployer).
+
## Installation
+#### CLI Installation
+
```bash
-yarn add @0xproject/deployer
+yarn global add @0xproject/deployer
```
-## Usage
-
-### CLI Usage
+#### API Installation
```bash
-node ./node_modules/@0xproject/deployer/lib/cli.js --help
-cli.js [command]
-
-Commands:
- cli.js compile compile contracts
- cli.js deploy deploy a single contract with provided arguments
-
-Options:
- --version Show version number [boolean]
- --contracts-dir path of contracts directory to compile
- [string] [default: "/Users/leonidlogvinov/Dev/0x/contracts"]
- --network-id mainnet=1, kovan=42, testrpc=50 [number] [default: 50]
- --should-optimize enable optimizer [boolean] [default: false]
- --artifacts-dir path to write contracts artifacts to
- [string] [default: "/Users/leonidlogvinov/Dev/0x/build/artifacts/"]
- --jsonrpc-port port connected to JSON RPC [number] [default: 8545]
- --gas-price gasPrice to be used for transactions
- [string] [default: "2000000000"]
- --account account to use for deploying contracts [string]
- --help Show help [boolean]
+yarn add @0xproject/deployer
```
-### API Usage
-
-## Migrations
-
-You might want to write a migration scripts (similar to `truffle migrate`), that deploys multiple contracts and configures them. Below you'll find a simple example of such a script to help you get started.
+**Import**
```typescript
-import { Deployer } from '@0xproject/deployer';
-import * as path from 'path';
-
-const deployerOpts = {
- artifactsDir: path.resolve('src', 'artifacts'),
- jsonrpcUrl: 'http://localhost:8545',
- networkId: 50,
- defaults: {
- gas: 1000000,
- },
-};
-
-const deployer = new Deployer(deployerOpts);
-
-(async () => {
- const etherToken = await deployer.deployAndSaveAsync('WETH9');
-})().catch(console.log);
+import { Deployer, Compiler } from '@0xproject/deployer';
```
-A more sophisticated example can be found [here](https://github.com/0xProject/0x-monorepo/tree/development/packages/contracts/migrations)
+or
+
+```javascript
+var Deployer = require('@0xproject/deployer').Deployer;
+var Compiler = require('@0xproject/deployer').Compiler;
+```
## Contributing
diff --git a/packages/deployer/package.json b/packages/deployer/package.json
index 3f0613677..a8b847cd0 100644
--- a/packages/deployer/package.json
+++ b/packages/deployer/package.json
@@ -15,7 +15,20 @@
"clean": "shx rm -rf lib scripts",
"migrate": "npm run build; node lib/src/cli.js migrate",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
- "test:circleci": "yarn test:coverage"
+ "test:circleci": "yarn test:coverage",
+ "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"
+ },
+ "config": {
+ "postpublish": {
+ "assets": [],
+ "docPublishConfigs": {
+ "extraFileIncludes": ["../types/src/index.ts"],
+ "s3BucketPath": "s3://doc-jsons/deployer/",
+ "s3StagingBucketPath": "s3://staging-doc-jsons/deployer/"
+ }
+ }
},
"bin": {
"0x-deployer": "lib/src/cli.js"
@@ -46,6 +59,7 @@
"shx": "^0.2.2",
"tslint": "5.8.0",
"types-bn": "^0.0.1",
+ "typedoc": "0xProject/typedoc",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.10.2"
},
diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts
index 712169c89..1f521dca1 100644
--- a/packages/deployer/src/compiler.ts
+++ b/packages/deployer/src/compiler.ts
@@ -33,6 +33,10 @@ import { utils } from './utils/utils';
const ALL_CONTRACTS_IDENTIFIER = '*';
+/**
+ * The Compiler facilitates compiling Solidity smart contracts and saves the results
+ * to artifact files.
+ */
export class Compiler {
private _contractsDir: string;
private _networkId: number;
@@ -96,7 +100,7 @@ export class Compiler {
this._specifiedContracts = opts.specifiedContracts;
}
/**
- * Compiles selected Solidity files and writes JSON artifacts to artifactsDir.
+ * Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`.
*/
public async compileAsync(): Promise<void> {
await createArtifactsDirIfDoesNotExistAsync(this._artifactsDir);
diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts
index 6c247d328..68518a931 100644
--- a/packages/deployer/src/deployer.ts
+++ b/packages/deployer/src/deployer.ts
@@ -19,12 +19,21 @@ import { utils } from './utils/utils';
// Gas added to gas estimate to make sure there is sufficient gas for deployment.
const EXTRA_GAS = 200000;
+/**
+ * The Deployer facilitates deploying Solidity smart contracts to the blockchain.
+ * It can be used to build custom migration scripts.
+ */
export class Deployer {
public web3Wrapper: Web3Wrapper;
private _artifactsDir: string;
private _networkId: number;
private _defaults: Partial<TxData>;
+ /**
+ * Instantiate a new instance of the Deployer class.
+ * @param opts Deployer options, including either an RPC url or Provider instance.
+ * @returns A Deployer instance
+ */
constructor(opts: DeployerOptions) {
this._artifactsDir = opts.artifactsDir;
this._networkId = opts.networkId;
@@ -42,8 +51,8 @@ export class Deployer {
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
}
/**
- * Loads contract artifact and deploys contract with given arguments.
- * @param contractName Name of the contract to deploy. Must match name of an artifact in artifacts directory.
+ * Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments.
+ * @param contractName Name of the contract to deploy. Must match name of an artifact in supplied artifacts directory.
* @param args Array of contract constructor arguments.
* @return Deployed contract instance.
*/
@@ -80,7 +89,8 @@ export class Deployer {
return contractInstance;
}
/**
- * Loads contract artifact, deploys with given arguments, and saves updated data to artifact.
+ * Loads a contract's artifact, deploys it with supplied constructor arguments, and saves the updated data
+ * back to the artifact file.
* @param contractName Name of the contract to deploy. Must match name of an artifact in artifacts directory.
* @param args Array of contract constructor arguments.
* @return Deployed contract instance.
diff --git a/packages/deployer/src/monorepo_scripts/stage_docs.ts b/packages/deployer/src/monorepo_scripts/stage_docs.ts
new file mode 100644
index 000000000..e732ac8eb
--- /dev/null
+++ b/packages/deployer/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);