44 <el-collapse v-model =" activeNames" >
55 <el-collapse-item title =" 账号配置" name =" account" >
66 <el-form label-width =" 180px" >
7- <el-form-item label =" Admin私钥" >
8- <el-input v-model =" privateKey" @change =" loadPrivateKey" placeholder =" 老板填,修改后自动导入" class =" w600" ></el-input >
9- </el-form-item >
107 <el-form-item label =" " >
11- <template slot="label">< span style = " color : orange " >或</ span > Admin助记词</template >
8+ <template slot="label">Admin助记词</template >
129 <el-input v-model =" mnemonic" @change =" loadFromMnemonic" placeholder =" 老板填,修改后自动导入" class =" w600" ></el-input >
13- </el-form-item >
14- <el-form-item label =" Admin地址" >
15- <el-input v-model =" accountAddress" readonly placeholder =" 点我自动显示" class =" w600" ></el-input >
1610 <span class =" ml6" >{{accountMessage}}</span >
1711 </el-form-item >
12+ <el-form-item label =" Admin Conflux地址" >
13+ <el-input v-model =" accountCfxAddress" readonly placeholder =" 点我自动显示" class =" w600" ></el-input >
14+ </el-form-item >
15+ <el-form-item label =" Admin Ethereum地址" >
16+ <el-input v-model =" accountEthAddress" readonly placeholder =" 点我自动显示" class =" w600" ></el-input >
17+ </el-form-item >
18+ <el-form-item label =" Admin Bitcoin地址" >
19+ <el-input v-model =" accountBitAddress" readonly placeholder =" 点我自动显示" class =" w600" ></el-input >
20+ </el-form-item >
1821 </el-form >
1922 </el-collapse-item >
2023
4245 </el-form-item >
4346 </el-form >
4447 </el-collapse-item >
45- <el-collapse-item title =" 合约升级 " name =" contract " >
48+ <el-collapse-item title =" Conflux消息签名 " name =" cfxSign " >
4649 <el-form label-width =" 180px" >
47- <el-form-item label =" 待签名消息" >
48- <el-input v-model =" hashToSign" aria-placeholder =" 老板填" class =" w600" ></el-input >
49- </el-form-item >
50- <el-form-item label =" " >
51- <el-button type =" primary" @click =" getHashUpgradeImpl" >生成签名</el-button >
52- <span class =" ml6" >{{contractSignMessage}}</span >
53- <el-button type =" primary" @click =" saveContractSign" class =" ml6" >保存到txt</el-button >
54- </el-form-item >
55- <el-form-item label =" " >
56- <el-input type =" text" :rows =" 5" v-model =" contractSign" class =" w600" ></el-input >
57- </el-form-item >
58- </el-form >
50+ <el-form-item label =" 待签名消息" >
51+ <el-input v-model =" hashToSign" aria-placeholder =" 老板填" class =" w600" ></el-input >
52+ </el-form-item >
53+ <el-form-item label =" " >
54+ <el-button type =" primary" @click =" getHashUpgradeImpl" >生成Conflux签名</el-button >
55+ <span class =" ml6" >{{contractSignMessage}}</span >
56+ <el-button type =" primary" @click =" saveContractSign" class =" ml6" >保存到txt</el-button >
57+ </el-form-item >
58+ <el-form-item label =" 签名结果" >
59+ <el-input type =" text" :rows =" 5" v-model =" contractSign" class =" w600" ></el-input >
60+ </el-form-item >
61+ </el-form >
62+ </el-collapse-item >
63+ <el-collapse-item title =" Ethereum消息签名" name =" ethSign" >
64+ <el-form label-width =" 180px" >
65+ <el-form-item label =" 待签名消息" >
66+ <el-input v-model =" hashToSignEth" aria-placeholder =" 老板填" class =" w600" ></el-input >
67+ </el-form-item >
68+ <el-form-item label =" " >
69+ <el-button type =" primary" @click =" getHashUpgradeEthImpl" >生成Ethereum签名</el-button >
70+ <span class =" ml6" >{{ethSignMessage}}</span >
71+ <el-button type =" primary" @click =" saveEthSign" class =" ml6" >保存到txt</el-button >
72+ </el-form-item >
73+ <el-form-item label =" 签名结果" >
74+ <el-input type =" text" :rows =" 5" v-model =" ethSign" class =" w600" ></el-input >
75+ </el-form-item >
76+ </el-form >
5977 </el-collapse-item >
6078 </el-collapse >
6179 </div >
6280</template >
6381
6482<script >
65- import {keysFromPrivateKey , keysFromMnemonic ,getEthWithdrawRawTransaction ,getHashUpgradeImpl ,signMessageCfx } from ' @/adminSigner'
83+ import {keysFromMnemonic ,getEthWithdrawRawTransaction ,getHashUpgradeImpl ,signMessageCfx , signMessageEth } from ' @/adminSigner'
6684import fileDownload from ' js-file-download'
6785export default {
6886 name: " Signer" ,
6987 methods: {
7088 saveContractSign () {
7189 const data = {
7290 hashToSign: this .hashToSign ,
73- contractNonce : this .contractNonce ,
74- contractSign : this .contractSign ,
91+ signBy : this .accountCfxAddress ,
92+ confluxSign : this .contractSign ,
7593 time: new Date ().Format (" yyyy-MM-dd hh:mm:ss" ),
7694 }
7795 const dataStr = JSON .stringify (data, null , 4 )
7896 const from = this .hashToSign .substr (2 , 6 )
79- const to = this .contractNonce
80- let filename = ` ${ new Date ().Format (" yyyy-MM-dd_hh-mm-ss" )} _Contract_${ from} _Nonce_${ to} .txt` ;
97+ let filename = ` ${ new Date ().Format (" yyyy-MM-dd_hh-mm-ss" )} _Conflux_${ from} .txt` ;
98+ fileDownload (dataStr, filename);
99+ },
100+ saveEthSign () {
101+ const data = {
102+ ethHashToSign: this .hashToSignEth ,
103+ signBy: this .accountEthAddress ,
104+ ethSign: this .ethSign ,
105+ time: new Date ().Format (" yyyy-MM-dd hh:mm:ss" ),
106+ }
107+ const dataStr = JSON .stringify (data, null , 4 )
108+ const from = this .hashToSignEth .substr (2 , 6 )
109+ let filename = ` ${ new Date ().Format (" yyyy-MM-dd_hh-mm-ss" )} _Eth_${ from} .txt` ;
81110 fileDownload (dataStr, filename);
82111 },
112+ getHashUpgradeEthImpl () {
113+ try {
114+ this .ethSign = signMessageEth (this .hashToSignEth , this .account .ethereum .privateKey )
115+ this .ethSignMessage = ' Ethereum签名成功'
116+ } catch (e) {
117+ this .ethSignMessage = ` Ethereum签名出错:${ e} `
118+ }
119+ },
83120 getHashUpgradeImpl () {
84121 try {
85- this .contractSign = signMessageCfx (this .hashToSign , this .privateKey )
86- this .contractSignMessage = ' 签名成功 '
122+ this .contractSign = signMessageCfx (this .hashToSign , this .account . conflux . privateKey )
123+ this .contractSignMessage = ' Conflux签名成功 '
87124 } catch (e) {
88- this .contractSignMessage = ` ${ e} `
125+ this .contractSignMessage = ` Conflux签名出错: ${ e} `
89126 }
90127 },
91128 saveWithdraw () {
@@ -121,31 +158,25 @@ export default {
121158 },
122159 loadFromMnemonic (){
123160 try {
124- const account = keysFromMnemonic (this .mnemonic )
125- this .accountAddress = account .address
126- this .privateKey = account .privateKey
161+ this .account = keysFromMnemonic (this .mnemonic )
162+ this .accountCfxAddress = this .account .conflux .address
163+ this .accountEthAddress = this .account .ethereum .address
164+ this .accountBitAddress = this .account .bitcoin .address
127165 this .accountMessage = ' 助记词导入成功'
128166 } catch (e) {
129- this .accountMessage = ` ${ e} `
167+ this .accountMessage = ` 导入出错: ${ e} `
130168 }
131169 },
132- loadPrivateKey (){
133- try {
134- const account = keysFromPrivateKey (this .privateKey )
135- this .accountAddress = account .address
136- this .accountMessage = ' 私钥导入成功'
137- } catch (e) {
138- this .accountMessage = ` ${ e} `
139- }
140- }
141170 },
142171 data () {
143172 return {
144173 activeNames: [' account' ],
145174 //
146- privateKey : ' ' ,
175+ account : {}, // multiple account
147176 mnemonic: ' ' ,
148- accountAddress: ' ' ,
177+ accountCfxAddress: ' ' ,
178+ accountEthAddress: ' ' ,
179+ accountBitAddress: ' ' ,
149180 accountMessage: ' ' ,
150181 //
151182 rawWithdrawTx: ' ' ,
@@ -154,11 +185,15 @@ export default {
154185 adminNonce: ' ' ,
155186 epochNumber: ' ' ,
156187 withdrawMessage: ' ' ,
157- //
188+ // conflux
158189 hashToSign: ' ' ,
159190 contractNonce: ' ' ,
160191 contractSignMessage: ' ' ,
161- contractSign: ' ' ,
192+ contractSign: ' ' , // conflux
193+ // eth
194+ hashToSignEth: ' ' ,
195+ ethSignMessage: ' ' ,
196+ ethSign: ' ' ,
162197 }
163198 }
164199}
0 commit comments