@moveindustries/wallet-adapter-react 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +306 -0
- package/dist/WalletProvider.d.ts +12 -0
- package/dist/WalletProvider.d.ts.map +1 -0
- package/dist/components/AboutMovementConnect.d.ts +29 -0
- package/dist/components/AboutMovementConnect.d.ts.map +1 -0
- package/dist/components/AboutPetraWeb.d.ts +31 -0
- package/dist/components/AboutPetraWeb.d.ts.map +1 -0
- package/dist/components/MovementPrivacyPolicy.d.ts +12 -0
- package/dist/components/MovementPrivacyPolicy.d.ts.map +1 -0
- package/dist/components/WalletItem.d.ts +16 -0
- package/dist/components/WalletItem.d.ts.map +1 -0
- package/dist/components/utils.d.ts +20 -0
- package/dist/components/utils.d.ts.map +1 -0
- package/dist/graphics/LinkGraphic.d.ts +3 -0
- package/dist/graphics/LinkGraphic.d.ts.map +1 -0
- package/dist/graphics/SmallMovementLogo.d.ts +3 -0
- package/dist/graphics/SmallMovementLogo.d.ts.map +1 -0
- package/dist/graphics/WalletGraphic.d.ts +3 -0
- package/dist/graphics/WalletGraphic.d.ts.map +1 -0
- package/dist/graphics/Web3Graphic.d.ts +3 -0
- package/dist/graphics/Web3Graphic.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +632 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +606 -0
- package/dist/index.mjs.map +1 -0
- package/dist/useWallet.d.ts +31 -0
- package/dist/useWallet.d.ts.map +1 -0
- package/package.json +60 -0
- package/src/WalletProvider.tsx +424 -0
- package/src/components/AboutMovementConnect.tsx +60 -0
- package/src/components/AboutPetraWeb.tsx +63 -0
- package/src/components/MovementPrivacyPolicy.tsx +44 -0
- package/src/components/WalletItem.tsx +122 -0
- package/src/components/utils.tsx +70 -0
- package/src/graphics/LinkGraphic.tsx +26 -0
- package/src/graphics/SmallMovementLogo.tsx +25 -0
- package/src/graphics/WalletGraphic.tsx +42 -0
- package/src/graphics/Web3Graphic.tsx +31 -0
- package/src/index.tsx +7 -0
- package/src/useWallet.tsx +67 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// TODO: Re-enable when Movement supports social sign-in (Petra Web)
|
|
2
|
+
// This is a stub component that just renders children - social sign-in education screens are disabled
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ForwardRefExoticComponent,
|
|
6
|
+
ReactNode,
|
|
7
|
+
RefAttributes,
|
|
8
|
+
SVGProps,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { HeadlessComponentProps, createHeadlessComponent } from "./utils";
|
|
11
|
+
|
|
12
|
+
/** @deprecated Social sign-in disabled */
|
|
13
|
+
export const EXPLORE_ECOSYSTEM_URL = "https://movementlabs.xyz/ecosystem";
|
|
14
|
+
|
|
15
|
+
/** @deprecated Social sign-in disabled */
|
|
16
|
+
export interface AboutPetraWebEducationScreen {
|
|
17
|
+
Graphic: ForwardRefExoticComponent<
|
|
18
|
+
Omit<SVGProps<SVGSVGElement>, "ref"> & RefAttributes<SVGSVGElement>
|
|
19
|
+
>;
|
|
20
|
+
Title: ForwardRefExoticComponent<
|
|
21
|
+
HeadlessComponentProps & RefAttributes<HTMLHeadingElement>
|
|
22
|
+
>;
|
|
23
|
+
Description: ForwardRefExoticComponent<
|
|
24
|
+
HeadlessComponentProps & RefAttributes<HTMLParagraphElement>
|
|
25
|
+
>;
|
|
26
|
+
screenIndex: number;
|
|
27
|
+
totalScreens: number;
|
|
28
|
+
screenIndicators: ForwardRefExoticComponent<HeadlessComponentProps & RefAttributes<HTMLButtonElement>>[];
|
|
29
|
+
back: () => void;
|
|
30
|
+
next: () => void;
|
|
31
|
+
cancel: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @deprecated Social sign-in disabled */
|
|
35
|
+
export interface AboutPetraWebProps {
|
|
36
|
+
renderEducationScreen: (screen: AboutPetraWebEducationScreen) => ReactNode;
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Social sign-in disabled - this component just renders children without any education screens
|
|
42
|
+
*/
|
|
43
|
+
const Root = ({ children }: AboutPetraWebProps) => {
|
|
44
|
+
return <>{children}</>;
|
|
45
|
+
};
|
|
46
|
+
Root.displayName = "AboutPetraWeb";
|
|
47
|
+
|
|
48
|
+
const Trigger = createHeadlessComponent(
|
|
49
|
+
"AboutPetraWeb.Trigger",
|
|
50
|
+
"button",
|
|
51
|
+
() => ({
|
|
52
|
+
// No-op since social sign-in is disabled
|
|
53
|
+
onClick: () => {},
|
|
54
|
+
style: { display: "none" },
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Social sign-in disabled - this component just renders children
|
|
60
|
+
*/
|
|
61
|
+
export const AboutPetraWeb = Object.assign(Root, {
|
|
62
|
+
Trigger,
|
|
63
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { SmallMovementLogo } from "../graphics/SmallMovementLogo";
|
|
3
|
+
import { HeadlessComponentProps, createHeadlessComponent } from "./utils";
|
|
4
|
+
|
|
5
|
+
export const MOVEMENT_PRIVACY_POLICY_URL = "https://movementlabs.xyz/privacy";
|
|
6
|
+
|
|
7
|
+
const Root = createHeadlessComponent("MovementPrivacyPolicy.Root", "div");
|
|
8
|
+
|
|
9
|
+
const Disclaimer = createHeadlessComponent(
|
|
10
|
+
"MovementPrivacyPolicy.Disclaimer",
|
|
11
|
+
"span",
|
|
12
|
+
{ children: "By continuing, you agree to Movement Labs'" },
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const Link = createHeadlessComponent("MovementPrivacyPolicy.Disclaimer", "a", {
|
|
16
|
+
href: MOVEMENT_PRIVACY_POLICY_URL,
|
|
17
|
+
target: "_blank",
|
|
18
|
+
rel: "noopener noreferrer",
|
|
19
|
+
children: "Privacy Policy",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const PoweredBy = forwardRef<
|
|
23
|
+
HTMLDivElement,
|
|
24
|
+
Pick<HeadlessComponentProps, "className">
|
|
25
|
+
>(({ className }, ref) => {
|
|
26
|
+
return (
|
|
27
|
+
<div ref={ref} className={className}>
|
|
28
|
+
<span>Powered by</span>
|
|
29
|
+
<SmallMovementLogo />
|
|
30
|
+
<span>Movement Labs</span>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
PoweredBy.displayName = "MovementPrivacyPolicy.PoweredBy";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A headless component for rendering the Movement Labs privacy policy disclaimer
|
|
38
|
+
* that should be placed under the Petra Web login options.
|
|
39
|
+
*/
|
|
40
|
+
export const MovementPrivacyPolicy = Object.assign(Root, {
|
|
41
|
+
Disclaimer,
|
|
42
|
+
Link,
|
|
43
|
+
PoweredBy,
|
|
44
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdapterNotDetectedWallet,
|
|
3
|
+
AdapterWallet,
|
|
4
|
+
WalletReadyState,
|
|
5
|
+
isRedirectable,
|
|
6
|
+
} from "@moveindustries/wallet-adapter-core";
|
|
7
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
8
|
+
import { createContext, forwardRef, useCallback, useContext } from "react";
|
|
9
|
+
import { useWallet } from "../useWallet";
|
|
10
|
+
import { HeadlessComponentProps, createHeadlessComponent } from "./utils";
|
|
11
|
+
|
|
12
|
+
export interface WalletItemProps extends HeadlessComponentProps {
|
|
13
|
+
/** The wallet option to be displayed. */
|
|
14
|
+
wallet: AdapterWallet | AdapterNotDetectedWallet;
|
|
15
|
+
/** A callback to be invoked when the wallet is connected. */
|
|
16
|
+
onConnect?: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function useWalletItemContext(displayName: string) {
|
|
20
|
+
const context = useContext(WalletItemContext);
|
|
21
|
+
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error(`\`${displayName}\` must be used within \`WalletItem\``);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const WalletItemContext = createContext<{
|
|
30
|
+
wallet: AdapterWallet | AdapterNotDetectedWallet;
|
|
31
|
+
connectWallet: () => void;
|
|
32
|
+
} | null>(null);
|
|
33
|
+
|
|
34
|
+
const Root = forwardRef<HTMLDivElement, WalletItemProps>(
|
|
35
|
+
({ wallet, onConnect, className, asChild, children }, ref) => {
|
|
36
|
+
const { connect } = useWallet();
|
|
37
|
+
|
|
38
|
+
const connectWallet = useCallback(() => {
|
|
39
|
+
connect(wallet.name);
|
|
40
|
+
onConnect?.();
|
|
41
|
+
}, [connect, wallet.name, onConnect]);
|
|
42
|
+
|
|
43
|
+
const isWalletReady = wallet.readyState === WalletReadyState.Installed;
|
|
44
|
+
|
|
45
|
+
const mobileSupport =
|
|
46
|
+
"deeplinkProvider" in wallet && wallet.deeplinkProvider;
|
|
47
|
+
|
|
48
|
+
if (!isWalletReady && isRedirectable() && !mobileSupport) return null;
|
|
49
|
+
|
|
50
|
+
const Component = asChild ? Slot : "div";
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<WalletItemContext.Provider value={{ wallet, connectWallet }}>
|
|
54
|
+
<Component ref={ref} className={className}>
|
|
55
|
+
{children}
|
|
56
|
+
</Component>
|
|
57
|
+
</WalletItemContext.Provider>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
Root.displayName = "WalletItem";
|
|
62
|
+
|
|
63
|
+
const Icon = createHeadlessComponent(
|
|
64
|
+
"WalletItem.Icon",
|
|
65
|
+
"img",
|
|
66
|
+
(displayName) => {
|
|
67
|
+
const context = useWalletItemContext(displayName);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
src: context.wallet.icon,
|
|
71
|
+
alt: `${context.wallet.name} icon`,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const Name = createHeadlessComponent(
|
|
77
|
+
"WalletItem.Name",
|
|
78
|
+
"div",
|
|
79
|
+
(displayName) => {
|
|
80
|
+
const context = useWalletItemContext(displayName);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
children: context.wallet.name,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const ConnectButton = createHeadlessComponent(
|
|
89
|
+
"WalletItem.ConnectButton",
|
|
90
|
+
"button",
|
|
91
|
+
(displayName) => {
|
|
92
|
+
const context = useWalletItemContext(displayName);
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
onClick: context.connectWallet,
|
|
96
|
+
children: "Connect",
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const InstallLink = createHeadlessComponent(
|
|
102
|
+
"WalletItem.InstallLink",
|
|
103
|
+
"a",
|
|
104
|
+
(displayName) => {
|
|
105
|
+
const context = useWalletItemContext(displayName);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
href: context.wallet.url,
|
|
109
|
+
target: "_blank",
|
|
110
|
+
rel: "noopener noreferrer",
|
|
111
|
+
children: "Install",
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/** A headless component for rendering a wallet option's name, icon, and either connect button or install link. */
|
|
117
|
+
export const WalletItem = Object.assign(Root, {
|
|
118
|
+
Icon,
|
|
119
|
+
Name,
|
|
120
|
+
ConnectButton,
|
|
121
|
+
InstallLink,
|
|
122
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { ReactNode, cloneElement, forwardRef, isValidElement } from "react";
|
|
3
|
+
|
|
4
|
+
export interface HeadlessComponentProps {
|
|
5
|
+
/** A class name for styling the element. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether to render as the child element instead of the default element provided.
|
|
9
|
+
* All props will be merged into the child element.
|
|
10
|
+
*/
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets an HTML element type from its tag name
|
|
17
|
+
* @example
|
|
18
|
+
* HTMLElementFromTag<"img"> // resolved type: HTMLImageElement
|
|
19
|
+
*/
|
|
20
|
+
type HTMLElementFromTag<T extends keyof JSX.IntrinsicElements> =
|
|
21
|
+
JSX.IntrinsicElements[T] extends React.ClassAttributes<infer Element>
|
|
22
|
+
? Element
|
|
23
|
+
: HTMLElement;
|
|
24
|
+
|
|
25
|
+
export function createHeadlessComponent<
|
|
26
|
+
TElement extends keyof JSX.IntrinsicElements,
|
|
27
|
+
>(
|
|
28
|
+
displayName: string,
|
|
29
|
+
elementType: TElement,
|
|
30
|
+
props?:
|
|
31
|
+
| JSX.IntrinsicElements[TElement]
|
|
32
|
+
| ((displayName: string) => JSX.IntrinsicElements[TElement]),
|
|
33
|
+
) {
|
|
34
|
+
const component = forwardRef<
|
|
35
|
+
HTMLElementFromTag<TElement>,
|
|
36
|
+
HeadlessComponentProps
|
|
37
|
+
>(({ className, asChild, children }, ref) => {
|
|
38
|
+
const Component = asChild ? Slot : elementType;
|
|
39
|
+
|
|
40
|
+
const { children: defaultChildren, ...resolvedProps } =
|
|
41
|
+
typeof props === "function" ? props(displayName) : (props ?? {});
|
|
42
|
+
const resolvedChildren =
|
|
43
|
+
/**
|
|
44
|
+
* Use props' default children if no children are set in the component element's children and when asChild is true.
|
|
45
|
+
*/
|
|
46
|
+
asChild && isValidElement(children) && !children.props.children
|
|
47
|
+
? cloneElement(children, {}, defaultChildren)
|
|
48
|
+
: (children ?? defaultChildren);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
/**
|
|
52
|
+
* Due to the complexity of the types at play, TypeScript reports the
|
|
53
|
+
* following error for our JSX below:
|
|
54
|
+
*
|
|
55
|
+
* `Expression produces a union type that is too complex to represent.`
|
|
56
|
+
*
|
|
57
|
+
* We can safely ignore this error and retain accurate return types for
|
|
58
|
+
* consumers of this function. The only drawback is that type-checking is
|
|
59
|
+
* ignored for the JSX block below.
|
|
60
|
+
*/
|
|
61
|
+
// @ts-expect-error
|
|
62
|
+
<Component ref={ref} className={className} {...resolvedProps}>
|
|
63
|
+
{resolvedChildren}
|
|
64
|
+
</Component>
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
component.displayName = displayName;
|
|
68
|
+
|
|
69
|
+
return component;
|
|
70
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SVGProps, forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
export const LinkGraphic = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(
|
|
4
|
+
(props, ref) => {
|
|
5
|
+
return (
|
|
6
|
+
<svg
|
|
7
|
+
ref={ref}
|
|
8
|
+
width="102"
|
|
9
|
+
height="132"
|
|
10
|
+
viewBox="0 0 102 132"
|
|
11
|
+
fill="none"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<g stroke="currentColor" strokeMiterlimit="10">
|
|
15
|
+
<path d="M59.633 80.66c11.742-2.814 17.48-7.018 20.925-13.254l17.518-31.69c6.257-11.317 2.142-25.55-9.189-31.798C82.737.53 75.723.188 69.593 2.398M60.7 69.565a14.09 14.09 0 0 1-6.907-1.767l-.228-.108" />
|
|
16
|
+
<path d="m52.365 41.075 12.507-22.627a14.146 14.146 0 0 1 4.727-5.062M32.407 118.619a14.139 14.139 0 0 1-7.034-1.768c-6.857-3.78-9.353-12.402-5.561-19.25l16.634-30.1a14.097 14.097 0 0 1 4.518-4.923" />
|
|
17
|
+
<path d="M41.211 78.85c11.332 6.248 25.583 2.14 31.84-9.177l17.518-31.691c6.256-11.317 2.142-25.55-9.19-31.798-6.085-3.357-13.018-3.724-19.104-1.59A23.31 23.31 0 0 0 49.541 15.36L36.863 38.298l7.989 5.036 12.506-22.627c3.786-6.848 12.419-9.34 19.276-5.554 6.856 3.78 9.353 12.402 5.561 19.25l-16.634 30.1c-3.785 6.848-12.418 9.341-19.275 5.555l-5.075 8.791ZM29.5 130.447c12.361-1.37 19.2-6.994 22.966-13.804l12.678-22.936-8.305-5.239" />
|
|
18
|
+
<path d="m55.72 61.947-.442.764 5.511-9.55c-6.901-3.806-18.65-3.124-27.105.814M44.85 43.523l7.635-2.486m-4.221 23.264 7.217-1.723m-9.316 7.517 7.59-2.405m-.562-12.156 7.508-2.221m10.136-51.32L62.761 4.43M49.642 90.778l7.514-2.26m.474 7.448 7.514-2.26m-50.306-60.13c7.135 0 12.918-5.776 12.918-12.9 0-7.126-5.783-12.902-12.918-12.902-7.134 0-12.917 5.776-12.917 12.901s5.783 12.901 12.918 12.901Z" />
|
|
19
|
+
<path d="M15.724 7.774h3.197c7.135 0 12.918 5.776 12.918 12.901 0 7.126-5.783 12.901-12.918 12.901h-3.425m65.112 66.935h3.198c7.135 0 12.918 5.775 12.918 12.901 0 7.125-5.783 12.9-12.918 12.9h-3.425" />
|
|
20
|
+
<path d="M79.717 126.312c7.135 0 12.918-5.775 12.918-12.9s-5.783-12.901-12.918-12.901c-7.134 0-12.917 5.776-12.917 12.901s5.783 12.9 12.917 12.9ZM53.281 55.414c-11.33-6.248-25.582-2.14-31.839 9.177L3.924 96.281c-6.257 11.318-2.142 25.55 9.189 31.799 11.331 6.248 25.582 2.139 31.839-9.177l12.677-22.937-7.988-5.036-12.507 22.627c-3.785 6.848-12.418 9.341-19.275 5.554-6.857-3.781-9.353-12.402-5.561-19.25l16.633-30.1c3.786-6.848 12.419-9.341 19.276-5.555l5.074-8.792Z" />
|
|
21
|
+
</g>
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
LinkGraphic.displayName = "LinkGraphic";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SVGProps, forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
export const SmallMovementLogo = forwardRef<
|
|
4
|
+
SVGSVGElement,
|
|
5
|
+
SVGProps<SVGSVGElement>
|
|
6
|
+
>((props, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<svg
|
|
9
|
+
ref={ref}
|
|
10
|
+
width="12"
|
|
11
|
+
height="12"
|
|
12
|
+
viewBox="0 0 12 12"
|
|
13
|
+
fill="none"
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<path
|
|
17
|
+
fillRule="evenodd"
|
|
18
|
+
clipRule="evenodd"
|
|
19
|
+
d="M6 12C9.31371 12 12 9.31371 12 6C12 2.68629 9.31371 0 6 0C2.68629 0 0 2.68629 0 6C0 9.31371 2.68629 12 6 12ZM7.17547 3.67976C7.13401 3.72309 7.07649 3.74757 7.01648 3.74757H3.00775C3.69185 2.83824 4.77995 2.25 6.00569 2.25C7.23142 2.25 8.31953 2.83824 9.00362 3.74757H8.28524C8.20824 3.74757 8.13498 3.71468 8.08401 3.65701L7.81608 3.35416C7.77618 3.30896 7.71882 3.28308 7.6585 3.28308H7.6454C7.58805 3.28308 7.53318 3.30646 7.49343 3.34792L7.17547 3.67976ZM8.05656 4.75897H7.39569C7.31869 4.75897 7.24543 4.72593 7.19447 4.66842L6.92638 4.36557C6.88647 4.32036 6.82896 4.29465 6.7688 4.29465C6.70863 4.29465 6.65112 4.32052 6.61121 4.36557L6.38131 4.6254C6.30603 4.71034 6.19801 4.75913 6.08454 4.75913H2.46703C2.36401 5.05278 2.29683 5.36296 2.27002 5.68467H5.68505C5.74506 5.68467 5.80258 5.66019 5.84404 5.61686L6.16201 5.28502C6.20175 5.24356 6.25662 5.22018 6.31398 5.22018H6.32707C6.38739 5.22018 6.44475 5.24606 6.48465 5.29126L6.75258 5.59411C6.80355 5.65178 6.87681 5.68467 6.95381 5.68467H9.74133C9.71452 5.3628 9.64734 5.05263 9.54431 4.75913H8.05641L8.05656 4.75897ZM4.33651 7.63095C4.39652 7.63095 4.45404 7.60648 4.4955 7.56315L4.81347 7.23131C4.85321 7.18985 4.90808 7.16647 4.96544 7.16647H4.97853C5.03885 7.16647 5.09621 7.19234 5.13611 7.23739L5.40404 7.54024C5.45501 7.59791 5.52827 7.6308 5.60527 7.6308H9.38285C9.52438 7.33839 9.62803 7.02463 9.68975 6.69591H6.06383C5.98683 6.69591 5.91357 6.66287 5.8626 6.60535L5.59467 6.3025C5.55477 6.2573 5.49725 6.23158 5.43709 6.23158C5.37692 6.23158 5.31941 6.25746 5.27951 6.3025L5.0496 6.56233C4.97432 6.64728 4.86631 6.69606 4.75268 6.69606H2.32147C2.3832 7.02479 2.487 7.33855 2.62837 7.63095H4.33651ZM5.57359 8.55745H4.59116C4.51417 8.55745 4.44091 8.52441 4.38994 8.46689L4.12201 8.16404C4.0821 8.11884 4.02459 8.09312 3.96442 8.09312C3.90426 8.09312 3.84675 8.119 3.80684 8.16404L3.57694 8.42387C3.50166 8.50882 3.39364 8.55761 3.28001 8.55761H3.26474C3.94915 9.29096 4.92378 9.74998 6.00596 9.74998C7.08815 9.74998 8.06262 9.29096 8.74719 8.55761H5.57359V8.55745Z"
|
|
20
|
+
fill="currentColor"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
SmallMovementLogo.displayName = "SmallMovementLogo";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SVGProps, forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
export const WalletGraphic = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(
|
|
4
|
+
(props, ref) => {
|
|
5
|
+
return (
|
|
6
|
+
<svg
|
|
7
|
+
ref={ref}
|
|
8
|
+
width="128"
|
|
9
|
+
height="102"
|
|
10
|
+
viewBox="0 0 128 102"
|
|
11
|
+
fill="none"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
d="m.96 25.93-.36-.35.36.85v-.5Zm7.79-7.81v-.5h-.21l-.15.15.36.35ZM1.3 26.28l7.79-7.8-.7-.71-7.8 7.8.7.71Zm7.44-7.66H10v-1H8.75v1Zm29.22 6.8h-37v1h37.01v-1Z"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
strokeMiterlimit="10"
|
|
21
|
+
d="M82.25 26.08c0 12.25-9.92 22.2-22.14 22.2a22.17 22.17 0 0 1-22.14-22.2H1.1v74.82h118.02V26.08H82.25Zm44.33 67.02h.33V18.27h-5.7"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
stroke="currentColor"
|
|
25
|
+
strokeMiterlimit="10"
|
|
26
|
+
d="M74.52 42.92a22.4 22.4 0 0 1-11.43 3.3 22.5 22.5 0 0 1-22.46-22.53H9.52M119.22 101l7.78-7.82m-7.88-67.1 7.79-7.81m-44.78 7.72 2.73-2.3m-46.89 2.39 2.39-2.4"
|
|
27
|
+
/>
|
|
28
|
+
<path
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
strokeMiterlimit="10"
|
|
31
|
+
d="M9.86 23.69V5.72h107.97v18.04H84.65"
|
|
32
|
+
/>
|
|
33
|
+
<path
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
strokeMiterlimit="10"
|
|
36
|
+
d="M117.83 20.46h3.39V1H13.25v4.72M9.36 23.69h31.78"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
WalletGraphic.displayName = "WalletGraphic";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SVGProps, forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
export const Web3Graphic = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>(
|
|
4
|
+
(props, ref) => {
|
|
5
|
+
return (
|
|
6
|
+
<svg
|
|
7
|
+
ref={ref}
|
|
8
|
+
width="142"
|
|
9
|
+
height="108"
|
|
10
|
+
viewBox="0 0 142 108"
|
|
11
|
+
fill="none"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<g stroke="currentColor" strokeLinejoin="round">
|
|
15
|
+
<path d="m91.26 35.8.06-10.46L71.3 1v10.53L87 30.5m-36.11 5.24-.06-10.45L71.3 1v10.53L55 30.5" />
|
|
16
|
+
<path d="M71 59.55V49.17L50.83 25.3l.06 10.45L57 42.5m14 17.05V49.18l20.33-23.84-.07 10.45L86 42M1 59.68l.22-9.07 35.33-19.8-.1 9L9 55" />
|
|
17
|
+
<path d="M36.55 30.8s-.08 5.92-.1 9l.1-9ZM71 59.51v-9.07L36.55 30.8l-.1 9L63.5 55" />
|
|
18
|
+
<path d="M71 59.51v-9.07L36.44 70.78l-.1 9.14L55.5 68.5" />
|
|
19
|
+
<path d="M1.22 50.6a77387.2 77387.2 0 0 0 35.22 20.18l-.1 9.14L1 59.68l.23-9.07h-.01ZM141 59.68l-.23-9.07-35.33-19.8.11 9L133 55" />
|
|
20
|
+
<path d="m105.44 30.8.11 9-.1-9Z" />
|
|
21
|
+
<path d="M71 59.51v-9.07l34.44-19.64.11 9L78.5 55" />
|
|
22
|
+
<path d="M71 59.51v-9.07l34.56 20.34.1 9.14L87 69" />
|
|
23
|
+
<path d="M140.78 50.6a78487.3 78487.3 0 0 1-35.23 20.18l.11 9.14L141 59.68l-.23-9.07ZM50.83 80.15l.06-6.33 20.1-23.38H71v9.26L55 79" />
|
|
24
|
+
<path d="M71.3 97.6 50.89 73.81l-.06 9.33L71.3 107v-9.4Zm20.03-14.5-.07-9.33L71 50.44v9.26l16 18.8" />
|
|
25
|
+
<path d="m71.3 97.6 19.96-23.83.06 9.33L71.3 107v-9.4Z" />
|
|
26
|
+
</g>
|
|
27
|
+
</svg>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
Web3Graphic.displayName = "Web3Graphic";
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "@moveindustries/wallet-adapter-core";
|
|
2
|
+
export * from "./WalletProvider";
|
|
3
|
+
export * from "./components/AboutMovementConnect";
|
|
4
|
+
export * from "./components/AboutPetraWeb";
|
|
5
|
+
export * from "./components/MovementPrivacyPolicy";
|
|
6
|
+
export * from "./components/WalletItem";
|
|
7
|
+
export * from "./useWallet";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useContext, createContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AccountAuthenticator,
|
|
4
|
+
AccountInfo,
|
|
5
|
+
AdapterWallet,
|
|
6
|
+
AnyRawTransaction,
|
|
7
|
+
MovementSignAndSubmitTransactionOutput,
|
|
8
|
+
InputTransactionData,
|
|
9
|
+
NetworkInfo,
|
|
10
|
+
MovementSignMessageInput,
|
|
11
|
+
MovementSignMessageOutput,
|
|
12
|
+
AdapterNotDetectedWallet,
|
|
13
|
+
Network,
|
|
14
|
+
MovementChangeNetworkOutput,
|
|
15
|
+
PendingTransactionResponse,
|
|
16
|
+
InputSubmitTransactionData,
|
|
17
|
+
MovementSignInInput,
|
|
18
|
+
MovementSignInOutput,
|
|
19
|
+
} from "@moveindustries/wallet-adapter-core";
|
|
20
|
+
|
|
21
|
+
export interface WalletContextState {
|
|
22
|
+
connected: boolean;
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
account: AccountInfo | null;
|
|
25
|
+
network: NetworkInfo | null;
|
|
26
|
+
connect(walletName: string): void;
|
|
27
|
+
signIn(args: {
|
|
28
|
+
walletName: string;
|
|
29
|
+
input: MovementSignInInput;
|
|
30
|
+
}): Promise<MovementSignInOutput | void>;
|
|
31
|
+
signAndSubmitTransaction(
|
|
32
|
+
transaction: InputTransactionData,
|
|
33
|
+
): Promise<MovementSignAndSubmitTransactionOutput>;
|
|
34
|
+
signTransaction(args: {
|
|
35
|
+
transactionOrPayload: AnyRawTransaction | InputTransactionData;
|
|
36
|
+
asFeePayer?: boolean;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
authenticator: AccountAuthenticator;
|
|
39
|
+
rawTransaction: Uint8Array;
|
|
40
|
+
}>;
|
|
41
|
+
signMessage(message: MovementSignMessageInput): Promise<MovementSignMessageOutput>;
|
|
42
|
+
signMessageAndVerify(message: MovementSignMessageInput): Promise<boolean>;
|
|
43
|
+
disconnect(): void;
|
|
44
|
+
changeNetwork(network: Network): Promise<MovementChangeNetworkOutput>;
|
|
45
|
+
submitTransaction(
|
|
46
|
+
transaction: InputSubmitTransactionData,
|
|
47
|
+
): Promise<PendingTransactionResponse>;
|
|
48
|
+
wallet: AdapterWallet | null;
|
|
49
|
+
wallets: ReadonlyArray<AdapterWallet>;
|
|
50
|
+
notDetectedWallets: ReadonlyArray<AdapterNotDetectedWallet>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const DEFAULT_CONTEXT = {
|
|
54
|
+
connected: false,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const WalletContext = createContext<WalletContextState>(
|
|
58
|
+
DEFAULT_CONTEXT as WalletContextState,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export function useWallet(): WalletContextState {
|
|
62
|
+
const context = useContext(WalletContext);
|
|
63
|
+
if (!context) {
|
|
64
|
+
throw new Error("useWallet must be used within a WalletContextState");
|
|
65
|
+
}
|
|
66
|
+
return context;
|
|
67
|
+
}
|