Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #35 from jstefanski/feature/wallet
Browse files Browse the repository at this point in the history
Tips Wallet
  • Loading branch information
biern authored Dec 10, 2017
2 parents 15fc9a2 + 748887e commit ced0929
Show file tree
Hide file tree
Showing 47 changed files with 15,362 additions and 1,139 deletions.
65 changes: 1 addition & 64 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
# IDEA
.idea/

# Contracts cache
.cache

# tsc generated files
*.map
# Compiled JS
*.js

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
74 changes: 37 additions & 37 deletions bin/seed.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
#!/usr/bin/env node

import { join } from 'path';
import { Logger, transports } from 'winston';

import { promisify } from '../utils';

import * as Web3 from 'web3';
import * as Config from 'truffle-config';
import * as TestRPC from 'ethereumjs-testrpc';
import * as Migrate from 'truffle-migrate';
import * as Resolver from 'truffle-resolver';
import * as mkdirp from 'mkdirp';
import * as Artifactor from 'truffle-artifactor';
import * as Compile from 'truffle-compile';
import * as mkdirp from 'mkdirp';
import * as Config from 'truffle-config';
import * as Migrate from 'truffle-migrate';
import * as Resolver from 'truffle-resolver';
import * as Web3 from 'web3';

(async function() {
const logger = new Logger({
colors: {
error: 'red',
info: 'blue',
verbose: 'grey',
warn: 'yellow'
},
transports: [
new transports.Console({
colorize: true,
prettyPrint: true,
timestamp: true
})
]
});

(async () => {
const config = configure();

await compileContracts(config);
Expand All @@ -21,7 +40,7 @@ import * as mkdirp from 'mkdirp';
await setupNetwork(config, deployer);
await migrate(config);
})().catch(err => {
console.error(err);
logger.error(err);
process.exit(1);
});

Expand All @@ -46,7 +65,7 @@ function configure(): Config {
}

async function compileContracts(config: Config) {
logStep(`Compiling contracts: ${config.contracts_directory}`);
logger.info(`Compiling contracts: ${config.contracts_directory}`);

const contracts = await promisify<Compile.ContractDefinitions>(cb =>
Compile.all(config, cb)
Expand All @@ -55,29 +74,29 @@ async function compileContracts(config: Config) {
await promisify<any>(cb => mkdirp(config.contracts_build_directory, cb));
await config.artifactor.saveAll(contracts);

console.log(`Saved to: ${config.contracts_build_directory}`);
logger.verbose(`Saved to: ${config.contracts_build_directory}`);
}

async function startTestRPC(port: number): Promise<TestRPC.State> {
logStep(`Starting TestRPC on port ${port}`);
logger.info(`Starting TestRPC on port ${port}`);

const options = {
secure: false,
logger: console,
mnemonic:
'try exile adapt shed width laugh similar duty neglect kick rug require',
logger: console
secure: false
};

const server = TestRPC.server(options);
const state = await promisify<TestRPC.State>(cb => server.listen(port, cb));

console.log(`Account mnemonic: ${options.mnemonic}`);
logger.verbose(`Account mnemonic: ${options.mnemonic}`);

return state;
}

async function setupNetwork(config: Config, deployer: Address) {
logStep(`Setting up network ${config.network}`);
logger.info(`Setting up network ${config.network}`);

const web3 = new Web3(config.provider);
const networkId = await promisify<string>(cb => web3.version.getNetwork(cb));
Expand All @@ -86,33 +105,14 @@ async function setupNetwork(config: Config, deployer: Address) {
networkConfig.network_id = networkId;
networkConfig.from = deployer;

console.log(`Using network: ${config.network} (${networkId})`);
console.log(`Using deployer: ${deployer}`);
logger.verbose(`Using network: ${config.network} (${networkId})`);
logger.verbose(`Using deployer: ${deployer}`);
}

async function migrate(config: Config) {
logStep(`Running migrations: ${config.migrations_directory}`);
logger.info(`Running migrations: ${config.migrations_directory}`);

await promisify<void>(cb => Migrate.run(config, cb));

logStep('Migrations completed');
}

function promisify<T>(fn: (cb: Callback<T>) => void) {
return new Promise<T>((resolve, reject) =>
fn((err: Error | null, res: T) => {
if (err) {
return reject(err);
}

return resolve(res);
})
);
}

function logStep(description: string) {
console.log();
console.log(Array(79).join('-'));
console.log(description);
console.log(Array(79).join('-'));
logger.info('Migrations completed');
}
10 changes: 5 additions & 5 deletions build/contracts/AddressSet.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 692,
"referencedDeclaration": 1501,
"type": "function (bool) pure",
"value": "require"
},
Expand Down Expand Up @@ -1390,7 +1390,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 692,
"referencedDeclaration": 1501,
"type": "function (bool) pure",
"value": "require"
},
Expand Down Expand Up @@ -4149,7 +4149,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 680,
"referencedDeclaration": 1489,
"type": "function (bool) pure",
"value": "assert"
},
Expand Down Expand Up @@ -4443,7 +4443,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 680,
"referencedDeclaration": 1489,
"type": "function (bool) pure",
"value": "assert"
},
Expand Down Expand Up @@ -4610,5 +4610,5 @@
},
"networks": {},
"schemaVersion": "1.0.1",
"updatedAt": "2017-11-16T23:38:29.113Z"
"updatedAt": "2017-12-09T23:00:14.493Z"
}
8 changes: 4 additions & 4 deletions build/contracts/Migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 689,
"referencedDeclaration": 1498,
"type": "msg",
"value": "msg"
},
Expand Down Expand Up @@ -363,7 +363,7 @@
"overloadedDeclarations": [
null
],
"referencedDeclaration": 689,
"referencedDeclaration": 1498,
"type": "msg",
"value": "msg"
},
Expand Down Expand Up @@ -823,5 +823,5 @@
},
"networks": {},
"schemaVersion": "1.0.1",
"updatedAt": "2017-11-16T23:38:29.962Z"
}
"updatedAt": "2017-12-09T23:00:14.494Z"
}
Loading

0 comments on commit ced0929

Please sign in to comment.