Skip to content

Commit

Permalink
Merge pull request #167 from MickWang/master
Browse files Browse the repository at this point in the history
 add node address selection;add manual controller varification
  • Loading branch information
MickWang committed Jun 19, 2019
2 parents b7b3b9f + c5b12cf commit b1006f4
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 255 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,7 +86,6 @@
"ant-design-vue": "^1.1.9",
"asar": "^0.14.3",
"axios": "^0.18.0",
"babel-plugin-import": "^1.11.0",
"bignumber.js": "^7.2.1",
"bootstrap": "^4.1.1",
"clipboard": "^2.0.1",
Expand Down Expand Up @@ -118,6 +117,7 @@
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-import": "^1.11.0",
"babel-plugin-syntax-flow": "^6.18.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand Down
6 changes: 4 additions & 2 deletions src/common/lang/en.js
Expand Up @@ -413,12 +413,14 @@ export default {
pathTit: 'Path: ',
path: 'Save keystore file path',
change: 'Change',
setNetworkSuccess: 'The network has been set to ',
setNetworkSuccess: 'The network has been set to: ',
wallets: 'Wallets',
ontid: 'ONT ID',
nodeStake: 'Node Stake',
help: 'Help',
settings: 'Settings'
settings: 'Settings',
nodeAddress: 'Node address',
setNodeSuccess: 'The node address has been set t: '
},

ledgerWallet: {
Expand Down
6 changes: 4 additions & 2 deletions src/common/lang/zh.js
Expand Up @@ -412,12 +412,14 @@ export default {
pathTit: '当前路径: ',
path: '钱包保存路径',
change: '修改',
setNetworkSuccess: '网络成功设置成:',
setNetworkSuccess: '网络成功设置为:',
wallets: '钱包',
ontid: 'ONT ID',
nodeStake: '节点质押',
help: '帮助',
settings: '设置'
settings: '设置',
nodeAddress: '节点',
setNodeSuccess: '节点成功设置为:'
},
ledgerWallet: {
nameOfLedgerWallet: 'Ledger钱包名称',
Expand Down
38 changes: 6 additions & 32 deletions src/core/consts.js
Expand Up @@ -62,37 +62,6 @@ export const DEFAULT_SCRYPT = {

export const SWAP_ADDRESS = 'AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM'

export const CON_NODE = [
{
"name": "Dubhe",
"pk": "02bcdd278a27e4969d48de95d6b7b086b65b8d1d4ff6509e7a9eab364a76115af7"
},
{
"name": "Merak",
"pk": "0251f06bc247b1da94ec7d9fe25f5f913cedaecba8524140353b826cf9b1cbd9f4"
},
{
"name": "Phecda",
"pk": "022e911fb5a20b4b2e4f917f10eb92f27d17cad16b916bce8fd2dd8c11ac2878c0"
},
{
"name": "Megrez",
"pk": "0253719ac66d7cafa1fe49a64f73bd864a346da92d908c19577a003a8a4160b7fa"
},
{
"name": "Alioth",
"pk": "022bf80145bd448d993abffa237f4cd06d9df13eaad37afce5cb71d80c47b03feb"
},
{
"name": "Mixar",
"pk": "02765d98bb092962734e365bd436bdc80c5b5991dcf22b28dbb02d3b3cf74d6444"
},
{
"name": "Alkaid",
"pk": "03c8f63775536eb420c96228cdccc9de7d80e87f1b562a6eb93c0838064350aa53"
}
]

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

Expand All @@ -105,4 +74,9 @@ export const PAX_API = {
validateTx: '/api/v1/validatetx',
EthScanTest: 'https://ropsten.etherscan.io/tx/',
EthScanMain: 'https://etherscan.io/tx/'
}
}

export const PAX_SC_HASH = {
MAIN: '6bbc07bae862db0d7867e4e5b1a13c663e2b4bc8',
TEST: 'b06f8eaf757030c7a944ce2a072017bde1e72308'
}
32 changes: 29 additions & 3 deletions src/core/utils.js
@@ -1,6 +1,7 @@
import {
TEST_NET,
MAIN_NET,
MAIN_NET_LIST,
DEFAULT_SCRYPT
} from './consts'
import axios from 'axios'
Expand All @@ -11,8 +12,25 @@ import {
BigNumber
} from 'bignumber.js'
import numeral from 'numeral'
import {Crypto} from 'ontology-ts-sdk'
import {Crypto, RestClient} from 'ontology-ts-sdk'
const opn = require('opn')
const {
BrowserWindow
} = require('electron').remote;

export function open(url) {
try {
opn(url)
} catch(err) {
let win = new BrowserWindow({width: 800, height: 600, center: true});
win.on('closed', () => {
win = null
})

// Load a remote URL
win.loadURL(url)
}
}
export function varifyPositiveInt(value) {
if (!/^[1-9]\d*$/.test(value)) {
return false;
Expand All @@ -33,9 +51,17 @@ export function isHexString(str) {
}

export function getNodeUrl() {
const net = localStorage.getItem('net');
return net === 'TEST_NET' ? TEST_NET + ':20334' : MAIN_NET + ':20334'
// const net = localStorage.getItem('net');
// return net === 'TEST_NET' ? TEST_NET + ':20334' : MAIN_NET + ':20334'
// return 'http://139.219.128.220:20334' //for test
const node = localStorage.getItem('nodeAddress') || MAIN_NET_LIST[0]
return node + ':20334';
}

export function getRestClient() {
let url = getNodeUrl();
const restClient = new RestClient(url);
return restClient;
}

export function convertNumber2Str(num, decimal = 0, division) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Common/CommonSignShared.vue
Expand Up @@ -34,7 +34,7 @@
<script>
import {mapState} from 'vuex'
import {DEFAULT_SCRYPT} from '../../../core/consts'
import {getNodeUrl, decryptWallet} from '../../../core/utils'
import {decryptWallet} from '../../../core/utils'
import {legacySignWithLedger} from '../../../core/ontLedger'
import {Crypto, Transaction, TransactionBuilder, TxSignature, utils, RestClient} from 'ontology-ts-sdk'
Expand Down
14 changes: 3 additions & 11 deletions src/renderer/components/Common/Oep4Home.vue
Expand Up @@ -212,7 +212,7 @@
import Breadcrumb from '../Breadcrumb'
import {mapState} from 'vuex'
import { TEST_NET } from '../../../core/consts'
const {BrowserWindow} = require('electron').remote;
import { open } from '../../../core/utils'
export default {
name: 'Oep4Home',
Expand Down Expand Up @@ -310,22 +310,14 @@ export default {
if (this.net === 'TEST_NET') {
url += '/testnet'
}
let win = new BrowserWindow({width: 1280, height: 800, center: true});
win.on('closed', () => {
win = null
})
win.loadURL(url)
openUrl(url)
},
checkMoreTx() {
let url = `https://explorer.ont.io/address/${this.address}/10/1`
if (this.net === 'TEST_NET') {
url += '/testnet'
}
let win = new BrowserWindow({width: 1280, height: 800, center: true});
win.on('closed', () => {
win = null
})
win.loadURL(url)
open(url)
},
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/components/Common/SignSendTx.vue
Expand Up @@ -23,7 +23,7 @@
<script>
import {mapState} from 'vuex'
import {DEFAULT_SCRYPT} from '../../../core/consts'
import {getNodeUrl} from '../../../core/utils'
import { getRestClient } from '../../../core/utils'
import {legacySignWithLedger} from '../../../core/ontLedger'
import {Crypto, TransactionBuilder, TxSignature, utils, RestClient} from 'ontology-ts-sdk'
export default {
Expand Down Expand Up @@ -113,8 +113,7 @@ export default {
},
sendTx(tx){
this.walletPassword = '';
const url = getNodeUrl();
const restClient = new RestClient(url);
const restClient = getRestClient();
restClient.sendRawTransaction(tx.serialize()).then(res => {
console.log(res)
this.$store.dispatch("hideLoadingModals");
Expand Down
10 changes: 2 additions & 8 deletions src/renderer/components/CommonWallet/CommonRedeem.vue
Expand Up @@ -61,6 +61,7 @@ import { TEST_NET, MAIN_NET, ONT_CONTRACT, ONT_PASS_NODE, DEFAULT_SCRYPT } from
import {mapState} from 'vuex'
import {getDeviceInfo, getPublicKey} from '../../../core/ontLedger'
import {BigNumber} from 'bignumber.js'
import { getRestClient } from '../../../core/utils'
export default {
name: 'CommonRedeem',
components: {
Expand All @@ -82,12 +83,6 @@ export default {
},
data() {
const net = localStorage.getItem('net');
let url = ''
if (net === 'TEST_NET') {
url = TEST_NET + ':20334'
} else {
url = MAIN_NET + ':20334'
}
const type = this.$route.params.walletType
const currentWallet = JSON.parse(sessionStorage.getItem('currentWallet'))
const routes = [{name: currentWallet.label, path:'/dashboard'}]
Expand All @@ -96,7 +91,6 @@ export default {
routes,
type,
password:'',
nodeUrl: url,
interval:10000,
invervalId:'',
publicKey:'',
Expand Down Expand Up @@ -149,7 +143,7 @@ export default {
})
},
sendTx(tx) {
const restClient = new RestClient(this.nodeUrl);
const restClient = getRestClient();
restClient.sendRawTransaction(tx.serialize()).then(res => {
console.log(res)
this.$store.dispatch('hideLoadingModals')
Expand Down
11 changes: 3 additions & 8 deletions src/renderer/components/CommonWallet/SendConfirm.vue
Expand Up @@ -197,6 +197,8 @@ import axios from 'axios';
import {getDeviceInfo, getPublicKey} from '../../../core/ontLedger'
import $ from 'jquery'
import {BigNumber} from 'bignumber.js'
import { getRestClient } from '../../../core/utils'
export default {
name: 'SendConfirm',
mounted: function () {
Expand All @@ -215,20 +217,13 @@ export default {
},
data() {
const net = localStorage.getItem('net');
let url = ''
if (net === 'TEST_NET') {
url = TEST_NET + ':20334'
} else {
url = MAIN_NET + ':20334'
}
const currentWallet = JSON.parse(sessionStorage.getItem('currentWallet'));
return {
interval:10000,
invervalId: '',
currentWallet,
checked: false,
password: '',
nodeUrl: url,
isCommonWallet: currentWallet.key ? true: false,
ledgerStatus: '',
publicKey: '',
Expand Down Expand Up @@ -280,7 +275,7 @@ export default {
})
},
sendTx(tx){
const restClient = new RestClient(this.nodeUrl);
const restClient = getRestClient();
restClient.sendRawTransaction(tx.serialize()).then(res => {
console.log(res)
this.$store.dispatch('hideLoadingModals')
Expand Down
24 changes: 4 additions & 20 deletions src/renderer/components/Dashboard.vue
Expand Up @@ -456,7 +456,7 @@
import Breadcrumb from './Breadcrumb'
import { BigNumber } from 'bignumber.js';
import RedeemInfoIcon from './RedeemInfoIcon'
const {BrowserWindow} = require('electron').remote;
import { open, getRestClient } from '../../core/utils'
const ONG_GOVERNANCE_CONTRACT = 'AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK'
export default {
name: 'Dashboard',
Expand All @@ -468,13 +468,6 @@ const ONG_GOVERNANCE_CONTRACT = 'AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK'
const currentWallet = JSON.parse(sessionStorage.getItem('currentWallet'));
const net = localStorage.getItem('net');
const network = net && net === 'TEST_NET' ? this.$t('common.testNet') : this.$t('common.mainNet');
let url = '';
if (net === 'TEST_NET') {
url = TEST_NET + ':20334'
} else {
url = MAIN_NET + ':20334'
}
return {
currentWallet,
Expand All @@ -485,7 +478,6 @@ const ONG_GOVERNANCE_CONTRACT = 'AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK'
transactions: '',
asset: 'ONT',
network: network,
nodeUrl: url,
completedTx: [],
intervalId: '',
interval:15000,
Expand Down Expand Up @@ -566,7 +558,7 @@ const ONG_GOVERNANCE_CONTRACT = 'AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK'
})
},
getUnclaimOng() {
const restClient = new RestClient(this.nodeUrl);
const restClient = getRestClient();
restClient.getAllowance('ong', new Crypto.Address(ONT_CONTRACT), new Crypto.Address(this.address)).then(res => {
console.log(res.Result)
this.unclaimOng = new BigNumber(res.Result).div(1e9);
Expand Down Expand Up @@ -664,22 +656,14 @@ const ONG_GOVERNANCE_CONTRACT = 'AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK'
if (this.network === 'TestNet') {
url += '/testnet'
}
let win = new BrowserWindow({width: 1280, height: 800, center: true});
win.on('closed', () => {
win = null
})
win.loadURL(url)
open(url)
},
showTxDetail(txHash) {
let url = `https://explorer.ont.io/transaction/${txHash}`
if (this.network === 'TestNet') {
url += '/testnet'
}
let win = new BrowserWindow({width: 1280, height: 800, center: true});
win.on('closed', () => {
win = null
})
win.loadURL(url)
open(url)
},
copy(value) {
this.$copyText(value);
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/components/Exchange.vue
Expand Up @@ -51,6 +51,7 @@ loading {
<script>
import axios from "axios";
import { isNumber, isNullOrUndefined } from "util";
import { open } from '../../core/utils'
export default {
name: "Exchange",
Expand Down Expand Up @@ -92,10 +93,15 @@ export default {
return array.long == value;
},
handleExchangeChangelly() {
this.$router.push({ name: "Changelly" });
// this.$router.push({ name: "Changelly" });
const changellyURL =
"https://widget.changelly.com?currencies=&from=btc&to=ont&amount=1&address=&fiat=true&fixedTo=false&theme=default&ref_id=su5srryl1mhz4fno&merchant_id=su5srryl1mhz4fno";
open(changellyURL)
},
handleExchangeCryptonex() {
this.$router.push({ name: "Cryptonex" });
// this.$router.push({ name: "Cryptonex" });
const cryptonexURL = "https://wallet.cryptonex.org/member/sign-in";
open(cryptonexURL)
},
formatPrice(value) {
if (isNumber(value)) {
Expand Down

0 comments on commit b1006f4

Please sign in to comment.