-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathuseChainWallet.ts
More file actions
28 lines (24 loc) · 1.19 KB
/
useChainWallet.ts
File metadata and controls
28 lines (24 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { computed, Ref } from 'vue'
import { AssetList, Chain } from "@chain-registry/v2-types"
import { useWalletManager } from "./useWalletManager"
import { useAccount } from "./useAccount"
import { BaseWallet } from "@interchain-kit/core"
import { UseChainReturnType } from "../types/chain"
import { useInterchainClient } from "./useInterchainClient"
import { getChainLogoUrl } from "../utils"
export function useChainWallet(chainName: Ref<string>, walletName: Ref<string>): UseChainReturnType {
const walletManager = useWalletManager()
const chainToShow = computed(() => walletManager.chains.find((c: Chain) => c.chainName === chainName.value))
const assetList = computed(() => walletManager.assetLists.find((a: AssetList) => a.chainName === chainName.value))
const wallet = computed(() => walletManager.wallets.find((w: BaseWallet) => w.option.name === walletName.value))
const account = useAccount(chainName, walletName)
const interchainClient = useInterchainClient(chainName, walletName)
return {
logoUrl: computed(() => getChainLogoUrl(assetList.value)),
chain: chainToShow,
assetList,
address: computed(() => account.value?.address),
wallet,
...interchainClient
}
}