diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-02 17:12:01 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-02 17:12:01 +0800 |
commit | de9f0732a09893f035ce8a7e8e01fa1141882a3a (patch) | |
tree | 63d1f0bbc6f9d65576e5d12b379378700eb88567 /packages/migrations/src/utils | |
parent | 20acdbf6c3ba6a62e87a9a496021cb6482c0c03a (diff) | |
parent | b9b00e10d39c3c84bc72892ef37f1313e904414d (diff) | |
download | dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.gz dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.bz2 dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.lz dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.xz dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.tar.zst dexon-sol-tools-de9f0732a09893f035ce8a7e8e01fa1141882a3a.zip |
Merge branch 'v2-prototype' into fix/five_decimal_scenario
* v2-prototype: (75 commits)
Update relayer grid tiles to use Text
Fix build
Update file structure
Update 2.0.0 artifacts
Move ledgerhq module declarations to typescript-typings
Export LedgerEthereumClient type in subproviders
Update artifacts
Add logging and updated artifacts
Fix migrations
Run prettier
Add Kovan artifacts
Use ledger subprovider
Add Kovan migrations
Remove state variable from Link component in Portal
Make registerAssetProxy append only
Update staging api link
Change getTransactionReceipt to awaitTransactionMined
Move /docs route to the end
Remove extra call to scrollIntoView for wallet in onboarding
Update expectRevertReasonOrAlwaysFailingTransactionAsync to check status codes
...
Diffstat (limited to 'packages/migrations/src/utils')
-rw-r--r-- | packages/migrations/src/utils/artifact_writer.ts | 26 | ||||
-rw-r--r-- | packages/migrations/src/utils/constants.ts | 16 | ||||
-rw-r--r-- | packages/migrations/src/utils/provider_factory.ts | 33 |
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; + }, +}; |