Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
0f54e99141 Version Packages (#2083)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-15 09:31:22 +13:00
c701c388c6 feat: ethers skipFetchSetup support (#2085)
Co-authored-by: Manan Tank <[email protected]>
2023-12-15 08:37:55 +13:00
iketwandGitHub 328ef5dc9c [RN] Hide back button in WC modal when WC is the only supportedWallet (#2086) 2023-12-14 18:13:55 +00:00
iketwandGitHub 07fbb799be [RN] Adds the ability to login with any arbitrary login payload (#2074) 2023-12-13 20:50:24 +00:00
iketwandGitHub 699f31c20a [RN/React-Core] Improve comments (#2082) 2023-12-13 02:56:39 +00:00
41 changed files with 492 additions and 56 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 4.1.18
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.3.1
## 4.1.17
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "4.1.17",
"version": "4.1.18",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+9
View File
@@ -1,5 +1,14 @@
# thirdweb
## 0.13.26
### Patch Changes
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e)]:
- @thirdweb-dev/sdk@4.0.22
- @thirdweb-dev/wallets@2.3.1
- @thirdweb-dev/auth@4.1.18
## 0.13.25
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.13.25",
"version": "0.13.26",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+11
View File
@@ -1,5 +1,16 @@
# @thirdweb-dev/react-core
## 4.1.16
### Patch Changes
- [#2082](https://github.com/thirdweb-dev/js/pull/2082) [`699f31c2`](https://github.com/thirdweb-dev/js/commit/699f31c20a76cd284dbed1629c4a19d93aca7b7f) Thanks [@iketw](https://github.com/iketw)! - Better comments
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e)]:
- @thirdweb-dev/sdk@4.0.22
- @thirdweb-dev/wallets@2.3.1
- @thirdweb-dev/auth@4.1.18
## 4.1.15
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "4.1.15",
"version": "4.1.16",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -84,11 +84,10 @@ export interface ThirdwebProviderCoreProps<TChains extends Chain[]>
/**
* @internal
*/
export const ThirdwebProviderCore = <TChains extends Chain[]>({
createWalletStorage = createAsyncLocalStorage,
...props
}: React.PropsWithChildren<ThirdwebProviderCoreProps<TChains>>) => {
const { activeChain } = props;
export const ThirdwebProviderCore = <TChains extends Chain[]>(
props: React.PropsWithChildren<ThirdwebProviderCoreProps<TChains>>,
) => {
const { activeChain, createWalletStorage = createAsyncLocalStorage } = props;
const supportedChains = (props.supportedChains || defaultChains) as Chain[];
@@ -1,5 +1,10 @@
import { createContext, useContext } from "react";
/**
* Secure storage interface for storing auth tokens.
*
* The implementation of this interface should provide a secure way to store values. Either by encrypting the values or by storing them in a secure location.
*/
export interface ISecureStorage {
getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>;
@@ -7,7 +12,7 @@ export interface ISecureStorage {
}
/**
* The configuration to use the react SDK with an [auth](https://portal.thirdweb.com/auth) server.
* The configuration to use by the React and React Native SDKs with an [auth](https://portal.thirdweb.com/auth) server.
*
*/
export interface ThirdwebAuthConfig {
@@ -12,8 +12,33 @@ import { AUTH_TOKEN_STORAGE_KEY } from "../../../core/constants/auth";
*
* @returns - A function to invoke to login with the connected wallet, and an isLoading state.
*
* @see {@link https://portal.thirdweb.com/react/react.uselogin?utm_source=sdk | Documentation}
* @example
* ```tsx
* function App() {
* const { isLoading, login } = useLogin();
*
* return (
* <button onClick={() => login()}>
* {isLoading ? "Loading..." : "Sign in with Ethereum"}
* </button>
* );
* }
* ```
*
* ```tsx
* // options
* login({
* domain: "https://your-domain.com", // Your dapp domain
* statement: "My statement", // Text that the user will sign
* uri: "https://your-domain.com/login", // RFC 3986 URI referring to the resource that is the subject of the signing
* version: "1.0", // The current version of the message, which MUST be 1 for this specification.
* chainId: "mainnet", // Chain ID to which the session is bound
* nonce: "my-nonce", // randomized token typically used to prevent replay attacks
* expirationTime: new Date(2021, 1, 1), // When this message expires
* invalidBefore: new Date(2020, 12, 1), // When this message becomes valid
* resources: ["balance", "history", "info"], // A list of information or references to information the user wishes to have resolved
* })
* ```
*/
export function useLogin() {
const queryClient = useQueryClient();
@@ -10,8 +10,18 @@ import invariant from "tiny-invariant";
*
* @returns - A function to invoke to logout.
*
* @see {@link https://portal.thirdweb.com/react/react.uselogout?utm_source=sdk | Documentation}
* @example
* ```tsx
* function App() {
* const { logout, isLoading } = useLogout();
*
* return (
* <button onClick={() => logout()}>
* {isLoading ? "Logging out..." : "Logout"}
* </button>
* );
*}
* ```
*/
export function useLogout() {
const queryClient = useQueryClient();
@@ -16,9 +16,23 @@ export interface UserWithData<
* Hook to get the currently logged in user.
*
* @returns - The currently logged in user or null if not logged in, as well as a loading state.
* ```tsx
* {
* user: {
* address: string;
* session?: Json;
* } | undefined;
* isLoggedIn: boolean;
* isLoading: boolean;
*}
* ```
*
* @see {@link https://portal.thirdweb.com/react/react.useuser?utm_source=sdk | Documentation}
*
* @example
* ```tsx
* function App() {
* const { user, isLoggedIn, isLoading } = useUser();
* }
* ```
*/
export function useUser<
TData extends Json = Json,
@@ -1,9 +1,27 @@
import { useSDK } from "../useSDK";
/**
* Get the configured `ThirdwebStorage` instance
* Get the configured `ThirdwebStorage` instance in the `ThirdwebProvider`.
*
* @returns The `storageInterface` configured on the `ThirdwebProvider`
* @see {@link https://portal.thirdweb.com/react/react.usestorage?utm_source=sdk | Documentation}
*
* @example
* ```tsx
* const storage = useStorage();
*
* cost resp = storage?.download("ipfs-url"); // Download a file from IPFS
* if (resp.ok) {
* const value = await resp?.json();
* }
*
* const fileIpfsHash = await storage?.upload({
* name: 'file1',
* type: 'file-mime-type',
* uri: 'file-uri-on-device',
* }); // Upload a file to IPFS
* const objIpfsHash = await storage?.upload({key: 'value'}); // Upload an object to IPFS
* const strIpfsHash = await storage?.upload('string-to-upload'); // Upload a string to IPFS
* ```
*/
export function useStorage() {
const sdk = useSDK();
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.5.1
## 0.5.0
## 0.4.14
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.5.0",
"version": "0.5.1",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+23
View File
@@ -1,5 +1,28 @@
# @thirdweb-dev/react-native
## 0.5.1
### Patch Changes
- [#2074](https://github.com/thirdweb-dev/js/pull/2074) [`07fbb799`](https://github.com/thirdweb-dev/js/commit/07fbb799be87c1c5229ae3183fa8bc67ae15c756) Thanks [@iketw](https://github.com/iketw)! - Adds the ability to login with any arbitrary login payload
```typescript
await embeddedWallet.authenticate({
strategy: "auth_endpoint",
payload: "SOME_STRING",
encryptionKey: "",
});
```
- [#2082](https://github.com/thirdweb-dev/js/pull/2082) [`699f31c2`](https://github.com/thirdweb-dev/js/commit/699f31c20a76cd284dbed1629c4a19d93aca7b7f) Thanks [@iketw](https://github.com/iketw)! - Better comments
- [#2086](https://github.com/thirdweb-dev/js/pull/2086) [`328ef5dc`](https://github.com/thirdweb-dev/js/commit/328ef5dc9c628a89a022a559852dfa2a788f70cb) Thanks [@iketw](https://github.com/iketw)! - Hide WC modal back button when only WC is defined as a supportedWallet
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e), [`699f31c2`](https://github.com/thirdweb-dev/js/commit/699f31c20a76cd284dbed1629c4a19d93aca7b7f)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.5.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.5.0",
"version": "0.5.1",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -12,17 +12,16 @@ import { DEFAULT_WALLETS } from "../constants/wallets";
import { DappContextProvider } from "./context-provider";
import { UIContextProvider } from "./ui-context-provider";
import { MainModal } from "../components/MainModal";
import { ThemeProvider } from "../styles/ThemeProvider";
import { ThemeProvider, ThemeType } from "../styles/ThemeProvider";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { walletIds } from "@thirdweb-dev/wallets";
import { ThirdwebStorage } from "../../core/storage/storage";
import { useColorScheme } from "react-native";
import type { Locale } from "../i18n/types";
interface ThirdwebProviderProps<TChains extends Chain[]>
extends Omit<
ThirdwebProviderCoreProps<TChains>,
"supportedWallets" | "secretKey" | "signer"
"supportedWallets" | "secretKey" | "signer" | "theme"
> {
/**
* Wallets that will be supported by the dApp
@@ -47,6 +46,27 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
*/
supportedWallets?: WalletConfig<any>[];
/**
* Set the theme for all thirdweb components
*
* By default it is set to "dark".
*
* theme can be set to either "dark" or "light" or a custom theme object.
*
* You can also import `lightTheme` or `darkTheme` functions from `@thirdweb-dev/react-native` to use the default themes as base and overrides parts of it.
*
* @example
* ```ts
* import { darkTheme } from "@thirdweb-dev/react-native";
* const customTheme = darkTheme({
* colors: {
* accentButtonColor: 'black',
* },
* })
* ```
*/
theme?: ThemeType;
/**
* Locale that the app will be displayed in
*
@@ -87,10 +107,15 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
locale?: Locale;
}
/**
* Array of default supported chains by the thirdweb SDK
*/
export type DefaultChains = typeof defaultChains;
/**
*
* The `<ThirdwebProvider />` component lets you control what networks you want users to connect to,
* what types of wallets can connect to your app, and the settings for the [Thirdweb SDK](https://docs.thirdweb.com/typescript).
* what types of wallets can connect to your app, and the settings for the Thirdweb SDK.
*
* @example
* You can wrap your application with the provider as follows:
@@ -107,21 +132,21 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
* };
* ```
*/
export const ThirdwebProvider = <
TChains extends Chain[] = typeof defaultChains,
>({
children,
createWalletStorage = createAsyncLocalStorage,
supportedWallets = DEFAULT_WALLETS,
authConfig,
theme,
storageInterface,
clientId,
sdkOptions,
locale = "en",
...restProps
}: PropsWithChildren<ThirdwebProviderProps<TChains>>) => {
const colorScheme = useColorScheme();
export const ThirdwebProvider = <TChains extends Chain[] = DefaultChains>(
props: PropsWithChildren<ThirdwebProviderProps<TChains>>,
) => {
const {
children,
createWalletStorage = createAsyncLocalStorage,
supportedWallets = DEFAULT_WALLETS,
authConfig,
theme,
storageInterface,
clientId,
sdkOptions,
locale = "en",
...restProps
} = props;
const coinbaseWalletObj = supportedWallets.find(
(w) => w.id === walletIds.coinbase,
@@ -161,9 +186,7 @@ export const ThirdwebProvider = <
{...sdkOptions}
{...restProps}
>
<ThemeProvider
theme={theme ? theme : colorScheme === "dark" ? "dark" : "light"}
>
<ThemeProvider theme={theme ? theme : "dark"}>
<UIContextProvider locale={locale}>
{hasMagicConfig ? (
<SafeAreaProvider>
@@ -5,8 +5,10 @@ import { PropsWithChildren, useContext } from "react";
import { useColorScheme } from "react-native";
import { useUIContext } from "../providers/ui-context-provider";
export type ThemeType = "dark" | "light" | Theme;
export type ThemeProviderProps = {
theme?: Theme | "light" | "dark";
theme?: ThemeType;
};
export function ThemeProvider({
@@ -1,4 +1,5 @@
import {
AuthEndpointOptions,
AuthOptions,
AuthParams,
AuthResult,
@@ -11,6 +12,7 @@ import type { Chain } from "@thirdweb-dev/chains";
import { providers, Signer } from "ethers";
import { utils } from "ethers";
import {
authEndpoint,
customJwt,
sendVerificationEmail,
socialLogin,
@@ -101,7 +103,13 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
case "jwt": {
return this.customJwt({
jwt: params.jwt,
password: params.encryptionKey || "",
password: params.encryptionKey,
});
}
case "auth_endpoint": {
return this.authEndpoint({
payload: params.payload,
encryptionKey: params.encryptionKey,
});
}
default:
@@ -230,6 +238,33 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
}
}
private async authEndpoint(
authOptions: AuthEndpointOptions,
): Promise<AuthResult> {
try {
const { verifiedToken, email } = await authEndpoint(
authOptions,
this.options.clientId,
);
this.email = email;
return {
user: {
status: UserWalletStatus.LOGGED_IN_WALLET_INITIALIZED,
recoveryShareManagement:
verifiedToken.authDetails.recoveryShareManagement,
},
isNewUser: verifiedToken.isNewUser,
needsRecoveryCode:
verifiedToken.authDetails.recoveryShareManagement ===
RecoveryShareManagement.USER_MANAGED,
};
} catch (error) {
console.error(`Error while verifying auth_endpoint auth: ${error}`);
this.disconnect();
throw error;
}
}
async disconnect(): Promise<void> {
clearConnectedEmail();
clearConnectedAuthStrategy();
@@ -27,11 +27,17 @@ import { Auth } from "aws-amplify";
import {
DOMAIN_URL_2023,
EWS_VERSION_HEADER,
ROUTE_AUTH_ENDPOINT_CALLBACK,
ROUTE_AUTH_JWT_CALLBACK,
ROUTE_HEADLESS_OAUTH_LOGIN,
THIRDWEB_SESSION_NONCE_HEADER,
} from "./helpers/constants";
import { AuthOptions, OauthOption, VerifiedTokenResponse } from "../types";
import {
AuthEndpointOptions,
AuthOptions,
OauthOption,
VerifiedTokenResponse,
} from "../types";
import { InAppBrowser } from "react-native-inappbrowser-reborn";
import { createErrorMessage } from "./helpers/errors";
import {
@@ -307,7 +313,62 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) {
return { verifiedToken, email: verifiedToken.authDetails.email };
} catch (e) {
throw new Error(
createErrorMessage("Malformed response from post authentication", e),
createErrorMessage("Malformed response from post jwt authentication", e),
);
}
}
export async function authEndpoint(
authOptions: AuthEndpointOptions,
clientId: string,
) {
const { payload, encryptionKey } = authOptions;
const resp = await fetch(ROUTE_AUTH_ENDPOINT_CALLBACK, {
method: "POST",
headers: {
"Content-Type": "application/json",
[EWS_VERSION_HEADER]: reactNativePackageVersion,
[BUNDLE_ID_HEADER]: appBundleId,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
},
body: JSON.stringify({
payload: payload,
developerClientId: clientId,
}),
});
if (!resp.ok) {
const error = await resp.json();
throw new Error(
`Custom auth endpoint authentication error: ${error.message}`,
);
}
try {
const { verifiedToken, verifiedTokenJwtString } = await resp.json();
const toStoreToken: AuthStoredTokenWithCookieReturnType["storedToken"] = {
jwtToken: verifiedToken.jwtToken,
authProvider: verifiedToken.authProvider,
authDetails: {
...verifiedToken.authDetails,
email: verifiedToken.authDetails.email,
},
developerClientId: verifiedToken.developerClientId,
cookieString: verifiedTokenJwtString,
shouldStoreCookieString: true,
isNewUser: verifiedToken.isNewUser,
};
await postPaperAuthUserManaged(toStoreToken, clientId, encryptionKey);
return { verifiedToken, email: verifiedToken.authDetails.email };
} catch (e) {
throw new Error(
createErrorMessage(
"Malformed response from post auth_endpoint authentication",
e,
),
);
}
}
@@ -127,7 +127,10 @@ async function getRecoveryCode(
storedToken.authDetails.recoveryShareManagement ===
RecoveryShareManagement.CLOUD_MANAGED
) {
if (storedToken.authProvider === AuthProvider.CUSTOM_JWT) {
if (
storedToken.authProvider === AuthProvider.CUSTOM_JWT ||
storedToken.authProvider === AuthProvider.CUSTOM_AUTH_ENDPOINT
) {
if (!recoveryCode) {
throw new Error(
`GetRecoveryCode error: ${ErrorMessages.missingRecoveryCode}`,
@@ -34,6 +34,7 @@ export const ROUTE_STORE_USER_SHARES = `${ROUTE_2023_10_20_API_BASE_PATH}/embedd
export const ROUTE_GET_USER_SHARES = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/embedded-wallet-shares`;
export const ROUTE_VERIFY_THIRDWEB_CLIENT_ID = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/verify-thirdweb-client-id`;
export const ROUTE_AUTH_JWT_CALLBACK = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-custom-jwt`;
export const ROUTE_AUTH_ENDPOINT_CALLBACK = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-custom-auth-endpoint`;
export const ROUTE_USER_MANAGED_OTP = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/send-user-managed-email-otp`;
export const ROUTE_VALIDATE_USER_MANAGED_OTP = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-thirdweb-email-otp`;
@@ -44,6 +44,11 @@ export interface AuthOptions {
password: string;
}
export interface AuthEndpointOptions {
payload: string;
encryptionKey: string;
}
export type SendEmailOtpReturnType = {
isNewUser: boolean;
isNewDevice: boolean;
@@ -73,11 +78,18 @@ type JwtAuthParams = {
encryptionKey: string;
};
type AuthEndpointParams = {
strategy: "auth_endpoint";
payload: string;
encryptionKey: string;
};
// this is the input to 'authenticate'
export type AuthParams =
| EmailVerificationAuthParams
| SocialAuthParams
| JwtAuthParams;
| JwtAuthParams
| AuthEndpointParams;
// TODO typed based off AuthParams["strategy"]
export type AuthResult = {
@@ -66,6 +66,26 @@ export class CoinbaseWallet extends AbstractClientWallet<CoinbaseWalletConnector
}
}
/**
* Wallet config for the Coinbase Wallet.
*
* @param config - The config for the Coinbase Wallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, coinbaseWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[
* coinbaseWallet({
* callbackURL: new URL('app-redirect-url://'),
* }),
* ]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const coinbaseWallet = (config?: {
callbackURL?: URL;
recommended?: boolean;
@@ -3,6 +3,24 @@ import { WalletOptions, walletIds } from "@thirdweb-dev/wallets";
import { createSecureStorage } from "../../../core/SecureStorage";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";
/**
* Wallet config for a Local Wallet
*
* @param config - The config for the Local Wallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, localWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[
* localWallet(),
* ]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const localWallet = () => {
const secureStorage = createSecureStorage(walletIds.localWallet);
const asyncStorage = createAsyncLocalStorage(walletIds.localWallet);
@@ -21,6 +21,22 @@ export class MetaMaskWallet extends WalletConnectBase {
}
}
/**
* Wallet config for MetaMask Wallet.
*
* @param config - The config for MetamaskWallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, metamaskWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[metamaskWallet()]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const metamaskWallet = (config?: WalletConnectConfig) => {
return {
id: MetaMaskWallet.id,
@@ -22,6 +22,22 @@ export class RainbowWallet extends WalletConnectBase {
}
}
/**
* Wallet config for Rainbow Wallet.
*
* @param config - The config for RainbowWallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, rainbowWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[rainbowWallet()]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const rainbowWallet = (config?: WalletConnectConfig) => {
return {
id: RainbowWallet.id,
@@ -3,6 +3,28 @@ import { SmartWallet, createAsyncLocalStorage } from "@thirdweb-dev/wallets";
import { SmartWalletConfig } from "../types/smart-wallet";
import { SmartWalletFlow } from "../../components/ConnectWalletFlow/SmartWallet/SmartWalletFlow";
/**
* Wallet config for Smart Wallet.
*
* @param wallet - The EOA wallet config to be connected to the SmartWallet
* @param config - The config for SmartWallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, smartWallet, metamaskWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[
* smartWallet(metamaskWallet(), {
* factoryAddress: 'factory-address',
* gasless: true,
* }),
* ]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const smartWallet = (
wallet: WalletConfig<any>,
config: SmartWalletConfig,
@@ -20,6 +20,22 @@ export class TrustWallet extends WalletConnectBase {
}
}
/**
* Wallet config for Trust Wallet.
*
* @param config - The config for TrustWallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, trustWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[trustWallet()]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const trustWallet = (config?: WalletConnectConfig) => {
return {
id: TrustWallet.id,
@@ -41,8 +41,9 @@ const MODAL_HEIGHT = Dimensions.get("window").height * 0.5;
export function WalletConnectUI({
connected,
walletConfig,
goBack,
projectId,
goBack,
supportedWallets,
}: ConnectUIProps<WalletConnect> & { projectId: string }) {
const l = useLocale();
const theme = useGlobalTheme();
@@ -163,7 +164,7 @@ export function WalletConnectUI({
style={[styles.modal, { backgroundColor: theme.colors.background }]}
>
<ModalHeaderTextClose
onBackPress={goBack}
onBackPress={supportedWallets.length === 1 ? undefined : goBack}
headerText="WalletConnect"
onClose={onClosePress}
paddingHorizontal="md"
@@ -9,6 +9,22 @@ export type WalletConnectConfig = {
recommended?: boolean;
};
/**
* Wallet config for WalletConnect.
*
* @param config - The config for WalletConnect
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, walletConnect } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[walletConnect()]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const walletConnect = (
config?: WalletConnectConfig,
): WalletConfig<WalletConnect> => {
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/react
## 4.1.16
### Patch Changes
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e), [`699f31c2`](https://github.com/thirdweb-dev/js/commit/699f31c20a76cd284dbed1629c4a19d93aca7b7f)]:
- @thirdweb-dev/sdk@4.0.22
- @thirdweb-dev/react-core@4.1.16
- @thirdweb-dev/wallets@2.3.1
## 4.1.15
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "4.1.15",
"version": "4.1.16",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+15
View File
@@ -1,5 +1,20 @@
# @thirdweb-dev/sdk
## 4.0.22
### Patch Changes
- [#2085](https://github.com/thirdweb-dev/js/pull/2085) [`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e) Thanks [@hsynlms](https://github.com/hsynlms)! - Fix error when fetching data on `vite-node` environment by setting a global variable `TW_SKIP_FETCH_SETUP` to `true`. Fixes https://github.com/thirdweb-dev/js/issues/2002
Setting this flag sets `skipFetchSetup` to `true` in [ethers ConnectionInfo](https://docs.ethers.org/v5/api/utils/web/#ConnectionInfo)
```ts
// set this global variable
globalThis.TW_SKIP_FETCH_SETUP = true;
// use the thirdweb sdk...
```
## 4.0.21
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "4.0.21",
"version": "4.0.22",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
+12
View File
@@ -284,6 +284,16 @@ export function getProviderFromRpcUrl(
if (existingProvider) {
return existingProvider;
}
// TODO: remove below `skipFetchSetup` logic when ethers.js v6 support arrives
let _skipFetchSetup = false;
if (
typeof globalThis !== "undefined" &&
"TW_SKIP_FETCH_SETUP" in globalThis &&
typeof (globalThis as any).TW_SKIP_FETCH_SETUP === "boolean"
) {
_skipFetchSetup = (globalThis as any).TW_SKIP_FETCH_SETUP as boolean;
}
// Otherwise, create a new provider on the specific network
const newProvider = chainId
@@ -292,6 +302,7 @@ export function getProviderFromRpcUrl(
{
url: rpcUrl,
headers,
skipFetchSetup: _skipFetchSetup,
},
chainId,
)
@@ -299,6 +310,7 @@ export function getProviderFromRpcUrl(
new providers.JsonRpcBatchProvider({
url: rpcUrl,
headers,
skipFetchSetup: _skipFetchSetup,
});
// Save the provider in our cache
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/unity-js-bridge
## 0.3.1
### Patch Changes
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e)]:
- @thirdweb-dev/sdk@4.0.22
- @thirdweb-dev/wallets@2.3.1
- @thirdweb-dev/auth@4.1.18
## 0.3.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.3.0",
"version": "0.3.1",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
@@ -349,8 +349,7 @@ class ThirdwebBridge implements TWBridge {
chainId: chainIdNumber,
authResult,
});
}
else {
} else {
throw new Error(
"Invalid auth provider: " + authOptionsParsed.authProvider,
);
@@ -680,11 +679,11 @@ class ThirdwebBridge implements TWBridge {
strategy: "encryptedJson",
password,
});
} catch(e) {
} catch (e) {
console.warn(e);
return localWallet;
}
return localWallet;
}
@@ -787,7 +786,7 @@ class ThirdwebBridge implements TWBridge {
return JSON.stringify({ result: res }, bigNumberReplacer);
}
public async getEmail(){
public async getEmail() {
const embeddedWallet = this.walletMap.get(
walletIds.embeddedWallet,
) as EmbeddedWallet;
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/wallets
## 2.3.1
### Patch Changes
- Updated dependencies [[`c701c388`](https://github.com/thirdweb-dev/js/commit/c701c388c65a1e531b88991d8fd67d25f153992e)]:
- @thirdweb-dev/sdk@4.0.22
## 2.3.0
### Minor Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "2.3.0",
"version": "2.3.1",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"browser": {