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
#include <eosiolib/eosio.hpp> | |
namespace eosio { | |
class voting : public eosio::contract { | |
/// @abi table candidates i64 | |
struct candidate { | |
uint64_t id; | |
account_name name; | |
auto primary_key() const { return id; } |
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
// Execute the encoded function in the specified contract | |
function executeCall(address to, uint256 value, bytes data) | |
internal | |
returns (bool success) | |
{ | |
assembly { | |
success := call(gas, to, value, add(data, 0x20), mload(data), 0, 0) | |
} | |
} |
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
'use strict'; | |
const WEB3_URL = process.env.WEB3_URL; | |
const prom = require('util').promisify; | |
const ethABI = require('ethereumjs-abi'); | |
const Web3 = require('web3'); | |
const provider = new Web3.providers.HttpProvider(WEB3_URL); | |
const web3 = module.exports = new Web3(provider); | |
const sendAsync = prom(web3.currentProvider.sendAsync).bind(web3.currentProvider); |
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
// Forecasting -> Forecasting finished | |
if (state === forecasting && forecastingEndTimestamp < block.timestamp) { | |
switch state -> forecasting_finished; | |
} | |
// Forecasting completed -> Crowdfunding deadline missed | |
if (state === forecasting_completed && forecastingEndTimestamp < (block.timestamp - secondsInDay * crowdsaleStartTimeout)) { | |
switch state -> crowdfunding_deadline_missed; | |
} |