-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from MickWang/master
update explorer api;update node list;add pax support;
- Loading branch information
Showing
48 changed files
with
2,736 additions
and
357 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"name": "owallet", | ||
"productName": "OWallet", | ||
"productName": "OWallet for PAX", | ||
"homepage": "http://ont.io", | ||
"version": "v0.9.7", | ||
"version": "v0.9.8", | ||
"author": "Ontology Foundation Ltd. <[email protected]>", | ||
"description": "OWallet is a comprehensive Ontology desktop wallet", | ||
"license": "Apache-2.0", | ||
|
@@ -96,6 +96,7 @@ | |
"font-awesome": "^4.7.0", | ||
"global": "^4.3.2", | ||
"jquery": "^3.3.1", | ||
"lodash": "^4.17.11", | ||
"nedb": "^1.8.0", | ||
"node-hid": "^0.7.7", | ||
"numeral": "^2.0.6", | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Vue from "vue"; | ||
import VueI18n from "vue-i18n"; | ||
import en from "./en"; | ||
import zh from "./zh"; | ||
import LangStorage from "../../core/lang"; | ||
|
||
Vue.use(VueI18n); | ||
|
||
const messages = { | ||
en, | ||
zh | ||
}; | ||
|
||
const i18n = new VueI18n({ | ||
locale: LangStorage.getLang("en"), | ||
messages | ||
}); | ||
|
||
export default i18n; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {WebsocketClient} from 'ontology-ts-sdk'; | ||
import store from '../renderer/store' | ||
import { MAIN_NET_LIST, TEST_NET_LIST } from './consts' | ||
let client; | ||
|
||
let net = localStorage.getItem('net'); // 'TEST_NET' or 'MAIN_NET' | ||
if(!net) { | ||
net = 'MAIN_NET' | ||
localStorage.setItem('net', net) | ||
} | ||
|
||
let node = localStorage.getItem('node') | ||
if(!node) { | ||
node = MAIN_NET_LIST[0] | ||
localStorage.setItem('node', node) | ||
} | ||
|
||
const WS_PORT = '20335' | ||
|
||
export function initNetwork() { | ||
reconnect() | ||
window.setInterval(async () => { | ||
try { | ||
await client.sendHeartBeat(); | ||
store.commit('NETWORK_CONNECTED') | ||
} catch (e) { | ||
if (net) { | ||
reconnect(); | ||
} | ||
|
||
store.commit('NETWORK_DISCONNECTED'); | ||
} | ||
}, 5000); | ||
} | ||
|
||
|
||
function reconnect() { | ||
if (client !== undefined) { | ||
try { | ||
client.close(); | ||
} catch (e) { | ||
// ignored | ||
} | ||
} | ||
|
||
const url = `${node}:${WS_PORT}`; | ||
client = new WebsocketClient(url, false, false); | ||
} | ||
|
||
export function getClient() { | ||
return client; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {get} from 'lodash' | ||
import { | ||
Crypto | ||
} from 'ontology-ts-sdk'; | ||
|
||
|
||
import { | ||
getClient | ||
} from './network'; | ||
|
||
|
||
export async function getBalance(addr) { | ||
let address = new Crypto.Address(addr); | ||
|
||
const client = getClient(); | ||
const response = await client.getBalance(address); | ||
const ont = Number(get(response, 'Result.ont')); | ||
const ong = Number(get(response, 'Result.ong')); | ||
|
||
return { | ||
ong, | ||
ont, | ||
}; | ||
} | ||
|
||
export async function getUnboundOng(addr) { | ||
let address = new Crypto.Address(addr); | ||
|
||
const client = getClient(); | ||
const response = await client.getUnboundong(address); | ||
const unboundOng = Number(get(response, 'Result')); | ||
return unboundOng; | ||
} | ||
|
||
export async function getGrantOng(addr) { | ||
let address = new Crypto.Address(addr); | ||
const client = getClient(); | ||
const response = await client.getGrantOng(address); | ||
const grantOng = Number(get(response, 'Result')); | ||
return grantOng; | ||
} | ||
|
||
export async function invokeTx(tx) { | ||
const client = getClient(); | ||
await client.sendRawTransaction(tx.serialize(), false, true); | ||
} | ||
|
||
export async function invokeReadTx(tx) { | ||
const client = getClient(); | ||
await client.sendRawTransaction(tx.serialize(), true, true); | ||
} |
Oops, something went wrong.