thirdweb 5.32.1 → 5.32.2-nightly-229561e1a79fe2ab3f010c5a8659c7e0fc497ec3-20240703090013
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/dist/cjs/react/core/hooks/wallets/useConnect.js +2 -2
- package/dist/cjs/react/core/hooks/wallets/useConnect.js.map +1 -1
- package/dist/cjs/react/native/ui/components/WalletImage.js +18 -20
- package/dist/cjs/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectButton.js +1 -6
- package/dist/cjs/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectModal.js +64 -15
- package/dist/cjs/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js +12 -18
- package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js +39 -34
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/WalletLoadingThumbnail.js +51 -0
- package/dist/cjs/react/native/ui/connect/WalletLoadingThumbnail.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useConnect.js +2 -2
- package/dist/esm/react/core/hooks/wallets/useConnect.js.map +1 -1
- package/dist/esm/react/native/ui/components/WalletImage.js +17 -20
- package/dist/esm/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectButton.js +1 -6
- package/dist/esm/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectModal.js +65 -16
- package/dist/esm/react/native/ui/connect/ConnectModal.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ExternalWalletsList.js +12 -18
- package/dist/esm/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js +39 -34
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/esm/react/native/ui/connect/WalletLoadingThumbnail.js +49 -0
- package/dist/esm/react/native/ui/connect/WalletLoadingThumbnail.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/react/native/ui/components/WalletImage.d.ts +1 -0
- package/dist/types/react/native/ui/components/WalletImage.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/ConnectModal.d.ts +8 -0
- package/dist/types/react/native/ui/connect/ConnectModal.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/ExternalWalletsList.d.ts +4 -2
- package/dist/types/react/native/ui/connect/ExternalWalletsList.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts +6 -2
- package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/WalletLoadingThumbnail.d.ts +10 -0
- package/dist/types/react/native/ui/connect/WalletLoadingThumbnail.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/react/core/hooks/wallets/useConnect.ts +2 -2
- package/src/react/native/ui/components/WalletImage.tsx +18 -20
- package/src/react/native/ui/connect/ConnectButton.tsx +0 -11
- package/src/react/native/ui/connect/ConnectModal.tsx +158 -13
- package/src/react/native/ui/connect/ExternalWalletsList.tsx +18 -35
- package/src/react/native/ui/connect/InAppWalletUI.tsx +49 -67
- package/src/react/native/ui/connect/WalletLoadingThumbnail.tsx +98 -0
- package/src/version.ts +1 -1
@@ -6,4 +6,5 @@ export declare const WalletImage: (props: {
|
|
6
6
|
size: number;
|
7
7
|
ensAvatar?: string | null;
|
8
8
|
}) => import("react/jsx-runtime.js").JSX.Element;
|
9
|
+
export declare function getAuthProviderImage(lastAuthProvider: string | null): string;
|
9
10
|
//# sourceMappingURL=WalletImage.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"WalletImage.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/components/WalletImage.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAYlE,eAAO,MAAM,WAAW,UAAW;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,+
|
1
|
+
{"version":3,"file":"WalletImage.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/components/WalletImage.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAYlE,eAAO,MAAM,WAAW,UAAW;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,+CAuCA,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAe5E"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ConnectButton.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ConnectButton.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAY/F;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,
|
1
|
+
{"version":3,"file":"ConnectButton.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ConnectButton.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAY/F;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,8CAmHtD"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { MultiStepAuthProviderType } from "../../../../wallets/in-app/core/authentication/type.js";
|
2
|
+
import type { InAppWalletAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
2
3
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
3
4
|
import type { Theme } from "../../../core/design-system/index.js";
|
4
5
|
import type { ConnectButtonProps } from "../../../core/hooks/connection/ConnectButtonProps.js";
|
@@ -6,6 +7,13 @@ import type { ConnectEmbedProps } from "../../../core/hooks/connection/ConnectEm
|
|
6
7
|
import { type ContainerType } from "../components/Header.js";
|
7
8
|
export type ModalState = {
|
8
9
|
screen: "base";
|
10
|
+
} | {
|
11
|
+
screen: "connecting";
|
12
|
+
wallet: Wallet;
|
13
|
+
authMethod?: InAppWalletAuth;
|
14
|
+
} | {
|
15
|
+
screen: "error";
|
16
|
+
error: string;
|
9
17
|
} | {
|
10
18
|
screen: "otp";
|
11
19
|
auth: MultiStepAuthProviderType;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ConnectModal.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ConnectModal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AACxG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;
|
1
|
+
{"version":3,"file":"ConnectModal.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ConnectModal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAO7F,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAgBrE,MAAM,MAAM,UAAU,GAClB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,eAAe,CAAA;CAAE,GACtE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,yBAAyB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAAE,GAC3E;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qDAUpD;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,kBAAkB,GAAG;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;CAC9B,8CAiPF"}
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
2
2
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
3
3
|
import type { Theme } from "../../../core/design-system/index.js";
|
4
|
-
import type { useConnect } from "../../hooks/wallets/useConnect.js";
|
5
4
|
import type { ContainerType } from "../components/Header.js";
|
6
5
|
export type ExternalWalletsUiProps = {
|
7
6
|
theme: Theme;
|
8
7
|
client: ThirdwebClient;
|
9
|
-
|
8
|
+
connector: (args: {
|
9
|
+
wallet: Wallet;
|
10
|
+
connectFn: () => Promise<Wallet>;
|
11
|
+
}) => Promise<void>;
|
10
12
|
containerType: ContainerType;
|
11
13
|
};
|
12
14
|
export declare function ExternalWalletsList(props: ExternalWalletsUiProps & {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalWalletsList.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ExternalWalletsList.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"ExternalWalletsList.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/ExternalWalletsList.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;KAClC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,sBAAsB,GAAG;IAAE,eAAe,EAAE,MAAM,EAAE,CAAA;CAAE,8CAsC9D"}
|
@@ -1,15 +1,19 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
2
2
|
import type { MultiStepAuthProviderType } from "../../../../wallets/in-app/core/authentication/type.js";
|
3
|
+
import type { InAppWalletAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
3
4
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
4
5
|
import type { Theme } from "../../../core/design-system/index.js";
|
5
|
-
import type { useConnect } from "../../hooks/wallets/useConnect.js";
|
6
6
|
import type { ModalState } from "./ConnectModal.js";
|
7
7
|
type InAppWalletFormUIProps = {
|
8
8
|
client: ThirdwebClient;
|
9
9
|
theme: Theme;
|
10
10
|
wallet: Wallet<"inApp">;
|
11
11
|
setScreen: (screen: ModalState) => void;
|
12
|
-
|
12
|
+
connector: (args: {
|
13
|
+
wallet: Wallet;
|
14
|
+
connectFn: () => Promise<Wallet>;
|
15
|
+
authMethod?: InAppWalletAuth;
|
16
|
+
}) => Promise<void>;
|
13
17
|
};
|
14
18
|
export declare function InAppWalletUI(props: InAppWalletFormUIProps): import("react/jsx-runtime.js").JSX.Element;
|
15
19
|
export declare function OtpLogin(props: InAppWalletFormUIProps & {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"InAppWalletUI.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/InAppWalletUI.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,wDAAwD,CAAC;
|
1
|
+
{"version":3,"file":"InAppWalletUI.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/InAppWalletUI.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAelE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgBpD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,CAAC,IAAI,EAAE;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QACjC,UAAU,CAAC,EAAE,eAAe,CAAC;KAC9B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,sBAAsB,8CAuC1D;AA+GD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,sBAAsB,GAAG;IAC9B,IAAI,EAAE,yBAAyB,CAAC;CACjC,8CAmEF"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Theme } from "../../../core/design-system/index.js";
|
2
|
+
interface Props {
|
3
|
+
theme: Theme;
|
4
|
+
children?: React.ReactNode;
|
5
|
+
imageSize: number;
|
6
|
+
showError?: boolean;
|
7
|
+
}
|
8
|
+
declare function WalletLoadingThumbnail({ theme, children, showError, imageSize, }: Props): import("react/jsx-runtime.js").JSX.Element;
|
9
|
+
export default WalletLoadingThumbnail;
|
10
|
+
//# sourceMappingURL=WalletLoadingThumbnail.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"WalletLoadingThumbnail.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/ui/connect/WalletLoadingThumbnail.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAQlE,UAAU,KAAK;IACb,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iBAAS,sBAAsB,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,GACV,EAAE,KAAK,8CA8DP;AAYD,eAAe,sBAAsB,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.32.
|
1
|
+
export declare const version = "5.32.2-nightly-229561e1a79fe2ab3f010c5a8659c7e0fc497ec3-20240703090013";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
|
package/package.json
CHANGED
@@ -18,13 +18,13 @@ export function useConnectCore(
|
|
18
18
|
// reset error state
|
19
19
|
setError(null);
|
20
20
|
if (typeof walletOrFn !== "function") {
|
21
|
-
return connect(walletOrFn, options);
|
21
|
+
return await connect(walletOrFn, options);
|
22
22
|
}
|
23
23
|
|
24
24
|
setIsConnecting(true);
|
25
25
|
try {
|
26
26
|
const w = await walletOrFn();
|
27
|
-
return connect(w, options);
|
27
|
+
return await connect(w, options);
|
28
28
|
} catch (e) {
|
29
29
|
console.error(e);
|
30
30
|
setError(e as Error);
|
@@ -42,26 +42,7 @@ export const WalletImage = (props: {
|
|
42
42
|
(wallet.id === "inApp" || wallet.id === "smart")
|
43
43
|
) {
|
44
44
|
const lastAuthProvider = await getLastAuthProvider(nativeLocalStorage);
|
45
|
-
|
46
|
-
case "phone":
|
47
|
-
imageData = PHONE_ICON;
|
48
|
-
break;
|
49
|
-
case "email":
|
50
|
-
imageData = EMAIL_ICON;
|
51
|
-
break;
|
52
|
-
case "google":
|
53
|
-
imageData = GOOGLE_ICON;
|
54
|
-
break;
|
55
|
-
case "apple":
|
56
|
-
imageData = APPLE_ICON;
|
57
|
-
break;
|
58
|
-
case "facebook":
|
59
|
-
imageData = FACEBOOK_ICON;
|
60
|
-
break;
|
61
|
-
default:
|
62
|
-
imageData = WALLET_ICON;
|
63
|
-
break;
|
64
|
-
}
|
45
|
+
imageData = getAuthProviderImage(lastAuthProvider);
|
65
46
|
return imageData;
|
66
47
|
}
|
67
48
|
try {
|
@@ -79,3 +60,20 @@ export const WalletImage = (props: {
|
|
79
60
|
const data = ensAvatar || imageData || WALLET_ICON;
|
80
61
|
return <RNImage theme={props.theme} data={data} size={size} />;
|
81
62
|
};
|
63
|
+
|
64
|
+
export function getAuthProviderImage(lastAuthProvider: string | null): string {
|
65
|
+
switch (lastAuthProvider) {
|
66
|
+
case "phone":
|
67
|
+
return PHONE_ICON;
|
68
|
+
case "email":
|
69
|
+
return EMAIL_ICON;
|
70
|
+
case "google":
|
71
|
+
return GOOGLE_ICON;
|
72
|
+
case "apple":
|
73
|
+
return APPLE_ICON;
|
74
|
+
case "facebook":
|
75
|
+
return FACEBOOK_ICON;
|
76
|
+
default:
|
77
|
+
return WALLET_ICON;
|
78
|
+
}
|
79
|
+
}
|
@@ -138,17 +138,6 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
138
138
|
wallet={wallet}
|
139
139
|
account={account}
|
140
140
|
/>
|
141
|
-
) : status === "connecting" ? (
|
142
|
-
<View
|
143
|
-
style={{
|
144
|
-
flexDirection: "column",
|
145
|
-
flex: 1,
|
146
|
-
alignItems: "center",
|
147
|
-
justifyContent: "center",
|
148
|
-
}}
|
149
|
-
>
|
150
|
-
<ThemedSpinner color={theme.colors.primaryText} size={32} />
|
151
|
-
</View>
|
152
141
|
) : (
|
153
142
|
<ConnectModal
|
154
143
|
{...props}
|
@@ -1,28 +1,39 @@
|
|
1
|
-
import { useState } from "react";
|
1
|
+
import { useCallback, useState } from "react";
|
2
2
|
import { Platform, StyleSheet, View } from "react-native";
|
3
3
|
import { SvgXml } from "react-native-svg";
|
4
4
|
import type { MultiStepAuthProviderType } from "../../../../wallets/in-app/core/authentication/type.js";
|
5
|
+
import type { InAppWalletAuth } from "../../../../wallets/in-app/core/wallet/types.js";
|
5
6
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
6
7
|
import { parseTheme } from "../../../core/design-system/CustomThemeProvider.js";
|
7
8
|
import type { Theme } from "../../../core/design-system/index.js";
|
8
9
|
import type { ConnectButtonProps } from "../../../core/hooks/connection/ConnectButtonProps.js";
|
9
10
|
import type { ConnectEmbedProps } from "../../../core/hooks/connection/ConnectEmbedProps.js";
|
10
11
|
import { genericWalletIcon } from "../../../core/utils/socialIcons.js";
|
12
|
+
import { useWalletInfo } from "../../../core/utils/wallet.js";
|
11
13
|
import { radius, spacing } from "../../design-system/index.js";
|
12
14
|
import { useActiveWallet } from "../../hooks/wallets/useActiveWallet.js";
|
13
|
-
import {
|
15
|
+
import { connectionManager } from "../../index.js";
|
14
16
|
import { getDefaultWallets } from "../../wallets/defaultWallets.js";
|
15
17
|
import { type ContainerType, Header } from "../components/Header.js";
|
18
|
+
import { RNImage } from "../components/RNImage.js";
|
19
|
+
import {
|
20
|
+
WalletImage,
|
21
|
+
getAuthProviderImage,
|
22
|
+
} from "../components/WalletImage.js";
|
16
23
|
import { ThemedButtonWithIcon } from "../components/button.js";
|
17
24
|
import { Spacer } from "../components/spacer.js";
|
18
25
|
import { ThemedText } from "../components/text.js";
|
19
26
|
import { ThemedView } from "../components/view.js";
|
20
27
|
import { TW_ICON } from "../icons/svgs.js";
|
28
|
+
import { ErrorView } from "./ErrorView.js";
|
21
29
|
import { ExternalWalletsList } from "./ExternalWalletsList.js";
|
22
30
|
import { InAppWalletUI, OtpLogin } from "./InAppWalletUI.js";
|
31
|
+
import WalletLoadingThumbnail from "./WalletLoadingThumbnail.js";
|
23
32
|
|
24
33
|
export type ModalState =
|
25
34
|
| { screen: "base" }
|
35
|
+
| { screen: "connecting"; wallet: Wallet; authMethod?: InAppWalletAuth }
|
36
|
+
| { screen: "error"; error: string }
|
26
37
|
| { screen: "otp"; auth: MultiStepAuthProviderType; wallet: Wallet<"inApp"> }
|
27
38
|
| { screen: "external_wallets" };
|
28
39
|
|
@@ -63,17 +74,44 @@ export function ConnectModal(
|
|
63
74
|
containerType: ContainerType;
|
64
75
|
},
|
65
76
|
) {
|
66
|
-
const {
|
67
|
-
|
77
|
+
const {
|
78
|
+
theme,
|
68
79
|
client,
|
80
|
+
containerType,
|
69
81
|
accountAbstraction,
|
70
|
-
onConnect
|
71
|
-
|
72
|
-
|
82
|
+
onConnect,
|
83
|
+
onClose,
|
84
|
+
} = props;
|
85
|
+
const [modalState, setModalState] = useState<ModalState>({ screen: "base" });
|
86
|
+
const connector = useCallback(
|
87
|
+
async (args: {
|
88
|
+
wallet: Wallet;
|
89
|
+
connectFn: () => Promise<Wallet>;
|
90
|
+
authMethod?: InAppWalletAuth;
|
91
|
+
}) => {
|
92
|
+
setModalState({
|
93
|
+
screen: "connecting",
|
94
|
+
wallet: args.wallet,
|
95
|
+
authMethod: args.authMethod,
|
96
|
+
});
|
97
|
+
try {
|
98
|
+
const w = await args.connectFn();
|
99
|
+
await connectionManager.connect(w, {
|
100
|
+
client,
|
101
|
+
accountAbstraction,
|
102
|
+
onConnect,
|
103
|
+
});
|
104
|
+
onClose?.();
|
105
|
+
} catch (error) {
|
106
|
+
setModalState({
|
107
|
+
screen: "error",
|
108
|
+
error: (error as Error)?.message || "unknown error",
|
109
|
+
});
|
110
|
+
}
|
73
111
|
},
|
74
|
-
|
112
|
+
[client, accountAbstraction, onConnect, onClose],
|
113
|
+
);
|
75
114
|
const wallets = props.wallets || getDefaultWallets(props);
|
76
|
-
const [modalState, setModalState] = useState<ModalState>({ screen: "base" });
|
77
115
|
const inAppWallet = wallets.find((wallet) => wallet.id === "inApp") as
|
78
116
|
| Wallet<"inApp">
|
79
117
|
| undefined;
|
@@ -105,7 +143,7 @@ export function ConnectModal(
|
|
105
143
|
client={client}
|
106
144
|
setScreen={setModalState}
|
107
145
|
theme={theme}
|
108
|
-
|
146
|
+
connector={connector}
|
109
147
|
/>
|
110
148
|
</View>
|
111
149
|
{containerType === "modal" ? (
|
@@ -131,9 +169,61 @@ export function ConnectModal(
|
|
131
169
|
theme={theme}
|
132
170
|
externalWallets={externalWallets}
|
133
171
|
client={client}
|
134
|
-
|
172
|
+
connector={connector}
|
173
|
+
containerType={containerType}
|
174
|
+
/>
|
175
|
+
</>
|
176
|
+
);
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
case "connecting": {
|
180
|
+
content = (
|
181
|
+
<>
|
182
|
+
<Header
|
183
|
+
theme={theme}
|
184
|
+
onClose={props.onClose}
|
135
185
|
containerType={containerType}
|
186
|
+
onBack={() => setModalState({ screen: "base" })}
|
187
|
+
/>
|
188
|
+
{containerType === "modal" ? (
|
189
|
+
<View style={{ flex: 1 }} />
|
190
|
+
) : (
|
191
|
+
<Spacer size="lg" />
|
192
|
+
)}
|
193
|
+
<LoadingView
|
194
|
+
theme={theme}
|
195
|
+
wallet={modalState.wallet}
|
196
|
+
authProvider={modalState.authMethod}
|
136
197
|
/>
|
198
|
+
{containerType === "modal" ? (
|
199
|
+
<View style={{ flex: 1 }} />
|
200
|
+
) : (
|
201
|
+
<Spacer size="md" />
|
202
|
+
)}
|
203
|
+
</>
|
204
|
+
);
|
205
|
+
break;
|
206
|
+
}
|
207
|
+
case "error": {
|
208
|
+
content = (
|
209
|
+
<>
|
210
|
+
<Header
|
211
|
+
theme={theme}
|
212
|
+
onClose={props.onClose}
|
213
|
+
containerType={containerType}
|
214
|
+
onBack={() => setModalState({ screen: "base" })}
|
215
|
+
/>
|
216
|
+
{containerType === "modal" ? (
|
217
|
+
<View style={{ flex: 1 }} />
|
218
|
+
) : (
|
219
|
+
<Spacer size="lg" />
|
220
|
+
)}
|
221
|
+
<ErrorView theme={theme} title={modalState.error} />
|
222
|
+
{containerType === "modal" ? (
|
223
|
+
<View style={{ flex: 1 }} />
|
224
|
+
) : (
|
225
|
+
<Spacer size="md" />
|
226
|
+
)}
|
137
227
|
</>
|
138
228
|
);
|
139
229
|
break;
|
@@ -165,7 +255,7 @@ export function ConnectModal(
|
|
165
255
|
setScreen={setModalState}
|
166
256
|
client={client}
|
167
257
|
theme={theme}
|
168
|
-
|
258
|
+
connector={connector}
|
169
259
|
/>
|
170
260
|
{externalWallets.length > 0 ? (
|
171
261
|
<>
|
@@ -199,7 +289,7 @@ export function ConnectModal(
|
|
199
289
|
theme={theme}
|
200
290
|
externalWallets={externalWallets}
|
201
291
|
client={client}
|
202
|
-
|
292
|
+
connector={connector}
|
203
293
|
containerType={containerType}
|
204
294
|
/>
|
205
295
|
</View>
|
@@ -225,6 +315,56 @@ export function ConnectModal(
|
|
225
315
|
);
|
226
316
|
}
|
227
317
|
|
318
|
+
function LoadingView({
|
319
|
+
theme,
|
320
|
+
wallet,
|
321
|
+
authProvider,
|
322
|
+
}: { theme: Theme; wallet: Wallet; authProvider?: InAppWalletAuth }) {
|
323
|
+
const walletInfo = useWalletInfo(wallet.id);
|
324
|
+
return (
|
325
|
+
<View
|
326
|
+
style={{
|
327
|
+
flexDirection: "column",
|
328
|
+
flex: 1,
|
329
|
+
alignItems: "center",
|
330
|
+
justifyContent: "center",
|
331
|
+
paddingVertical: spacing.xl,
|
332
|
+
}}
|
333
|
+
>
|
334
|
+
<WalletLoadingThumbnail theme={theme} imageSize={100}>
|
335
|
+
{authProvider ? (
|
336
|
+
<View
|
337
|
+
style={{
|
338
|
+
borderRadius: spacing.md,
|
339
|
+
padding: spacing.xs,
|
340
|
+
}}
|
341
|
+
>
|
342
|
+
<RNImage
|
343
|
+
theme={theme}
|
344
|
+
size={90}
|
345
|
+
data={getAuthProviderImage(authProvider)}
|
346
|
+
/>
|
347
|
+
</View>
|
348
|
+
) : (
|
349
|
+
<WalletImage theme={theme} size={90} wallet={wallet} />
|
350
|
+
)}
|
351
|
+
</WalletLoadingThumbnail>
|
352
|
+
<Spacer size="xl" />
|
353
|
+
<ThemedText theme={theme} type="subtitle">
|
354
|
+
{authProvider
|
355
|
+
? `Connecting with ${capitalizeFirstLetter(authProvider)}`
|
356
|
+
: "Awaiting confirmation"}
|
357
|
+
</ThemedText>
|
358
|
+
<Spacer size="sm" />
|
359
|
+
<ThemedText theme={theme} type="subtext">
|
360
|
+
{authProvider
|
361
|
+
? `Sign into your ${capitalizeFirstLetter(authProvider)} account`
|
362
|
+
: `Accept the connection request in ${walletInfo.data?.name}`}
|
363
|
+
</ThemedText>
|
364
|
+
</View>
|
365
|
+
);
|
366
|
+
}
|
367
|
+
|
228
368
|
function OrDivider({ theme }: { theme: Theme }) {
|
229
369
|
return (
|
230
370
|
<View
|
@@ -284,6 +424,11 @@ function PoweredByThirdweb({ theme }: { theme: Theme }) {
|
|
284
424
|
);
|
285
425
|
}
|
286
426
|
|
427
|
+
function capitalizeFirstLetter(str: string): string {
|
428
|
+
if (!str) return str;
|
429
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
430
|
+
}
|
431
|
+
|
287
432
|
const styles = StyleSheet.create({
|
288
433
|
modalContainer: {
|
289
434
|
flex: 1,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { useState } from "react";
|
2
1
|
import {
|
3
2
|
Image,
|
4
3
|
Linking,
|
@@ -12,32 +11,33 @@ import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
|
12
11
|
import type { Theme } from "../../../core/design-system/index.js";
|
13
12
|
import { useWalletImage, useWalletInfo } from "../../../core/utils/wallet.js";
|
14
13
|
import { spacing } from "../../design-system/index.js";
|
15
|
-
import type { useConnect } from "../../hooks/wallets/useConnect.js";
|
16
14
|
import type { ContainerType } from "../components/Header.js";
|
17
15
|
import { Skeleton } from "../components/Skeleton.js";
|
18
|
-
import { ThemedSpinner } from "../components/spinner.js";
|
19
16
|
import { ThemedText } from "../components/text.js";
|
20
17
|
|
21
18
|
export type ExternalWalletsUiProps = {
|
22
19
|
theme: Theme;
|
23
20
|
client: ThirdwebClient;
|
24
|
-
|
21
|
+
connector: (args: {
|
22
|
+
wallet: Wallet;
|
23
|
+
connectFn: () => Promise<Wallet>;
|
24
|
+
}) => Promise<void>;
|
25
25
|
containerType: ContainerType;
|
26
26
|
};
|
27
27
|
|
28
28
|
export function ExternalWalletsList(
|
29
29
|
props: ExternalWalletsUiProps & { externalWallets: Wallet[] },
|
30
30
|
) {
|
31
|
-
const {
|
32
|
-
const [selectedWallet, setSelectedWallet] = useState<Wallet>();
|
33
|
-
|
31
|
+
const { connector, client, theme } = props;
|
34
32
|
const connectWallet = (wallet: Wallet) => {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
connector({
|
34
|
+
wallet,
|
35
|
+
connectFn: async () => {
|
36
|
+
await wallet.connect({
|
37
|
+
client,
|
38
|
+
});
|
39
|
+
return wallet;
|
40
|
+
},
|
41
41
|
});
|
42
42
|
};
|
43
43
|
|
@@ -57,9 +57,6 @@ export function ExternalWalletsList(
|
|
57
57
|
wallet={wallet}
|
58
58
|
connectWallet={connectWallet}
|
59
59
|
theme={theme}
|
60
|
-
isConnecting={
|
61
|
-
connectMutation.isConnecting && wallet.id === selectedWallet?.id
|
62
|
-
}
|
63
60
|
/>
|
64
61
|
))}
|
65
62
|
</View>
|
@@ -72,32 +69,18 @@ export function ExternalWalletsList(
|
|
72
69
|
function ExternalWalletRow(props: {
|
73
70
|
theme: Theme;
|
74
71
|
wallet: Wallet;
|
75
|
-
isConnecting: boolean;
|
76
72
|
connectWallet: (wallet: Wallet) => void;
|
77
73
|
}) {
|
78
|
-
const { wallet, theme,
|
74
|
+
const { wallet, theme, connectWallet } = props;
|
79
75
|
const imageQuery = useWalletImage(wallet.id);
|
80
76
|
const infoQuery = useWalletInfo(wallet.id);
|
81
77
|
return (
|
82
78
|
<TouchableOpacity style={styles.row} onPress={() => connectWallet(wallet)}>
|
83
79
|
{imageQuery.data ? (
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
height: 52,
|
89
|
-
justifyContent: "center",
|
90
|
-
alignItems: "center",
|
91
|
-
}}
|
92
|
-
>
|
93
|
-
<ThemedSpinner color={theme.colors.primaryText} />
|
94
|
-
</View>
|
95
|
-
) : (
|
96
|
-
<Image
|
97
|
-
source={{ uri: imageQuery.data ?? "" }}
|
98
|
-
style={{ width: 52, height: 52, borderRadius: 6 }}
|
99
|
-
/>
|
100
|
-
)
|
80
|
+
<Image
|
81
|
+
source={{ uri: imageQuery.data ?? "" }}
|
82
|
+
style={{ width: 52, height: 52, borderRadius: 6 }}
|
83
|
+
/>
|
101
84
|
) : (
|
102
85
|
<Skeleton
|
103
86
|
theme={theme}
|