Skip to content

Commit

Permalink
Merge pull request #510 from owallet-io/feat/owallet-mobile
Browse files Browse the repository at this point in the history
Add OWallet Mobile to Wallet-Kit
  • Loading branch information
pyramation authored Dec 16, 2024
2 parents 00b62e1 + 2cdd878 commit ea30b49
Show file tree
Hide file tree
Showing 31 changed files with 862 additions and 174 deletions.
6 changes: 3 additions & 3 deletions packages/cosmos-kit/src/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { wallets as frontierExtension } from '@cosmos-kit/frontier-extension';
import { wallets as keplrExtension } from '@cosmos-kit/keplr-extension';
import { wallets as keplrMobile } from '@cosmos-kit/keplr-mobile';
import { wallets as owalletExtension } from '@cosmos-kit/owallet-extension';
import { wallets as owalletMobile } from '@cosmos-kit/owallet-mobile';
import { wallets as leapExtension } from '@cosmos-kit/leap-extension';
import { wallets as leapMobile } from '@cosmos-kit/leap-mobile';
import { wallets as leapMetamaskCosmosSnap } from '@cosmos-kit/leap-metamask-cosmos-snap';
Expand Down Expand Up @@ -79,7 +80,6 @@ export function createWalletList<
}

export const keplr = createWalletList(keplrExtension[0], keplrMobile[0]);

export const cosmostation = createWalletList(
cosmostationExtension[0],
cosmostationMobile[0]
Expand All @@ -103,7 +103,7 @@ export const coin98 = createWalletList(coin98Extension[0], null);
export const compass = createWalletList(compassExtension[0], null);
export const exodus = createWalletList(exodusExtension[0], null);
export const tailwind = createWalletList(tailwindWallet[0], null);
export const owallet = createWalletList(owalletExtension[0], null);
export const owallet = createWalletList(owalletExtension[0], owalletMobile[0]);
export const galaxystation = createWalletList(galaxyStationExtension[0], null);
export const cdcwallet = createWalletList(cdcwalletExtension[0], null);

Expand All @@ -130,7 +130,7 @@ export type AllWalletList = SubWalletList & {
exodus: typeof exodus;
tailwind: typeof tailwind;
owallet: typeof owallet;
galaxystation: typeof owallet;
galaxystation: typeof galaxystation;
cdcwallet: typeof cdcwallet;
for: (...names: WalletName[]) => SubWalletList;
not: (...names: WalletName[]) => SubWalletList;
Expand Down
9 changes: 7 additions & 2 deletions packages/example/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ import { RootLayout } from "../components/layout";
// import { useTheme } from "@interchain-ui/react";

function MyApp({ Component, pageProps }: AppProps) {
const defaultWallets: MainWalletBase[] = [...keplrWallets, ...leapWallets];
const defaultWallets: MainWalletBase[] = [
...keplrWallets,
...leapWallets,
...owalletWallets,
];
const [wallets, setWallets] = useState<MainWalletBase[]>(defaultWallets);
const [loadingWallets, setLoadingWallet] = useState<boolean>(false);
// const web3AuthWallets = useMemo(
Expand Down Expand Up @@ -94,9 +98,10 @@ function MyApp({ Component, pageProps }: AppProps) {
assetLists={[]}
wallets={[
// ...wallets,
...owalletWallets,
...keplrWallets,
...leapWallets,
// ...owalletWallets,

// ...ninjiWallets,
// ...snapWallet,
// ...ledgerWallets,
Expand Down
97 changes: 70 additions & 27 deletions packages/example/pages/wallet-manager/main-wallets.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,105 @@
import { WalletManager, Logger } from "@cosmos-kit/core";
import { useMemo, useState } from 'react'
import { useMemo, useState } from "react";
import { wallets as leapWallets } from "@cosmos-kit/leap";
import { wallets as stationWallets } from "@cosmos-kit/station";
import { wallets as keplrWallets } from "@cosmos-kit/keplr";
import { wallets as oWallets } from "@cosmos-kit/owallet";
import { assets } from "chain-registry";
import { Button } from "components/button";
export default () => {
const walletManager = useMemo(() => {
return new WalletManager(
["cosmoshub", "juno", "stargaze"], [
keplrWallets[0], leapWallets[0], stationWallets[0]
], new Logger('NONE'), false,
undefined, undefined, assets
["cosmoshub", "juno", "stargaze"],
[keplrWallets[0], leapWallets[0], oWallets[0], stationWallets[0]],
new Logger("NONE"),
false,
undefined,
undefined,
assets
);
}, [])
}, []);

const [_, forceUpdate] = useState(0)
const [_, forceUpdate] = useState(0);

const mainWallets = walletManager.mainWallets
const mainWallets = walletManager.mainWallets;

return (
<div>
Main Wallets
<table className="text-xs table-auto">
<thead>
<tr>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">Wallet</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">Connect</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">Disconnect</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">Chain</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">Address</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
Wallet
</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
Connect
</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
Disconnect
</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
Chain
</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
Address
</td>
</tr>
</thead>
<tbody>
{mainWallets.map(mainWallet => {
const chainWallets = mainWallet.getChainWalletList(false)
{mainWallets.map((mainWallet) => {
const chainWallets = mainWallet.getChainWalletList(false);
return chainWallets.map((w, index) => {
return (
<tr>
{index === 0 && (
<>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap" rowSpan={chainWallets.length}>{w.walletName}</td>
<td className="border p-2 w-60" rowSpan={chainWallets.length}>
<Button onClick={async () => { await mainWallet.connectAll(false); forceUpdate(i => i + 1) }}>MainWallets Connect All</Button>
<td
className="border p-2 break-words w-16 overflow-wrap text-wrap"
rowSpan={chainWallets.length}
>
{w.walletName}
</td>
<td className="border p-2 w-64" rowSpan={chainWallets.length}>
<Button onClick={async () => { await mainWallet.disconnectAll(false); forceUpdate(i => i + 1) }}>MainWallets Disconnect All</Button>
<td
className="border p-2 w-60"
rowSpan={chainWallets.length}
>
<Button
onClick={async () => {
await mainWallet.connectAll(false);
forceUpdate((i) => i + 1);
}}
>
MainWallets Connect All
</Button>
</td>
<td
className="border p-2 w-64"
rowSpan={chainWallets.length}
>
<Button
onClick={async () => {
await mainWallet.disconnectAll(false);
forceUpdate((i) => i + 1);
}}
>
MainWallets Disconnect All
</Button>
</td>
</>
)}
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">{w.chainName}</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">{w.address}</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
{w.chainName}
</td>
<td className="border p-2 break-words w-16 overflow-wrap text-wrap">
{w.address}
</td>
</tr>
)
})
);
});
})}
</tbody>
</table>
</div >
)
}
</div>
);
};
Loading

0 comments on commit ea30b49

Please sign in to comment.