Install command improvements (#794)

Co-authored-by: Adam Majmudar <[email protected]>
Co-authored-by: adam-maj <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
This commit is contained in:
sid
2023-03-23 21:39:05 +00:00
committed by GitHub
co-authored by Adam Majmudar adam-maj Jonas Daniels
parent 2129c1f8c1
commit a6fce0f691
51 changed files with 253 additions and 172 deletions
+12
View File
@@ -0,0 +1,12 @@
---
"@thirdweb-dev/react-native-compat": patch
"@thirdweb-dev/unity-js-bridge": patch
"@thirdweb-dev/react-native": patch
"@thirdweb-dev/react-core": patch
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/react": patch
"@thirdweb-dev/auth": patch
"@thirdweb-dev/sdk": patch
---
Minor copy changes
+5
View File
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---
Improved install command
+1 -1
View File
@@ -21,7 +21,7 @@
## Packages
| Package | Description | Latest Version |
|--------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ------------------------------ | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [/sdk](./packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/react](./packages/react) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/auth](./packages/auth) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
+1 -1
View File
@@ -1,10 +1,10 @@
import { LoginPayload, ThirdwebAuth, VerifyOptions } from "../core";
import { ThirdwebProviderConfig } from "./types";
import { EthersWallet } from "@thirdweb-dev/wallets/evm/wallets/ethers";
import { ethers } from "ethers";
import { Awaitable, Session } from "next-auth/core/types";
import { JWT } from "next-auth/jwt/types";
import CredentialsProvider from "next-auth/providers/credentials";
import { EthersWallet } from "@thirdweb-dev/wallets/evm/wallets/ethers";
export function ThirdwebAuthProvider(cfg: ThirdwebProviderConfig) {
const wallet = new EthersWallet(ethers.Wallet.createRandom());
+1 -1
View File
@@ -1,7 +1,7 @@
import { ThirdwebAuth } from "../src/core";
import { Keypair } from "@solana/web3.js";
import { expect } from "chai";
import { KeypairWallet } from "@thirdweb-dev/wallets/solana/wallets/keypair";
import { expect } from "chai";
describe("Wallet Authentication", async () => {
let adminWallet: any, signerWallet: any, attackerWallet: any;
+78 -61
View File
@@ -1,21 +1,34 @@
import {
EXTENSION_REGISTRY_ADDRESS,
ROUTER_CONTRACTS,
PreDeployedRouter,
TWRouterParams,
RouterParams,
} from "../constants/router-contracts";
import { cliVersion, THIRDWEB_URL } from "../constants/urls";
import build from "../core/builder/build";
import detect from "../core/detection/detect";
import { execute } from "../core/helpers/exec";
import { error, info, logger, spinner } from "../core/helpers/logger";
import { createContractsPrompt, createRouterPrompt } from "../core/helpers/selector";
import {
createContractsPrompt,
createRouterPrompt,
} from "../core/helpers/selector";
import { ContractPayload } from "../core/interfaces/ContractPayload";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import {
Extension,
ExtensionFunction,
ExtensionMetadata,
ExtensionDeployArgs,
} from "../core/interfaces/Extension";
import { detectFeatures } from "@thirdweb-dev/sdk";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import chalk from "chalk";
import { readFileSync, writeFileSync } from "fs";
import { ethers } from "ethers";
import { readFileSync, writeFileSync } from "fs";
import ora from "ora";
import path from "path";
import { Extension, ExtensionFunction, ExtensionMetadata, ExtensionDeployArgs } from "../core/interfaces/Extension";
import { EXTENSION_REGISTRY_ADDRESS, ROUTER_CONTRACTS, PreDeployedRouter, TWRouterParams, RouterParams } from "../constants/router-contracts";
export async function processProject(
options: any,
command: "deploy" | "publish",
@@ -99,16 +112,18 @@ export async function processProject(
process.exit(1);
}
let selectedRouter: PreDeployedRouter = { name: "", metadataUri: "", bytecodeUri: ""};
if(options.dynamic) {
const choices = Object.keys(ROUTER_CONTRACTS).map((key) => { return { title: key, value: key } });
let selectedRouter: PreDeployedRouter = {
name: "",
metadataUri: "",
bytecodeUri: "",
};
if (options.dynamic) {
const choices = Object.keys(ROUTER_CONTRACTS).map((key) => {
return { title: key, value: key };
});
let routerType: string = "";
const res = await createRouterPrompt(
choices,
"Choose a router to deploy",
);
const res = await createRouterPrompt(choices, "Choose a router to deploy");
if (typeof res.routerType === "string") {
routerType = res.routerType.trim();
}
@@ -116,17 +131,13 @@ export async function processProject(
selectedRouter = ROUTER_CONTRACTS[routerType];
}
if(options.dynamic && !selectedRouter) {
error(
`No router selected. Please select a router contract to deploy.`,
);
if (options.dynamic && !selectedRouter) {
error(`No router selected. Please select a router contract to deploy.`);
process.exit(1);
}
if (options.dynamic && !selectedRouter.name) {
error(
`No router selected. Please select a router contract to deploy.`,
);
error(`No router selected. Please select a router contract to deploy.`);
process.exit(1);
}
@@ -185,7 +196,9 @@ export async function processProject(
});
const prompt = createContractsPrompt(
choices,
options.dynamic ? "Choose which extensions to add to your contract" : `Choose which contract(s) to ${command}`,
options.dynamic
? "Choose which extensions to add to your contract"
: `Choose which contract(s) to ${command}`,
);
const selection: Record<string, ContractPayload> = await prompt.run();
selectedContracts = Object.keys(selection).map((key) => selection[key]);
@@ -207,27 +220,32 @@ export async function processProject(
const soliditySDKPackage = "@thirdweb-dev/contracts";
let usesSoliditySDK = false;
if(selectedRouter.name === "thirdweb-router") {
if (selectedRouter.name === "thirdweb-router") {
const deployArgs: TWRouterParams = {
extensionRegistry: EXTENSION_REGISTRY_ADDRESS,
extensionNames: selectedContracts.map((c) => c.name),
}
};
const outputDeployArgs = JSON.stringify(deployArgs, undefined, 2);
writeFileSync("./deployArgs.json", outputDeployArgs, "utf-8");
info("Deployment parameters written to deployArgs.json in your project directory");
info(
"Deployment parameters written to deployArgs.json in your project directory",
);
} else {
const deployArgs: RouterParams = await formatToExtensions(selectedContracts);
const deployArgs: RouterParams = await formatToExtensions(
selectedContracts,
);
const outputDeployArgs = JSON.stringify(deployArgs, undefined, 2);
writeFileSync("./deployArgs.json", outputDeployArgs, "utf-8");
info("Deployment parameters written to deployArgs.json in your project directory");
info(
"Deployment parameters written to deployArgs.json in your project directory",
);
}
const loader = spinner("Uploading contract data...");
try {
// Upload contract sources.
for (let i = 0; i < selectedContracts.length; i++) {
const contract = selectedContracts[i];
@@ -268,8 +286,7 @@ export async function processProject(
const bytecodeURIs = await storage.uploadBatch(bytecodes);
let combinedContents = [];
if(options.dynamic) {
if (options.dynamic) {
const analytics = {
command,
contract_name: selectedRouter.name,
@@ -284,10 +301,8 @@ export async function processProject(
metadataUri: selectedRouter.metadataUri,
bytecodeUri: selectedRouter.bytecodeUri,
analytics,
})
});
} else {
combinedContents = selectedContracts.map((c, i) => {
// attach analytics blob to metadata
const analytics = {
@@ -307,7 +322,6 @@ export async function processProject(
});
}
let combinedURIs: string[] = [];
if (combinedContents.length === 1) {
// use upload single if only one contract to get a clean IPFS hash
@@ -346,26 +360,26 @@ export function getUrl(hashes: string[], command: string) {
return url;
}
async function formatToExtensions(contracts: ContractPayload[]): Promise<{extensions: Extension[], extensionDeployArgs: ExtensionDeployArgs[]}> {
async function formatToExtensions(contracts: ContractPayload[]): Promise<{
extensions: Extension[];
extensionDeployArgs: ExtensionDeployArgs[];
}> {
const storage = new ThirdwebStorage();
const extensions: Extension[] = [];
const extensionDeployArgs: ExtensionDeployArgs[] = [];
for(const contract of contracts) {
for (const contract of contracts) {
// Prepare extension metadata.
let metadata: ExtensionMetadata = {
name: contract.name,
metadataURI: await getMetadataURIForExtension(contract, storage),
implementation: ethers.constants.AddressZero
}
let metadata: ExtensionMetadata = {
name: contract.name,
metadataURI: await getMetadataURIForExtension(contract, storage),
implementation: ethers.constants.AddressZero,
};
// Get extension ABI.
const abi: Parameters<typeof detectFeatures>[0] = JSON.parse(
contract.metadata,
)["output"]["abi"];
const abi: Parameters<typeof detectFeatures>[0] = JSON.parse(
contract.metadata,
)["output"]["abi"];
// Format ABI as `ExtensionFunction[]`.
const extensionInterface = new ethers.utils.Interface(abi);
@@ -374,28 +388,31 @@ async function formatToExtensions(contracts: ContractPayload[]): Promise<{extens
const fragments = extensionInterface.functions;
for (const fnSignature of Object.keys(fragments)) {
functions.push({
functionSelector: extensionInterface.getSighash(fragments[fnSignature]),
functionSignature: fnSignature
});
functionSelector: extensionInterface.getSighash(fragments[fnSignature]),
functionSignature: fnSignature,
});
}
extensions.push({
extensions.push({
metadata,
functions
functions,
});
extensionDeployArgs.push({
name: contract.name,
amount: 0,
salt: ethers.utils.keccak256(ethers.utils.toUtf8Bytes(contract.name)),
bytecode: contract.bytecode
})
}
bytecode: contract.bytecode,
});
}
return { extensions, extensionDeployArgs };
}
async function getMetadataURIForExtension(contract: ContractPayload, storage: ThirdwebStorage): Promise<string> {
return await storage.upload(JSON.parse(JSON.stringify(contract.metadata)), {
uploadWithoutDirectory: true,
});
}
async function getMetadataURIForExtension(
contract: ContractPayload,
storage: ThirdwebStorage,
): Promise<string> {
return await storage.upload(JSON.parse(JSON.stringify(contract.metadata)), {
uploadWithoutDirectory: true,
});
}
@@ -16,10 +16,11 @@ export interface TWRouterParams {
extensionNames: string[];
}
export const EXTENSION_REGISTRY_ADDRESS: string = "0x0000000000000000000000000000000000000000";
export const EXTENSION_REGISTRY_ADDRESS: string =
"0x0000000000000000000000000000000000000000";
export const ROUTER_CONTRACTS: Record<string, PreDeployedRouter> = {
"upgradeable": {
upgradeable: {
name: "RouterUpgradeableFactory",
metadataUri: "ipfs://QmdqXhoJg9RfDDURHxtHKDprh3VvyWEwZWVtQvnvXMannF",
bytecodeUri: "ipfs://QmS63fhpjFFSzGXhM9deRSVaqWvEHEN9gcDkwNjiLr5oiV/1",
@@ -33,5 +34,5 @@ export const ROUTER_CONTRACTS: Record<string, PreDeployedRouter> = {
name: "TWRouterFactory",
metadataUri: "ipfs://QmbrV9NUBZAXqoSHpdTzxsZjtubdqumgt6WTMLV8RW3tkV",
bytecodeUri: "ipfs://QmYjMfB1uhnnsdz6qmmc3bBAv8jmnniCkjXpDU6jGN8H5s/1",
}
}
},
};
+12 -12
View File
@@ -1,24 +1,24 @@
import { BytesLike } from "ethers";
export interface ExtensionMetadata {
name: string;
metadataURI: string;
implementation: string;
name: string;
metadataURI: string;
implementation: string;
}
export interface ExtensionFunction {
functionSelector: BytesLike;
functionSignature: string;
functionSelector: BytesLike;
functionSignature: string;
}
export interface Extension {
metadata: ExtensionMetadata;
functions: ExtensionFunction[];
metadata: ExtensionMetadata;
functions: ExtensionFunction[];
}
export interface ExtensionDeployArgs {
name: string;
amount: number;
salt: string;
bytecode: string;
}
name: string;
amount: number;
salt: string;
bytecode: string;
}
+60 -8
View File
@@ -29,7 +29,9 @@ export async function install(projectPath = ".", options: any) {
const hasYarn = new YarnDetector().matches(".");
const hasNPM = new NPMDetector().matches(".");
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
const packageJson = JSON.parse(
fs.readFileSync(projectPath + "/package.json", "utf8"),
);
const hasEthers =
!!packageJson.dependencies?.ethers || !!packageJson.devDependencies?.ethers;
@@ -46,29 +48,79 @@ export async function install(projectPath = ".", options: any) {
throw new Error("No supported project detected");
}
const dependenciesToAdd = new Set<string>();
const thirdwebDepsToUpdate = new Set<string>([
...Object.keys(packageJson.dependencies).filter((dep) =>
dep.startsWith("@thirdweb-dev/"),
),
...Object.keys(packageJson.devDependencies).filter((dep) =>
dep.startsWith("@thirdweb-dev/"),
),
...Object.keys(packageJson.peerDependencies).filter((dep) =>
dep.startsWith("@thirdweb-dev/"),
),
]);
const thirdwebDepsToInstall = new Set<string>();
const otherDeps = new Set<string>();
supportedContractFrameworks.forEach((detector) => {
console.log(`Detected ${detector.projectType} project`);
dependenciesToAdd.add(`@thirdweb-dev/contracts${version}`);
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/contracts`)) {
thirdwebDepsToInstall.add(`@thirdweb-dev/contracts`);
}
});
supportedAppFrameworks.forEach((detector) => {
console.log(`Detected ${detector.projectType} project`);
dependenciesToAdd.add(`@thirdweb-dev/react${version}`);
dependenciesToAdd.add(`@thirdweb-dev/sdk${version}`);
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/react`)) {
thirdwebDepsToInstall.add(`@thirdweb-dev/react`);
}
if (!thirdwebDepsToUpdate.has(`@thirdweb-dev/sdk`)) {
thirdwebDepsToInstall.add(`@thirdweb-dev/sdk`);
}
if (!hasEthers) {
dependenciesToAdd.add("ethers@5");
otherDeps.add("ethers@5");
}
});
try {
if (thirdwebDepsToUpdate.size !== 0) {
console.log(
`Updating dependencies: "${[...thirdwebDepsToUpdate].join('", "')}"`,
);
}
if (thirdwebDepsToInstall.size !== 0) {
console.log(
`Installing dependencies: "${[...thirdwebDepsToInstall].join('", "')}"`,
);
}
const dependenciesToAdd = [
...[...thirdwebDepsToInstall].map((dep) => `${dep}${version}`),
...otherDeps,
];
const dependenciesToUpdate = [...thirdwebDepsToUpdate].map(
(dep) => `${dep}${version}`,
);
if (hasYarn) {
await runCommand("yarn add", [...dependenciesToAdd]);
if (dependenciesToAdd.length !== 0) {
await runCommand("yarn add", dependenciesToAdd);
}
if (dependenciesToUpdate.length !== 0) {
await runCommand("yarn upgrade", dependenciesToUpdate);
}
} else if (hasNPM) {
await runCommand("npm install", [...dependenciesToAdd]);
if (dependenciesToAdd.length !== 0) {
await runCommand("npm install", dependenciesToAdd);
}
if (dependenciesToUpdate.length !== 0) {
await runCommand("npm update", dependenciesToUpdate);
}
}
} catch (err) {
console.error("Can't install within project");
@@ -2,7 +2,9 @@ import {
ThirdwebAuthConfig,
ThirdwebAuthProvider,
} from "../../evm/contexts/thirdweb-auth";
import { useUpdateChainsWithApiKeys } from "../../evm/hooks/chain-hooks";
import { ThirdwebSDKProvider } from "../../evm/providers/thirdweb-sdk-provider";
import { ThirdwebSDKProviderProps } from "../../evm/providers/types";
import { DAppMetaData } from "../types/dAppMeta";
import { SupportedWallet } from "../types/wallet";
import { ThirdwebThemeContext } from "./theme-context";
@@ -19,8 +21,6 @@ import {
CreateAsyncStorage,
} from "@thirdweb-dev/wallets";
import React, { useMemo } from "react";
import { useUpdateChainsWithApiKeys } from "../../evm/hooks/chain-hooks";
import { ThirdwebSDKProviderProps } from "../../evm/providers/types";
/**
* The possible props for the ThirdwebProvider.
@@ -14,8 +14,8 @@ import {
useQueryClient,
} from "@tanstack/react-query";
import { ValidContractInstance } from "@thirdweb-dev/sdk";
import invariant from "tiny-invariant";
import type { providers } from "ethers";
import invariant from "tiny-invariant";
/**
* Get App URI
@@ -19,8 +19,8 @@ import type {
CustomContractMetadata,
ValidContractInstance,
} from "@thirdweb-dev/sdk";
import invariant from "tiny-invariant";
import type { providers } from "ethers";
import invariant from "tiny-invariant";
// primary sales
@@ -32,8 +32,8 @@ import type {
import { NFTDrop } from "@thirdweb-dev/sdk/dist/declarations/src/evm/contracts/prebuilt-implementations/nft-drop";
import { SignatureDrop } from "@thirdweb-dev/sdk/dist/declarations/src/evm/contracts/prebuilt-implementations/signature-drop";
import { SmartContract } from "@thirdweb-dev/sdk/dist/declarations/src/evm/contracts/smart-contract";
import invariant from "tiny-invariant";
import type { providers } from "ethers";
import invariant from "tiny-invariant";
/** **********************/
/** READ HOOKS **/
@@ -21,8 +21,8 @@ import {
UseMutationResult,
useQueryClient,
} from "@tanstack/react-query";
import invariant from "tiny-invariant";
import type { providers } from "ethers";
import invariant from "tiny-invariant";
/** **********************/
/** READ HOOKS **/
@@ -1,3 +1,4 @@
import { useWallet } from "../../../core/hooks/wallet-hooks";
import { useThirdwebAuthContext } from "../../contexts/thirdweb-auth";
import { cacheKeys } from "../../utils/cache-keys";
import { useMutation, useQueryClient } from "@tanstack/react-query";
@@ -6,9 +7,8 @@ import type {
LoginPayload,
LoginPayloadData,
} from "@thirdweb-dev/auth";
import invariant from "tiny-invariant";
import { useWallet } from "../../../core/hooks/wallet-hooks";
import { GenericAuthWallet } from "@thirdweb-dev/wallets";
import invariant from "tiny-invariant";
/**
* Hook to securely login to a backend with the connected wallet. The backend
@@ -1,6 +1,6 @@
import { useMemo } from "react";
import { updateChainRPCs } from "../../core/utils/updateChainRpcs";
import { ThirdwebSDKProviderProps } from "../providers/types";
import { useMemo } from "react";
export function useUpdateChainsWithApiKeys(
supportedChains: NonNullable<ThirdwebSDKProviderProps["supportedChains"]>,
@@ -2,12 +2,12 @@ import { DEFAULT_API_KEY } from "../../core/constants/rpc";
import { QueryClientProviderWithDefault } from "../../core/providers/query-client";
import { ThirdwebConfigProvider } from "../contexts/thirdweb-config";
import { ThirdwebConnectedWalletProvider } from "../contexts/thirdweb-wallet";
import { useUpdateChainsWithApiKeys } from "../hooks/chain-hooks";
import { ThirdwebSDKProviderProps } from "./types";
import { Chain, defaultChains, getChainRPC } from "@thirdweb-dev/chains";
import { SDKOptionsOutput, ThirdwebSDK } from "@thirdweb-dev/sdk/evm";
import { createContext, useContext, useEffect, useMemo } from "react";
import invariant from "tiny-invariant";
import { useUpdateChainsWithApiKeys } from "../hooks/chain-hooks";
import { ThirdwebSDKProviderProps } from "./types";
interface TWSDKContext {
sdk?: ThirdwebSDK;
@@ -1,9 +1,9 @@
import type { QueryClientProviderProps } from "../../core/providers/query-client";
import type { ThirdwebAuthConfig } from "../contexts/thirdweb-auth";
import type { Chain, defaultChains } from "@thirdweb-dev/chains";
import type { SDKOptions } from "@thirdweb-dev/sdk";
import type { ThirdwebStorage } from "@thirdweb-dev/storage";
import type { Signer } from "ethers";
import type { ThirdwebAuthConfig } from "../contexts/thirdweb-auth";
export interface ThirdwebSDKProviderProps<
TChains extends Chain[] = typeof defaultChains,
@@ -112,9 +112,8 @@ export const cacheKeys = {
) => createContractCacheKey(contractAddress, ["call", functionName, args]),
app: {
get: (
contractAddress: RequiredParam<ContractAddress>
) => createContractCacheKey(contractAddress, ["appURI"]),
get: (contractAddress: RequiredParam<ContractAddress>) =>
createContractCacheKey(contractAddress, ["appURI"]),
},
events: {
@@ -1,15 +1,15 @@
import { ensureTWPrefix } from "../../../core/query-utils/query-key";
import { useThirdwebAuthContext } from "../../contexts/thirdweb-auth";
import { useSDK } from "../../providers/base";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import type {
LoginOptions,
LoginPayload,
LoginPayloadData,
} from "@thirdweb-dev/auth";
import invariant from "tiny-invariant";
import { GenericAuthWallet } from "@thirdweb-dev/wallets";
import { useSDK } from "../../providers/base";
import { SignerWallet } from "@thirdweb-dev/wallets/solana/wallets/signer";
import invariant from "tiny-invariant";
export interface LoginConfig {
/**
@@ -2,8 +2,8 @@ import { createSOLProgramQueryKey } from "../../../core/query-utils/query-key";
import { RequiredParam } from "../../../core/query-utils/required-param";
import { UseProgramResult } from "./useProgram";
import { useQuery, UseQueryResult } from "@tanstack/react-query";
import invariant from "tiny-invariant";
import { NFTMetadata } from "@thirdweb-dev/sdk";
import invariant from "tiny-invariant";
export function programMetadataQuery(
program: RequiredParam<UseProgramResult["program"]>,
@@ -3,4 +3,3 @@
import "react-native-get-random-values";
import "./shims";
@@ -1,9 +1,9 @@
import { ModalFooter } from "../../base/modal/ModalFooter";
import { ModalHeaderTextClose } from "../../base/modal/ModalHeaderTextClose";
import { ChooseWalletContent } from "./ChooseWalletContent";
import { SupportedWallet } from "@thirdweb-dev/react-core";
import { ReactNode } from "react";
import { View } from "react-native";
import { SupportedWallet } from "@thirdweb-dev/react-core";
export type ChooseWalletProps = {
headerText?: ReactNode | string;
@@ -2,6 +2,7 @@ import BaseButton from "../base/BaseButton";
import Text from "../base/Text";
import { TWModal } from "../base/modal/TWModal";
import { ChooseWallet } from "./ChooseWallet/ChooseWallet";
import { ConnectingWallet } from "./ConnectingWallet/ConnectingWallet";
import {
SupportedWallet,
useConnect,
@@ -9,7 +10,6 @@ import {
} from "@thirdweb-dev/react-core";
import { useState } from "react";
import { StyleSheet } from "react-native";
import { ConnectingWallet } from "./ConnectingWallet/ConnectingWallet";
export const ConnectWalletFlow = () => {
const [modalVisible, setModalVisible] = useState(false);
@@ -2,9 +2,9 @@ import { useAppTheme } from "../../../styles/hooks";
import Text from "../../base/Text";
import { ModalFooter } from "../../base/modal/ModalFooter";
import { ConnectWalletHeader } from "./ConnectingWalletHeader";
import { SupportedWallet } from "@thirdweb-dev/react-core";
import { ReactNode } from "react";
import { ActivityIndicator, Linking, StyleSheet, View } from "react-native";
import { SupportedWallet } from "@thirdweb-dev/react-core";
export type ConnectingWalletProps = {
headerText?: ReactNode | string;
@@ -1,2 +1,2 @@
export const TW_WC_PROJECT_ID = '145769e410f16970a79ff77b2d89a1e0'
export const WC_RELAY_URL = 'wss://relay.walletconnect.com'
export const TW_WC_PROJECT_ID = "145769e410f16970a79ff77b2d89a1e0";
export const WC_RELAY_URL = "wss://relay.walletconnect.com";
@@ -1,5 +1,5 @@
export function shortenString(str: string, extraShort?: true) {
return `${str.substring(0, extraShort ? 4 : 6)}...${str.substring(
str.length - (extraShort ? 3 : 4),
)}`;
}
return `${str.substring(0, extraShort ? 4 : 6)}...${str.substring(
str.length - (extraShort ? 3 : 4),
)}`;
}
+1 -1
View File
@@ -1 +1 @@
export * from "./evm";
export * from "./evm";
@@ -1,6 +1,6 @@
import { useConnect } from "@thirdweb-dev/react-core";
import type { SafeConnectionArgs } from "@thirdweb-dev/wallets";
import { useCallback } from "react";
import { useConnect } from "@thirdweb-dev/react-core";
export function useSafe() {
const connect = useConnect();
@@ -1,4 +1,5 @@
import { useCallback } from "react";
// import { useConnect } from "../../../core/hooks/wallet-hooks";
export function useMagic() {
@@ -1,6 +1,6 @@
import { useCallback } from "react";
import { useConnect } from "@thirdweb-dev/react-core";
import { CoinbaseWallet } from "../../../wallet/wallets";
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
export function useCoinbaseWallet() {
const connect = useConnect();
@@ -1,6 +1,6 @@
import { DeviceWallet } from "../../../wallet/wallets";
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
import { DeviceWallet } from "../../../wallet/wallets";
export function useDeviceWallet() {
const connect = useConnect();
@@ -1,6 +1,6 @@
import { useCallback } from "react";
import { useConnect } from "@thirdweb-dev/react-core";
import { MetamaskWallet } from "../../../wallet/wallets";
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
export function useMetamask() {
const connect = useConnect();
@@ -1,6 +1,6 @@
import { WalletConnectV1, WalletConnect } from "../../../wallet/wallets";
import { useConnect } from "@thirdweb-dev/react-core";
import { useCallback } from "react";
import { WalletConnectV1, WalletConnect } from "../../../wallet/wallets";
export function useWalletConnectV1() {
const connect = useConnect();
@@ -9,18 +9,18 @@ import { CoinbaseWalletSetup } from "./screens/Coinbase/CoinbaseConnecting";
import { CoinbaseGetStarted } from "./screens/Coinbase/CoinbaseGetStarted";
import { ScanCoinbase } from "./screens/Coinbase/CoinbaseScan";
import { ConnectToDeviceWallet } from "./screens/DeviceWallet/DeviceWalletSetup";
import { GetStartedWithWallets } from "./screens/GetStartedWithWallets";
import { MetamaskConnecting } from "./screens/Metamask/MetamaskConnecting";
import { MetamaskGetStarted } from "./screens/Metamask/MetamaskGetStarted";
import { ScanMetamask } from "./screens/Metamask/MetamaskScan";
import { SafeForm } from "./screens/Safe/SafeForm";
import { SelectpersonalWallet } from "./screens/Safe/SelectPersonalWallet";
import {
useConnect,
useConnectionStatus,
useWallets,
} from "@thirdweb-dev/react-core";
import { useEffect, useState } from "react";
import { SelectpersonalWallet } from "./screens/Safe/SelectPersonalWallet";
import { SafeForm } from "./screens/Safe/SafeForm";
import { GetStartedWithWallets } from "./screens/GetStartedWithWallets";
type Screen =
| "deviceWallet/connect"
@@ -9,9 +9,9 @@ import {
} from "../../../components/modalElements";
import { fontSize, iconSize, radius, spacing } from "../../../design-system";
import { Theme } from "../../../design-system/index";
import { Apple, Chrome, GooglePlay } from "../iconURLs";
import styled from "@emotion/styled";
import { useState } from "react";
import { Apple, Chrome, GooglePlay } from "../iconURLs";
export const GetStartedScreen: React.FC<{
onBack: () => void;
@@ -8,11 +8,11 @@ import {
ModalTitle,
} from "../../../components/modalElements";
import { fontSize, iconSize, spacing, Theme } from "../../../design-system";
import { useState } from "react";
import { Apple, Chrome, GooglePlay } from "../iconURLs";
import { MetamaskWallet } from "../../wallets";
import { Apple, Chrome, GooglePlay } from "../iconURLs";
import { ButtonLink } from "./GetStartedScreen";
import styled from "@emotion/styled";
import { useState } from "react";
const walletName = MetamaskWallet.meta.name;
const walletIconURL = MetamaskWallet.meta.iconURL;
@@ -1,3 +1,25 @@
import { Img } from "../../../../components/Img";
import { Spacer } from "../../../../components/Spacer";
import { Spinner } from "../../../../components/Spinner";
import { Button } from "../../../../components/buttons";
import { ErrorMessage, Label } from "../../../../components/formElements";
import { FormField } from "../../../../components/formFields";
import {
BackButton,
ModalTitle,
ModalDescription,
HelperLink,
} from "../../../../components/modalElements";
import {
iconSize,
spacing,
media,
Theme,
fontSize,
} from "../../../../design-system";
import { useIsNonLocalWallet } from "../../../hooks/useCanSwitchNetwork";
import { SafeWallet } from "../../../wallets";
import { Steps } from "./Steps";
import styled from "@emotion/styled";
import {
ChevronDownIcon,
@@ -14,28 +36,6 @@ import {
import { SafeSupportedChainsSet } from "@thirdweb-dev/wallets";
import { utils } from "ethers";
import { useState } from "react";
import { Button } from "../../../../components/buttons";
import { ErrorMessage, Label } from "../../../../components/formElements";
import { FormField } from "../../../../components/formFields";
import { Img } from "../../../../components/Img";
import {
BackButton,
ModalTitle,
ModalDescription,
HelperLink,
} from "../../../../components/modalElements";
import { Spacer } from "../../../../components/Spacer";
import { Spinner } from "../../../../components/Spinner";
import {
iconSize,
spacing,
media,
Theme,
fontSize,
} from "../../../../design-system";
import { useIsNonLocalWallet } from "../../../hooks/useCanSwitchNetwork";
import { SafeWallet } from "../../../wallets";
import { Steps } from "./Steps";
export const gnosisAddressPrefixToChainId = {
eth: 1,
@@ -1,17 +1,17 @@
import styled from "@emotion/styled";
import { Img } from "../../../../components/Img";
import { Spacer } from "../../../../components/Spacer";
import {
BackButton,
ModalTitle,
HelperLink,
ModalDescription,
} from "../../../../components/modalElements";
import { Spacer } from "../../../../components/Spacer";
import { iconSize, spacing, media } from "../../../../design-system";
import { WalletMeta } from "../../../types";
import { SafeWallet } from "../../../wallets";
import { WalletSelection } from "../../WalletSelector";
import { Steps } from "./Steps";
import styled from "@emotion/styled";
export const SelectpersonalWallet: React.FC<{
onBack: () => void;
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import { media, spacing, Theme } from "../../../../design-system";
import styled from "@emotion/styled";
export function Steps({ step }: { step: 1 | 2 }) {
return (
+1 -1
View File
@@ -297,7 +297,7 @@ export function getApprovedImplementation(
*/
export function getContractAddressByChainId(
chainId: SUPPORTED_CHAIN_ID | ChainId.Hardhat,
contractName: keyof typeof CONTRACT_ADDRESSES[SUPPORTED_CHAIN_ID],
contractName: keyof (typeof CONTRACT_ADDRESSES)[SUPPORTED_CHAIN_ID],
): string | undefined {
// for testing only
if (chainId === ChainId.Hardhat || chainId === ChainId.Localhost) {
@@ -2,8 +2,8 @@ import { EventType } from "../../constants";
import { ContractEvent, EventQueryOptions } from "../../types";
import { ContractWrapper } from "./contract-wrapper";
import type { BaseContract, Event, providers } from "ethers";
import type { EventEmitter } from "eventemitter3";
import type { EventFragment } from "ethers/lib/utils.js";
import type { EventEmitter } from "eventemitter3";
/**
* Listen to Contract events in real time
@@ -3,16 +3,16 @@ import { ThirdwebAuth } from "@thirdweb-dev/auth";
import { CoinbasePayIntegration, FundWalletOptions } from "@thirdweb-dev/pay";
import { ThirdwebSDK, ChainIdOrName } from "@thirdweb-dev/sdk";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { DAppMetaData } from "@thirdweb-dev/wallets";
import type { AbstractBrowserWallet } from "@thirdweb-dev/wallets/evm/wallets/base";
import { CoinbaseWallet } from "@thirdweb-dev/wallets/evm/wallets/coinbase-wallet";
import { DeviceBrowserWallet } from "@thirdweb-dev/wallets/evm/wallets/device-wallet";
import { EthersWallet } from "@thirdweb-dev/wallets/evm/wallets/ethers";
import { InjectedWallet } from "@thirdweb-dev/wallets/evm/wallets/injected";
import { MetaMask } from "@thirdweb-dev/wallets/evm/wallets/metamask";
import { WalletConnect } from "@thirdweb-dev/wallets/evm/wallets/wallet-connect";
import { DeviceBrowserWallet } from "@thirdweb-dev/wallets/evm/wallets/device-wallet";
import { BigNumber } from "ethers";
import type { ContractInterface, Signer } from "ethers";
import { DAppMetaData } from "@thirdweb-dev/wallets";
declare global {
interface Window {
-1
View File
@@ -34,7 +34,6 @@ await wallet.connect();
- Magic.link
- Ethers
#### Backend Wallets
- Privatekey
@@ -11,11 +11,11 @@ import {
SwitchChainError,
UserRejectedRequestError,
} from "../../../lib/wagmi-core";
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
import { getInjectedName } from "../../utils/getInjectedName";
import { Ethereum } from "./types";
import type { Chain } from "@thirdweb-dev/chains";
import { utils, providers } from "ethers";
import { Ethereum } from "./types";
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
export type InjectedConnectorOptions = {
/** Name of connector */
@@ -5,12 +5,11 @@ import {
RpcError,
UserRejectedRequestError,
} from "../../../lib/wagmi-core/errors";
import { InjectedConnector, InjectedConnectorOptions } from "../injected";
import type { Chain } from "@thirdweb-dev/chains";
import { utils } from "ethers";
import { Ethereum } from "../injected/types";
import { assertWindowEthereum } from "../../utils/assertWindowEthereum";
import { InjectedConnector, InjectedConnectorOptions } from "../injected";
import { Ethereum } from "../injected/types";
import type { Chain } from "@thirdweb-dev/chains";
import { utils } from "ethers";
export type MetaMaskConnectorOptions = Pick<
InjectedConnectorOptions,
@@ -1,5 +1,5 @@
import type { Chain } from "@thirdweb-dev/chains";
import type { AbstractBrowserWallet } from "../../wallets/base";
import type { Chain } from "@thirdweb-dev/chains";
export interface SafeConnectionArgs {
safeAddress: string;
-1
View File
@@ -1,6 +1,5 @@
import { AsyncStorage, createAsyncLocalStorage } from "../../core/AsyncStorage";
import type { DAppMetaData } from "../../core/types/dAppMeta";
import { ConnectParams, TWConnector } from "../interfaces/tw-connector";
import { AbstractWallet } from "./abstract";
import { Chain, defaultChains } from "@thirdweb-dev/chains";
@@ -1,5 +1,4 @@
import { AsyncStorage, createAsyncLocalStorage } from "../../core";
import { TWConnector } from "../interfaces/tw-connector";
import { AbstractWallet } from "./abstract";
import { AbstractBrowserWallet, WalletOptions } from "./base";
+1 -1
View File
@@ -1,7 +1,7 @@
import { SafeConnectionArgs } from "../connectors/safe/types";
import { ConnectParams, TWConnector } from "../interfaces/tw-connector";
import { AbstractBrowserWallet, WalletOptions } from "./base";
import type { Chain } from "@thirdweb-dev/chains";
import { SafeConnectionArgs } from "../connectors/safe/types";
export { SafeSupportedChainsSet } from "../connectors/safe";
@@ -1,5 +1,4 @@
import { Chain, defaultChains } from "@thirdweb-dev/chains";
import { default as EventEmitter } from "eventemitter3";
export type ConnectorData<Provider = any> = {