Skip to content

Commit

Permalink
Merge pull request #227 from theQRL/testnet
Browse files Browse the repository at this point in the history
Merging changes
  • Loading branch information
scottdonaldau authored Jun 25, 2018
2 parents 3dd33ab + 37921a8 commit c9431d1
Show file tree
Hide file tree
Showing 19 changed files with 421 additions and 291 deletions.
6 changes: 6 additions & 0 deletions .electrify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ app.on('ready', function() {
window.webContents.on('contextmenu', () => {
menu.popup(window);
});

// Prevent drag and drop links from opening in electron window
window.webContents.on('will-navigate', ev => {
ev.preventDefault()
})

var template = [{
label: "Application",
submenu: [
Expand Down
2 changes: 1 addition & 1 deletion .electrify/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .electrify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "QRLWallet",
"productName": "QRLWallet",
"projectName": "qrl-wallet",
"version": "0.4.0",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"electrify-qrl": "0.0.1",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ public/web-libjsqrl.wasm
.build/
.DS_Store
.idea/
localtests/
2 changes: 1 addition & 1 deletion imports/startup/both/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './nodes.js'
SHOR_PER_QUANTA=1000000000

// qrl-wallet Version
WALLET_VERSION="0.4.0"
WALLET_VERSION="1.0.0"

// Function to cleanly represent large decimal numbers without exponentional formatting.
numberToString = (num) => {
Expand Down
129 changes: 86 additions & 43 deletions imports/startup/both/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,126 @@
// All functions and variables are here are not defined by 'let' or 'const'
// so that they can be utilised in other files within Meteor.

// Define the default nodes available in the UI.
// Define the default networks available in the UI.
// eslint-disable-next-line no-unused-vars, no-undef
DEFAULT_NODES = [
DEFAULT_NETWORKS = [
{
id: 'testnet-1',
name: 'Testnet (Official QRL Node 1)',
disabled: '',
explorerUrl: 'https://explorer.theqrl.org',
grpc: '104.237.3.185:9009',
type: 'both',
},
{
id: 'testnet-2',
name: 'Testnet (Official QRL Node 2)',
disabled: '',
explorerUrl: 'https://explorer.theqrl.org',
grpc: '104.251.219.215:9009',
type: 'both',
},
{
id: 'testnet-3',
name: 'Testnet (Official QRL Node 3)',
id: 'mainnet',
name: 'Mainnet',
disabled: '',
explorerUrl: 'https://explorer.theqrl.org',
grpc: '104.251.219.145:9009',
type: 'both',
healthy: false,
nodes: [
{
id: 'mainnet-1',
grpc: 'mainnet-1.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'mainnet-2',
grpc: 'mainnet-2.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'mainnet-3',
grpc: 'mainnet-3.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'mainnet-4',
grpc: 'mainnet-4.automated.theqrl.org:19009',
state: false,
height: 0,
}
],
},
{
id: 'testnet-4',
name: 'Testnet (Official QRL Node 4)',
id: 'testnet',
name: 'Testnet',
disabled: '',
explorerUrl: 'https://explorer.theqrl.org',
grpc: '104.251.219.40:9009',
type: 'both',
},
{
id: 'mainnet',
name: 'Mainnet (Official QRL Node)',
disabled: 'disabled',
explorerUrl: 'https://explorer.theqrl.org',
grpc: '127.0.0.1:9009',
explorerUrl: 'https://testnet-explorer.theqrl.org',
type: 'both',
healthy: false,
nodes: [
{
id: 'testnet-1',
grpc: 'testnet-1.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'testnet-2',
grpc: 'testnet-2.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'testnet-3',
grpc: 'testnet-3.automated.theqrl.org:19009',
state: false,
height: 0,
},
{
id: 'testnet-4',
grpc: 'testnet-4.automated.theqrl.org:19009',
state: false,
height: 0,
}
],
},
{
id: 'localhost',
name: 'Localhost (Desktop App Only)',
disabled: '',
explorerUrl: 'http://explorer.theqrl.org',
grpc: 'localhost:9009',
type: 'desktop',
healthy: false,
nodes: [
{
id: 'localhost',
grpc: 'localhost:19009',
state: false,
height: 0,
}
],
}
]

// Override DEFAULT_NODES if provided in settings file
// Override DEFAULT_NETWORKS if provided in settings file
try {
if (Meteor.settings.public.defaultNodes.length > 0) {
// Reset DEFAULT_NODES
DEFAULT_NODES = []
// Set DEFAULT_NODES from Meteor settings
DEFAULT_NODES=Meteor.settings.public.defaultNodes
if (Meteor.settings.public.defaultNetworks.length > 0) {
// Reset DEFAULT_NETWORKS
DEFAULT_NETWORKS = []
// Set DEFAULT_NETWORKS from Meteor settings
DEFAULT_NETWORKS=Meteor.settings.public.defaultNetworks
}
} catch (e) {
// no configuration file used
}

// Function to search through the DEFAULT_NODES array and identify and return an
// Function to search through the DEFAULT_NETWORKS array and identify and return an
// object based on its 'id' value.
// eslint-disable-next-line no-unused-vars, no-undef
findNodeData = (array, key) => {
findNetworkData = (array, key) => {
if((LocalStore.get('nodeId') == 'custom') && (LocalStore.get('nodeStatus') != 'connecting')) {
const nodeData = {
id: 'custom',
name: LocalStore.get('customNodeName'),
disabled: '',
explorerUrl: LocalStore.get('customNodeExplorerUrl'),
grpc: LocalStore.get('customNodeGrpc'),
type: 'both',
nodes: [
{
id: 'custom',
grpc: LocalStore.get('customNodeGrpc'),
state: false,
height: 0,
}
],
}
return nodeData
} else {
Expand Down
42 changes: 28 additions & 14 deletions imports/startup/client/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ isElectrified = () => {
}

// Returns the selected node
selectedNode = () => {
const selectedNode = document.getElementById('network').value
return selectedNode
selectedNetwork = () => {
const selectedNetwork = document.getElementById('network').value
return selectedNetwork
}

// Fetchs XMSS details from the global XMSS_OBJECT variable
Expand Down Expand Up @@ -179,15 +179,31 @@ supportedBrowser = () => {
}


// Wrapper for Meteor.call
wrapMeteorCall = (method, request, callback) => {
// Modify network to gRPC endpoint for custom/localhost settings
if (request.network == "localhost") {
// Override network to localhost
request.network = 'localhost:9009'
}
if (request.network == "custom") {
// Override network to localhost
request.network = LocalStore.get('nodeGrpc')
}

Meteor.call(method, request, (err, res) => {
callback(err, res)
})
}

// Get wallet address state details
getBalance = (getAddress, callBack) => {
const grpcEndpoint = findNodeData(DEFAULT_NODES, selectedNode()).grpc
const request = {
address: addressForAPI(getAddress),
grpc: grpcEndpoint,
network: selectedNetwork(),
}

Meteor.call('getAddress', request, (err, res) => {
wrapMeteorCall('getAddress', request, (err, res) => {
if (err) {
console.log('err: ',err)
LocalStore.set('transferFromBalance', 0)
Expand Down Expand Up @@ -226,13 +242,13 @@ getBalance = (getAddress, callBack) => {
loadAddressTransactions = (txArray) => {
const request = {
tx: txArray,
grpc: findNodeData(DEFAULT_NODES, selectedNode()).grpc,
network: selectedNetwork(),
}

LocalStore.set('addressTransactions', [])
$('#loadingTransactions').show()

Meteor.call('addressTransactions', request, (err, res) => {
wrapMeteorCall('addressTransactions', request, (err, res) => {
if (err) {
LocalStore.set('addressTransactions', { error: err })
} else {
Expand All @@ -244,13 +260,12 @@ loadAddressTransactions = (txArray) => {
}

getTokenBalances = (getAddress, callback) => {
const grpcEndpoint = findNodeData(DEFAULT_NODES, selectedNode()).grpc
const request = {
address: addressForAPI(getAddress),
grpc: grpcEndpoint,
network: selectedNetwork(),
}

Meteor.call('getAddress', request, (err, res) => {
wrapMeteorCall('getAddress', request, (err, res) => {
if (err) {
console.log('err: ',err)
LocalStore.set('transferFromBalance', 0)
Expand All @@ -269,13 +284,12 @@ getTokenBalances = (getAddress, callback) => {

let thisToken = {}

const grpcEndpoint = findNodeData(DEFAULT_NODES, selectedNode()).grpc
const request = {
query: tokenHash,
grpc: grpcEndpoint,
network: selectedNetwork(),
}

Meteor.call('getTxnHash', request, (err, res) => {
wrapMeteorCall('getTxnHash', request, (err, res) => {
if (err) {
console.log('err:',err)
LocalStore.set('tokensHeld', [])
Expand Down
Loading

0 comments on commit c9431d1

Please sign in to comment.