aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/scripts/testrpc.ts43
-rw-r--r--packages/contracts/src/utils/constants.ts22
-rw-r--r--packages/contracts/src/utils/utils.ts7
3 files changed, 72 insertions, 0 deletions
diff --git a/packages/contracts/scripts/testrpc.ts b/packages/contracts/scripts/testrpc.ts
new file mode 100644
index 000000000..8379cc69c
--- /dev/null
+++ b/packages/contracts/scripts/testrpc.ts
@@ -0,0 +1,43 @@
+import * as testrpc from 'ganache-cli';
+import * as _ from 'lodash';
+
+import { constants } from '../src/utils/constants';
+import { utils } from '../src/utils/utils';
+
+const opts = {
+ accounts: constants.TESTRPC_ACCOUNTS,
+};
+
+const server = testrpc.server(opts);
+
+server.listen(constants.TESTRPC_PORT, (err: any, result: any) => {
+ if (err) {
+ utils.consoleLog(err);
+ return;
+ }
+
+ const state = result ? result : server.provider.manager.state;
+
+ utils.consoleLog('');
+ utils.consoleLog('Available Accounts');
+ utils.consoleLog('==================');
+
+ const accounts = state.accounts;
+ const addresses = _.keys(accounts);
+
+ _.forEach(addresses, (address, index) => {
+ const line = `(${index}) ${address}`;
+ utils.consoleLog(line);
+ });
+
+ utils.consoleLog('');
+ utils.consoleLog('Private Keys');
+ utils.consoleLog('==================');
+
+ _.forEach(addresses, (address, index) => {
+ utils.consoleLog(`(${index}) ${accounts[address].secretKey.toString('hex')}`);
+ });
+
+ utils.consoleLog('');
+ utils.consoleLog('Listening on localhost:' + constants.TESTRPC_PORT);
+});
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index d1152e683..09dd65653 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -1,3 +1,5 @@
+import * as ethUtil from 'ethereumjs-util';
+
const DUMMY_TOKEN_NAME = '';
const DUMMY_TOKEN_SYMBOL = '';
const DUMMY_TOKEN_DECIMALS = 18;
@@ -11,4 +13,24 @@ export const constants = {
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
MAX_TOKEN_APPROVE_GAS: 60000,
DUMMY_TOKEN_ARGS: [DUMMY_TOKEN_NAME, DUMMY_TOKEN_SYMBOL, DUMMY_TOKEN_DECIMALS, DUMMY_TOKEN_TOTAL_SUPPLY],
+ TESTRPC_PORT: 8545,
+ TESTRPC_INITIAL_BALANCE_HEX: parseInt('100000000000000000000', 16),
+ TESTRPC_ACCOUNTS: [
+ {
+ balance: this.TESTRPC_INITIAL_BALANCE_HEX,
+ secretKey: ethUtil.sha3('secret0'),
+ },
+ {
+ balance: this.TESTRPC_INITIAL_BALANCE_HEX,
+ secretKey: ethUtil.sha3('secret1'),
+ },
+ {
+ balance: this.TESTRPC_INITIAL_BALANCE_HEX,
+ secretKey: ethUtil.sha3('secret2'),
+ },
+ {
+ balance: this.TESTRPC_INITIAL_BALANCE_HEX,
+ secretKey: ethUtil.sha3('secret3'),
+ },
+ ],
};
diff --git a/packages/contracts/src/utils/utils.ts b/packages/contracts/src/utils/utils.ts
new file mode 100644
index 000000000..04ac36b54
--- /dev/null
+++ b/packages/contracts/src/utils/utils.ts
@@ -0,0 +1,7 @@
+export const utils = {
+ consoleLog(message: string): void {
+ /* tslint:disable */
+ console.log(message);
+ /* tslint:enable */
+ },
+};