Skip to content

Commit

Permalink
Removed TODO and updated cosmos kit to fix useChains.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 5, 2023
1 parent 1969b15 commit c4241b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
22 changes: 5 additions & 17 deletions packages/stateful/components/SelfRelayExecuteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,15 @@ export const SelfRelayExecuteModal = ({
const chainIds = [currentChainId, ..._chainIds]
const chains = uniq(chainIds).map(getChainForChainId)

const chainNames = chains.map(({ chain_name }) => chain_name)
const wallets = useChains(chainNames)
const wallets = useChains(chains.map(({ chain_name }) => chain_name))
// Connect other chains.
useDeepCompareEffect(() => {
const currentWallet = wallets[currentChainName]
if (!currentWallet?.wallet || !currentWallet.isWalletConnected) {
if (!wallets[currentChainName]?.isWalletConnected) {
return
}
// Connect wallet to other chains.
chainNames.forEach((chainName) => {
if (chainName === currentChainName) {
return
}
wallets[chainName]?.walletRepo.connect(currentWallet.wallet!.name)
})
}, [
currentChainName,
t,
chainNames,
wallets[currentChainName]?.isWalletConnected,
])
// Connect other chain wallets.
Object.values(wallets).forEach((wallet) => wallet.connect())
}, [currentChainName, t, wallets[currentChainName]?.isWalletConnected])

const [status, setStatus] = useState<RelayStatus>(RelayStatus.Uninitialized)
const [relayError, setRelayError] = useState<string>()
Expand Down
6 changes: 2 additions & 4 deletions packages/stateful/hooks/useWalletInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export const useWalletInfo = ({
})
chainId ||= walletChain.chain_id

// TODO(cosmos-kit-dynamic-conn-fn): Replace this when cosmos-kit supports
// dynamic chain connection fn.
// PFPK uses Juno signatures for signing.
const junoWallet = useWallet({
chainId: ChainId.JunoMainnet,
})
Expand Down Expand Up @@ -182,8 +181,7 @@ export const useWalletInfo = ({
profile: Omit<WalletProfileUpdate, 'nonce'>,
onUpdate?: () => void
): Promise<void> => {
// Use a consistent chain for the signer since the chain ID is part of the
// signature and PFPK needs to know what to expect.
// PFPK uses Juno signatures for signing.
const { address: signer, signAmino } = junoWallet
if (
!signer ||
Expand Down
2 changes: 1 addition & 1 deletion packages/stateful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@cosmos-kit/keplr-mobile": "^2.3.3",
"@cosmos-kit/leap": "^2.3.3",
"@cosmos-kit/omni": "^2.3.3",
"@cosmos-kit/react-lite": "^2.4.4",
"@cosmos-kit/react-lite": "^2.4.5",
"@cosmos-kit/shell": "^2.3.3",
"@cosmos-kit/station": "^2.3.3",
"@cosmos-kit/trust": "^2.3.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3402,10 +3402,10 @@
dependencies:
"@cosmos-kit/omni-mobile" "^2.3.3"

"@cosmos-kit/react-lite@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.4.4.tgz#8c0cb9688c94ebec7a87c0ede92bb886effb2efa"
integrity sha512-00bmwcTI4aVoVSdNjWMcDpScxYKKeZiIpIggiqGdGxJIccrrHyCbOendV8nWHMjBAhj01rVozNJvKUy6TByZng==
"@cosmos-kit/react-lite@^2.4.5":
version "2.4.5"
resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.4.5.tgz#7efbce761d6654828d6a9943b7f05e9cea279724"
integrity sha512-Mhpa2+8fPQAkSiwlYQc/ltQ8GnfCgs3iGb7HWC57rTB+5OQ12JPkGRY12f/qgPWG1caGxwf1qUrPe/lxl8GAwQ==
dependencies:
"@chain-registry/types" "0.13.1"
"@cosmos-kit/core" "^2.5.3"
Expand Down

0 comments on commit c4241b0

Please sign in to comment.