Skip to content

Commit

Permalink
Merge pull request #159 from MickWang/master
Browse files Browse the repository at this point in the history
update explorer api;update node list;add pax support;
  • Loading branch information
MickWang authored May 23, 2019
2 parents 189d385 + deeac57 commit 67c1ed6
Show file tree
Hide file tree
Showing 48 changed files with 2,736 additions and 357 deletions.
5 changes: 3 additions & 2 deletions package.json
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",
Expand Down Expand Up @@ -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",
Expand Down
69 changes: 66 additions & 3 deletions src/common/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export default {
},

dashboard: {
getTransErr: 'Fetch transaction history failed. Network error.'
getTransErr: 'Fetch transaction history failed. Network error. Plese try later.',
getBalanceErr: 'Fetch balance failed. Network error. Plese try later.'
},

createJsonWallet: {
Expand Down Expand Up @@ -289,7 +290,69 @@ export default {
sign: 'Sign',
checkMore: 'Check more',
publicKey: 'Public key',
redeemOng: 'Redeem ONG'
redeemOng: 'Redeem ONG',
paxMgmt: 'PAX management',
unprocessed: 'Unprocessed',
processing: 'In processing',
completed: 'Completed',
txMgmt: 'Transaction management'
},

pax: {
ethAddress: 'Eth Address',
ontAddress: 'Ont Address',
amount: 'Amount',
date: 'Date',
toProcess: 'To process',
paxStart: 'Start',
paxSign: 'Sign',
selectCurrentSigner: 'Select current signer: ',
back: 'Back',
confirm: 'Confirm',
sponsorSign: 'Sponsor sign',
inputPassword: 'Input the password of current signer',
queryEthScan: 'Query Total Eth amount',
currentSign: 'Current signer sign',
txToSend: 'Number of transactions to send: ',
txSent: 'Number of transactoins sent succeed: ',
sendingTx: 'Sending transactoins',
selectedNum: 'Number of selected orders: ',
totalAmount: 'Total amount of selected orders: ',
ethTotal: 'Total amount of received ETH: ',
startProcessSuccess: 'Start process succeed.',
signSuccess: 'Sign transactions succeed.',
ledgerSignMultiTimes: 'You may have to sign multi times on your ledger device',
hasSignedSent: 'These transactions has been signed and sent. Please review the completed data.',
toEthScan: 'To Eth Scan',
txCompleted: 'Transaction completed',
txDetail: 'Detail',
toVarify: 'Varify',
varifySuccess: 'Varify succeed!',
varifyFailed: 'Varify failed!',
varifyResult: 'Varified result',
failedTxhashes: 'Failed transaction hash:'
},

sharedTx: {
startTx: 'Start multi-sign transaction',
signTx: 'Sign multi-sign transaction',
selectSponsor: 'Select sponsor',
createTx: 'Create Transaction',
contractHash: 'Contract hash',
method: 'Method',
parameters: 'Parameters',
starterSign: 'Start sign',
txSerialized: 'Signed and serialized transaction:',
addSign: 'Add signature',
txContent: 'Transaction data',
currentSign: 'Current signer',
selectSigner: 'Select wallet to sign',
addSign: 'Add signature',
copy: 'Copy',
send: 'Send now',
isSendTxTip: 'The transaction can be sent to the blockchain now. Confirm to send?',
txSentSuccess: 'Send transaction succeed.',
paramsError: 'Error parameters. Please check the input.'
},

commonWalletHome: {
Expand Down Expand Up @@ -324,7 +387,7 @@ export default {
invalidScriptHash: 'The script hash is invalid',
addOep4Success: 'Add OEP-44 token succeed!',
noOep4Contract: 'The OEP-44 contract is not found',
networkError: 'Network error!Please try later.',
networkError: 'Network error! Please try later.',
oep4Exists: 'You have already added this OEP-4 token.',
go: 'Go'
},
Expand Down
19 changes: 19 additions & 0 deletions src/common/lang/index.js
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;
69 changes: 66 additions & 3 deletions src/common/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export default {
},

dashboard: {
getTransErr: '交易记录获取失败,网络错误。'
getTransErr: '交易记录获取失败,网络错误。请稍后重试。',
getBalanceErr: '余额获取失败。网络错误,请稍后重试。'
},

createJsonWallet: {
Expand Down Expand Up @@ -284,11 +285,73 @@ export default {
balance: '余额',
confirmation: '确认',
agreeToSend: '我同意发送资产',
signSequence: '选择签名人数',
signSequence: '签名顺序',
sign: '签名',
checkMore: '查看更多',
publicKey: '公钥',
redeemOng: '提取ONG'
redeemOng: '提取ONG',
paxMgmt: 'PAX管理',
unprocessed: '未处理',
processing: '处理中',
completed: '已完成',
txMgmt: '多签交易管理'
},

pax: {
ethAddress: 'Eth 地址',
ontAddress: 'ONT 地址',
amount: '数额',
date: '日期',
toProcess: '去处理',
paxStart: '发起',
paxSign: '签名',
selectCurrentSigner: '选择当前签名钱包: ',
back: '返回',
confirm: '确认',
sponsorSign: '发起人签名',
inputPassword: '输入当前签名钱包密码',
queryEthScan: '查询Eth转出总额',
currentSign: '当前签名者签名',
txToSend: '要发送上链的交易个数:',
txSent: '已发送上链的交易个数: ',
sendingTx: '正在发送交易上链:',
selectedNum: '已选择条目数量: ',
totalAmount: '已选择条目的PAX总额: ',
ethTotal: '已收到的ETH总额: ',
startProcessSuccess: '发起处理流程成功',
signSuccess: '签名交易成功',
ledgerSignMultiTimes: '您可能需要在ledger设备上进行多次签名',
hasSignedSent: '注意!这些交易已经被签名并已发送到链上。请检查已完成的数据。',
toEthScan: '查看ETH Scan',
txCompleted: '已上链',
txDetail: '查看交易',
toVarify: '验证',
varifySuccess: '验证失败',
varifyFailed: '验证通过',
varifyResult: '验证结果',
failedTxhashes: '验证失败的交易哈希'
},

sharedTx: {
startTx: '发起多签交易',
signTx: '签名多签交易',
selectSponsor: '选择发起人',
createTx: '构建多签交易',
contractHash: '合约哈希',
method: '方法名',
parameters: '参数列表',
starterSign: '发起人签名',
txSerialized: '签名后的交易:',
addSign: '增加签名',
txContent: '交易内容',
currentSign: '当前签名地址',
selectSigner: '选择签名地址',
addSign: '增加签名',
copy: '复制',
send: '立即发送',
isSendTxTip: '该交易的签名数量已满足要求。是否立即发送交易上链?',
txSentSuccess: '发送交易上链成功。',
paramsError: '输入参数有误。请检查。'
},

commonWalletHome: {
Expand Down
27 changes: 26 additions & 1 deletion src/core/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ export const ONT_CONTRACT = '0000000000000000000000000000000000000001';
export const TEST_NET = 'http://polaris1.ont.io';
export const MAIN_NET = 'http://dappnode1.ont.io';

export const TEST_NET_LIST = [
'http://polaris1.ont.io',
'http://polaris2.ont.io',
'http://polaris3.ont.io',
'http://polaris4.ont.io',
'http://polaris5.ont.io'
]

export const MAIN_NET_LIST = [
'http://dappnode1.ont.io',
'http://dappnode2.ont.io',
'http://dappnode3.ont.io',
'http://dappnode4.ont.io',
]
//test environment
export const ONT_PASS_NODE = 'https://app.ont.io'
//prod
Expand Down Expand Up @@ -80,4 +94,15 @@ export const CON_NODE = [
]

export const NODE_DETAIL = 'https://explorer.ont.io/nodes/detail/'
export const NODE_NAME_LIST = 'https://ont.io/api/v1/candidate/info/All'
export const NODE_NAME_LIST = 'https://ont.io/api/v1/candidate/info/All'

export const PAX_API = {
Host: 'http://18.138.83.180:20800',
// TestHost: 'http://172.168.3.61:20800',
TestHost: 'http://18.139.19.52:20800',
fetchApprovalList: '/api/v1/approvals',
updateApprovals: '/api/v1/processapplist',
validateTx: '/api/v1/validatetx',
EthScanTest: 'https://ropsten.etherscan.io/tx/',
EthScanMain: 'https://etherscan.io/tx/'
}
52 changes: 52 additions & 0 deletions src/core/network.js
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;
}
51 changes: 51 additions & 0 deletions src/core/runtime.js
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);
}
Loading

0 comments on commit 67c1ed6

Please sign in to comment.