Last active
August 27, 2019 13:20
-
-
Save jondubois/a6b21c1b3f77101de0809f0b9e0c6298 to your computer and use it in GitHub Desktop.
capitalisk-installation-on-lisk-node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Application } from 'lisk-sdk'; | |
import { | |
DappTransaction, | |
InTransferTransaction, | |
OutTransferTransaction, | |
} from './transactions'; | |
import attachInterchain from 'lisk-interchain'; | |
import CapitaliskModule from 'capitalisk'; | |
import CapitaliskHTTPAPI from 'capitalisk-http-api'; | |
try { | |
/** | |
* We have to keep it in try/catch block as it can throw | |
* exception while validating the configuration | |
*/ | |
// tslint:disable-next-line no-require-imports no-var-requires | |
const { config } = require('./helpers/config'); | |
const { NETWORK } = config; | |
// tslint:disable-next-line no-var-requires | |
const genesisBlock = require(`../config/${NETWORK}/genesis_block.json`); | |
const app = new Application(genesisBlock, config); | |
app.registerTransaction(DappTransaction, { | |
matcher: context => | |
context.blockHeight < | |
app.config.modules.chain.exceptions.precedent.disableDappTransaction, | |
}); | |
app.registerTransaction( | |
InTransferTransaction, | |
{ | |
matcher: context => | |
context.blockHeight < | |
app.config.modules.chain.exceptions.precedent.disableDappTransfer, | |
} | |
); | |
app.registerTransaction( | |
OutTransferTransaction, | |
{ | |
matcher: context => | |
context.blockHeight < | |
app.config.modules.chain.exceptions.precedent.disableDappTransfer, | |
} | |
); | |
// START CUSTOM CODE | |
app.registerModule(CapitaliskModule, { registeredTransactions: app.getTransactions() }); | |
app.registerModule(CapitaliskHTTPAPI); | |
attachInterchain(app); | |
// END CUSTOM CODE | |
app | |
.run() | |
.then(() => app.logger.info('App started...')) | |
.catch(error => { | |
if (error instanceof Error) { | |
app.logger.error('App stopped with error', error.message); | |
app.logger.debug(error.stack); | |
} else { | |
app.logger.error('App stopped with error', error); | |
} | |
process.exit(); | |
}); | |
} catch (e) { | |
// tslint:disable-next-line no-console | |
console.error('Application start error.', e); | |
process.exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment