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
@@ -16,12 +16,10 @@ import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
|
16
16
|
import type { Theme } from "../../../core/design-system/index.js";
|
17
17
|
import { setLastAuthProvider } from "../../../core/utils/storage.js";
|
18
18
|
import { radius, spacing } from "../../design-system/index.js";
|
19
|
-
import type { useConnect } from "../../hooks/wallets/useConnect.js";
|
20
19
|
import { RNImage } from "../components/RNImage.js";
|
21
20
|
import { ThemedButton, ThemedButtonWithIcon } from "../components/button.js";
|
22
21
|
import { ThemedInput, ThemedInputWithSubmit } from "../components/input.js";
|
23
22
|
import { Spacer } from "../components/spacer.js";
|
24
|
-
import { ThemedSpinner } from "../components/spinner.js";
|
25
23
|
import { ThemedText } from "../components/text.js";
|
26
24
|
import {
|
27
25
|
APPLE_ICON,
|
@@ -51,7 +49,11 @@ type InAppWalletFormUIProps = {
|
|
51
49
|
theme: Theme;
|
52
50
|
wallet: Wallet<"inApp">;
|
53
51
|
setScreen: (screen: ModalState) => void;
|
54
|
-
|
52
|
+
connector: (args: {
|
53
|
+
wallet: Wallet;
|
54
|
+
connectFn: () => Promise<Wallet>;
|
55
|
+
authMethod?: InAppWalletAuth;
|
56
|
+
}) => Promise<void>;
|
55
57
|
};
|
56
58
|
|
57
59
|
export function InAppWalletUI(props: InAppWalletFormUIProps) {
|
@@ -98,21 +100,23 @@ export function InAppWalletUI(props: InAppWalletFormUIProps) {
|
|
98
100
|
function SocialLogin(
|
99
101
|
props: InAppWalletFormUIProps & { auth: InAppWalletSocialAuth },
|
100
102
|
) {
|
101
|
-
const { theme, wallet, auth, client,
|
103
|
+
const { theme, wallet, auth, client, connector } = props;
|
102
104
|
// TODO (rn) - move this onPress and state up
|
103
105
|
const strategy = props.auth;
|
104
|
-
const [selectedAuth, setSelectedAuth] = useState<InAppWalletSocialAuth>();
|
105
106
|
const connectInAppWallet = useCallback(() => {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
107
|
+
connector({
|
108
|
+
wallet,
|
109
|
+
connectFn: async () => {
|
110
|
+
await wallet.connect({
|
111
|
+
client,
|
112
|
+
strategy: auth,
|
113
|
+
});
|
114
|
+
await setLastAuthProvider(auth, nativeLocalStorage);
|
115
|
+
return wallet;
|
116
|
+
},
|
117
|
+
authMethod: auth,
|
114
118
|
});
|
115
|
-
}, [
|
119
|
+
}, [connector, auth, wallet, client]);
|
116
120
|
|
117
121
|
return (
|
118
122
|
<View
|
@@ -121,17 +125,9 @@ function SocialLogin(
|
|
121
125
|
{ borderColor: theme.colors.borderColor },
|
122
126
|
]}
|
123
127
|
>
|
124
|
-
{
|
125
|
-
<
|
126
|
-
|
127
|
-
<TouchableOpacity
|
128
|
-
key={strategy}
|
129
|
-
onPress={connectInAppWallet}
|
130
|
-
disabled={connectMutation.isConnecting}
|
131
|
-
>
|
132
|
-
<RNImage theme={theme} size={38} data={socialIcons[auth]} />
|
133
|
-
</TouchableOpacity>
|
134
|
-
)}
|
128
|
+
<TouchableOpacity key={strategy} onPress={connectInAppWallet}>
|
129
|
+
<RNImage theme={theme} size={38} data={socialIcons[auth]} />
|
130
|
+
</TouchableOpacity>
|
135
131
|
</View>
|
136
132
|
);
|
137
133
|
}
|
@@ -215,29 +211,33 @@ export function OtpLogin(
|
|
215
211
|
auth: MultiStepAuthProviderType;
|
216
212
|
},
|
217
213
|
) {
|
218
|
-
const { theme, auth, wallet, client,
|
214
|
+
const { theme, auth, wallet, client, connector } = props;
|
219
215
|
const [verificationCode, setVerificationCode] = useState("");
|
220
216
|
|
221
217
|
const connectInAppWallet = async () => {
|
222
218
|
if (!verificationCode || !verificationCode) return;
|
223
|
-
await
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
219
|
+
await connector({
|
220
|
+
wallet,
|
221
|
+
connectFn: async () => {
|
222
|
+
if (auth.strategy === "phone") {
|
223
|
+
await wallet.connect({
|
224
|
+
client,
|
225
|
+
strategy: auth.strategy,
|
226
|
+
phoneNumber: auth.phoneNumber,
|
227
|
+
verificationCode,
|
228
|
+
});
|
229
|
+
} else {
|
230
|
+
await wallet.connect({
|
231
|
+
client,
|
232
|
+
strategy: auth.strategy,
|
233
|
+
email: auth.email,
|
234
|
+
verificationCode,
|
235
|
+
});
|
236
|
+
}
|
237
|
+
await setLastAuthProvider(auth.strategy, nativeLocalStorage);
|
238
|
+
return wallet;
|
239
|
+
},
|
240
|
+
authMethod: auth.strategy,
|
241
241
|
});
|
242
242
|
};
|
243
243
|
|
@@ -265,33 +265,15 @@ export function OtpLogin(
|
|
265
265
|
value={verificationCode}
|
266
266
|
keyboardType="number-pad"
|
267
267
|
/>
|
268
|
-
<ThemedButton
|
269
|
-
theme={theme}
|
270
|
-
onPress={connectInAppWallet}
|
271
|
-
variant="accent"
|
272
|
-
disabled={connectMutation.isConnecting}
|
273
|
-
>
|
274
|
-
{connectMutation.isConnecting ? (
|
275
|
-
<ThemedSpinner color={theme.colors.accentButtonText} />
|
276
|
-
) : (
|
277
|
-
<ThemedText
|
278
|
-
theme={theme}
|
279
|
-
type="defaultSemiBold"
|
280
|
-
style={{ color: theme.colors.accentButtonText }}
|
281
|
-
>
|
282
|
-
Verify
|
283
|
-
</ThemedText>
|
284
|
-
)}
|
285
|
-
</ThemedButton>
|
286
|
-
{connectMutation.error && (
|
268
|
+
<ThemedButton theme={theme} onPress={connectInAppWallet} variant="accent">
|
287
269
|
<ThemedText
|
288
270
|
theme={theme}
|
289
|
-
type="
|
290
|
-
style={{ color: theme.colors.
|
271
|
+
type="defaultSemiBold"
|
272
|
+
style={{ color: theme.colors.accentButtonText }}
|
291
273
|
>
|
292
|
-
|
274
|
+
Verify
|
293
275
|
</ThemedText>
|
294
|
-
|
276
|
+
</ThemedButton>
|
295
277
|
</>
|
296
278
|
);
|
297
279
|
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import { useEffect, useRef } from "react";
|
2
|
+
import { Animated, Easing, StyleSheet, View } from "react-native";
|
3
|
+
import { Rect, Svg } from "react-native-svg";
|
4
|
+
import type { Theme } from "../../../core/design-system/index.js";
|
5
|
+
import { radius } from "../../design-system/index.js";
|
6
|
+
|
7
|
+
const AnimatedRect = Animated.createAnimatedComponent(Rect);
|
8
|
+
|
9
|
+
const PADDING = 10;
|
10
|
+
const INTERNAL_PADDING = 5;
|
11
|
+
|
12
|
+
interface Props {
|
13
|
+
theme: Theme;
|
14
|
+
children?: React.ReactNode;
|
15
|
+
imageSize: number;
|
16
|
+
showError?: boolean;
|
17
|
+
}
|
18
|
+
|
19
|
+
function WalletLoadingThumbnail({
|
20
|
+
theme,
|
21
|
+
children,
|
22
|
+
showError,
|
23
|
+
imageSize,
|
24
|
+
}: Props) {
|
25
|
+
const spinValue = useRef(new Animated.Value(0));
|
26
|
+
|
27
|
+
useEffect(() => {
|
28
|
+
const animation = Animated.timing(spinValue.current, {
|
29
|
+
toValue: 1,
|
30
|
+
duration: 1150,
|
31
|
+
useNativeDriver: true,
|
32
|
+
easing: Easing.linear,
|
33
|
+
});
|
34
|
+
|
35
|
+
const loop = Animated.loop(animation);
|
36
|
+
loop.start();
|
37
|
+
|
38
|
+
return () => {
|
39
|
+
loop.stop();
|
40
|
+
};
|
41
|
+
}, []);
|
42
|
+
|
43
|
+
const spin = spinValue.current.interpolate({
|
44
|
+
inputRange: [0, 1],
|
45
|
+
outputRange: [0, -400],
|
46
|
+
});
|
47
|
+
|
48
|
+
return (
|
49
|
+
<View style={styles.container}>
|
50
|
+
<Svg
|
51
|
+
width={imageSize + PADDING}
|
52
|
+
height={imageSize + PADDING}
|
53
|
+
viewBox={`0 0 ${imageSize + PADDING} ${imageSize + PADDING}`}
|
54
|
+
style={styles.loader}
|
55
|
+
>
|
56
|
+
<AnimatedRect
|
57
|
+
x="2"
|
58
|
+
y="2"
|
59
|
+
width={imageSize + INTERNAL_PADDING}
|
60
|
+
height={imageSize + INTERNAL_PADDING}
|
61
|
+
rx={15}
|
62
|
+
stroke={showError ? "transparent" : theme.colors.accentButtonBg}
|
63
|
+
strokeWidth={3}
|
64
|
+
fill="transparent"
|
65
|
+
strokeDasharray={"100 300"}
|
66
|
+
strokeDashoffset={spin}
|
67
|
+
/>
|
68
|
+
</Svg>
|
69
|
+
{showError && (
|
70
|
+
<View
|
71
|
+
style={[
|
72
|
+
{
|
73
|
+
position: "absolute",
|
74
|
+
borderWidth: 3,
|
75
|
+
height: imageSize + INTERNAL_PADDING,
|
76
|
+
width: imageSize + INTERNAL_PADDING,
|
77
|
+
borderRadius: radius.lg,
|
78
|
+
borderColor: theme.colors.borderColor,
|
79
|
+
},
|
80
|
+
]}
|
81
|
+
/>
|
82
|
+
)}
|
83
|
+
{children}
|
84
|
+
</View>
|
85
|
+
);
|
86
|
+
}
|
87
|
+
|
88
|
+
const styles = StyleSheet.create({
|
89
|
+
container: {
|
90
|
+
alignItems: "center",
|
91
|
+
justifyContent: "center",
|
92
|
+
},
|
93
|
+
loader: {
|
94
|
+
position: "absolute",
|
95
|
+
},
|
96
|
+
});
|
97
|
+
|
98
|
+
export default WalletLoadingThumbnail;
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.32.
|
1
|
+
export const version = "5.32.2-nightly-229561e1a79fe2ab3f010c5a8659c7e0fc497ec3-20240703090013";
|