Skip to content

Instantly share code, notes, and snippets.

View kristjank's full-sized avatar
💻
...

Kristjan Kosic kristjank

💻
...
View GitHub Profile
@kristjank
kristjank / clone.sh
Created June 7, 2018 04:59
bash plugin
bash
git clone https://github.com/ArkEcosystem/core-plugin-skeleton your-plugin-name
cd your-plugin-name
yarn install
@kristjank
kristjank / paskage.json
Created June 7, 2018 05:00
json definition
{
"name": "@vendor/your-plugin-name",
"description": "This plugin provides X for ARK Core 2.0",
}
@kristjank
kristjank / twillio-setup.js
Last active June 7, 2018 05:02
Setting up the Twilio Client
const twilio = require('twilio')
const util = require('util')
const container = require('@arkecosystem/core-container')
const logger = container.resolvePlugin('logger')
module.exports = class Twilio {
constructor(options) {
this.client = twilio(options.accountSid, options.authToken)
this.options = options
}
@kristjank
kristjank / event-listener.js
Created June 7, 2018 05:02
event-listener
'use strict'
const container = require('@arkecosystem/core-container')
const emitter = container.resolvePlugin('event-emitter')
class Listener {
setUp(options, twilio) {
emitter.on('forging.missing', data => {
if (data.delegate.publicKey === options.publicKey) {
twilio.sendMessage(data.delegate, data.block)
}
})
@kristjank
kristjank / set-plugin.js
Last active June 7, 2018 05:03
setting up plugin
'use strict'
const listener = require('./listener')
const Twilio = require('./twilio')
exports.plugin = {
pkg: require('../package.json'),
register: async (container, options) => {
logger.info('[Monitor] Waiting for Missed Blocks')
listener.setUp(options, new Twilio(options.twilio))
}
@kristjank
kristjank / register.js
Created June 7, 2018 05:04
register plugin
module.exports = {
'@arkecosystem/core-event-emitter': {},
'@arkecosystem/core-config': {},
'@arkecosystem/core-logger': {},
...
'@vendor/your-plugin-name': {
publicKey: 'your-delegate-public-key',
twilio: {
body: '%s is missing',
to: '+12345678901',
{
"name": "devnet",
"messagePrefix": "DARK message:\n",
"bip32": {
"public": 46090600,
"private": 46089520
},
"pubKeyHash": 30,
"nethash": "578e820911f24e039733b45e4882b73e301f813a0d2c31330dafda84534ffa23",
"wif": 170,
@kristjank
kristjank / Dynamic fee calculation.js
Last active September 24, 2018 08:43
Dynamic Fees
/** Calculates delegate fee for processing and forging if transaction
* @param {Number} Fee price per byte in ARKTOSHI as set by forger/delegate in delegate.json setting feeMultiplier
* @param {Transaction} Transaction for which we calculate dynamic fee
* @returns {Number} Calculated dynamic fee in ARKTOSHI
*/
calculateFee (feeMultiplier, transaction) {
if (feeMultiplier <= 0) {
feeMultiplier = 1
}
@kristjank
kristjank / Transaction payload - type transfer.json
Created September 24, 2018 09:52
Transaction payload - type transfer.json
// dynamic transaction payload
{
"verified":true,
"id":"afaa18bfc29762b7b5172fa1f71ea7471c0d9e6dcf2992638865ecb4b3d1f26b",
"version":1,
"timestamp":47674390,
"senderPublicKey":"03d7dfe44e771039334f4712fb95ad355254f674c8f5d286503199157b7bf7c357",
"recipientId":"DBm8ZgZvaDhgba9jyFNVwDGD8ysbN3w8Tv",
"type":0,
"vendorFieldHex":"5449443a2030",
@kristjank
kristjank / Transaction payload - serialised.json
Created September 24, 2018 09:56
Serialised transaction
// serialised transaction Transfer
// serialised.length = 160
{"serialized":
{
"type":"Buffer",
"data":[255,1,30,0,22,116,215,2,3,215,223,228,78,119,16,57,51,79,71,18,251,149,173,53,82,84,246,116,200,245,210,134,80,49,153,21,123,123,247,195,87,14,1,0,0,0,0,0,0,6,84,73,68,58,32,48,0,194,235,11,0,0,0,0,15,0,0,0,30,72,161,107,90,67,151,232,118,184,105,194,229,52,233,123,39,157,230,102,177,48,68,2,32,69,177,255,192,154,14,176,62,80,182,75,185,130,144,48,143,68,177,152,153,1,75,93,101,109,175,41,10,149,220,23,79,2,32,15,59,8,76,121,202,240,45,147,56,172,137,149,29,183,136,156,137,156,69,81,149,205,254,98,22,126,19,61,71,244,227]
}
}