Skip to content

Commit 04b4c05

Browse files
committed
fix: use correct signer
1 parent caa234a commit 04b4c05

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/src/lib/wallet/cosmos/config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ function createCosmosStore(
121121

122122
export const cosmosStore = createCosmosStore()
123123

124-
export const getCosmosOfflineSigner = (chainId: string): Promise<OfflineSigner> =>
124+
export const getCosmosOfflineSigner = ({
125+
chainId,
126+
connectedWallet
127+
}: {
128+
chainId: string
129+
connectedWallet: CosmosWalletId
130+
}): Promise<OfflineSigner> =>
125131
// @ts-expect-error
126-
get(cosmosStore).connectedWallet === "keplr"
127-
? window.keplr?.getOfflineSignerAuto(chainId, { disableBalanceCheck: false })
128-
: window.leap?.getOfflineSignerAuto(chainId, { disableBalanceCheck: false })
129-
132+
window[connectedWallet]?.getOfflineSignerAuto(chainId, { disableBalanceCheck: false })
130133

131134
export const userAddrCosmos: Readable<UserAddressCosmos | null> = derived(
132135
[cosmosStore],

app/src/routes/transfer/(components)/transfer-form.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type EvmChainId,
66
createUnionClient,
77
type CosmosChainId,
8+
type OfflineSigner,
89
evmChainFromChainId,
910
bech32ToBech32Address
1011
} from "@unionlabs/client"
@@ -37,14 +38,14 @@ import * as Card from "$lib/components/ui/card/index.ts"
3738
import type { Chain, UserAddresses } from "$lib/types.ts"
3839
import { Input } from "$lib/components/ui/input/index.js"
3940
import { userAddrOnChain } from "$lib/utilities/address.ts"
41+
import { cosmosStore } from "$/lib/wallet/cosmos/config.ts"
4042
import { Button } from "$lib/components/ui/button/index.ts"
4143
import { getSupportedAsset } from "$lib/utilities/helpers.ts"
4244
import CardSectionHeading from "./card-section-heading.svelte"
4345
import ArrowLeftRight from "virtual:icons/lucide/arrow-left-right"
4446
import { getCosmosChainInfo } from "$lib/wallet/cosmos/chain-info.ts"
4547
import { submittedTransfers } from "$lib/stores/submitted-transfers.ts"
4648
import { parseUnits, formatUnits, type HttpTransport, getAddress } from "viem"
47-
import { cosmosStore, getCosmosOfflineSigner } from "$/lib/wallet/cosmos/config.ts"
4849
import { type Writable, writable, derived, get, type Readable } from "svelte/store"
4950
import { type TransferState, stepBefore, stepAfter } from "$lib/transfer/transfer.ts"
5051
@@ -230,7 +231,7 @@ const transfer = async () => {
230231
return
231232
}
232233
233-
const wallet = window[connectedWallet as "keplr" | "leap"]
234+
const wallet = window[connectedWallet]
234235
235236
if (!wallet) {
236237
transferState.set({
@@ -240,6 +241,10 @@ const transfer = async () => {
240241
return
241242
}
242243
244+
const cosmosOfflineSigner = (await wallet.getOfflineSignerAuto($fromChainId, {
245+
disableBalanceCheck: false
246+
})) as OfflineSigner
247+
243248
// @ts-ignore
244249
transferState.set({ kind: "SWITCHING_TO_CHAIN" })
245250
@@ -280,8 +285,6 @@ const transfer = async () => {
280285
281286
if (stepBefore($transferState, "TRANSFERRING")) {
282287
try {
283-
const cosmosOfflineSigner = await getCosmosOfflineSigner($fromChainId)
284-
285288
const unionClient = createUnionClient({
286289
account: cosmosOfflineSigner,
287290
transport: http(`https://${rpcUrl}`),

0 commit comments

Comments
 (0)