Compare commits

...
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
c9b0131acd Version Packages (#1478)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-10 15:51:09 -07:00
Joaquim VergesandGitHub 34b315993c [Wallets] use RPCs with no client id when adding to external wallets (#1477) 2023-08-10 22:33:47 +00:00
iketwandGitHub 14d9a71c92 [RN] Deprecates magicWallet in favor of magicLink for consistency (#1479) 2023-08-10 21:22:49 +00:00
YashandGitHub 7f5311222b [SDK] Enable dynamic contract deployment with any evm (#1468) 2023-08-10 19:32:51 +00:00
37 changed files with 396 additions and 55 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth
## 3.2.30
### Patch Changes
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2)]:
- @thirdweb-dev/wallets@1.1.13
## 3.2.29
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.29",
"version": "3.2.30",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+7
View File
@@ -1,5 +1,12 @@
# thirdweb
## 0.11.13
### Patch Changes
- Updated dependencies [[`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/sdk@3.10.49
## 0.11.12
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.11.12",
"version": "0.11.13",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/react-core
## 3.14.30
### Patch Changes
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/wallets@1.1.13
- @thirdweb-dev/sdk@3.10.49
- @thirdweb-dev/auth@3.2.30
## 3.14.29
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.14.29",
"version": "3.14.30",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.2.49
## 0.2.48
## 0.2.47
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.48",
"version": "0.2.49",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+13
View File
@@ -1,5 +1,18 @@
# @thirdweb-dev/react-native
## 0.2.49
### Patch Changes
- [#1479](https://github.com/thirdweb-dev/js/pull/1479) [`14d9a71c`](https://github.com/thirdweb-dev/js/commit/14d9a71c928019907618cc8694af0bc631e94b68) Thanks [@iketw](https://github.com/iketw)! - Deprecates magicWallet in favor of magicLink for consistency with our React package
- [#1477](https://github.com/thirdweb-dev/js/pull/1477) [`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Pass unauth'd RPCs to wallets when adding new chains
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/wallets@1.1.13
- @thirdweb-dev/sdk@3.10.49
- @thirdweb-dev/react-core@3.14.30
## 0.2.48
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-native",
"version": "0.2.48",
"version": "0.2.49",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -3,7 +3,12 @@ import Modal, { ModalProps } from "react-native-modal";
// Populate with the data...
export function TWModal(props: Partial<ModalProps>) {
return (
<Modal {...props} useNativeDriver hideModalContentWhileAnimating={true}>
<Modal
{...props}
avoidKeyboard
useNativeDriver
hideModalContentWhileAnimating={true}
>
{props.children}
</Modal>
);
+4 -2
View File
@@ -15,8 +15,10 @@ export { TrustWallet, trustWallet } from "./wallets/wallets/trust-wallet";
export { smartWallet } from "./wallets/wallets/smart-wallet";
export { localWallet } from "./wallets/wallets/local-wallet";
export { LocalWallet } from "./wallets/wallets/LocalWallet";
export { magicWallet } from "./wallets/wallets/magic-wallet";
export { MagicWallet } from "./wallets/wallets/MagicWallet";
export { magicWallet } from "./wallets/wallets/magic-link";
export { MagicWallet } from "./wallets/wallets/MagicLink";
export { MagicLink } from "./wallets/wallets/MagicLink";
export { magicLink } from "./wallets/wallets/magic-link";
export * from "./wallets/wallets/WalletConnectV2";
export type { WCMeta } from "./wallets/types/wc";
@@ -7,47 +7,47 @@ import {
useState,
} from "react";
import { useWalletConnectListener } from "../wallets/hooks/useWalletConnectListener";
import { MagicWallet } from "../wallets/wallets/MagicWallet";
import { MagicLink } from "../wallets/wallets/MagicLink";
import { useWalletContext } from "@thirdweb-dev/react-core";
type DappContextType = {
smartWallet?: SmartWallet;
setSmartWallet?: (value?: SmartWallet) => void;
magicWallet?: MagicWallet;
setMagicWallet?: (value?: MagicWallet) => void;
magicLink?: MagicLink;
setMagicLink?: (value?: MagicLink) => void;
};
const DappContext = createContext<DappContextType>({});
export const DappContextProvider = (props: React.PropsWithChildren) => {
const [smartWallet, setSmartWallet] = useState<SmartWallet | undefined>();
const [magicWallet, setMagicWallet] = useState<MagicWallet | undefined>();
const [magicLink, setMagicLink] = useState<MagicLink | undefined>();
const createdWalletInstance = useWalletContext().createdWalletInstance;
useEffect(() => {
if (createdWalletInstance?.walletId === walletIds.magicLink) {
setMagicWallet(createdWalletInstance as MagicWallet);
setMagicLink(createdWalletInstance as MagicLink);
}
}, [createdWalletInstance, setMagicWallet]);
}, [createdWalletInstance, setMagicLink]);
useWalletConnectListener();
const magicSDK = useCallback(() => {
if (magicWallet) {
const magic = magicWallet.getMagicSDK();
if (magicLink) {
const magic = magicLink.getMagicSDK();
return <magic.Relayer />;
}
return null;
}, [magicWallet]);
}, [magicLink]);
return (
<DappContext.Provider
value={{
smartWallet,
setSmartWallet,
magicWallet: magicWallet,
setMagicWallet: setMagicWallet,
magicLink: magicLink,
setMagicLink: setMagicLink,
}}
>
{props.children}
@@ -66,11 +66,11 @@ export const useSmartWallet = () => {
return [context.smartWallet, context.setSmartWallet] as const;
};
export const useMagicWallet = () => {
export const useMagicLink = () => {
const context = useContext(DappContext);
return {
magicWallet: context.magicWallet,
setMagicWallet: context.setMagicWallet,
magicLink: context.magicLink,
setMagicLink: context.setMagicLink,
} as const;
};
@@ -1,3 +1,4 @@
import { Chain, getValidChainRPCs } from "@thirdweb-dev/chains";
import { WCMeta } from "../wallets/types/wc";
/**
@@ -20,3 +21,19 @@ export function formatWalletConnectDisplayUri(
}wc?uri=${encodedUri}`
: `${uri}`;
}
export function getValidPublicRPCUrl(chain: Chain) {
return getValidChainRPCs(chain).map((rpc) => {
try {
const url = new URL(rpc);
// remove client id from url
if (url.hostname.endsWith(".thirdweb.com")) {
url.pathname = "";
url.search = "";
}
return url.toString();
} catch (e) {
return rpc;
}
});
}
@@ -4,7 +4,6 @@ import type {
WalletMobileSDKProviderOptions,
} from "@coinbase/wallet-mobile-sdk/build/WalletMobileSDKEVMProvider";
import type { ConfigurationParams } from "@coinbase/wallet-mobile-sdk/src/CoinbaseWalletSDK.types";
import { getValidChainRPCs } from "@thirdweb-dev/chains";
import {
UserRejectedRequestError,
ChainNotConfiguredError,
@@ -18,6 +17,7 @@ import {
} from "@thirdweb-dev/wallets";
import type { Address } from "abitype";
import { providers, utils } from "ethers";
import { getValidPublicRPCUrl } from "evm/utils/uri";
export type CoinbaseWalletConnectorOptions = WalletMobileSDKProviderOptions &
ConfigurationParams & {
@@ -227,7 +227,7 @@ export class CoinbaseWalletConnector extends WagmiConnector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [getValidChainRPCs(chain)],
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
@@ -6,7 +6,7 @@ import {
import type { MagicConnector as MagicConnectorType } from "../connectors/magic/magic-connector";
import { MagicConnector } from "../connectors/magic/magic-connector";
export class MagicWallet extends AbstractClientWallet<
export class MagicLink extends AbstractClientWallet<
MagicLinkOptions,
MagicConnectorOptions
> {
@@ -68,3 +68,10 @@ export class MagicWallet extends AbstractClientWallet<
return super.disconnect();
}
}
/**
* @deprecated Use `MagicLink` instead
*
* Renamed for consistency with our React package
*/
export class MagicWallet extends MagicLink {}
@@ -10,22 +10,22 @@ import {
useWalletContext,
} from "@thirdweb-dev/react-core";
import { MagicLinkOptions } from "../connectors/magic/types";
import { MagicWallet } from "./MagicWallet";
import { MagicLink } from "./MagicLink";
import { useEffect, useRef } from "react";
import Box from "../../components/base/Box";
import { TextInput } from "../../components/base/TextInput";
import Text from "../../components/base/Text";
import { ActivityIndicator } from "react-native";
import { useMagicWallet } from "../../providers/context-provider";
import { useMagicLink } from "../../providers/context-provider";
export const magicWallet = (
export const magicLink = (
magicLinkOptions: MagicLinkOptions,
): WalletConfig<MagicWallet> => {
): WalletConfig<MagicLink> => {
return {
id: walletIds.magicLink,
meta: MagicWallet.meta,
meta: MagicLink.meta,
create: (options: WalletOptions) => {
return new MagicWallet({
return new MagicLink({
...options,
...magicLinkOptions,
chainId: options.chain.chainId,
@@ -42,7 +42,7 @@ export const magicWallet = (
/**
* UI for selecting wallet - this UI is rendered in the wallet selection screen
*/
selectUI: (props: SelectUIProps<MagicWallet>) => {
selectUI: (props: SelectUIProps<MagicLink>) => {
return (
<Box flex={1}>
<TextInput
@@ -71,23 +71,23 @@ export const magicWallet = (
};
const MagicConnectionUI: React.FC<
ConnectUIProps<MagicWallet> & { magicLinkOptions: MagicLinkOptions }
ConnectUIProps<MagicLink> & { magicLinkOptions: MagicLinkOptions }
> = ({ selectionData, walletConfig, close, magicLinkOptions }) => {
const createWalletInstance = useCreateWalletInstance();
const setConnectedWallet = useSetConnectedWallet();
const chainToConnect = useWalletContext().chainToConnect;
const setConnectionStatus = useSetConnectionStatus();
const { magicWallet: ctxMagicWallet, setMagicWallet } = useMagicWallet();
const { magicLink: ctxMagicLink, setMagicLink } = useMagicLink();
useEffect(() => {
const inst = createWalletInstance(walletConfig);
setMagicWallet?.(inst);
}, [createWalletInstance, setMagicWallet, walletConfig]);
setMagicLink?.(inst);
}, [createWalletInstance, setMagicLink, walletConfig]);
const connectPrompted = useRef(false);
useEffect(() => {
if (connectPrompted.current || !ctxMagicWallet) {
if (connectPrompted.current || !ctxMagicLink) {
return;
}
connectPrompted.current = true;
@@ -105,10 +105,10 @@ const MagicConnectionUI: React.FC<
: { phoneNumber: selectionData }),
};
close();
await ctxMagicWallet.connect(connectParams);
await ctxMagicWallet.getMagicSDK().user.getMetadata();
await ctxMagicLink.connect(connectParams);
await ctxMagicLink.getMagicSDK().user.getMetadata();
setConnectedWallet(ctxMagicWallet, connectParams);
setConnectedWallet(ctxMagicLink, connectParams);
setConnectionStatus("connected");
} catch (e) {
setConnectionStatus("disconnected");
@@ -119,7 +119,7 @@ const MagicConnectionUI: React.FC<
selectionData,
walletConfig,
close,
ctxMagicWallet,
ctxMagicLink,
setConnectedWallet,
setConnectionStatus,
chainToConnect?.chainId,
@@ -129,6 +129,14 @@ const MagicConnectionUI: React.FC<
return (
<Box minHeight={500}>
<ActivityIndicator size="small" />
<TextInput placeholder="Enter the OTP sent to your email / phone number" />
</Box>
);
};
/**
* @deprecated Use `magicLink()` instead
*
* Renamed for consistency with our React package
*/
export const magicWallet = magicLink;
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/react
## 3.14.30
### Patch Changes
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/wallets@1.1.13
- @thirdweb-dev/sdk@3.10.49
- @thirdweb-dev/react-core@3.14.30
## 3.14.29
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.14.29",
"version": "3.14.30",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/sdk
## 3.10.49
### Patch Changes
- [#1468](https://github.com/thirdweb-dev/js/pull/1468) [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Enable dynamic contract deployment with any evm
## 3.10.48
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.10.48",
"version": "3.10.49",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -9,8 +9,13 @@ import { fetchAndCacheDeployMetadata } from "./fetchAndCacheDeployMetadata";
import { getCreate2FactoryAddress } from "./getCreate2FactoryAddress";
import { caches } from "./caches";
import { computeDeploymentInfo } from "./computeDeploymentInfo";
import { generatePluginFunctions } from "../plugin/generatePluginFunctions";
import {
generateExtensionFunctions,
generatePluginFunctions,
} from "../plugin/generatePluginFunctions";
import { getMetadataForPlugins } from "../plugin/getMetadataForPlugins";
import { getMetadataForExtensions } from "../plugin/getMetadataForExtensions";
import { Extension } from "../../types/extensions";
/**
*
* Returns txn data for keyless deploys as well as signer deploys.
@@ -42,6 +47,10 @@ export async function getDeploymentInfo(
storage,
);
const pluginMetadata = await getMetadataForPlugins(metadataUri, storage);
const extensionMetadata = await getMetadataForExtensions(
metadataUri,
storage,
);
// if pluginMetadata is not empty, then it's a plugin-pattern router contract
if (pluginMetadata.length > 0) {
@@ -87,6 +96,42 @@ export async function getDeploymentInfo(
};
finalDeploymentInfo.push(...pluginDeploymentInfo, pluginMapTransaction);
} else if (extensionMetadata.length > 0) {
// get deployment info for all extensions
const extensionDeploymentInfo = await Promise.all(
extensionMetadata.map(async (metadata) => {
const info = await computeDeploymentInfo(
"extension",
provider,
storage,
create2FactoryAddress,
{ metadata: metadata },
);
return info;
}),
);
// create constructor param input for BaseRouter
const routerInput: Extension[] = [];
extensionMetadata.forEach((metadata, index) => {
const extensionFunctions = generateExtensionFunctions(metadata.abi);
routerInput.push({
metadata: {
name: metadata.name,
metadataURI: "",
implementation:
extensionDeploymentInfo[index].transaction.predictedAddress,
},
functions: extensionFunctions,
});
});
// routerInput as constructor param for BaseRouter
customParams["_extensions"] = {
value: routerInput,
};
finalDeploymentInfo.push(...extensionDeploymentInfo);
}
const implementationDeployInfo = await computeDeploymentInfo(
@@ -1,13 +1,18 @@
import { Abi } from "../../schema/contracts/custom";
import { utils } from "ethers";
import { Plugin } from "../../types/plugins";
import { ExtensionFunction } from "../../types/extensions";
function getFunctionSignature(fnInputs: any): string {
return (
"(" +
fnInputs
.map((i: any) => {
return i.type === "tuple" ? getFunctionSignature(i.components) : i.type;
return i.type === "tuple"
? getFunctionSignature(i.components)
: i.type === "tuple[]"
? getFunctionSignature(i.components) + `[]`
: i.type;
})
.join(",") +
")"
@@ -34,3 +39,25 @@ export function generatePluginFunctions(
}
return pluginFunctions;
}
export function generateExtensionFunctions(
extensionAbi: any,
): ExtensionFunction[] {
const extensionInterface = new utils.Interface(extensionAbi);
const extensionFunctions: ExtensionFunction[] = [];
// TODO - filter out common functions like _msgSender(), contractType(), etc.
for (const fnFragment of Object.values(extensionInterface.functions)) {
const fn = extensionInterface.getFunction(
extensionInterface.getSighash(fnFragment),
);
if (fn.name.startsWith("_")) {
continue;
}
extensionFunctions.push({
functionSelector: extensionInterface.getSighash(fn),
functionSignature: fn.name + getFunctionSignature(fn.inputs),
});
}
return extensionFunctions;
}
@@ -0,0 +1,74 @@
import { getAllExtensionsAbi } from "../../constants/thirdweb-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper";
import {
AbiSchema,
PreDeployMetadataFetched,
} from "../../schema/contracts/custom";
import { isFeatureEnabled } from "../feature-detection/isFeatureEnabled";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { getChainProvider } from "../../constants/urls";
import { fetchAndCachePublishedContractURI } from "../any-evm-utils/fetchAndCachePublishedContractURI";
import { fetchAndCacheDeployMetadata } from "../any-evm-utils/fetchAndCacheDeployMetadata";
import { Extension } from "../../types/extensions";
export async function getMetadataForExtensions(
publishedMetadataUri: string,
storage: ThirdwebStorage,
): Promise<PreDeployMetadataFetched[]> {
let extensionMetadata: PreDeployMetadataFetched[] = [];
const { compilerMetadata, extendedMetadata } =
await fetchAndCacheDeployMetadata(publishedMetadataUri, storage);
// check if contract is extension-pattern
const isExtensionRouter: boolean = isFeatureEnabled(
AbiSchema.parse(compilerMetadata.abi),
"ExtensionRouter",
);
if (isExtensionRouter) {
if (
extendedMetadata &&
extendedMetadata.factoryDeploymentData?.implementationAddresses
) {
const implementationsAddresses = Object.entries(
extendedMetadata.factoryDeploymentData.implementationAddresses,
);
try {
const entry = implementationsAddresses.find(
([, implementation]) => implementation !== "",
);
const [network, implementation] = entry ? entry : [];
if (network && implementation) {
const provider = getChainProvider(parseInt(network), {});
const contract = new ContractWrapper(
provider,
implementation,
getAllExtensionsAbi,
{},
storage,
);
const extensions = await contract.call("getAllExtensions");
const extensionNames: string[] = Array.from(
new Set(extensions.map((item: Extension) => item.metadata.name)),
);
const extensionUris = await Promise.all(
extensionNames.map((name) => {
return fetchAndCachePublishedContractURI(name);
}),
);
extensionMetadata = (
await Promise.all(
extensionUris.map(async (uri) => {
return fetchAndCacheDeployMetadata(uri, storage);
}),
)
).map((fetchedMetadata) => fetchedMetadata.compilerMetadata);
}
} catch {}
}
}
return extensionMetadata;
}
@@ -0,0 +1,31 @@
import { BytesLikeSchema } from "../../../../core/schema/shared";
import { AddressOrEnsSchema } from "../../shared/AddressOrEnsSchema";
import { z } from "zod";
/**
* @internal
*/
export const ExtensionMetadataInput = /* @__PURE__ */ (() =>
z.object({
name: z.string(),
metadataURI: z.string(),
implementation: AddressOrEnsSchema,
}))();
/**
* @internal
*/
export const ExtensionFunctionInput = /* @__PURE__ */ (() =>
z.object({
functionSelector: BytesLikeSchema,
functionSignature: z.string(),
}))();
/**
* @internal
*/
export const ExtensionInput = /* @__PURE__ */ (() =>
z.object({
metadata: ExtensionMetadataInput,
functions: z.array(ExtensionFunctionInput),
}))();
@@ -31,6 +31,7 @@ export type DeployedContractType =
| "implementation"
| "create2Factory"
| "plugin"
| "extension"
| "custom";
export type DeploymentTransaction = {
+24
View File
@@ -0,0 +1,24 @@
import {
ExtensionFunctionInput,
ExtensionInput,
ExtensionMetadataInput,
} from "../schema/contracts/common/extensions";
import { z } from "zod";
/**
* Input model to pass an extension's metadata -- name, metadataURI, implementation address
* @public
*/
export type ExtensionMetadata = z.input<typeof ExtensionMetadataInput>;
/**
* Input model to pass a list function-selectors
* @public
*/
export type ExtensionFunction = z.input<typeof ExtensionFunctionInput>;
/**
* Input model to pass a list of extension-addresses + function-selectors
* @public
*/
export type Extension = z.input<typeof ExtensionInput>;
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/unity-js-bridge
## 0.2.67
### Patch Changes
- Updated dependencies [[`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2), [`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/wallets@1.1.13
- @thirdweb-dev/sdk@3.10.49
- @thirdweb-dev/auth@3.2.30
## 0.2.66
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.66",
"version": "0.2.67",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
+9
View File
@@ -1,5 +1,14 @@
# @thirdweb-dev/wallets
## 1.1.13
### Patch Changes
- [#1477](https://github.com/thirdweb-dev/js/pull/1477) [`34b31599`](https://github.com/thirdweb-dev/js/commit/34b315993c0abaccb9640a5d5804c2c93af569c2) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Pass unauth'd RPCs to wallets when adding new chains
- Updated dependencies [[`7f531122`](https://github.com/thirdweb-dev/js/commit/7f5311222b14da04877df056baae36409dff4696)]:
- @thirdweb-dev/sdk@3.10.49
## 1.1.12
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "1.1.12",
"version": "1.1.13",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts",
@@ -15,7 +15,8 @@ import type {
import BloctoSDK from "@blocto/sdk";
import { providers, utils } from "ethers";
import { walletIds } from "../../constants/walletIds";
import { Chain } from "@thirdweb-dev/chains";
import type { Chain } from "@thirdweb-dev/chains";
import { getValidPublicRPCUrl } from "../../utils/url";
type BloctoSigner = providers.JsonRpcSigner;
type BloctoOptions = Partial<EthereumProviderConfig>;
@@ -165,7 +166,12 @@ export class BloctoConnector extends WagmiConnector<
try {
await provider.request({
method: "wallet_addEthereumChain",
params: [{ chainId: id, rpcUrls: [chain?.rpc[0] ?? ""] }],
params: [
{
chainId: id,
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
},
],
});
await provider.request({
@@ -15,6 +15,7 @@ import type { CoinbaseWalletSDKOptions } from "@coinbase/wallet-sdk/dist/Coinbas
import type { Chain } from "@thirdweb-dev/chains";
import { providers, utils } from "ethers";
import { walletIds } from "../../constants/walletIds";
import { getValidPublicRPCUrl } from "../../utils/url";
type Options = CoinbaseWalletSDKOptions & {
/**
@@ -231,7 +232,7 @@ export class CoinbaseWalletConnector extends WagmiConnector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: chain.rpc,
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
@@ -16,6 +16,7 @@ import {
} from "../../../lib/wagmi-core";
import { Ethereum } from "../injected/types";
import { AsyncStorage } from "../../../core";
import { getValidPublicRPCUrl } from "../../utils/url";
export type FrameConnectorOptions = {
/**
@@ -241,7 +242,7 @@ export class FrameConnector extends WagmiConnector<
chainId: chainIdHex,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpc: [chain.rpc[0] ?? ""],
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
@@ -13,8 +13,9 @@ import {
} from "../../../lib/wagmi-core";
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
import { getInjectedName } from "../../utils/getInjectedName";
import { getValidPublicRPCUrl } from "../../utils/url";
import { Ethereum } from "./types";
import type { Chain } from "@thirdweb-dev/chains";
import { getValidChainRPCs, type Chain } from "@thirdweb-dev/chains";
import { utils, providers } from "ethers";
export type InjectedConnectorOptions = {
@@ -340,6 +341,7 @@ export class InjectedConnector extends WagmiConnector<
?.originalError?.code === 4902
) {
try {
console.log("adding chain", getValidChainRPCs(chain));
// request provider to add chain
await provider.request({
method: "wallet_addEthereumChain",
@@ -348,7 +350,7 @@ export class InjectedConnector extends WagmiConnector<
chainId: chainIdHex,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: chain.rpc as string[],
rpcUrls: getValidPublicRPCUrl(chain), // no client id on purpose here
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
@@ -6,11 +6,12 @@ import {
UserRejectedRequestError,
WagmiConnector,
} from "../../../lib/wagmi-core";
import type { Chain } from "@thirdweb-dev/chains";
import { type Chain } from "@thirdweb-dev/chains";
import type WalletConnectProvider from "@walletconnect/ethereum-provider";
import { providers, utils } from "ethers";
import { walletIds } from "../../constants/walletIds";
import { QRModalOptions } from "./qrModalOptions";
import { getValidPublicRPCUrl } from "../../utils/url";
const chainsToRequest = new Set([1, 137, 10, 42161, 56]);
@@ -291,7 +292,7 @@ export class WalletConnectConnector extends WagmiConnector<
chainId: utils.hexValue(chain.chainId),
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [...chain.rpc],
rpcUrls: getValidPublicRPCUrl(chain), // no clientId on purpose
...blockExplorerUrls,
},
],
+18
View File
@@ -1,6 +1,24 @@
import { getValidChainRPCs, type Chain } from "@thirdweb-dev/chains";
export function isTwUrl(url: string): boolean {
const host = new URL(url).hostname;
return (
host.endsWith(".thirdweb.com") || host === "localhost" || host === "0.0.0.0"
);
}
export function getValidPublicRPCUrl(chain: Chain) {
return getValidChainRPCs(chain).map((rpc) => {
try {
const url = new URL(rpc);
// remove client id from url
if (url.hostname.endsWith(".thirdweb.com")) {
url.pathname = "";
url.search = "";
}
return url.toString();
} catch (e) {
return rpc;
}
});
}