Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Leap Capsule Social Login #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ next-env.d.ts

# IntelliJ
.idea

bun.lockb
.vscode
5 changes: 4 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const nextConfig = {
},
transpilePackages: [
'@leapwallet/cosmos-social-login-capsule-provider-ui',
'@leapwallet/cosmos-social-login-capsule-provider'
'@leapwallet/cosmos-social-login-capsule-provider',
"@usecapsule/user-management-client",
"@usecapsule/core-sdk",
"@usecapsule/web-sdk",
],
}

Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
"@cosmos-kit/react": "2.8.4",
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@keplr-wallet/cosmos": "^0.12.107",
"@keplr-wallet/types": "^0.12.107",
"@leapwallet/cosmos-social-login-capsule-provider": "0.0.28",
"@leapwallet/cosmos-social-login-capsule-provider-ui": "0.0.47",
"@leapwallet/cosmos-social-login-capsule-provider": "0.0.39",
"@leapwallet/cosmos-social-login-capsule-provider-ui": "0.0.56",
"@leapwallet/elements": "1.1.0",
"@leapwallet/embedded-wallet-sdk-react": "^0.3.7",
"@types/bignumber.js": "^5.0.0",
Expand Down
59 changes: 23 additions & 36 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "../styles/globals.css";
import "@leapwallet/embedded-wallet-sdk-react/styles.css";
import "@leapwallet/cosmos-social-login-capsule-provider-ui/styles.css";
import type { AppProps } from "next/app";
import { ChainProvider } from "@cosmos-kit/react";
import { wallets as keplrWallets } from "@cosmos-kit/keplr";
Expand All @@ -17,11 +18,12 @@ import ConnectWalletSideCurtain from "../components/ConnectWalletSideCurtain/con
import dynamic from "next/dynamic";
import { useEffect, useState } from "react";
import "@leapwallet/elements/styles.css";
import { createPublicClient } from 'viem';
import { mainnet } from 'wagmi/chains';
import { createConfig, WagmiConfig } from 'wagmi';
import { http } from "viem"
import { Layout } from '../components/Layout';
import { OAuthMethod } from "@leapwallet/cosmos-social-login-capsule-provider";
import { createPublicClient } from "viem";
import { mainnet } from "wagmi/chains";
import { createConfig, WagmiConfig } from "wagmi";
import { http } from "viem";
import { Layout } from "../components/Layout";

if (typeof global.self === "undefined") {
(global as any).self = global;
Expand All @@ -31,9 +33,9 @@ const config = createConfig({
autoConnect: true,
publicClient: createPublicClient({
chain: mainnet,
transport: http()
transport: http(),
}),
})
});

const updatedChains = chains.map((chain) => {
if (chain.chain_id === "stargaze-1") {
Expand All @@ -43,16 +45,12 @@ const updatedChains = chains.map((chain) => {
...chain.apis,
rest: [
{
address:
process.env.NEXT_PUBLIC_NODE_REST_ENDPOINT ||
"https://rest.stargaze-apis.com/",
address: process.env.NEXT_PUBLIC_NODE_REST_ENDPOINT || "https://rest.stargaze-apis.com/",
},
].concat(chain.apis?.rest ?? []),
rpc: [
{
address:
process.env.NEXT_PUBLIC_NODE_REST_ENDPOINT ||
"https://rpc.stargaze-apis.com/",
address: process.env.NEXT_PUBLIC_NODE_REST_ENDPOINT || "https://rpc.stargaze-apis.com/",
},
].concat(chain.apis?.rpc ?? []),
},
Expand All @@ -69,19 +67,14 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
// }
};

const [cosmosCapsuleWallet, setCosmosCapsuleWallet] =
useState<LeapCapsuleWallet>();
const [cosmosCapsuleWallet, setCosmosCapsuleWallet] = useState<LeapCapsuleWallet>();
const [wallets, setWallets] = useState();

useEffect(() => {
const fn = async () => {
if (!cosmosCapsuleWallet) {
const WalletClass = await import(
"@cosmos-kit/leap-capsule-social-login"
).then((m) => m.LeapCapsuleWallet);
const WalletInfo: Wallet = await import(
"../leap-social-login/registry"
).then((m) => m.LeapCapsuleInfo);
const WalletClass = await import("@cosmos-kit/leap-capsule-social-login").then((m) => m.LeapCapsuleWallet);
const WalletInfo: Wallet = await import("../leap-social-login/registry").then((m) => m.LeapCapsuleInfo);
const cosmosCapsuleWallet = new WalletClass(WalletInfo);
setCosmosCapsuleWallet(cosmosCapsuleWallet);
// @ts-ignore: Disabling typecheck until we figureout proper way of adding cosmoscapsulewallet in cosmos-kit
Expand Down Expand Up @@ -124,12 +117,11 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
},
},
}}
signerOptions={signerOptions}
>
signerOptions={signerOptions}>
<Layout>
<Component {...pageProps} />
{!!cosmosCapsuleWallet && <CustomCapsuleModalViewX />}
</ Layout>
<Component {...pageProps} />
{!!cosmosCapsuleWallet && <CustomCapsuleModalViewX />}
</Layout>
</ChainProvider>
</LeapUiTheme>
p0
Expand All @@ -142,26 +134,20 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
export default CreateCosmosApp;

const CCUI = dynamic(
() =>
import("@leapwallet/cosmos-social-login-capsule-provider-ui").then(
(m) => m.CustomCapsuleModalView
),
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.CustomCapsuleModalView),
{ ssr: false }
);

const TransactionSigningModal = dynamic(
() =>
import("@leapwallet/cosmos-social-login-capsule-provider-ui").then(
(m) => m.TransactionSigningModal
),
() => import("@leapwallet/cosmos-social-login-capsule-provider-ui").then((m) => m.TransactionSigningModal),
{ ssr: false }
);

export function CustomCapsuleModalViewX() {
const [showCapsuleModal, setShowCapsuleModal] = useState(false);

return (
<>
<div className="leap-ui dark !z-[99999] fixed">
<CCUI
showCapsuleModal={showCapsuleModal}
setShowCapsuleModal={setShowCapsuleModal}
Expand All @@ -172,8 +158,9 @@ export function CustomCapsuleModalViewX() {
onLoginFailure={() => {
window.failureFromCapsuleModal();
}}
oAuthMethods={[OAuthMethod.GOOGLE, OAuthMethod.APPLE, OAuthMethod.TWITTER, OAuthMethod.DISCORD]}
/>
<TransactionSigningModal dAppInfo={{ name: "Celestine Sloths" }} />
</>
</div>
);
}