-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(namadillo): starting integration with keplr wallet
- Loading branch information
1 parent
9153a1f
commit b8d1a96
Showing
24 changed files
with
480 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import cosmos from "@namada/chains/chains/cosmos"; | ||
import { integrations } from "@namada/integrations"; | ||
import { selectedIBCChainAtom, selectedIBCWallet } from "atoms/integrations"; | ||
import { wallets } from "integrations"; | ||
import { useAtom } from "jotai"; | ||
import { WalletProvider } from "types"; | ||
import { TransferModule } from "./TransferModule"; | ||
|
||
export const IBCFromNamadaModule = (): JSX.Element => { | ||
const [selectedWallet, setWallet] = useAtom(selectedIBCWallet); | ||
const [chainId, setChainId] = useAtom(selectedIBCChainAtom); | ||
|
||
return ( | ||
<div> | ||
<TransferModule isConnected={false} onSubmitTransfer={() => {}} /> | ||
<TransferModule | ||
isConnected={false} | ||
onSubmitTransfer={() => {}} | ||
availableWallets={Object.values(wallets)} | ||
selectedWallet={selectedWallet ? wallets[selectedWallet] : undefined} | ||
onChangeWallet={async (wallet: WalletProvider) => { | ||
try { | ||
await integrations[wallet.id].connect(); | ||
setWallet(wallet.id); | ||
if (!chainId) { | ||
setChainId(cosmos.chainId); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { integrations } from "@namada/integrations"; | ||
import { SelectModal } from "App/Common/SelectModal"; | ||
import { WalletProvider } from "types"; | ||
import { WalletCard } from "./WalletCard"; | ||
|
||
type SelectWalletModalProps = { | ||
onClose: () => void; | ||
wallets: WalletProvider[]; | ||
onConnect: (wallet: WalletProvider) => void; | ||
}; | ||
|
||
export const SelectWalletModal = ({ | ||
onClose, | ||
onConnect, | ||
wallets, | ||
}: SelectWalletModalProps): JSX.Element => { | ||
const isConnected = (_wallet: WalletProvider): boolean => { | ||
return false; | ||
}; | ||
|
||
const isInstalled = (wallet: WalletProvider): boolean => { | ||
if (wallet.id in integrations) { | ||
return integrations[wallet.id].detect(); | ||
} | ||
return false; | ||
}; | ||
|
||
return ( | ||
<SelectModal title="Source" onClose={onClose}> | ||
<ul> | ||
{wallets.map((wallet: WalletProvider, index) => ( | ||
<li key={index} className="px-5 text-sm"> | ||
<WalletCard | ||
connected={isConnected(wallet)} | ||
installed={isInstalled(wallet)} | ||
wallet={wallet} | ||
onConnect={() => onConnect(wallet)} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</SelectModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { integrations } from "@namada/integrations"; | ||
import { shortenAddress } from "@namada/utils"; | ||
import clsx from "clsx"; | ||
import { useEffect, useState } from "react"; | ||
import { WalletProvider } from "types"; | ||
|
||
type SelectedWalletProps = { | ||
wallet: WalletProvider; | ||
onClick?: () => void; | ||
}; | ||
|
||
export const SelectedWallet = ({ | ||
wallet, | ||
onClick, | ||
}: SelectedWalletProps): JSX.Element => { | ||
const [walletAddress, setWalletAddress] = useState(""); | ||
|
||
const loadAccounts = async (): Promise<void> => { | ||
try { | ||
const integration = integrations[wallet.id]; | ||
integration.detect(); | ||
await integration.connect(); | ||
const accounts = await integration.accounts(); | ||
if (accounts && accounts.length > 0) { | ||
setWalletAddress(accounts[0].address); | ||
} | ||
} catch { | ||
// TODO: handle error catching | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
loadAccounts(); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
role="button" | ||
className={clsx( | ||
"flex justify-between items-center gap-2 text-sm text-neutral-500", | ||
"font-light text-right transition-colors hover:text-neutral-400" | ||
)} | ||
onClick={onClick} | ||
> | ||
{walletAddress && shortenAddress(walletAddress, 8, 6)} | ||
<img src={wallet.iconUrl} alt={wallet.name + " Logo"} className="w-6" /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.