Skip to content

Commit

Permalink
feat: check for cosmos wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Sep 21, 2022
1 parent c4d1af5 commit 925f68b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/sdk-ui-ts/src/core/clients/MsgBroadcastClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getInjectiveAddress,
IndexerGrpcTransactionApi,
} from '@injectivelabs/sdk-ts'
import { Wallet } from '@injectivelabs/wallet-ts'
import { isCosmosWallet } from '@injectivelabs/wallet-ts'
import { MsgBroadcastOptions, MsgBroadcastTxOptions } from './types'
import { getGasPriceBasedOnMessage } from './utils'

Expand All @@ -22,7 +22,7 @@ export class MsgBroadcastClient {
const { options } = this
const { walletStrategy } = options

return [Wallet.Keplr, Wallet.Leap].includes(walletStrategy.wallet)
return isCosmosWallet(walletStrategy.wallet)
? this.broadcastCosmos(tx)
: this.broadcastWeb3(tx)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
DEFAULT_TIMEOUT_HEIGHT,
} from '@injectivelabs/sdk-ts'
import { recoverTypedSignaturePubKey } from '@injectivelabs/sdk-ts/dist/utils/transaction'
import { Wallet } from '@injectivelabs/wallet-ts'
import {
createTransaction,
createTxRawEIP712,
Expand All @@ -26,6 +25,7 @@ import {
TransactionException,
UnspecifiedErrorCode,
} from '@injectivelabs/exceptions'
import { isCosmosWallet } from '@injectivelabs/wallet-ts'

export class MsgBroadcastExperimentalClient {
public options: MsgBroadcastOptions
Expand All @@ -38,7 +38,7 @@ export class MsgBroadcastExperimentalClient {
const { options } = this
const { walletStrategy } = options

return [Wallet.Keplr, Wallet.Leap].includes(walletStrategy.wallet)
return isCosmosWallet(walletStrategy.wallet)
? this.broadcastKeplr(tx)
: this.broadcastWeb3(tx)
}
Expand Down
5 changes: 5 additions & 0 deletions packages/wallet-ts/src/wallet-strategy/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { Wallet } from './types'

export { default as WalletStrategy } from './WalletStrategy'
export * from './strategies'
export * from './types'

export const isCosmosWallet = (wallet: Wallet): boolean =>
[Wallet.Cosmostation, Wallet.Leap, Wallet.Keplr].includes(wallet)

0 comments on commit 925f68b

Please sign in to comment.