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.
Files changed (54) hide show
  1. package/dist/cjs/react/core/hooks/wallets/useConnect.js +2 -2
  2. package/dist/cjs/react/core/hooks/wallets/useConnect.js.map +1 -1
  3. package/dist/cjs/react/native/ui/components/WalletImage.js +18 -20
  4. package/dist/cjs/react/native/ui/components/WalletImage.js.map +1 -1
  5. package/dist/cjs/react/native/ui/connect/ConnectButton.js +1 -6
  6. package/dist/cjs/react/native/ui/connect/ConnectButton.js.map +1 -1
  7. package/dist/cjs/react/native/ui/connect/ConnectModal.js +64 -15
  8. package/dist/cjs/react/native/ui/connect/ConnectModal.js.map +1 -1
  9. package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js +12 -18
  10. package/dist/cjs/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
  11. package/dist/cjs/react/native/ui/connect/InAppWalletUI.js +39 -34
  12. package/dist/cjs/react/native/ui/connect/InAppWalletUI.js.map +1 -1
  13. package/dist/cjs/react/native/ui/connect/WalletLoadingThumbnail.js +51 -0
  14. package/dist/cjs/react/native/ui/connect/WalletLoadingThumbnail.js.map +1 -0
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/version.js.map +1 -1
  17. package/dist/esm/react/core/hooks/wallets/useConnect.js +2 -2
  18. package/dist/esm/react/core/hooks/wallets/useConnect.js.map +1 -1
  19. package/dist/esm/react/native/ui/components/WalletImage.js +17 -20
  20. package/dist/esm/react/native/ui/components/WalletImage.js.map +1 -1
  21. package/dist/esm/react/native/ui/connect/ConnectButton.js +1 -6
  22. package/dist/esm/react/native/ui/connect/ConnectButton.js.map +1 -1
  23. package/dist/esm/react/native/ui/connect/ConnectModal.js +65 -16
  24. package/dist/esm/react/native/ui/connect/ConnectModal.js.map +1 -1
  25. package/dist/esm/react/native/ui/connect/ExternalWalletsList.js +12 -18
  26. package/dist/esm/react/native/ui/connect/ExternalWalletsList.js.map +1 -1
  27. package/dist/esm/react/native/ui/connect/InAppWalletUI.js +39 -34
  28. package/dist/esm/react/native/ui/connect/InAppWalletUI.js.map +1 -1
  29. package/dist/esm/react/native/ui/connect/WalletLoadingThumbnail.js +49 -0
  30. package/dist/esm/react/native/ui/connect/WalletLoadingThumbnail.js.map +1 -0
  31. package/dist/esm/version.js +1 -1
  32. package/dist/esm/version.js.map +1 -1
  33. package/dist/types/react/native/ui/components/WalletImage.d.ts +1 -0
  34. package/dist/types/react/native/ui/components/WalletImage.d.ts.map +1 -1
  35. package/dist/types/react/native/ui/connect/ConnectButton.d.ts.map +1 -1
  36. package/dist/types/react/native/ui/connect/ConnectModal.d.ts +8 -0
  37. package/dist/types/react/native/ui/connect/ConnectModal.d.ts.map +1 -1
  38. package/dist/types/react/native/ui/connect/ExternalWalletsList.d.ts +4 -2
  39. package/dist/types/react/native/ui/connect/ExternalWalletsList.d.ts.map +1 -1
  40. package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts +6 -2
  41. package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts.map +1 -1
  42. package/dist/types/react/native/ui/connect/WalletLoadingThumbnail.d.ts +10 -0
  43. package/dist/types/react/native/ui/connect/WalletLoadingThumbnail.d.ts.map +1 -0
  44. package/dist/types/version.d.ts +1 -1
  45. package/dist/types/version.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/react/core/hooks/wallets/useConnect.ts +2 -2
  48. package/src/react/native/ui/components/WalletImage.tsx +18 -20
  49. package/src/react/native/ui/connect/ConnectButton.tsx +0 -11
  50. package/src/react/native/ui/connect/ConnectModal.tsx +158 -13
  51. package/src/react/native/ui/connect/ExternalWalletsList.tsx +18 -35
  52. package/src/react/native/ui/connect/InAppWalletUI.tsx +49 -67
  53. package/src/react/native/ui/connect/WalletLoadingThumbnail.tsx +98 -0
  54. 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
- connectMutation: ReturnType<typeof useConnect>;
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, connectMutation } = props;
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
- setSelectedAuth(strategy);
107
- connectMutation.connect(async () => {
108
- await wallet.connect({
109
- client,
110
- strategy: auth,
111
- });
112
- await setLastAuthProvider(auth, nativeLocalStorage);
113
- return wallet;
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
- }, [connectMutation, auth, client, wallet, strategy]);
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
- {connectMutation.isConnecting && selectedAuth === auth ? (
125
- <ThemedSpinner color={theme.colors.primaryText} />
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, connectMutation } = props;
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 connectMutation.connect(async () => {
224
- if (auth.strategy === "phone") {
225
- await wallet.connect({
226
- client,
227
- strategy: auth.strategy,
228
- phoneNumber: auth.phoneNumber,
229
- verificationCode,
230
- });
231
- } else {
232
- await wallet.connect({
233
- client,
234
- strategy: auth.strategy,
235
- email: auth.email,
236
- verificationCode,
237
- });
238
- }
239
- await setLastAuthProvider(auth.strategy, nativeLocalStorage);
240
- return wallet;
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="subtext"
290
- style={{ color: theme.colors.danger }}
271
+ type="defaultSemiBold"
272
+ style={{ color: theme.colors.accentButtonText }}
291
273
  >
292
- {connectMutation.error.message}
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";
1
+ export const version = "5.32.2-nightly-229561e1a79fe2ab3f010c5a8659c7e0fc497ec3-20240703090013";