aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'packages/migrations/src/utils')
-rw-r--r--packages/migrations/src/utils/artifact_writer.ts26
-rw-r--r--packages/migrations/src/utils/constants.ts16
-rw-r--r--packages/migrations/src/utils/provider_factory.ts33
3 files changed, 75 insertions, 0 deletions
diff --git a/packages/migrations/src/utils/artifact_writer.ts b/packages/migrations/src/utils/artifact_writer.ts
new file mode 100644
index 000000000..2da5a09dd
--- /dev/null
+++ b/packages/migrations/src/utils/artifact_writer.ts
@@ -0,0 +1,26 @@
+import { BaseContract } from '@0xproject/base-contract';
+import { ContractArtifact } from '@0xproject/sol-compiler';
+import * as fs from 'fs';
+import * as path from 'path';
+
+export class ArtifactWriter {
+ private _artifactsDir: string;
+ private _networkId: number;
+ constructor(artifactsDir: string, networkId: number) {
+ this._artifactsDir = artifactsDir;
+ this._networkId = networkId;
+ }
+ // This updates the artifact file but does not update the `artifacts` module above. It will not
+ // contain the saved artifact changes.
+ public saveArtifact(contract: BaseContract): void {
+ const contractName = contract.contractName;
+ const artifactFile = path.join(this._artifactsDir, `${contractName}.json`);
+ const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFile).toString());
+ artifact.networks[this._networkId] = {
+ address: contract.address,
+ links: {},
+ constructorArgs: JSON.stringify(contract.constructorArgs),
+ };
+ fs.writeFileSync(artifactFile, JSON.stringify(artifact, null, '\t'));
+ }
+}
diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts
new file mode 100644
index 000000000..068122e28
--- /dev/null
+++ b/packages/migrations/src/utils/constants.ts
@@ -0,0 +1,16 @@
+import { BigNumber } from '@0xproject/utils';
+
+export const constants = {
+ ASSET_PROXY_OWNER_OWNERS: [
+ '0x9df8137872ac09a8fee71d0da5c7539923fb9bf0',
+ '0xcf34d44db312d188789f43a63d11cf2bebb4da15',
+ '0x73fd50f2a6beac9cdac9fe87ef68a18edc415831',
+ ],
+ ASSET_PROXY_OWNER_TIMELOCK: new BigNumber(0),
+ ASSET_PROXY_OWNER_CONFIRMATIONS: new BigNumber(1),
+ ERC20_PROXY_ID: '0xf47261b0',
+ ERC721_PROXY_ID: '0x08e937fa',
+ NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
+ RPC_URL: 'http://localhost:8545',
+ KOVAN_NETWORK_ID: 42,
+};
diff --git a/packages/migrations/src/utils/provider_factory.ts b/packages/migrations/src/utils/provider_factory.ts
new file mode 100644
index 000000000..7a217b1e0
--- /dev/null
+++ b/packages/migrations/src/utils/provider_factory.ts
@@ -0,0 +1,33 @@
+import { LedgerEthereumClient, LedgerSubprovider } from '@0xproject/subproviders';
+import Eth from '@ledgerhq/hw-app-eth';
+// tslint:disable:no-implicit-dependencies
+import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
+import { Provider } from 'ethereum-types';
+import ProviderEngine = require('web3-provider-engine');
+import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
+
+import { constants } from './constants';
+
+async function ledgerEthereumNodeJsClientFactoryAsync(): Promise<LedgerEthereumClient> {
+ const ledgerConnection = await TransportNodeHid.create();
+ const ledgerEthClient = new Eth(ledgerConnection);
+ return ledgerEthClient;
+}
+export const providerFactory = {
+ async getLedgerProviderAsync(): Promise<Provider> {
+ const provider = new ProviderEngine();
+ const ledgerWalletConfigs = {
+ networkId: constants.KOVAN_NETWORK_ID,
+ ledgerEthereumClientFactoryAsync: ledgerEthereumNodeJsClientFactoryAsync,
+ };
+ const ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs);
+ provider.addProvider(ledgerSubprovider);
+ provider.addProvider(
+ new RpcSubprovider({
+ rpcUrl: constants.RPC_URL,
+ }),
+ );
+ provider.start();
+ return provider;
+ },
+};