@@ -59,32 +59,40 @@ function resolveMoniker(valAddr: string): string {
5959}
6060
6161// ── Detect available wallets ──
62- export function getAvailableWallets ( ) : { keplr : boolean ; leap : boolean } {
63- if ( typeof window === "undefined" ) return { keplr : false , leap : false } ;
62+ export function getAvailableWallets ( ) : { keplr : boolean ; leap : boolean ; cosmostation : boolean } {
63+ if ( typeof window === "undefined" ) return { keplr : false , leap : false , cosmostation : false } ;
6464 return {
6565 keplr : ! ! ( window as any ) . keplr ,
6666 leap : ! ! ( window as any ) . leap ,
67+ cosmostation : ! ! ( window as any ) . cosmostation ,
6768 } ;
6869}
6970
70- // ── Get wallet provider (Keplr or Leap ) ──
71- function getWalletProvider ( type : "keplr" | "leap" ) {
71+ // ── Get wallet provider (Keplr, Leap, or Cosmostation ) ──
72+ function getWalletProvider ( type : "keplr" | "leap" | "cosmostation" ) {
7273 if ( typeof window === "undefined" ) return null ;
7374 if ( type === "leap" ) return ( window as any ) . leap ;
75+ if ( type === "cosmostation" ) {
76+ // Cosmostation exposes a Keplr-compatible provider
77+ const cosmostation = ( window as any ) . cosmostation ;
78+ if ( cosmostation ?. providers ?. keplr ) return cosmostation . providers . keplr ;
79+ // Fallback: some versions expose it directly
80+ return cosmostation ;
81+ }
7482 return ( window as any ) . keplr ;
7583}
7684
7785/**
7886 * Connect wallet (Keplr or Leap) and return wallet state
7987 */
80- export async function connectWallet ( walletType : "keplr" | "leap" = "keplr" ) : Promise < WalletState > {
88+ export async function connectWallet ( walletType : "keplr" | "leap" | "cosmostation" = "keplr" ) : Promise < WalletState > {
8189 if ( typeof window === "undefined" ) {
8290 throw new Error ( "Window not available" ) ;
8391 }
8492
8593 const provider = getWalletProvider ( walletType ) ;
8694 if ( ! provider ) {
87- const name = walletType === "leap" ? "Leap" : "Keplr" ;
95+ const name = walletType === "cosmostation" ? "Cosmostation" : walletType === " leap" ? "Leap" : "Keplr" ;
8896 throw new Error (
8997 `${ name } wallet not found. Please install the ${ name } browser extension.`
9098 ) ;
@@ -240,7 +248,7 @@ async function fetchUnbondingDelegations(address: string): Promise<UnbondingDele
240248export async function delegateTokens (
241249 validatorAddress : string ,
242250 amount : number ,
243- walletType : "keplr" | "leap" = "keplr"
251+ walletType : "keplr" | "leap" | "cosmostation" = "keplr"
244252) : Promise < string > {
245253 const provider = getWalletProvider ( walletType ) ;
246254 if ( ! provider ) throw new Error ( `${ walletType } not available` ) ;
@@ -278,7 +286,7 @@ export async function delegateTokens(
278286export async function undelegateTokens (
279287 validatorAddress : string ,
280288 amount : number ,
281- walletType : "keplr" | "leap" = "keplr"
289+ walletType : "keplr" | "leap" | "cosmostation" = "keplr"
282290) : Promise < string > {
283291 const provider = getWalletProvider ( walletType ) ;
284292 if ( ! provider ) throw new Error ( `${ walletType } not available` ) ;
@@ -320,7 +328,7 @@ export async function undelegateTokens(
320328 */
321329export async function claimAllRewards (
322330 delegations : Delegation [ ] ,
323- walletType : "keplr" | "leap" = "keplr"
331+ walletType : "keplr" | "leap" | "cosmostation" = "keplr"
324332) : Promise < string > {
325333 const provider = getWalletProvider ( walletType ) ;
326334 if ( ! provider ) throw new Error ( `${ walletType } not available` ) ;
@@ -377,7 +385,7 @@ export async function redelegateTokens(
377385 srcValidatorAddress : string ,
378386 dstValidatorAddress : string ,
379387 amount : number ,
380- walletType : "keplr" | "leap" = "keplr"
388+ walletType : "keplr" | "leap" | "cosmostation" = "keplr"
381389) : Promise < string > {
382390 const provider = getWalletProvider ( walletType ) ;
383391 if ( ! provider ) throw new Error ( `${ walletType } not available` ) ;
0 commit comments