rename all libs from xxx.yyy to xxx-yyy
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
"serve-favicon": "^2.4.5",
|
"serve-favicon": "^2.4.5",
|
||||||
"socket.io": "^2.1.1",
|
"socket.io": "^2.1.1",
|
||||||
"tic.action": "git+https://git.faronear.org/tic/tic.action#20190714_release_passtoken",
|
"tic.action": "git+https://git.faronear.org/tic/tic.action#20190714_release_passtoken",
|
||||||
"tic.crypto": "git+https://git.faronear.org/tic/tic.crypto#20190109_preview",
|
"tic-crypto": "git+https://git.faronear.org/tic/tic-crypto#20190109_preview",
|
||||||
"vue": "^2.5.17",
|
"vue": "^2.5.17",
|
||||||
"vue-axios": "^2.1.3",
|
"vue-axios": "^2.1.3",
|
||||||
"vue-i18n": "^8.1.0",
|
"vue-i18n": "^8.1.0",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import '../axios'
|
import '../axios'
|
||||||
import ticCrypto from 'tic.crypto'
|
import ticrypto from 'tic-crypto'
|
||||||
import { TIC } from '../tic'
|
import { TIC } from '../tic'
|
||||||
|
|
||||||
export const seckey2pubkey = seckey => ticCrypto.seckey2pubkey(seckey)
|
export const seckey2pubkey = seckey => ticrypto.seckey2pubkey(seckey)
|
||||||
export const secword2address = secword => ticCrypto.secword2address(secword)
|
export const secword2address = secword => ticrypto.secword2address(secword)
|
||||||
export const secword2account = secword => ticCrypto.secword2account(secword)
|
export const secword2account = secword => ticrypto.secword2account(secword)
|
||||||
// export const randomSecword = lang => ticCrypto.randomSecword(lang)
|
// export const randomSecword = lang => ticrypto.randomSecword(lang)
|
||||||
export const isAddress = address => ticCrypto.isAddress(address)
|
export const isAddress = address => ticrypto.isAddress(address)
|
||||||
|
|
||||||
export const transferTic = ({ mnemonic, to, amount, fee }) => {
|
export const transferTic = ({ mnemonic, to, amount, fee }) => {
|
||||||
const instance = TIC.fromMnemonic(mnemonic)
|
const instance = TIC.fromMnemonic(mnemonic)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import * as Ticrypto from 'tic.crypto'
|
import * as Ticrypto from 'tic-crypto'
|
||||||
import * as ticAction from 'tic.action'
|
import * as ticAction from 'tic.action'
|
||||||
|
|
||||||
const TicActionTransfer = ticAction.ActionTransfer
|
const TicActionTransfer = ticAction.ActionTransfer
|
||||||
@@ -7,103 +7,113 @@ const TicActionTransfer = ticAction.ActionTransfer
|
|||||||
const TIC_TXFEE = 10
|
const TIC_TXFEE = 10
|
||||||
|
|
||||||
export class TIC {
|
export class TIC {
|
||||||
constructor(seckey, option = {}) {
|
constructor (seckey, option = {}) {
|
||||||
if (!seckey || !Ticrypto.isSeckey(seckey)) throw Error('ERROR:Invalid Seckey')
|
if (!seckey || !Ticrypto.isSeckey(seckey))
|
||||||
|
throw Error('ERROR:Invalid Seckey')
|
||||||
Object.defineProperties(this, {
|
Object.defineProperties(this, {
|
||||||
'seckey': {
|
seckey: {
|
||||||
value: seckey,
|
value: seckey,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: false,
|
writable: false
|
||||||
},
|
},
|
||||||
'pubkey': {
|
pubkey: {
|
||||||
value: Ticrypto.seckey2pubkey(seckey),
|
value: Ticrypto.seckey2pubkey(seckey),
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: false,
|
writable: false
|
||||||
},
|
},
|
||||||
'address': {
|
address: {
|
||||||
value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(seckey)),
|
value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(seckey)),
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: false,
|
writable: false
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
_defaultFee: option.fee || TIC_TXFEE, // fee cannot be zero
|
_defaultFee: option.fee || TIC_TXFEE // fee cannot be zero
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
get txfee() {
|
get txfee () {
|
||||||
return this._defaultFee
|
return this._defaultFee
|
||||||
}
|
}
|
||||||
set txfee(fee) {
|
set txfee (fee) {
|
||||||
this._defaultFee = fee
|
this._defaultFee = fee
|
||||||
}
|
}
|
||||||
|
|
||||||
static generateNewAccount() {
|
static generateNewAccount () {
|
||||||
var secword = Ticrypto.randomSecword()
|
var secword = Ticrypto.randomSecword()
|
||||||
return Object.assign(new TIC(Ticrypto.secword2keypair(secword).seckey), {
|
return Object.assign(new TIC(Ticrypto.secword2keypair(secword).seckey), {
|
||||||
secword: secword,
|
secword: secword
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
static fromMnemonic(secword) {
|
static fromMnemonic (secword) {
|
||||||
if (!secword || !Ticrypto.isSecword(secword)) throw Error('ERROR:Invalid Secword')
|
if (!secword || !Ticrypto.isSecword(secword))
|
||||||
|
throw Error('ERROR:Invalid Secword')
|
||||||
return new TIC(Ticrypto.secword2keypair(secword).seckey)
|
return new TIC(Ticrypto.secword2keypair(secword).seckey)
|
||||||
}
|
}
|
||||||
static async getBalance(address) {
|
static async getBalance (address) {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw new Error('Address is required')
|
throw new Error('Address is required')
|
||||||
}
|
}
|
||||||
return (await axios.post('Account/getBalance', {
|
return (
|
||||||
'Account': {
|
await axios.post('Account/getBalance', {
|
||||||
'address': address,
|
Account: {
|
||||||
},
|
address: address
|
||||||
})).data
|
|
||||||
}
|
}
|
||||||
static async getActions(address) {
|
})
|
||||||
|
).data
|
||||||
|
}
|
||||||
|
static async getActions (address) {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw new Error('Address is required')
|
throw new Error('Address is required')
|
||||||
}
|
}
|
||||||
return (await axios.post('Action/getActionList', {
|
return (
|
||||||
'Action': {
|
await axios.post('Action/getActionList', {
|
||||||
'actorAddress': address,
|
Action: {
|
||||||
'toAddress': address,
|
actorAddress: address,
|
||||||
|
toAddress: address
|
||||||
},
|
},
|
||||||
'config': {
|
config: {
|
||||||
'logic': 'OR',
|
logic: 'OR'
|
||||||
},
|
|
||||||
})).data
|
|
||||||
}
|
}
|
||||||
static encrypt(data, key) {
|
})
|
||||||
|
).data
|
||||||
|
}
|
||||||
|
static encrypt (data, key) {
|
||||||
if (!data || !key) throw new Error('Required Params Missing')
|
if (!data || !key) throw new Error('Required Params Missing')
|
||||||
return Ticrypto.encrypt(data, key)
|
return Ticrypto.encrypt(data, key)
|
||||||
}
|
}
|
||||||
static decrypt(data, key) {
|
static decrypt (data, key) {
|
||||||
return Ticrypto.decrypt(data, key, {
|
return Ticrypto.decrypt(data, key, {
|
||||||
format: 'json',
|
format: 'json'
|
||||||
}) // return null for wrong key
|
}) // return null for wrong key
|
||||||
}
|
}
|
||||||
|
|
||||||
static isValidAddress(address) {
|
static isValidAddress (address) {
|
||||||
return Ticrypto.isAddress(address)
|
return Ticrypto.isAddress(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendTransaction(toAddress, amount, option = {
|
async sendTransaction (
|
||||||
gasFee: TIC_TXFEE,
|
toAddress,
|
||||||
}) {
|
amount,
|
||||||
|
option = {
|
||||||
|
gasFee: TIC_TXFEE
|
||||||
|
}
|
||||||
|
) {
|
||||||
if (!toAddress || !amount) {
|
if (!toAddress || !amount) {
|
||||||
throw new Error('ERROR:RequiredParamsMissing')
|
throw new Error('ERROR:RequiredParamsMissing')
|
||||||
} // amount cannot be zero
|
} // amount cannot be zero
|
||||||
let action = new TicActionTransfer({
|
let action = new TicActionTransfer({
|
||||||
amount: parseInt(amount),
|
amount: parseInt(amount),
|
||||||
toAddress: toAddress,
|
toAddress: toAddress,
|
||||||
fee: option.gasFee,
|
fee: option.gasFee
|
||||||
})
|
})
|
||||||
// 对交易数据签名,packMe 内的参数是交易发起人的keypair
|
// 对交易数据签名,packMe 内的参数是交易发起人的keypair
|
||||||
action.packMe({
|
action.packMe({
|
||||||
seckey: this.seckey,
|
seckey: this.seckey,
|
||||||
pubkey: this.pubkey,
|
pubkey: this.pubkey,
|
||||||
address: this.address,
|
address: this.address
|
||||||
})
|
})
|
||||||
let data = {
|
let data = {
|
||||||
Action: action,
|
Action: action
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let res = (await axios.post('Action/prepare', data)).data
|
let res = (await axios.post('Action/prepare', data)).data
|
||||||
@@ -112,13 +122,13 @@ export class TIC {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getBalance() {
|
async getBalance () {
|
||||||
return TIC.getBalance(this.address)
|
return TIC.getBalance(this.address)
|
||||||
}
|
}
|
||||||
async getActions() {
|
async getActions () {
|
||||||
return TIC.getActions(this.address)
|
return TIC.getActions(this.address)
|
||||||
}
|
}
|
||||||
getSerializedTx(option) {
|
getSerializedTx (option) {
|
||||||
if (!option.toAddress || !option.amount) {
|
if (!option.toAddress || !option.amount) {
|
||||||
throw new Error('ERROR:RequiredParamsMissing')
|
throw new Error('ERROR:RequiredParamsMissing')
|
||||||
}
|
}
|
||||||
@@ -126,24 +136,24 @@ export class TIC {
|
|||||||
amount: parseInt(option.amount),
|
amount: parseInt(option.amount),
|
||||||
toAddress: option.toAddress,
|
toAddress: option.toAddress,
|
||||||
fee: option.fee || this._defaultFee,
|
fee: option.fee || this._defaultFee,
|
||||||
message: option.message || '',
|
message: option.message || ''
|
||||||
})
|
})
|
||||||
// sign for txBody use function packMe, which needs actor's keypair as parameter
|
// sign for txBody use function packMe, which needs actor's keypair as parameter
|
||||||
action.packMe({
|
action.packMe({
|
||||||
seckey: this.seckey,
|
seckey: this.seckey,
|
||||||
pubkey: this.pubkey,
|
pubkey: this.pubkey,
|
||||||
address: this.address,
|
address: this.address
|
||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
}
|
}
|
||||||
// default key for sign&encrypt is account's seckey,other keys are optional.
|
// default key for sign&encrypt is account's seckey,other keys are optional.
|
||||||
sign(message, key = this.seckey) {
|
sign (message, key = this.seckey) {
|
||||||
return Ticrypto.sign(message, key)
|
return Ticrypto.sign(message, key)
|
||||||
}
|
}
|
||||||
verify(message, signature) {
|
verify (message, signature) {
|
||||||
return Ticrypto.sign(message, signature, this.seckey)
|
return Ticrypto.sign(message, signature, this.seckey)
|
||||||
}
|
}
|
||||||
encrypt(key) {
|
encrypt (key) {
|
||||||
return TIC.encrypt(this, key)
|
return TIC.encrypt(this, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
import router from '../../router'
|
import router from '../../router'
|
||||||
import { i18n } from '../../i18n'
|
import { i18n } from '../../i18n'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import ticCrypto from 'tic.crypto'
|
import ticrypto from 'tic-crypto'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import * as Ticrypto from 'tic.crypto'
|
import * as Ticrypto from 'tic-crypto'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
@@ -14,44 +14,50 @@ export default {
|
|||||||
passwd: '',
|
passwd: '',
|
||||||
erroruser: '',
|
erroruser: '',
|
||||||
signing: false,
|
signing: false,
|
||||||
renewing: false,
|
renewing: false
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
inputError: state => !!state.erroruser,
|
inputError: state => !!state.erroruser
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
updateUserName(state, username) {
|
updateUserName (state, username) {
|
||||||
if (state.errorMnemonic) {
|
if (state.errorMnemonic) {
|
||||||
state.errorMnemonic = ''
|
state.errorMnemonic = ''
|
||||||
}
|
}
|
||||||
state.username = username
|
state.username = username
|
||||||
},
|
},
|
||||||
updatePasswd(state, passwd) {
|
updatePasswd (state, passwd) {
|
||||||
if (state.errorMnemonic) {
|
if (state.errorMnemonic) {
|
||||||
state.errorMnemonic = ''
|
state.errorMnemonic = ''
|
||||||
}
|
}
|
||||||
state.passwd = passwd
|
state.passwd = passwd
|
||||||
},
|
},
|
||||||
|
|
||||||
updateError(state, error) {
|
updateError (state, error) {
|
||||||
state.erroruser = error
|
state.erroruser = error
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSign(state, signing) {
|
updateSign (state, signing) {
|
||||||
state.signing = signing
|
state.signing = signing
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
async login({ state, commit }) {
|
async login ({ state, commit }) {
|
||||||
commit('updateSign', true)
|
commit('updateSign', true)
|
||||||
const passwd = Ticrypto.hash(state.passwd)
|
const passwd = Ticrypto.hash(state.passwd)
|
||||||
const ts = Date.now()
|
const ts = Date.now()
|
||||||
const path = '/admin/in'
|
const path = '/admin/in'
|
||||||
const sig = ticCrypto.hash(ts + path + 'LimitSaltLOL8080', { hasher: 'md5' })
|
const sig = ticrypto.hash(ts + path + 'LimitSaltLOL8080', {
|
||||||
let result = await axios.post('admin/in', { name: state.username, passwd }, { headers: { ts, sig } })
|
hasher: 'md5'
|
||||||
|
})
|
||||||
|
let result = await axios.post(
|
||||||
|
'admin/in',
|
||||||
|
{ name: state.username, passwd },
|
||||||
|
{ headers: { ts, sig } }
|
||||||
|
)
|
||||||
commit('updateSign', false)
|
commit('updateSign', false)
|
||||||
if (result.data.code === 0) {
|
if (result.data.code === 0) {
|
||||||
commit('updateAccount', result.data.data, { root: true })
|
commit('updateAccount', result.data.data, { root: true })
|
||||||
@@ -61,9 +67,9 @@ export default {
|
|||||||
commit('updateError', result.data.msg)
|
commit('updateError', result.data.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async createSecword({ state, commit }) {
|
async createSecword ({ state, commit }) {
|
||||||
let secword = ticCrypto.randomSecword() // 不能用 webworker 里的randomSecword,会导致报错 "window is not defined"。猜测是 bitcore-mnemonic 用到了window。
|
let secword = ticrypto.randomSecword() // 不能用 webworker 里的randomSecword,会导致报错 "window is not defined"。猜测是 bitcore-mnemonic 用到了window。
|
||||||
commit('updateMnemonic', secword)
|
commit('updateMnemonic', secword)
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9544,11 +9544,11 @@ thunky@^1.0.2:
|
|||||||
resolved "git+https://git.faronear.org/tic/tic.action.git#2a6607669a47d132a469984fef05004e2e4d1179"
|
resolved "git+https://git.faronear.org/tic/tic.action.git#2a6607669a47d132a469984fef05004e2e4d1179"
|
||||||
dependencies:
|
dependencies:
|
||||||
so.ling "git+https://git.faronear.org/so/so.ling#20190427_fon2so"
|
so.ling "git+https://git.faronear.org/so/so.ling#20190427_fon2so"
|
||||||
tic.crypto "git+https://git.faronear.org/tic/tic.crypto#20190109_preview"
|
tic-crypto "git+https://git.faronear.org/tic/tic-crypto#20190109_preview"
|
||||||
|
|
||||||
"tic.crypto@git+https://git.faronear.org/tic/tic.crypto#20190109_preview":
|
"tic-crypto@git+https://git.faronear.org/tic/tic-crypto#20190109_preview":
|
||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
resolved "git+https://git.faronear.org/tic/tic.crypto#15c35c803fb28ac0f289c367085620e800a5ddf9"
|
resolved "git+https://git.faronear.org/tic/tic-crypto#15c35c803fb28ac0f289c367085620e800a5ddf9"
|
||||||
dependencies:
|
dependencies:
|
||||||
bignumber.js "^6.0.0"
|
bignumber.js "^6.0.0"
|
||||||
bitcore-mnemonic "^1.5.0"
|
bitcore-mnemonic "^1.5.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user