2.1.1 • Published 7 months ago
@leapwallet/embedded-wallet-sdk-react v2.1.1
Leap Snaps SDK React
Installation
npm install @leapwallet/embedded-wallet-sdk-reactUsage
Get Started
import React from "react";
import { useChain } from "@cosmos-kit/react";
import { AccountModal } from "@leapwallet/embedded-wallet-sdk-react";
const chainId = "osmosis-1";
const chain = "osmosis";
const restUrl = "https://rest.cosmos.directory/osmosis";
const YourApp = () => {
const { address } = useChain(chain);
const [isModalOpen, setIsModalOpen] = React.useState(false);
return (
<div>
{/* other components */}
<button onClick={() => setIsModalOpen(true)}>Open Modal</button>
<AccountModal
theme="dark"
chainId={chainId}
restUrl={restUrl}
address={address}
isOpen={isModalOpen}
onClose={closeModal}
/>
{/* other components */}
</div>
);
};Props
| Name | Type | Description |
|---|---|---|
theme | "light" \| "dark" \| ThemeDefinition | Theme of the modal |
chainId | string | Chain ID of the chain |
restUrl | string | REST URL of the chain |
address | string | Address of the user |
isOpen | boolean | Whether the modal is open |
onClose | () => void | Callback function when the modal is closed |
config | Config | Config of the modal |
Here is the type definition of Config:
type Config = {
// This function is called to render the title of the modal
title?: (page: Page) => React.ReactNode;
// This function is called to render the sub-title of the modal
subTitle?: (page: Page) => React.ReactNode;
// Should the modal be closed when the backdrop is clicked
closeOnBackdropClick?: boolean;
// Should the modal be closed when the escape key is pressed
closeOnEscape?: boolean;
// Configure the action list on the home page
actionListConfig?: ActionListConfig;
};
type ActionListConfig = Record<
string,
{
label?: string;
onClick?: (chainId: string) => void;
enabled?: boolean;
}
>;
enum Page {
HOME = "home",
ACTIVITY = "activity",
}Example Configuration
const config: Config = {
title: (page) => {
switch (page) {
case Page.HOME:
return "Assets";
case Page.ACTIVITY:
return "Activity";
}
},
closeOnBackdropClick: true,
closeOnEscape: true,
actionListConfig: {
[Actions.Swap]: {
label: "Swap",
onClick: (chainId) => {
console.log(chainId);
},
enabled: true,
},
[Actions.Bridge]: {
enabled: false,
},
},
};2.1.0-beta.18
9 months ago
2.1.0-beta.17
10 months ago
2.1.0-beta.16
10 months ago
2.1.0-beta.15
10 months ago
2.1.0-beta.14
10 months ago
2.1.0-beta.13
10 months ago
2.1.0-beta.12
10 months ago
2.1.0-beta.11
11 months ago
2.1.0-beta.10
11 months ago
2.1.1
7 months ago
2.1.0
9 months ago
2.1.0-beta.19
9 months ago
2.1.0-beta.1
1 year ago
2.1.0-beta.3
1 year ago
2.1.0-beta.2
1 year ago
2.1.0-beta.5
1 year ago
2.1.0-beta.4
1 year ago
2.1.0-beta.23
9 months ago
2.1.0-beta.7
1 year ago
2.1.0-beta.22
9 months ago
2.1.0-beta.6
1 year ago
2.1.0-beta.21
9 months ago
2.1.0-beta.20
9 months ago
2.1.0-beta.9
11 months ago
2.1.0-beta.8
11 months ago
1.0.2
1 year ago
1.1.0
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago
2.0.3
1 year ago
2.0.2
1 year ago
2.0.1
1 year ago
2.0.0
1 year ago
0.3.7
2 years ago
0.3.6
2 years ago
0.3.3
2 years ago
0.3.2
2 years ago
0.3.1
2 years ago