1- import { StdSignDoc } from '@interchainjs/types' ;
21import { Chain } from '@chain-registry/types' ;
32import { BaseWallet , CosmosWallet , DirectSignDoc , getWalletByType , isInstanceOf , OfflineAminoSigner , OfflineDirectSigner , SignType , WalletAccount , WalletManager , WalletState , WCWallet } from '@interchain-kit/core' ;
3+ import { StdSignDoc } from '@interchainjs/types' ;
44
55import { InterchainStore } from '../store' ;
66
@@ -21,6 +21,7 @@ export class ChainWalletStore extends BaseWallet {
2121 this . chain = chain ;
2222 this . store = store ;
2323 this . walletManager = walletManager ;
24+ this . info = this . wallet . info ;
2425 }
2526
2627 get walletState ( ) : WalletState {
@@ -33,14 +34,14 @@ export class ChainWalletStore extends BaseWallet {
3334
3435 async init ( ) : Promise < void > {
3536 this . wallet . events . on ( 'accountChanged' , ( ) => {
36- this . refreshAccount ( )
37+ this . refreshAccount ( ) ;
3738 } ) ;
3839 }
3940 async connect ( ) : Promise < void > {
4041
4142 const chainWalletState = this . store . getChainWalletState ( this . wallet . info . name , this . chain . chainName ) ;
4243 if ( chainWalletState && chainWalletState . walletState === WalletState . NotExist ) {
43- return Promise . resolve ( )
44+ return Promise . resolve ( ) ;
4445 }
4546
4647 if ( isInstanceOf ( this . wallet , WCWallet ) ) {
@@ -51,7 +52,8 @@ export class ChainWalletStore extends BaseWallet {
5152 }
5253
5354 try {
54- this . store . updateChainWalletState ( this . wallet . info . name , this . chain . chainName , { walletState : WalletState . Connecting } ) ;
55+ console . log ( 1 ) ;
56+ this . store . updateChainWalletState ( this . wallet . info . name , this . chain . chainName , { walletState : WalletState . Connecting , errorMessage : '' } ) ;
5557 await this . wallet . connect ( this . chain . chainId ) ;
5658 const account = await this . getAccount ( ) ;
5759 this . store . updateChainWalletState ( this . wallet . info . name , this . chain . chainName , { walletState : WalletState . Connected , account } ) ;
@@ -77,9 +79,7 @@ export class ChainWalletStore extends BaseWallet {
7779
7880 async refreshAccount ( ) : Promise < void > {
7981 try {
80- const account = await this . wallet . getAccount ( this . chain . chainId )
81-
82- console . log ( this . wallet )
82+ const account = await this . wallet . getAccount ( this . chain . chainId ) ;
8383
8484 this . store . updateChainWalletState ( this . wallet . info . name , this . chain . chainName , { account } ) ;
8585 } catch ( error ) {
@@ -108,20 +108,20 @@ export class ChainWalletStore extends BaseWallet {
108108
109109 const preferredSignTypeFromSettings = this . walletManager . getPreferSignType ( this . chain . chainName ) ;
110110
111- const account = await this . getAccount ( )
111+ const account = await this . getAccount ( ) ;
112112
113113 const aminoOfflineSigner = {
114114 getAccounts : async ( ) => [ account ] ,
115115 signAmino : async ( signer : string , signDoc : StdSignDoc ) => {
116116 return cosmosWallet . signAmino ( this . chain . chainId , signer , signDoc , { } ) ;
117117 }
118- }
118+ } ;
119119 const directOfflineSigner = {
120120 getAccounts : async ( ) => [ account ] ,
121121 signDirect : async ( signer : string , signDoc : DirectSignDoc ) => {
122122 return cosmosWallet . signDirect ( this . chain . chainId , signer , signDoc , { } ) ;
123123 }
124- }
124+ } ;
125125
126126 const signType = preferSignType || preferredSignTypeFromSettings ;
127127
0 commit comments