You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.0 KiB
57 lines
2.0 KiB
const useCapture = false; // capture, bubbling: false
|
|
|
|
button = document.getElementsByTagName('button')[0];
|
|
button.addEventListener('click',genesis,false);
|
|
console.log(button)
|
|
var payload = 'QmVnvdASdT1c9fJ2mcDhTAYhb63gcFRkiRmJW7NAm1YcSf';
|
|
//var txcoinhash = 'ZCBtx7Wg59hvMogWDchKVcGUMo68qDe2dkRfzaskAh3G';
|
|
//var prevhash = 'Z9BEeWD4Mww7yrXyPRXrfM2y6FxsQGfaNPzC8DxWq4ATq';
|
|
var pow = '11501558695957493006';
|
|
var comment = 'Genesis ~ Manuela J. Savina';
|
|
|
|
// get default values (from nodes) ...
|
|
let promised_config = fetch(api_url + 'config').
|
|
then(resp => resp.json()).
|
|
then(obj => { return obj.config }).
|
|
catch(console.error)
|
|
|
|
let promised_nullhash = fetch(api_url + 'getjson?obj=Genesis::nullhash').
|
|
then(resp => resp.json()).
|
|
then(obj => { console.log('promised_nullhash.obj:',obj)
|
|
return obj;
|
|
}).
|
|
catch(console.error);
|
|
|
|
Promise.all([promised_config, promised_nullhash]).then( _ => {
|
|
let [config,nullhash] = _;
|
|
console.log('genesis.config:',config);
|
|
document.getElementsByName('payload')[0].value = payload;
|
|
document.getElementsByName('txcoinhash')[0].value = config.txcoin;
|
|
document.getElementsByName('prevhash')[0].value = nullhash;
|
|
document.getElementsByName('pow')[0].value = pow;
|
|
document.getElementsByName('comment')[0].value = comment;
|
|
}).catch(console.error);
|
|
|
|
|
|
function genesis(ev) {
|
|
console.log('genesis.ev: %o',ev);
|
|
let query = {
|
|
"payload": document.getElementsByName('payload')[0].value,
|
|
"txcoin": document.getElementsByName('txcoinhash')[0].value,
|
|
"bkprev": document.getElementsByName('prevhash')[0].value,
|
|
"pow": document.getElementsByName('pow')[0].value,
|
|
"comment": document.getElementsByName('comment')[0].value
|
|
};
|
|
query_string = Object.keys(query).map( k => k +'='+ query[k] ).join('&');
|
|
let url = api_url + `creategen?${query_string}`;
|
|
document.getElementByName('pow')[0].value = 'working...';
|
|
let promised = fetch(url).
|
|
then(resp => resp.json()).
|
|
then(obj => {
|
|
console.log('genesis.obj:',obj);
|
|
document.getElementsByName('pow')[0].value = obj.pow;
|
|
}).
|
|
catch(console.error);
|
|
}
|
|
|
|
|