11import { INightElfWalletAdapterConfig } from './index' ;
2- import { makeError , utils , ERR_CODE } from '@aelf-web-login/wallet-adapter-base' ;
2+ import { makeError , utils , ERR_CODE , WalletTypeEnum } from '@aelf-web-login/wallet-adapter-base' ;
33import type { AElfDappBridge , PublicKey } from '@aelf-react/types' ;
44import AelfBridgeCheck from './AelfBridgeCheck' ;
55import NightElfCheck from './NightElfCheck' ;
66
77export const getBridges = async ( nodes : INightElfWalletAdapterConfig [ 'nodes' ] , appName : string ) => {
8- const { isMobileDevices } = utils ;
8+ const { isMobileDevices, checkConnectedWallet } = utils ;
99 try {
1010 const isAElfBridge = isMobileDevices ( ) && ! ( window as any ) ?. NightElf ;
1111 console . log ( 'aelf-wallet-debug----------1' ) ;
@@ -24,7 +24,8 @@ export const getBridges = async (nodes: INightElfWalletAdapterConfig['nodes'], a
2424 const bridges : { [ key : string ] : AElfDappBridge } = { } ;
2525 console . log ( 'nodes:' , nodes ) ;
2626 if ( ! nodes || Object . keys ( nodes ) . length === 0 ) {
27- throw makeError ( ERR_CODE . INIT_BRIDGE_ERROR ) ;
27+ checkConnectedWallet ( WalletTypeEnum . elf ) ;
28+ throw makeError ( ERR_CODE . NIGHT_ELF_NOT_DETECTED ) ;
2829 }
2930 Object . entries ( nodes ) . forEach ( ( [ k , v ] ) => {
3031 if ( ! firstKey ) firstKey = k ;
@@ -35,7 +36,8 @@ export const getBridges = async (nodes: INightElfWalletAdapterConfig['nodes'], a
3536 const bridge = bridges [ firstKey ] ;
3637 return { bridge, node, bridges } ;
3738 } catch ( e ) {
38- throw makeError ( ERR_CODE . INIT_BRIDGE_ERROR ) ;
39+ checkConnectedWallet ( WalletTypeEnum . elf ) ;
40+ throw makeError ( ERR_CODE . NIGHT_ELF_NOT_DETECTED ) ;
3941 }
4042} ;
4143
0 commit comments