@@ -480,14 +480,13 @@ async function walletInitialized() {
480480 const transferFromButton = getElement ( 'transfer_from' )
481481 const getCFXButton = getElement ( 'get-cfx' )
482482 const importAddressButton = getElement ( 'import_address_button' )
483- const importPrivateKeyButton = getElement ( 'import_private_key_button' )
484483 const nativeReceiverAddressInput = getElement ( 'native-receiver' )
485484 const countInput = getElement ( 'native-count' )
486485 const approveAccountInput = getElement ( 'approve-account' )
487486 const transferFromAccountInput = getElement ( 'from-account' )
488487 const transferToAccountInput = getElement ( 'to-account' )
489488 const importAddressInput = getElement ( 'import_address_input' )
490- const importPrivateKeyInput = getElement ( 'import_private_key_input ' )
489+ const importAddressNameInput = getElement ( 'import_address_name_input ' )
491490
492491 const deployContract = getElement ( 'deploy_contract' )
493492
@@ -508,7 +507,6 @@ async function walletInitialized() {
508507 connectButton . disabled = true
509508 logoutButton . disabled = false
510509 importAddressButton . disabled = false
511- importPrivateKeyButton . disabled = false
512510 }
513511
514512 function unAuthed ( ) {
@@ -523,7 +521,6 @@ async function walletInitialized() {
523521 connectButton . disabled = false
524522 logoutButton . disabled = true
525523 importAddressButton . disabled = true
526- importPrivateKeyButton . disabled = true
527524 }
528525
529526 provider . on ( 'accountsChanged' , ( accounts ) => {
@@ -726,34 +723,26 @@ async function walletInitialized() {
726723 getElement ( 'import_address_result' ) . innerHTML = 'valid Params'
727724 return
728725 }
729- try {
730- const tx = {
731- address : importAddressInput . value . replace ( / \s + / g, '' ) . split ( ',' ) ,
732- }
733- provider
734- . request ( { method : 'anyweb_importAccount' , params : [ tx ] } )
735- . then ( ( result ) => {
736- getElement ( 'import_address_result' ) . innerHTML = result
737- console . log ( 'result' , result )
738- } )
739- } catch ( err ) {
740- console . log ( 'err' , err )
741- }
742- }
743-
744- importPrivateKeyButton . onclick = async ( ) => {
745- if ( importPrivateKeyInput . value . replace ( / \s + / g, '' ) === '' ) {
746- getElement ( 'import_private_key_result' ) . innerHTML = 'valid Params'
726+ const addressLength = importAddressInput . value . split ( ',' ) . length
727+ const addressName = importAddressNameInput . value
728+ . split ( ',' )
729+ . filter ( ( name ) => name !== '' )
730+ const addressNamesLength = addressName . length
731+ console . log ( 'addressNamesLength' , addressNamesLength )
732+ if ( addressNamesLength > 0 && addressNamesLength !== addressLength ) {
733+ getElement ( 'import_address_result' ) . innerHTML =
734+ 'address length not equal to address name length'
747735 return
748736 }
749737 try {
750738 const tx = {
751- privateKey : importPrivateKeyInput . value . replace ( / \s + / g, '' ) . split ( ',' ) ,
739+ address : importAddressInput . value . replace ( / \s + / g, '' ) . split ( ',' ) ,
740+ addressName : addressName ,
752741 }
753742 provider
754743 . request ( { method : 'anyweb_importAccount' , params : [ tx ] } )
755744 . then ( ( result ) => {
756- getElement ( 'import_private_key_result ' ) . innerHTML = result
745+ getElement ( 'import_address_result ' ) . innerHTML = result
757746 console . log ( 'result' , result )
758747 } )
759748 } catch ( err ) {
0 commit comments