thirdweb 5.98.1 → 5.98.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/dist/cjs/extensions/erc20/read/getCurrencyMetadata.js +2 -2
- package/dist/cjs/extensions/erc20/read/getCurrencyMetadata.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/ConnectButton.js +4 -1
- package/dist/cjs/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +6 -4
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +5 -15
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +8 -1
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/connection/autoConnectCore.js +29 -12
- package/dist/cjs/wallets/connection/autoConnectCore.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/is-in-app-signer.js +15 -0
- package/dist/cjs/wallets/in-app/core/wallet/is-in-app-signer.js.map +1 -0
- package/dist/esm/extensions/erc20/read/getCurrencyMetadata.js +2 -2
- package/dist/esm/extensions/erc20/read/getCurrencyMetadata.js.map +1 -1
- package/dist/esm/react/native/ui/connect/ConnectButton.js +4 -1
- package/dist/esm/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +6 -4
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -11
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +8 -1
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/connection/autoConnectCore.js +29 -12
- package/dist/esm/wallets/connection/autoConnectCore.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/is-in-app-signer.js +12 -0
- package/dist/esm/wallets/in-app/core/wallet/is-in-app-signer.js.map +1 -0
- package/dist/types/react/native/ui/connect/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/connection/autoConnectCore.d.ts.map +1 -1
- package/dist/types/wallets/connection/types.d.ts +9 -0
- package/dist/types/wallets/connection/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/is-in-app-signer.d.ts +6 -0
- package/dist/types/wallets/in-app/core/wallet/is-in-app-signer.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/extensions/erc20/read/getCurrencyMetadata.ts +2 -2
- package/src/react/native/ui/connect/ConnectButton.tsx +4 -1
- package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +11 -3
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -21
- package/src/react/web/ui/PayEmbed.tsx +15 -1
- package/src/version.ts +1 -1
- package/src/wallets/connection/autoConnectCore.ts +33 -12
- package/src/wallets/connection/types.ts +10 -0
- package/src/wallets/in-app/core/wallet/is-in-app-signer.ts +21 -0
@@ -297,6 +297,9 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
297
297
|
);
|
298
298
|
const localeQuery = useConnectLocale(props.locale || "en_US");
|
299
299
|
const connectionManager = useConnectionManager();
|
300
|
+
const activeAccount = useActiveAccount();
|
301
|
+
const activeWallet = useActiveWallet();
|
302
|
+
const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
|
300
303
|
|
301
304
|
usePreloadWalletProviders({
|
302
305
|
wallets,
|
@@ -337,6 +340,7 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
337
340
|
}
|
338
341
|
accountAbstraction={props.accountAbstraction}
|
339
342
|
onConnect={props.onConnect}
|
343
|
+
siweAuth={siweAuth}
|
340
344
|
/>
|
341
345
|
);
|
342
346
|
|
@@ -362,7 +366,11 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
362
366
|
|
363
367
|
return (
|
364
368
|
<WalletUIStatesProvider theme={props.theme} isOpen={false}>
|
365
|
-
<ConnectButtonInner
|
369
|
+
<ConnectButtonInner
|
370
|
+
{...props}
|
371
|
+
siweAuth={siweAuth}
|
372
|
+
connectLocale={localeQuery.data}
|
373
|
+
/>
|
366
374
|
<ConnectModal
|
367
375
|
shouldSetActive={true}
|
368
376
|
accountAbstraction={props.accountAbstraction}
|
@@ -396,11 +404,11 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
396
404
|
function ConnectButtonInner(
|
397
405
|
props: ConnectButtonProps & {
|
398
406
|
connectLocale: ConnectLocale;
|
407
|
+
siweAuth: ReturnType<typeof useSiweAuth>;
|
399
408
|
},
|
400
409
|
) {
|
401
|
-
const
|
410
|
+
const siweAuth = props.siweAuth;
|
402
411
|
const activeAccount = useActiveAccount();
|
403
|
-
const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
|
404
412
|
const [showSignatureModal, setShowSignatureModal] = useState(false);
|
405
413
|
|
406
414
|
// if wallet gets disconnected suddently, close the signature modal if it's open
|
@@ -247,6 +247,7 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
|
|
247
247
|
chain={preferredChain}
|
248
248
|
appMetadata={props.appMetadata}
|
249
249
|
client={props.client}
|
250
|
+
siweAuth={siweAuth}
|
250
251
|
wallets={wallets}
|
251
252
|
accountAbstraction={props.accountAbstraction}
|
252
253
|
timeout={
|
@@ -23,10 +23,7 @@ import { sendTransaction } from "../../../../../../../transaction/actions/send-t
|
|
23
23
|
import type { WaitForReceiptOptions } from "../../../../../../../transaction/actions/wait-for-tx-receipt.js";
|
24
24
|
import { waitForReceipt } from "../../../../../../../transaction/actions/wait-for-tx-receipt.js";
|
25
25
|
import { formatNumber } from "../../../../../../../utils/formatNumber.js";
|
26
|
-
import {
|
27
|
-
import { isInAppWallet } from "../../../../../../../wallets/in-app/core/wallet/index.js";
|
28
|
-
import type { Wallet } from "../../../../../../../wallets/interfaces/wallet.js";
|
29
|
-
import { isSmartWallet } from "../../../../../../../wallets/smart/is-smart-wallet.js";
|
26
|
+
import { isInAppSigner } from "../../../../../../../wallets/in-app/core/wallet/is-in-app-signer.js";
|
30
27
|
import { spacing } from "../../../../../../core/design-system/index.js";
|
31
28
|
import { useChainName } from "../../../../../../core/hooks/others/useChainQuery.js";
|
32
29
|
import { useBuyWithCryptoStatus } from "../../../../../../core/hooks/pay/useBuyWithCryptoStatus.js";
|
@@ -779,20 +776,3 @@ function useSwapMutation(props: {
|
|
779
776
|
},
|
780
777
|
});
|
781
778
|
}
|
782
|
-
|
783
|
-
function isInAppSigner(options: {
|
784
|
-
wallet: Wallet;
|
785
|
-
connectedWallets: Wallet[];
|
786
|
-
}) {
|
787
|
-
const isInAppOrEcosystem = (w: Wallet) =>
|
788
|
-
isInAppWallet(w) || isEcosystemWallet(w);
|
789
|
-
const isSmartWalletWithAdmin =
|
790
|
-
isSmartWallet(options.wallet) &&
|
791
|
-
options.connectedWallets.some(
|
792
|
-
(w) =>
|
793
|
-
isInAppOrEcosystem(w) &&
|
794
|
-
w.getAccount()?.address?.toLowerCase() ===
|
795
|
-
options.wallet.getAdminAccount?.()?.address?.toLowerCase(),
|
796
|
-
);
|
797
|
-
return isInAppOrEcosystem(options.wallet) || isSmartWalletWithAdmin;
|
798
|
-
}
|
@@ -9,13 +9,19 @@ import type { AppMetadata } from "../../../wallets/types.js";
|
|
9
9
|
import type { WalletId } from "../../../wallets/wallet-types.js";
|
10
10
|
import { CustomThemeProvider } from "../../core/design-system/CustomThemeProvider.js";
|
11
11
|
import type { Theme } from "../../core/design-system/index.js";
|
12
|
-
import
|
12
|
+
import {
|
13
|
+
type SiweAuthOptions,
|
14
|
+
useSiweAuth,
|
15
|
+
} from "../../core/hooks/auth/useSiweAuth.js";
|
13
16
|
import type {
|
14
17
|
ConnectButton_connectModalOptions,
|
15
18
|
PayUIOptions,
|
16
19
|
} from "../../core/hooks/connection/ConnectButtonProps.js";
|
20
|
+
import { useActiveAccount } from "../../core/hooks/wallets/useActiveAccount.js";
|
21
|
+
import { useActiveWallet } from "../../core/hooks/wallets/useActiveWallet.js";
|
17
22
|
import { useConnectionManager } from "../../core/providers/connection-manager.js";
|
18
23
|
import type { SupportedTokens } from "../../core/utils/defaultTokens.js";
|
24
|
+
import { AutoConnect } from "../../web/ui/AutoConnect/AutoConnect.js";
|
19
25
|
import { EmbedContainer } from "./ConnectWallet/Modal/ConnectEmbed.js";
|
20
26
|
import { useConnectLocale } from "./ConnectWallet/locale/getConnectLocale.js";
|
21
27
|
import BuyScreen from "./ConnectWallet/screens/Buy/BuyScreen.js";
|
@@ -300,6 +306,13 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
300
306
|
const [screen, setScreen] = useState<"buy" | "execute-tx">("buy");
|
301
307
|
const theme = props.theme || "dark";
|
302
308
|
const connectionManager = useConnectionManager();
|
309
|
+
const activeAccount = useActiveAccount();
|
310
|
+
const activeWallet = useActiveWallet();
|
311
|
+
const siweAuth = useSiweAuth(
|
312
|
+
activeWallet,
|
313
|
+
activeAccount,
|
314
|
+
props.connectOptions?.auth,
|
315
|
+
);
|
303
316
|
|
304
317
|
// Add props.chain and props.chains to defined chains store
|
305
318
|
useEffect(() => {
|
@@ -342,6 +355,7 @@ export function PayEmbed(props: PayEmbedProps) {
|
|
342
355
|
} else {
|
343
356
|
content = (
|
344
357
|
<>
|
358
|
+
<AutoConnect client={props.client} siweAuth={siweAuth} />
|
345
359
|
{screen === "buy" && (
|
346
360
|
<BuyScreen
|
347
361
|
title={metadata?.name || "Buy"}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.98.
|
1
|
+
export const version = "5.98.2";
|
@@ -8,6 +8,7 @@ import type {
|
|
8
8
|
AuthArgsType,
|
9
9
|
AuthStoredTokenWithCookieReturnType,
|
10
10
|
} from "../in-app/core/authentication/types.js";
|
11
|
+
import { isInAppSigner } from "../in-app/core/wallet/is-in-app-signer.js";
|
11
12
|
import { getUrlToken } from "../in-app/web/lib/get-url-token.js";
|
12
13
|
import type { Wallet } from "../interfaces/wallet.js";
|
13
14
|
import {
|
@@ -82,11 +83,11 @@ const _autoConnectCore = async ({
|
|
82
83
|
getStoredActiveWalletId(storage),
|
83
84
|
]);
|
84
85
|
|
85
|
-
const
|
86
|
+
const urlToken = getUrlToken();
|
86
87
|
|
87
88
|
// If an auth cookie is found and this site supports the wallet, we'll set the auth cookie in the client storage
|
88
|
-
const wallet = wallets.find((w) => w.id ===
|
89
|
-
if (
|
89
|
+
const wallet = wallets.find((w) => w.id === urlToken?.walletId);
|
90
|
+
if (urlToken?.authCookie && wallet) {
|
90
91
|
const clientStorage = new ClientScopedStorage({
|
91
92
|
storage,
|
92
93
|
clientId: props.client.clientId,
|
@@ -97,17 +98,17 @@ const _autoConnectCore = async ({
|
|
97
98
|
}
|
98
99
|
: undefined,
|
99
100
|
});
|
100
|
-
await clientStorage.saveAuthCookie(
|
101
|
+
await clientStorage.saveAuthCookie(urlToken.authCookie);
|
101
102
|
}
|
102
|
-
if (
|
103
|
-
lastActiveWalletId =
|
104
|
-
lastConnectedWalletIds = lastConnectedWalletIds?.includes(
|
103
|
+
if (urlToken?.walletId) {
|
104
|
+
lastActiveWalletId = urlToken.walletId;
|
105
|
+
lastConnectedWalletIds = lastConnectedWalletIds?.includes(urlToken.walletId)
|
105
106
|
? lastConnectedWalletIds
|
106
|
-
: [
|
107
|
+
: [urlToken.walletId, ...(lastConnectedWalletIds || [])];
|
107
108
|
}
|
108
109
|
|
109
|
-
if (
|
110
|
-
await setLastAuthProvider?.(
|
110
|
+
if (urlToken?.authProvider) {
|
111
|
+
await setLastAuthProvider?.(urlToken.authProvider, storage);
|
111
112
|
}
|
112
113
|
|
113
114
|
// if no wallets were last connected or we didn't receive an auth token
|
@@ -132,7 +133,7 @@ const _autoConnectCore = async ({
|
|
132
133
|
wallet: activeWallet,
|
133
134
|
client: props.client,
|
134
135
|
lastConnectedChain,
|
135
|
-
authResult:
|
136
|
+
authResult: urlToken?.authResult,
|
136
137
|
}),
|
137
138
|
{
|
138
139
|
ms: timeout,
|
@@ -183,13 +184,33 @@ const _autoConnectCore = async ({
|
|
183
184
|
wallet,
|
184
185
|
client: props.client,
|
185
186
|
lastConnectedChain,
|
186
|
-
authResult:
|
187
|
+
authResult: urlToken?.authResult,
|
187
188
|
});
|
188
189
|
manager.addConnectedWallet(wallet);
|
189
190
|
} catch {
|
190
191
|
// no-op
|
191
192
|
}
|
192
193
|
}
|
194
|
+
|
195
|
+
// Auto-login with SIWE
|
196
|
+
const isIAW =
|
197
|
+
activeWallet &&
|
198
|
+
isInAppSigner({
|
199
|
+
wallet: activeWallet,
|
200
|
+
connectedWallets: activeWallet
|
201
|
+
? [activeWallet, ...otherWallets]
|
202
|
+
: otherWallets,
|
203
|
+
});
|
204
|
+
if (
|
205
|
+
isIAW &&
|
206
|
+
props.siweAuth?.requiresAuth &&
|
207
|
+
!props.siweAuth?.isLoggedIn &&
|
208
|
+
!props.siweAuth?.isLoggingIn
|
209
|
+
) {
|
210
|
+
await props.siweAuth?.doLogin().catch((err) => {
|
211
|
+
console.warn("Error signing in with SIWE:", err.message);
|
212
|
+
});
|
213
|
+
}
|
193
214
|
manager.isAutoConnecting.setValue(false);
|
194
215
|
return autoConnected; // useQuery needs a return value
|
195
216
|
};
|
@@ -118,4 +118,14 @@ export type AutoConnectProps = {
|
|
118
118
|
* Callback to be called when the connection is timeout-ed
|
119
119
|
*/
|
120
120
|
onTimeout?: () => void;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* @hidden
|
124
|
+
*/
|
125
|
+
siweAuth?: {
|
126
|
+
requiresAuth: boolean;
|
127
|
+
doLogin: () => Promise<void>;
|
128
|
+
isLoggedIn: boolean | undefined;
|
129
|
+
isLoggingIn: boolean | undefined;
|
130
|
+
};
|
121
131
|
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
2
|
+
import type { Wallet } from "../../../interfaces/wallet.js";
|
3
|
+
import { isSmartWallet } from "../../../smart/index.js";
|
4
|
+
import { isInAppWallet } from "./index.js";
|
5
|
+
|
6
|
+
export function isInAppSigner(options: {
|
7
|
+
wallet: Wallet;
|
8
|
+
connectedWallets: Wallet[];
|
9
|
+
}) {
|
10
|
+
const isInAppOrEcosystem = (w: Wallet) =>
|
11
|
+
isInAppWallet(w) || isEcosystemWallet(w);
|
12
|
+
const isSmartWalletWithAdmin =
|
13
|
+
isSmartWallet(options.wallet) &&
|
14
|
+
options.connectedWallets.some(
|
15
|
+
(w) =>
|
16
|
+
isInAppOrEcosystem(w) &&
|
17
|
+
w.getAccount()?.address?.toLowerCase() ===
|
18
|
+
options.wallet.getAdminAccount?.()?.address?.toLowerCase(),
|
19
|
+
);
|
20
|
+
return isInAppOrEcosystem(options.wallet) || isSmartWalletWithAdmin;
|
21
|
+
}
|