Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for testnet #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
theme: jekyll-theme-minimal
title: NeoBurger Dashboard
description: <a href="/">NeoBurger</a> Infomation Explorer
description: <a href="/">NeoBurger</a> Infomation Explorer <select id="network-select" onchange='(()=>{window.location.href = "?network=" + this.value + "&address=" + new URLSearchParams(location.search).get("address")})()'><option value="mainnet">mainnet</option><option value="testnet">testnet</option></select>
show_downloads: false
github: [metadata]
4 changes: 3 additions & 1 deletion account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const ENDPOINT = 'https://neofura.ngd.network:1927';
const isTestNet = new URLSearchParams(location.search).get('network') == 'testnet'
const ENDPOINT = isTestNet ? 'https://n3seed2.ngd.network:10331' : 'https://neofura.ngd.network:1927';
const NEO = '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5';
const GAS = '0xd2a4cff31913016155e38e474a2c06d08be276cf';
const BNEO = '0x48c40d4666f93408be1bef038b6722404d9a4c2a';
Expand All @@ -8,6 +9,7 @@ const SCRIPTHASH = `0x${[...[...ADDRESS].map(c => BASE58CHARS.indexOf(c)).reduce
const FETCHFUNC = (ctr, method, args) => fetch(ENDPOINT, { method: 'POST', body: JSON.stringify({ params: [ctr, method, args, [{ account: BNEO, scopes: 'CalledByEntry', 'allowedcontracts': [], 'allowedgroups': [] }]], method: 'invokefunction', jsonrpc: '2.0', id: 1 }) }).then(v => v.json()).then(v => v.result);
const DISPLAY = (id, value) => { const element = document.createElement('code'); element.innerText = value; const title = document.getElementById(id); title.parentElement.insertBefore(element, title.nextSibling); }

document.getElementById('network-select').value = isTestNet ? 'testnet' : 'mainnet';
new Promise(resolve => resolve(ADDRESS)).then(v => DISPLAY('account-address', v));
FETCHFUNC(BNEO, 'balanceOf', [{type: "Hash160", value: SCRIPTHASH}]).then(v => DISPLAY('bneo-balance', v.stack[0].value));
FETCHFUNC(BNEO, 'reward', [{type: "Hash160", value: SCRIPTHASH}]).then(v => DISPLAY('gas-unclaimed-multiplied-by-108', v.stack[0].value));
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const ENDPOINT = 'https://neofura.ngd.network:1927';
const isTestNet = new URLSearchParams(location.search).get('network') == 'testnet'
const ENDPOINT = isTestNet ? 'https://n3seed1.ngd.network:10332' : 'https://neofura.ngd.network:1927';
const NEO = '0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5';
const GAS = '0xd2a4cff31913016155e38e474a2c06d08be276cf';
const BNEO = '0x48c40d4666f93408be1bef038b6722404d9a4c2a';
Expand All @@ -8,6 +9,8 @@ const FETCHFUNC = (ctr, method, args) => fetch(ENDPOINT, { method: 'POST', body:
const FETCHSCRIPT = (script) => fetch(ENDPOINT, { method: 'POST', body: JSON.stringify({ params: [script, [{ account: BNEO, scopes: 'CalledByEntry', 'allowedcontracts': [], 'allowedgroups': [] }]], method: 'invokescript', jsonrpc: '2.0', id: 1 }) }).then(v => v.json()).then(v => v.result)
const DISPLAY = (id, value) => { const element = document.createElement('code'); element.innerText = value; const title = document.getElementById(id); title.parentElement.insertBefore(element, title.nextSibling); }

document.getElementById('network_input').value = isTestNet ? 'testnet' : 'mainnet';
document.getElementById('network-select').value = isTestNet ? 'testnet' : 'mainnet';
new Promise(resolve => resolve(BNEO)).then(v => DISPLAY('bneo-script-hash', v));
new Promise(resolve => resolve(BNEOADDR)).then(v => DISPLAY('bneo-contract-address', v))
FETCHFUNC(BNEO, 'totalSupply', []).then(v => DISPLAY('bneo-total-supply-multiplied-by-108', v.stack[0].value))
Expand Down
4 changes: 3 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

## whitelisted candidates

# Account Infomation
# Account Information

<form action="account" method="get" target="_blank">
<input id = "network_input" name="network" style="display: none;">
<input name="address" placeholder="type address and enter">
<input type="submit" style="visibility: hidden;" />
</form>

<script src="index.js" />