From 908ba3c66e896a40f74f05e7af6a3f8a571a0b9a Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 14 Aug 2022 15:52:39 +0800 Subject: [PATCH] rename seckey to prikey --- src/services/api/tic-bg.js | 2 +- src/services/api/tic.js | 4 ++-- src/services/tic.js | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/services/api/tic-bg.js b/src/services/api/tic-bg.js index 485eb02..6a30908 100644 --- a/src/services/api/tic-bg.js +++ b/src/services/api/tic-bg.js @@ -2,7 +2,7 @@ import ticrypto from 'tic-crypto' import { TIC } from '../tic' -export const seckey2pubkey = seckey => ticrypto.seckey2pubkey(seckey) +export const seckey2pubkey = prikey => ticrypto.seckey2pubkey(prikey) export const secword2address = secword => ticrypto.secword2address(secword) export const secword2account = secword => ticrypto.secword2account(secword) // export const randomSecword = lang => ticrypto.randomSecword(lang) diff --git a/src/services/api/tic.js b/src/services/api/tic.js index 400ae5e..cd5e02c 100644 --- a/src/services/api/tic.js +++ b/src/services/api/tic.js @@ -4,10 +4,10 @@ import * as worker from 'workerize-loader!./tic-bg' const instance = worker() export default { - seckey2pubkey: seckey => instance.seckey2pubkey(seckey), + seckey2pubkey: prikey => instance.seckey2pubkey(prikey), secword2address: secword => instance.secword2address(secword), isAddress: address => instance.isAddress(address), secword2account: secword => instance.secword2account(secword), // randomSecword: async lang => instance.randomSecword(lang), - transferTic: params => instance.transferTic(params), + transferTic: params => instance.transferTic(params) } diff --git a/src/services/tic.js b/src/services/tic.js index 0809984..9c8022d 100644 --- a/src/services/tic.js +++ b/src/services/tic.js @@ -7,22 +7,22 @@ const TicActionTransfer = ticAction.ActionTransfer const TIC_TXFEE = 10 export class TIC { - constructor (seckey, option = {}) { - if (!seckey || !Ticrypto.isSeckey(seckey)) + constructor (prikey, option = {}) { + if (!prikey || !Ticrypto.isSeckey(prikey)) throw Error('ERROR:Invalid Seckey') Object.defineProperties(this, { - seckey: { - value: seckey, + prikey: { + value: prikey, enumerable: true, writable: false }, pubkey: { - value: Ticrypto.seckey2pubkey(seckey), + value: Ticrypto.seckey2pubkey(prikey), enumerable: true, writable: false }, address: { - value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(seckey)), + value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(prikey)), enumerable: true, writable: false } @@ -40,14 +40,14 @@ export class TIC { static generateNewAccount () { var secword = Ticrypto.randomSecword() - return Object.assign(new TIC(Ticrypto.secword2keypair(secword).seckey), { + return Object.assign(new TIC(Ticrypto.secword2keypair(secword).prikey), { secword: secword }) } static fromMnemonic (secword) { if (!secword || !Ticrypto.isSecword(secword)) throw Error('ERROR:Invalid Secword') - return new TIC(Ticrypto.secword2keypair(secword).seckey) + return new TIC(Ticrypto.secword2keypair(secword).prikey) } static async getBalance (address) { if (!address) { @@ -108,7 +108,7 @@ export class TIC { }) // 对交易数据签名,packMe 内的参数是交易发起人的keypair action.packMe({ - seckey: this.seckey, + prikey: this.prikey, pubkey: this.pubkey, address: this.address }) @@ -140,18 +140,18 @@ export class TIC { }) // sign for txBody use function packMe, which needs actor's keypair as parameter action.packMe({ - seckey: this.seckey, + prikey: this.prikey, pubkey: this.pubkey, address: this.address }) return action } - // default key for sign&encrypt is account's seckey,other keys are optional. - sign (message, key = this.seckey) { + // default key for sign&encrypt is account's prikey,other keys are optional. + sign (message, key = this.prikey) { return Ticrypto.sign(message, key) } verify (message, signature) { - return Ticrypto.sign(message, signature, this.seckey) + return Ticrypto.sign(message, signature, this.prikey) } encrypt (key) { return TIC.encrypt(this, key)