Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 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
Huseyin ELMASandManan Tank c701c388c6 feat: ethers skipFetchSetup support (#2085)
Co-authored-by: Manan Tank <[email protected]>
2023-12-15 08:37:55 +13:00
iketw 328ef5dc9c [RN] Hide back button in WC modal when WC is the only supportedWallet (#2086) 2023-12-14 18:13:55 +00:00
iketw 07fbb799be [RN] Adds the ability to login with any arbitrary login payload (#2074) 2023-12-13 20:50:24 +00:00
iketw 699f31c20a [RN/React-Core] Improve comments (#2082) 2023-12-13 02:56:39 +00:00
github-actions[bot]andgithub-actions[bot] c97e51b855 Version Packages (#2071)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 13:11:43 +13:00
Adam Majmudar e10173bf8a [Wallets] Add support for signTransaction for smart wallets (#2080) 2023-12-12 23:57:45 +00:00
Joaquim Verges dbfa73d75a [SDK] Export contract verifier (#2081) 2023-12-12 23:34:31 +00:00
Joaquim Verges 1b1212d9fb [Wallet] Export getUserOpReceipt() (#2079) 2023-12-12 22:46:52 +00:00
Firekeeper 065f85bf71 [Unity] Support revokeSessionKey/getAllActiveSigners (#2078) 2023-12-12 21:30:46 +00:00
Joaquim Verges 09bafa9aeb [Wallets] Respect value in smart wallet gas estimations + add getUserOpReceipt utility function (#2077) 2023-12-12 21:13:18 +00:00
Joaquim Verges fe30c88cc3 [SDK] Re-export classes, comment cleanup (#2076) 2023-12-12 09:35:51 +00:00
Joaquim Verges 3a9538259c [SDK] cleanup (#2075) 2023-12-12 00:12:03 +00:00
Firekeeper 0c730e57e0 [Unity] Add JWT/AuthEndpoint login options (#2073) 2023-12-11 23:43:10 +00:00
iketw 33c9f6b1ab [Embedded] Enforce encryption key for custom jwt (#2018) 2023-12-11 22:47:41 +00:00
iketw 2346396bdf [RN] Adds analytics nonce to ews (#2072) 2023-12-11 22:41:32 +00:00
Manan Tank de5ebc9093 [wallets] Fix assertWindowEthereum (#2070) 2023-12-11 20:37:32 +00:00
Joaquim Verges 42c4c33d30 [SDK] un-export unneeded classes + package reorganization (#2069) 2023-12-11 19:06:32 +00:00
github-actions[bot]andgithub-actions[bot] 046603ac54 Version Packages (#2068)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-08 22:29:51 -08:00
Yash bcfa9463bb Fix deployments (#2067) 2023-12-09 04:37:58 +00:00
188 changed files with 1663 additions and 773 deletions
+21
View File
@@ -1,5 +1,26 @@
# @thirdweb-dev/auth # @thirdweb-dev/auth
## 4.1.18
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.3.1
## 4.1.17
### Patch Changes
- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]:
- @thirdweb-dev/wallets@2.3.0
## 4.1.16
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.2.1
## 4.1.15 ## 4.1.15
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/auth", "name": "@thirdweb-dev/auth",
"version": "4.1.15", "version": "4.1.18",
"main": "dist/thirdweb-dev-auth.cjs.js", "main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js", "module": "dist/thirdweb-dev-auth.esm.js",
"browser": { "browser": {
+26
View File
@@ -1,5 +1,31 @@
# thirdweb # 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
- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]:
- @thirdweb-dev/wallets@2.3.0
- @thirdweb-dev/auth@4.1.17
## 0.13.24
### Patch Changes
- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]:
- @thirdweb-dev/sdk@4.0.21
- @thirdweb-dev/wallets@2.2.1
- @thirdweb-dev/auth@4.1.16
## 0.13.23 ## 0.13.23
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "thirdweb", "name": "thirdweb",
"main": "dist/cli/index.js", "main": "dist/cli/index.js",
"version": "0.13.23", "version": "0.13.26",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+28
View File
@@ -1,5 +1,33 @@
# @thirdweb-dev/react-core # @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
- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]:
- @thirdweb-dev/wallets@2.3.0
- @thirdweb-dev/auth@4.1.17
## 4.1.14
### Patch Changes
- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]:
- @thirdweb-dev/sdk@4.0.21
- @thirdweb-dev/wallets@2.2.1
- @thirdweb-dev/auth@4.1.16
## 4.1.13 ## 4.1.13
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-core", "name": "@thirdweb-dev/react-core",
"version": "4.1.13", "version": "4.1.16",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -84,11 +84,10 @@ export interface ThirdwebProviderCoreProps<TChains extends Chain[]>
/** /**
* @internal * @internal
*/ */
export const ThirdwebProviderCore = <TChains extends Chain[]>({ export const ThirdwebProviderCore = <TChains extends Chain[]>(
createWalletStorage = createAsyncLocalStorage, props: React.PropsWithChildren<ThirdwebProviderCoreProps<TChains>>,
...props ) => {
}: React.PropsWithChildren<ThirdwebProviderCoreProps<TChains>>) => { const { activeChain, createWalletStorage = createAsyncLocalStorage } = props;
const { activeChain } = props;
const supportedChains = (props.supportedChains || defaultChains) as Chain[]; const supportedChains = (props.supportedChains || defaultChains) as Chain[];
@@ -1,5 +1,10 @@
import { createContext, useContext } from "react"; 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 { export interface ISecureStorage {
getItem(key: string): Promise<string | null>; getItem(key: string): Promise<string | null>;
setItem(key: string, value: string): Promise<void>; 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 { 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. * @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() { export function useLogin() {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@@ -10,8 +10,18 @@ import invariant from "tiny-invariant";
* *
* @returns - A function to invoke to logout. * @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() { export function useLogout() {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@@ -16,9 +16,23 @@ export interface UserWithData<
* Hook to get the currently logged in user. * 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. * @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< export function useUser<
TData extends Json = Json, TData extends Json = Json,
@@ -1,9 +1,27 @@
import { useSDK } from "../useSDK"; import { useSDK } from "../useSDK";
/** /**
* Get the configured `ThirdwebStorage` instance * Get the configured `ThirdwebStorage` instance in the `ThirdwebProvider`.
*
* @returns The `storageInterface` configured on 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() { export function useStorage() {
const sdk = useSDK(); const sdk = useSDK();
+2 -4
View File
@@ -3,9 +3,7 @@ import type {
AirdropInput, AirdropInput,
Amount, Amount,
Erc721, Erc721,
Erc721Mintable,
Erc1155, Erc1155,
Erc1155Mintable,
ListingType, ListingType,
NFTMetadataInput, NFTMetadataInput,
Price, Price,
@@ -150,9 +148,9 @@ export type MintNFTParams = {
* *
*/ */
export type MintNFTReturnType<TContract> = TContract extends Erc721 export type MintNFTReturnType<TContract> = TContract extends Erc721
? Awaited<ReturnType<Erc721Mintable["to"]>> ? Awaited<ReturnType<Erc721["mintTo"]>>
: TContract extends Erc1155 : TContract extends Erc1155
? Awaited<ReturnType<Erc1155Mintable["to"]>> ? Awaited<ReturnType<Erc1155["mintTo"]>>
: never; : never;
/** /**
@@ -1,5 +1,11 @@
# @thirdweb-dev/react-native-compat # @thirdweb-dev/react-native-compat
## 0.5.1
## 0.5.0
## 0.4.14
## 0.4.13 ## 0.4.13
## 0.4.12 ## 0.4.12
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@thirdweb-dev/react-native-compat", "name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects", "description": "Shims for Thirdweb in React Native Projects",
"version": "0.4.13", "version": "0.5.1",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0", "license": "Apache-2.0",
+56
View File
@@ -1,5 +1,61 @@
# @thirdweb-dev/react-native # @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
- [#2018](https://github.com/thirdweb-dev/js/pull/2018) [`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba) Thanks [@iketw](https://github.com/iketw)! - Enforces passing an encryption key for custom jwt auth
```typescript
const embedded = useEmbeddedWallet();
embedded.connect({
jwt: "<token>",
encryptionKey: "<my-key>",
strategy: "jwt",
});
```
### Patch Changes
- [#2072](https://github.com/thirdweb-dev/js/pull/2072) [`2346396b`](https://github.com/thirdweb-dev/js/commit/2346396bdffeed169cdfc15839bfb42d87f24303) Thanks [@iketw](https://github.com/iketw)! - Adds analytics nonce to embedded wallet
- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.4.14
### Patch Changes
- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 0.4.13 ## 0.4.13
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-native", "name": "@thirdweb-dev/react-native",
"version": "0.4.13", "version": "0.5.1",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -12,17 +12,16 @@ import { DEFAULT_WALLETS } from "../constants/wallets";
import { DappContextProvider } from "./context-provider"; import { DappContextProvider } from "./context-provider";
import { UIContextProvider } from "./ui-context-provider"; import { UIContextProvider } from "./ui-context-provider";
import { MainModal } from "../components/MainModal"; 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 { SafeAreaProvider } from "react-native-safe-area-context";
import { walletIds } from "@thirdweb-dev/wallets"; import { walletIds } from "@thirdweb-dev/wallets";
import { ThirdwebStorage } from "../../core/storage/storage"; import { ThirdwebStorage } from "../../core/storage/storage";
import { useColorScheme } from "react-native";
import type { Locale } from "../i18n/types"; import type { Locale } from "../i18n/types";
interface ThirdwebProviderProps<TChains extends Chain[]> interface ThirdwebProviderProps<TChains extends Chain[]>
extends Omit< extends Omit<
ThirdwebProviderCoreProps<TChains>, ThirdwebProviderCoreProps<TChains>,
"supportedWallets" | "secretKey" | "signer" "supportedWallets" | "secretKey" | "signer" | "theme"
> { > {
/** /**
* Wallets that will be supported by the dApp * Wallets that will be supported by the dApp
@@ -47,6 +46,27 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
*/ */
supportedWallets?: WalletConfig<any>[]; 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 * Locale that the app will be displayed in
* *
@@ -87,10 +107,15 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
locale?: Locale; 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, * 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 * @example
* You can wrap your application with the provider as follows: * You can wrap your application with the provider as follows:
@@ -107,9 +132,10 @@ interface ThirdwebProviderProps<TChains extends Chain[]>
* }; * };
* ``` * ```
*/ */
export const ThirdwebProvider = < export const ThirdwebProvider = <TChains extends Chain[] = DefaultChains>(
TChains extends Chain[] = typeof defaultChains, props: PropsWithChildren<ThirdwebProviderProps<TChains>>,
>({ ) => {
const {
children, children,
createWalletStorage = createAsyncLocalStorage, createWalletStorage = createAsyncLocalStorage,
supportedWallets = DEFAULT_WALLETS, supportedWallets = DEFAULT_WALLETS,
@@ -120,8 +146,7 @@ export const ThirdwebProvider = <
sdkOptions, sdkOptions,
locale = "en", locale = "en",
...restProps ...restProps
}: PropsWithChildren<ThirdwebProviderProps<TChains>>) => { } = props;
const colorScheme = useColorScheme();
const coinbaseWalletObj = supportedWallets.find( const coinbaseWalletObj = supportedWallets.find(
(w) => w.id === walletIds.coinbase, (w) => w.id === walletIds.coinbase,
@@ -161,9 +186,7 @@ export const ThirdwebProvider = <
{...sdkOptions} {...sdkOptions}
{...restProps} {...restProps}
> >
<ThemeProvider <ThemeProvider theme={theme ? theme : "dark"}>
theme={theme ? theme : colorScheme === "dark" ? "dark" : "light"}
>
<UIContextProvider locale={locale}> <UIContextProvider locale={locale}>
{hasMagicConfig ? ( {hasMagicConfig ? (
<SafeAreaProvider> <SafeAreaProvider>
@@ -5,8 +5,10 @@ import { PropsWithChildren, useContext } from "react";
import { useColorScheme } from "react-native"; import { useColorScheme } from "react-native";
import { useUIContext } from "../providers/ui-context-provider"; import { useUIContext } from "../providers/ui-context-provider";
export type ThemeType = "dark" | "light" | Theme;
export type ThemeProviderProps = { export type ThemeProviderProps = {
theme?: Theme | "light" | "dark"; theme?: ThemeType;
}; };
export function ThemeProvider({ export function ThemeProvider({
@@ -1,4 +1,5 @@
import { import {
AuthEndpointOptions,
AuthOptions, AuthOptions,
AuthParams, AuthParams,
AuthResult, AuthResult,
@@ -11,6 +12,7 @@ import type { Chain } from "@thirdweb-dev/chains";
import { providers, Signer } from "ethers"; import { providers, Signer } from "ethers";
import { utils } from "ethers"; import { utils } from "ethers";
import { import {
authEndpoint,
customJwt, customJwt,
sendVerificationEmail, sendVerificationEmail,
socialLogin, socialLogin,
@@ -101,7 +103,13 @@ export class EmbeddedWalletConnector extends Connector<EmbeddedWalletConnectionA
case "jwt": { case "jwt": {
return this.customJwt({ return this.customJwt({
jwt: params.jwt, jwt: params.jwt,
password: params.encryptionKey || "", password: params.encryptionKey,
});
}
case "auth_endpoint": {
return this.authEndpoint({
payload: params.payload,
encryptionKey: params.encryptionKey,
}); });
} }
default: 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> { async disconnect(): Promise<void> {
clearConnectedEmail(); clearConnectedEmail();
clearConnectedAuthStrategy(); clearConnectedAuthStrategy();
@@ -27,10 +27,17 @@ import { Auth } from "aws-amplify";
import { import {
DOMAIN_URL_2023, DOMAIN_URL_2023,
EWS_VERSION_HEADER, EWS_VERSION_HEADER,
ROUTE_AUTH_ENDPOINT_CALLBACK,
ROUTE_AUTH_JWT_CALLBACK, ROUTE_AUTH_JWT_CALLBACK,
ROUTE_HEADLESS_OAUTH_LOGIN, ROUTE_HEADLESS_OAUTH_LOGIN,
THIRDWEB_SESSION_NONCE_HEADER,
} from "./helpers/constants"; } from "./helpers/constants";
import { AuthOptions, OauthOption, VerifiedTokenResponse } from "../types"; import {
AuthEndpointOptions,
AuthOptions,
OauthOption,
VerifiedTokenResponse,
} from "../types";
import { InAppBrowser } from "react-native-inappbrowser-reborn"; import { InAppBrowser } from "react-native-inappbrowser-reborn";
import { createErrorMessage } from "./helpers/errors"; import { createErrorMessage } from "./helpers/errors";
import { import {
@@ -38,6 +45,7 @@ import {
reactNativePackageVersion, reactNativePackageVersion,
} from "../../../../utils/version"; } from "../../../../utils/version";
import { BUNDLE_ID_HEADER } from "../../../../constants/headers"; import { BUNDLE_ID_HEADER } from "../../../../constants/headers";
import { ANALYTICS } from "./helpers/analytics";
export async function sendVerificationEmail(options: { export async function sendVerificationEmail(options: {
email: string; email: string;
@@ -189,6 +197,7 @@ export async function socialLogin(oauthOptions: OauthOption, clientId: string) {
headers: { headers: {
[EWS_VERSION_HEADER]: reactNativePackageVersion, [EWS_VERSION_HEADER]: reactNativePackageVersion,
[BUNDLE_ID_HEADER]: appBundleId, [BUNDLE_ID_HEADER]: appBundleId,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
}, },
}); });
@@ -271,6 +280,7 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) {
"Content-Type": "application/json", "Content-Type": "application/json",
[EWS_VERSION_HEADER]: reactNativePackageVersion, [EWS_VERSION_HEADER]: reactNativePackageVersion,
[BUNDLE_ID_HEADER]: appBundleId, [BUNDLE_ID_HEADER]: appBundleId,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
}, },
body: JSON.stringify({ body: JSON.stringify({
jwt: jwt, jwt: jwt,
@@ -303,7 +313,62 @@ export async function customJwt(authOptions: AuthOptions, clientId: string) {
return { verifiedToken, email: verifiedToken.authDetails.email }; return { verifiedToken, email: verifiedToken.authDetails.email };
} catch (e) { } catch (e) {
throw new Error( 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,
),
); );
} }
} }
@@ -0,0 +1,5 @@
import { getRandomString } from "./getRandomValues";
export const ANALYTICS = {
nonce: getRandomString(16),
};
@@ -8,6 +8,7 @@ import {
ROUTE_VALIDATE_USER_MANAGED_OTP, ROUTE_VALIDATE_USER_MANAGED_OTP,
ROUTE_IS_VALID_USER_MANAGED_OTP, ROUTE_IS_VALID_USER_MANAGED_OTP,
EWS_VERSION_HEADER, EWS_VERSION_HEADER,
THIRDWEB_SESSION_NONCE_HEADER,
} from "../constants"; } from "../constants";
import { getAuthTokenClient } from "../storage/local"; import { getAuthTokenClient } from "../storage/local";
import { import {
@@ -24,6 +25,7 @@ import {
reactNativePackageVersion, reactNativePackageVersion,
} from "../../../../../../utils/version"; } from "../../../../../../utils/version";
import { BUNDLE_ID_HEADER } from "../../../../../../constants/headers"; import { BUNDLE_ID_HEADER } from "../../../../../../constants/headers";
import { ANALYTICS } from "../analytics";
const EMBEDDED_WALLET_TOKEN_HEADER = "embedded-wallet-token"; const EMBEDDED_WALLET_TOKEN_HEADER = "embedded-wallet-token";
const PAPER_CLIENT_ID_HEADER = "x-thirdweb-client-id"; const PAPER_CLIENT_ID_HEADER = "x-thirdweb-client-id";
@@ -31,6 +33,7 @@ const HEADERS = {
"Content-Type": "application/json", "Content-Type": "application/json",
[BUNDLE_ID_HEADER]: appBundleId, [BUNDLE_ID_HEADER]: appBundleId,
[EWS_VERSION_HEADER]: reactNativePackageVersion, [EWS_VERSION_HEADER]: reactNativePackageVersion,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
}; };
export const verifyClientId = async (clientId: string) => { export const verifyClientId = async (clientId: string) => {
@@ -68,6 +71,7 @@ export const authFetchEmbeddedWalletUser = async (
[BUNDLE_ID_HEADER]: appBundleId, [BUNDLE_ID_HEADER]: appBundleId,
[PAPER_CLIENT_ID_HEADER]: clientId, [PAPER_CLIENT_ID_HEADER]: clientId,
[EWS_VERSION_HEADER]: reactNativePackageVersion, [EWS_VERSION_HEADER]: reactNativePackageVersion,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
} }
: { : {
Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${ Authorization: `Bearer ${EMBEDDED_WALLET_TOKEN_HEADER}:${
@@ -76,6 +80,7 @@ export const authFetchEmbeddedWalletUser = async (
[BUNDLE_ID_HEADER]: appBundleId, [BUNDLE_ID_HEADER]: appBundleId,
[PAPER_CLIENT_ID_HEADER]: clientId, [PAPER_CLIENT_ID_HEADER]: clientId,
[EWS_VERSION_HEADER]: reactNativePackageVersion, [EWS_VERSION_HEADER]: reactNativePackageVersion,
[THIRDWEB_SESSION_NONCE_HEADER]: ANALYTICS.nonce,
}; };
return fetch(url, params); return fetch(url, params);
}; };
@@ -4,7 +4,7 @@ import {
COGNITO_APP_CLIENT_ID, COGNITO_APP_CLIENT_ID,
COGNITO_USER_POOL_ID, COGNITO_USER_POOL_ID,
} from "../constants"; } from "../constants";
import { getRandomValues } from "../getRandomValues"; import { getRandomString } from "../getRandomValues";
Amplify.configure({ Amplify.configure({
Auth: { Auth: {
@@ -25,13 +25,6 @@ export async function cognitoEmailSignUp(email: string, clientId: string) {
await Auth.signOut(); await Auth.signOut();
} }
function getRandomString(bytes: number) {
const randomValues = getRandomValues(new Uint8Array(bytes));
return Array.from(randomValues)
.map((nr) => nr.toString(16).padStart(2, "0"))
.join("");
}
export async function cognitoEmailSignIn(email: string, clientId: string) { export async function cognitoEmailSignIn(email: string, clientId: string) {
const cognitoUser = await Auth.signIn(`${email}:email:${clientId}`); const cognitoUser = await Auth.signIn(`${email}:email:${clientId}`);
return cognitoUser; return cognitoUser;
@@ -127,15 +127,16 @@ async function getRecoveryCode(
storedToken.authDetails.recoveryShareManagement === storedToken.authDetails.recoveryShareManagement ===
RecoveryShareManagement.CLOUD_MANAGED RecoveryShareManagement.CLOUD_MANAGED
) { ) {
if (storedToken.authProvider === AuthProvider.CUSTOM_JWT) { if (
// derive sub here storedToken.authProvider === AuthProvider.CUSTOM_JWT ||
const code = extractSubFromJwt(storedToken.jwtToken); storedToken.authProvider === AuthProvider.CUSTOM_AUTH_ENDPOINT
if (!code) { ) {
if (!recoveryCode) {
throw new Error( throw new Error(
`GetRecoveryCode error: ${ErrorMessages.missingRecoveryCode}`, `GetRecoveryCode error: ${ErrorMessages.missingRecoveryCode}`,
); );
} }
return code; return recoveryCode;
} else { } else {
try { try {
const code = await getCognitoRecoveryPassword(clientId); const code = await getCognitoRecoveryPassword(clientId);
@@ -156,25 +157,3 @@ async function getRecoveryCode(
throw new Error("Invalid recovery share management option"); throw new Error("Invalid recovery share management option");
} }
} }
function extractSubFromJwt(jwtToken: string): string | undefined {
const parts = jwtToken.split(".");
if (parts.length !== 3) {
throw new Error("Invalid JWT format.");
}
const encodedPayload = parts[1];
if (!encodedPayload) {
throw new Error("Invalid JWT format.");
}
const decodedPayload = Buffer.from(encodedPayload, "base64").toString("utf8");
try {
const payloadObject = JSON.parse(decodedPayload);
if (payloadObject && payloadObject.sub) {
return payloadObject.sub;
}
} catch (error) {
throw new Error("Error parsing JWT payload as JSON.");
}
}
@@ -13,6 +13,7 @@ export const RECOVERY_SHARE_INDEX = RECOVERY_SHARE_ID - 1;
export const AWS_REGION = "us-west-2"; export const AWS_REGION = "us-west-2";
export const EWS_VERSION_HEADER = "x-embedded-wallet-version"; export const EWS_VERSION_HEADER = "x-embedded-wallet-version";
export const THIRDWEB_SESSION_NONCE_HEADER = "x-session-nonce";
export const COGNITO_USER_POOL_ID = "us-west-2_UFwLcZIpq"; export const COGNITO_USER_POOL_ID = "us-west-2_UFwLcZIpq";
export const COGNITO_APP_CLIENT_ID = "2e02ha2ce6du13ldk8pai4h3d0"; export const COGNITO_APP_CLIENT_ID = "2e02ha2ce6du13ldk8pai4h3d0";
@@ -33,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_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_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_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_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`; export const ROUTE_VALIDATE_USER_MANAGED_OTP = `${ROUTE_2023_10_20_API_BASE_PATH}/embedded-wallet/validate-thirdweb-email-otp`;
@@ -11,3 +11,10 @@ export function getRandomValues<T extends IntArrayBufferView>(array: T): T {
// @ts-ignore getRandomValues is polyfilled // @ts-ignore getRandomValues is polyfilled
return crypto.getRandomValues(array); return crypto.getRandomValues(array);
} }
export function getRandomString(bytes: number) {
const randomValues = getRandomValues(new Uint8Array(bytes));
return Array.from(randomValues)
.map((nr) => nr.toString(16).padStart(2, "0"))
.join("");
}
@@ -44,6 +44,11 @@ export interface AuthOptions {
password: string; password: string;
} }
export interface AuthEndpointOptions {
payload: string;
encryptionKey: string;
}
export type SendEmailOtpReturnType = { export type SendEmailOtpReturnType = {
isNewUser: boolean; isNewUser: boolean;
isNewDevice: boolean; isNewDevice: boolean;
@@ -70,14 +75,21 @@ type SocialAuthParams = {
type JwtAuthParams = { type JwtAuthParams = {
strategy: "jwt"; strategy: "jwt";
jwt: string; jwt: string;
encryptionKey?: string; encryptionKey: string;
};
type AuthEndpointParams = {
strategy: "auth_endpoint";
payload: string;
encryptionKey: string;
}; };
// this is the input to 'authenticate' // this is the input to 'authenticate'
export type AuthParams = export type AuthParams =
| EmailVerificationAuthParams | EmailVerificationAuthParams
| SocialAuthParams | SocialAuthParams
| JwtAuthParams; | JwtAuthParams
| AuthEndpointParams;
// TODO typed based off AuthParams["strategy"] // TODO typed based off AuthParams["strategy"]
export type AuthResult = { 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?: { export const coinbaseWallet = (config?: {
callbackURL?: URL; callbackURL?: URL;
recommended?: boolean; recommended?: boolean;
@@ -13,6 +13,8 @@ import {
import { EMAIL_WALLET_ICON } from "../../../assets/svgs"; import { EMAIL_WALLET_ICON } from "../../../assets/svgs";
import { WalletMeta } from "@thirdweb-dev/wallets/dist/declarations/src/evm/wallets/base"; import { WalletMeta } from "@thirdweb-dev/wallets/dist/declarations/src/evm/wallets/base";
import { AUTH_OPTIONS_ICONS } from "../../types/embedded-wallet"; import { AUTH_OPTIONS_ICONS } from "../../types/embedded-wallet";
import { getRandomString } from "../../connectors/embedded-wallet/embedded/helpers/getRandomValues";
import { ANALYTICS } from "../../connectors/embedded-wallet/embedded/helpers/analytics";
export type EmbeddedWalletOptions = WalletOptions< export type EmbeddedWalletOptions = WalletOptions<
EmbeddedWalletAdditionalOptions & WalletConnectReceiverConfig EmbeddedWalletAdditionalOptions & WalletConnectReceiverConfig
@@ -103,6 +105,7 @@ export class EmbeddedWallet extends AbstractClientWallet<
onDisconnect = () => { onDisconnect = () => {
this.removeListeners(); this.removeListeners();
ANALYTICS.nonce = getRandomString(16);
}; };
onChange = async (payload: any) => { onChange = async (payload: any) => {
@@ -3,6 +3,24 @@ import { WalletOptions, walletIds } from "@thirdweb-dev/wallets";
import { createSecureStorage } from "../../../core/SecureStorage"; import { createSecureStorage } from "../../../core/SecureStorage";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage"; 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 = () => { export const localWallet = () => {
const secureStorage = createSecureStorage(walletIds.localWallet); const secureStorage = createSecureStorage(walletIds.localWallet);
const asyncStorage = createAsyncLocalStorage(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) => { export const metamaskWallet = (config?: WalletConnectConfig) => {
return { return {
id: MetaMaskWallet.id, 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) => { export const rainbowWallet = (config?: WalletConnectConfig) => {
return { return {
id: RainbowWallet.id, id: RainbowWallet.id,
@@ -3,6 +3,28 @@ import { SmartWallet, createAsyncLocalStorage } from "@thirdweb-dev/wallets";
import { SmartWalletConfig } from "../types/smart-wallet"; import { SmartWalletConfig } from "../types/smart-wallet";
import { SmartWalletFlow } from "../../components/ConnectWalletFlow/SmartWallet/SmartWalletFlow"; 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 = ( export const smartWallet = (
wallet: WalletConfig<any>, wallet: WalletConfig<any>,
config: SmartWalletConfig, 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) => { export const trustWallet = (config?: WalletConnectConfig) => {
return { return {
id: TrustWallet.id, id: TrustWallet.id,
@@ -41,8 +41,9 @@ const MODAL_HEIGHT = Dimensions.get("window").height * 0.5;
export function WalletConnectUI({ export function WalletConnectUI({
connected, connected,
walletConfig, walletConfig,
goBack,
projectId, projectId,
goBack,
supportedWallets,
}: ConnectUIProps<WalletConnect> & { projectId: string }) { }: ConnectUIProps<WalletConnect> & { projectId: string }) {
const l = useLocale(); const l = useLocale();
const theme = useGlobalTheme(); const theme = useGlobalTheme();
@@ -163,7 +164,7 @@ export function WalletConnectUI({
style={[styles.modal, { backgroundColor: theme.colors.background }]} style={[styles.modal, { backgroundColor: theme.colors.background }]}
> >
<ModalHeaderTextClose <ModalHeaderTextClose
onBackPress={goBack} onBackPress={supportedWallets.length === 1 ? undefined : goBack}
headerText="WalletConnect" headerText="WalletConnect"
onClose={onClosePress} onClose={onClosePress}
paddingHorizontal="md" paddingHorizontal="md"
@@ -9,6 +9,22 @@ export type WalletConnectConfig = {
recommended?: boolean; 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 = ( export const walletConnect = (
config?: WalletConnectConfig, config?: WalletConnectConfig,
): WalletConfig<WalletConnect> => { ): WalletConfig<WalletConnect> => {
+26
View File
@@ -1,5 +1,31 @@
# @thirdweb-dev/react # @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
- Updated dependencies [[`33c9f6b1`](https://github.com/thirdweb-dev/js/commit/33c9f6b1ab3e65187b2c49c083412d39a1334bba), [`de5ebc90`](https://github.com/thirdweb-dev/js/commit/de5ebc9093aaf5fc08bc0d2d414138b520fe17fe), [`e10173bf`](https://github.com/thirdweb-dev/js/commit/e10173bf8aeaaabdb45231109b4da0c52c91b9da), [`09bafa9a`](https://github.com/thirdweb-dev/js/commit/09bafa9aebadb01641214747148c67d0b39c1275)]:
- @thirdweb-dev/wallets@2.3.0
- @thirdweb-dev/react-core@4.1.15
## 4.1.14
### Patch Changes
- Updated dependencies [[`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173)]:
- @thirdweb-dev/sdk@4.0.21
- @thirdweb-dev/react-core@4.1.14
- @thirdweb-dev/wallets@2.2.1
## 4.1.13 ## 4.1.13
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react", "name": "@thirdweb-dev/react",
"version": "4.1.13", "version": "4.1.16",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+21
View File
@@ -1,5 +1,26 @@
# @thirdweb-dev/sdk # @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
- [#2067](https://github.com/thirdweb-dev/js/pull/2067) [`bcfa9463`](https://github.com/thirdweb-dev/js/commit/bcfa9463bbae6bf1d3b6389b7a141f65ef3e1173) Thanks [@kumaryash90](https://github.com/kumaryash90)! - fix deployments
## 4.0.20 ## 4.0.20
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/sdk", "name": "@thirdweb-dev/sdk",
"version": "4.0.20", "version": "4.0.22",
"description": "The main thirdweb SDK.", "description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0", "license": "Apache-2.0",
+3
View File
@@ -1,3 +1,6 @@
/**
* @internal
*/
export function getRpcUrl(network: string, clientId?: string) { export function getRpcUrl(network: string, clientId?: string) {
return `https://${network}.rpc.thirdweb.com/${clientId || ""}`; return `https://${network}.rpc.thirdweb.com/${clientId || ""}`;
} }
+9 -1
View File
@@ -1,5 +1,13 @@
let alreadyChecked = false; let alreadyChecked = false;
export function checkClientIdOrSecretKey(message: string, clientId?: string, secretKey?: string) {
/**
* @internal
*/
export function checkClientIdOrSecretKey(
message: string,
clientId?: string,
secretKey?: string,
) {
if (alreadyChecked) { if (alreadyChecked) {
return; return;
} }
+3
View File
@@ -1,6 +1,9 @@
import { GENERATED_ABI } from "@thirdweb-dev/generated-abis"; import { GENERATED_ABI } from "@thirdweb-dev/generated-abis";
import { ContractInterface } from "ethers/lib/ethers"; import { ContractInterface } from "ethers/lib/ethers";
/**
* @internal
*/
export function getCachedAbiForContract( export function getCachedAbiForContract(
address: string, address: string,
): ContractInterface | undefined { ): ContractInterface | undefined {
@@ -4,7 +4,7 @@ import { getSaltHash } from "./getSaltHash";
/** /**
* Pre-compute a contract's deployment address for a CREATE2 deployment. * Pre-compute a contract's deployment address for a CREATE2 deployment.
* *
* @public * @internal
* @param bytecode - Creation bytecode of the contract to deploy * @param bytecode - Creation bytecode of the contract to deploy
* @param encodedArgs - Abi-encoded constructor params * @param encodedArgs - Abi-encoded constructor params
* @param create2FactoryAddress - The create2 factory address to use * @param create2FactoryAddress - The create2 factory address to use
@@ -23,6 +23,9 @@ import { extractConstructorParamsFromAbi } from "../feature-detection/extractCon
import { caches } from "./caches"; import { caches } from "./caches";
import { getRoyaltyEngineV1ByChainId } from "../../constants/royaltyEngine"; import { getRoyaltyEngineV1ByChainId } from "../../constants/royaltyEngine";
/**
* @internal
*/
export async function computeDeploymentInfo( export async function computeDeploymentInfo(
contractType: DeployedContractType, contractType: DeployedContractType,
provider: providers.Provider, provider: providers.Provider,
@@ -1,5 +1,11 @@
/**
* @internal
*/
export const CREATE2_FACTORY_BYTECODE = export const CREATE2_FACTORY_BYTECODE =
"0x604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"; "0x604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3";
/**
* @internal
*/
export const SIGNATURE = { export const SIGNATURE = {
v: 27, v: 27,
r: "0x2222222222222222222222222222222222222222222222222222222222222222", r: "0x2222222222222222222222222222222222222222222222222222222222222222",
@@ -7,9 +13,18 @@ export const SIGNATURE = {
}; };
export const COMMON_FACTORY = "0x4e59b44847b379578588920cA78FbF26c0B4956C"; // for pre-eip-155 supporting chains export const COMMON_FACTORY = "0x4e59b44847b379578588920cA78FbF26c0B4956C"; // for pre-eip-155 supporting chains
/**
* @internal
*/
export const GAS_LIMIT_FOR_DEPLOYER = 5000000; export const GAS_LIMIT_FOR_DEPLOYER = 5000000;
/**
* @internal
*/
export const DEPLOYER_BYTECODE = export const DEPLOYER_BYTECODE =
"0x60806040526040516107f33803806107f383398101604081905261002291610359565b805160005b818110156100c157828181518110610041576100416104c9565b6020026020010151600001516001600160a01b03163b600014156100af576100ad838281518110610074576100746104c9565b602002602001015160200151848381518110610092576100926104c9565b6020026020010151604001516100c960201b6100091760201c565b505b806100b9816104df565b915050610027565b505050610557565b606061011183836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061011860201b60201c565b9392505050565b6060610127848460008561012f565b949350505050565b6060824710156101955760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101ec5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161018c565b600080866001600160a01b031685876040516102089190610508565b60006040518083038185875af1925050503d8060008114610245576040519150601f19603f3d011682016040523d82523d6000602084013e61024a565b606091505b50909250905061025b828286610266565b979650505050505050565b60608315610275575081610111565b8251156102855782518084602001fd5b8160405162461bcd60e51b815260040161018c9190610524565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156102d7576102d761029f565b60405290565b604051601f8201601f191681016001600160401b03811182821017156103055761030561029f565b604052919050565b80516001600160a01b038116811461032457600080fd5b919050565b60005b8381101561034457818101518382015260200161032c565b83811115610353576000848401525b50505050565b6000602080838503121561036c57600080fd5b82516001600160401b038082111561038357600080fd5b818501915085601f83011261039757600080fd5b8151818111156103a9576103a961029f565b8060051b6103b88582016102dd565b91825283810185019185810190898411156103d257600080fd5b86860192505b838310156104bc578251858111156103f05760008081fd5b86016060601f19828d0381018213156104095760008081fd5b6104116102b5565b61041c8b850161030d565b8152604061042b81860161030d565b828d01529284015192898411156104425760008081fd5b83850194508e603f86011261045957600093508384fd5b8b85015193508984111561046f5761046f61029f565b61047f8c84601f870116016102dd565b92508383528e818587010111156104965760008081fd5b6104a5848d8501838801610329565b8101919091528452505091860191908601906103d8565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561050157634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825161051a818460208701610329565b9190910192915050565b6020815260008251806020840152610543816040850160208701610329565b601f01601f19169190910160400192915050565b61028d806105666000396000f3fe6080604052600080fd5b606061004b83836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610052565b9392505050565b60606100618484600085610069565b949350505050565b6060824710156100cf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101265760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016100c6565b600080866001600160a01b031685876040516101429190610208565b60006040518083038185875af1925050503d806000811461017f576040519150601f19603f3d011682016040523d82523d6000602084013e610184565b606091505b509150915061019482828661019f565b979650505050505050565b606083156101ae57508161004b565b8251156101be5782518084602001fd5b8160405162461bcd60e51b81526004016100c69190610224565b60005b838110156101f35781810151838201526020016101db565b83811115610202576000848401525b50505050565b6000825161021a8184602087016101d8565b9190910192915050565b60208152600082518060208401526102438160408501602087016101d8565b601f01601f1916919091016040019291505056fea26469706673582212200b524eb8ceaafe6c603273ee859fddbc2d6f1b7860c3d853dcf6f129f9d9371364736f6c634300080c0033"; "0x60806040526040516107f33803806107f383398101604081905261002291610359565b805160005b818110156100c157828181518110610041576100416104c9565b6020026020010151600001516001600160a01b03163b600014156100af576100ad838281518110610074576100746104c9565b602002602001015160200151848381518110610092576100926104c9565b6020026020010151604001516100c960201b6100091760201c565b505b806100b9816104df565b915050610027565b505050610557565b606061011183836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061011860201b60201c565b9392505050565b6060610127848460008561012f565b949350505050565b6060824710156101955760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101ec5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161018c565b600080866001600160a01b031685876040516102089190610508565b60006040518083038185875af1925050503d8060008114610245576040519150601f19603f3d011682016040523d82523d6000602084013e61024a565b606091505b50909250905061025b828286610266565b979650505050505050565b60608315610275575081610111565b8251156102855782518084602001fd5b8160405162461bcd60e51b815260040161018c9190610524565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156102d7576102d761029f565b60405290565b604051601f8201601f191681016001600160401b03811182821017156103055761030561029f565b604052919050565b80516001600160a01b038116811461032457600080fd5b919050565b60005b8381101561034457818101518382015260200161032c565b83811115610353576000848401525b50505050565b6000602080838503121561036c57600080fd5b82516001600160401b038082111561038357600080fd5b818501915085601f83011261039757600080fd5b8151818111156103a9576103a961029f565b8060051b6103b88582016102dd565b91825283810185019185810190898411156103d257600080fd5b86860192505b838310156104bc578251858111156103f05760008081fd5b86016060601f19828d0381018213156104095760008081fd5b6104116102b5565b61041c8b850161030d565b8152604061042b81860161030d565b828d01529284015192898411156104425760008081fd5b83850194508e603f86011261045957600093508384fd5b8b85015193508984111561046f5761046f61029f565b61047f8c84601f870116016102dd565b92508383528e818587010111156104965760008081fd5b6104a5848d8501838801610329565b8101919091528452505091860191908601906103d8565b9998505050505050505050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561050157634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825161051a818460208701610329565b9190910192915050565b6020815260008251806020840152610543816040850160208701610329565b601f01601f19169190910160400192915050565b61028d806105666000396000f3fe6080604052600080fd5b606061004b83836040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610052565b9392505050565b60606100618484600085610069565b949350505050565b6060824710156100cf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084015b60405180910390fd5b6001600160a01b0385163b6101265760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016100c6565b600080866001600160a01b031685876040516101429190610208565b60006040518083038185875af1925050503d806000811461017f576040519150601f19603f3d011682016040523d82523d6000602084013e610184565b606091505b509150915061019482828661019f565b979650505050505050565b606083156101ae57508161004b565b8251156101be5782518084602001fd5b8160405162461bcd60e51b81526004016100c69190610224565b60005b838110156101f35781810151838201526020016101db565b83811115610202576000848401525b50505050565b6000825161021a8184602087016101d8565b9190910192915050565b60208152600082518060208401526102438160408501602087016101d8565b601f01601f1916919091016040019291505056fea26469706673582212200b524eb8ceaafe6c603273ee859fddbc2d6f1b7860c3d853dcf6f129f9d9371364736f6c634300080c0033";
/**
* @internal
*/
export const DEPLOYER_ABI = [ export const DEPLOYER_ABI = [
{ {
inputs: [ inputs: [
@@ -1,6 +1,9 @@
import { BigNumber, utils } from "ethers"; import { BigNumber, utils } from "ethers";
import invariant from "tiny-invariant"; import invariant from "tiny-invariant";
/**
* @internal
*/
export function convertParamValues( export function convertParamValues(
constructorParamTypes: string[], constructorParamTypes: string[],
constructorParamValues: any[], constructorParamValues: any[],
@@ -2,6 +2,9 @@ import { PrecomputedDeploymentTransaction } from "../../types/any-evm/deploy-dat
import { GAS_LIMIT_FOR_DEPLOYER } from "./constants"; import { GAS_LIMIT_FOR_DEPLOYER } from "./constants";
import { estimateGasForDeploy } from "./estimateGasForDeploy"; import { estimateGasForDeploy } from "./estimateGasForDeploy";
/**
* @internal
*/
export function createTransactionBatches( export function createTransactionBatches(
transactions: PrecomputedDeploymentTransaction[], transactions: PrecomputedDeploymentTransaction[],
upperGasLimit: number = GAS_LIMIT_FOR_DEPLOYER, upperGasLimit: number = GAS_LIMIT_FOR_DEPLOYER,
@@ -8,7 +8,7 @@ import { isContractDeployed } from "./isContractDeployed";
* Deploy a contract at a deterministic address, using Create2 method * Deploy a contract at a deterministic address, using Create2 method
* Address depends on the Create2 factory address. * Address depends on the Create2 factory address.
* *
* @public * @internal
* *
* @param signer - The signer to use * @param signer - The signer to use
* @param bytecode - The bytecode to deploy * @param bytecode - The bytecode to deploy
@@ -13,7 +13,7 @@ import { getInitBytecodeWithSalt } from "./getInitBytecodeWithSalt";
* Deploy a contract at a deterministic address, using Create2 method * Deploy a contract at a deterministic address, using Create2 method
* Address depends on the Create2 factory address. * Address depends on the Create2 factory address.
* *
* @public * @internal
* *
* @param signer - The signer to use * @param signer - The signer to use
* @param bytecode - The bytecode to deploy * @param bytecode - The bytecode to deploy
@@ -4,6 +4,9 @@ import type { DeployOptions } from "../../types/deploy/deploy-options";
import { DEPLOYER_ABI, DEPLOYER_BYTECODE } from "./constants"; import { DEPLOYER_ABI, DEPLOYER_BYTECODE } from "./constants";
import { createTransactionBatches } from "./createTransactionBatches"; import { createTransactionBatches } from "./createTransactionBatches";
/**
* @internal
*/
export async function deployWithThrowawayDeployer( export async function deployWithThrowawayDeployer(
signer: Signer, signer: Signer,
transactions: PrecomputedDeploymentTransaction[], transactions: PrecomputedDeploymentTransaction[],
@@ -1,5 +1,8 @@
import { utils } from "ethers"; import { utils } from "ethers";
/**
* @internal
*/
export function estimateGasForDeploy(initCode: string) { export function estimateGasForDeploy(initCode: string) {
let gasLimit = let gasLimit =
utils utils
@@ -5,6 +5,9 @@ import type { DeployMetadata } from "../../types/deploy/deploy-options";
const deployMetadataCache: Record<string, any> = {}; const deployMetadataCache: Record<string, any> = {};
/**
* @internal
*/
export async function fetchAndCacheDeployMetadata( export async function fetchAndCacheDeployMetadata(
publishMetadataUri: string, publishMetadataUri: string,
storage: ThirdwebStorage, storage: ThirdwebStorage,
@@ -13,6 +13,9 @@ import { PublishedContractSchema } from "../../schema/contracts/custom";
export const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024"; export const THIRDWEB_DEPLOYER = "0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
/**
* @internal
*/
export async function fetchPublishedContractFromPolygon( export async function fetchPublishedContractFromPolygon(
publisherAddress: AddressOrEns, publisherAddress: AddressOrEns,
contractName: string, contractName: string,
@@ -5,7 +5,7 @@ import { getKeylessTxn } from "./getKeylessTxn";
/** /**
* *
* @public * @internal
* @param transaction - Unsigned transaction object * @param transaction - Unsigned transaction object
* @param signature - Signature bytes * @param signature - Signature bytes
*/ */
@@ -3,7 +3,7 @@ import { providers } from "ethers";
/** /**
* Check if a contract exists at the given address * Check if a contract exists at the given address
* *
* @internal * @public
* @param address - The address to check * @param address - The address to check
* @param provider - The provider to use * @param provider - The provider to use
*/ */
@@ -1,5 +1,5 @@
import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency"; import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { Address } from "../../schema/shared/Address"; import { Address } from "../../schema/shared/Address";
import type { Price } from "../../types/currency"; import type { Price } from "../../types/currency";
import { BigNumberish, CallOverrides } from "ethers"; import { BigNumberish, CallOverrides } from "ethers";
@@ -9,6 +9,9 @@ import {
import { ThirdwebStorage } from "@thirdweb-dev/storage"; import { ThirdwebStorage } from "@thirdweb-dev/storage";
import type { providers } from "ethers"; import type { providers } from "ethers";
/**
* @internal
*/
export async function fetchSnapshotEntryForAddress( export async function fetchSnapshotEntryForAddress(
address: string, address: string,
merkleRoot: string, merkleRoot: string,
@@ -1,4 +1,4 @@
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import type { import type {
ClaimCondition, ClaimCondition,
ClaimVerification, ClaimVerification,
@@ -1,7 +1,10 @@
import type { IERC20 } from "@thirdweb-dev/contracts-js"; import type { IERC20 } from "@thirdweb-dev/contracts-js";
import { BigNumber, utils, type BigNumberish } from "ethers"; import { BigNumber, utils, type BigNumberish } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
/**
* @internal
*/
export async function approveErc20Allowance( export async function approveErc20Allowance(
contractToApprove: ContractWrapper<any>, contractToApprove: ContractWrapper<any>,
currencyAddress: string, currencyAddress: string,
@@ -1,6 +1,9 @@
import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency"; import { NATIVE_TOKEN_ADDRESS } from "../../constants/currency";
import { isNativeToken } from "./isNativeToken"; import { isNativeToken } from "./isNativeToken";
/**
* @internal
*/
export function cleanCurrencyAddress(currencyAddress: string): string { export function cleanCurrencyAddress(currencyAddress: string): string {
if (isNativeToken(currencyAddress)) { if (isNativeToken(currencyAddress)) {
return NATIVE_TOKEN_ADDRESS; return NATIVE_TOKEN_ADDRESS;
@@ -1,7 +1,10 @@
import type { IERC20 } from "@thirdweb-dev/contracts-js"; import type { IERC20 } from "@thirdweb-dev/contracts-js";
import { BigNumber } from "ethers"; import { BigNumber } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
/**
* @internal
*/
export async function hasERC20Allowance( export async function hasERC20Allowance(
contractToApprove: ContractWrapper<any>, contractToApprove: ContractWrapper<any>,
currencyAddress: string, currencyAddress: string,
@@ -1,9 +1,12 @@
import { BigNumber, utils } from "ethers"; import { BigNumber, utils } from "ethers";
import { AmountSchema } from "../../../core/schema/shared"; import { AmountSchema } from "../../../core/schema/shared";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { Amount } from "../../types/currency"; import { Amount } from "../../types/currency";
import { BaseERC20 } from "../../types/eips"; import { BaseERC20 } from "../../types/eips";
/**
* @internal
*/
export async function normalizeAmount( export async function normalizeAmount(
contractWrapper: ContractWrapper<BaseERC20>, contractWrapper: ContractWrapper<BaseERC20>,
amount: Amount, amount: Amount,
@@ -1,8 +1,11 @@
import type { IERC20 } from "@thirdweb-dev/contracts-js"; import type { IERC20 } from "@thirdweb-dev/contracts-js";
import { BigNumber } from "ethers"; import { BigNumber } from "ethers";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { isNativeToken } from "./isNativeToken"; import { isNativeToken } from "./isNativeToken";
/**
* @internal
*/
export async function setErc20Allowance( export async function setErc20Allowance(
contractToApprove: ContractWrapper<any>, contractToApprove: ContractWrapper<any>,
value: BigNumber, value: BigNumber,
@@ -11,6 +11,9 @@ let provider: providers.Provider | undefined;
const ENS_CACHE = new Map<string, Promise<CachedEns>>(); const ENS_CACHE = new Map<string, Promise<CachedEns>>();
/**
* @internal
*/
export async function resolveEns( export async function resolveEns(
ens: string, ens: string,
depth = 0, depth = 0,
@@ -1,5 +1,5 @@
import { FeatureName } from "../../constants/contract-features"; import { FeatureName } from "../../constants/contract-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { AbiSchema } from "../../schema/contracts/custom"; import { AbiSchema } from "../../schema/contracts/custom";
import { BaseContract } from "ethers"; import { BaseContract } from "ethers";
import { isExtensionEnabled } from "./isFeatureEnabled"; import { isExtensionEnabled } from "./isFeatureEnabled";
@@ -31,6 +31,9 @@ export function detectFeatures(
return results; return results;
} }
/**
* @internal
*/
export function detectFeaturesFromBytecode( export function detectFeaturesFromBytecode(
bytecode: string, bytecode: string,
features: Record<string, Feature> = SUPPORTED_FEATURES, features: Record<string, Feature> = SUPPORTED_FEATURES,
@@ -20,6 +20,9 @@ export function getAllDetectedFeatures(abi: AbiInput): FeatureWithEnabled[] {
return features; return features;
} }
/**
* @internal
*/
export function getAllDetectedExtensionsFromBytecode( export function getAllDetectedExtensionsFromBytecode(
bytecode: string, bytecode: string,
): FeatureWithEnabled[] { ): FeatureWithEnabled[] {
@@ -28,6 +31,9 @@ export function getAllDetectedExtensionsFromBytecode(
return features; return features;
} }
/**
* @internal
*/
export function constructAbiFromBytecode(bytecode: string): AbiInput { export function constructAbiFromBytecode(bytecode: string): AbiInput {
let extensions = getAllDetectedExtensionsFromBytecode(bytecode); let extensions = getAllDetectedExtensionsFromBytecode(bytecode);
// special deduping for ERC721 and ERC20 // special deduping for ERC721 and ERC20
@@ -1,4 +1,4 @@
import type { ContractWrapper } from "../../core/classes/contract-wrapper"; import type { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import type { BaseContract } from "ethers"; import type { BaseContract } from "ethers";
/** /**
@@ -40,6 +40,9 @@ export function hasMatchingAbi(
return intersection.length === interfaceFn.length; return intersection.length === interfaceFn.length;
} }
/**
* @internal
*/
export function matchesAbiFromBytecode( export function matchesAbiFromBytecode(
contractBytecode: string, contractBytecode: string,
featureAbis: readonly AbiInput[], featureAbis: readonly AbiInput[],
@@ -10,6 +10,7 @@ import { detectFeatures } from "./detectFeatures";
* @deprecated use isExtensionEnabled instead * @deprecated use isExtensionEnabled instead
* @param abi - The abi to check * @param abi - The abi to check
* @param featureName - The feature name to check * @param featureName - The feature name to check
* @internal
*/ */
export function isFeatureEnabled( export function isFeatureEnabled(
abi: AbiInput, abi: AbiInput,
@@ -1,4 +1,4 @@
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { AbiInput, AbiSchema } from "../../schema/contracts/custom"; import { AbiInput, AbiSchema } from "../../schema/contracts/custom";
import { BaseContract } from "ethers"; import { BaseContract } from "ethers";
import { hasMatchingAbi } from "./hasMatchingAbi"; import { hasMatchingAbi } from "./hasMatchingAbi";
@@ -15,6 +15,9 @@ export async function resolveContractUriFromAddress(
return extractIPFSHashFromBytecode(bytecode); return extractIPFSHashFromBytecode(bytecode);
} }
/**
* @internal
*/
export async function resolveContractUriAndBytecode( export async function resolveContractUriAndBytecode(
address: string, address: string,
provider: providers.Provider, provider: providers.Provider,
@@ -28,6 +28,9 @@ export async function fetchContractMetadata(
return formatCompilerMetadata(metadata); return formatCompilerMetadata(metadata);
} }
/**
* @internal
*/
export function formatCompilerMetadata(metadata: any): PublishedMetadata { export function formatCompilerMetadata(metadata: any): PublishedMetadata {
const abi = AbiSchema.parse(metadata.output.abi); const abi = AbiSchema.parse(metadata.output.abi);
const compilationTarget = metadata.settings.compilationTarget; const compilationTarget = metadata.settings.compilationTarget;
+1 -1
View File
@@ -13,7 +13,7 @@ import {
InterfaceId_IERC1155, InterfaceId_IERC1155,
InterfaceId_IERC721, InterfaceId_IERC721,
} from "../constants/contract"; } from "../constants/contract";
import { ContractWrapper } from "../core/classes/contract-wrapper"; import { ContractWrapper } from "../core/classes/internal/contract-wrapper";
import { fetchCurrencyValue } from "./currency/fetchCurrencyValue"; import { fetchCurrencyValue } from "./currency/fetchCurrencyValue";
import { NewDirectListing } from "../types/marketplace/NewDirectListing"; import { NewDirectListing } from "../types/marketplace/NewDirectListing";
import { NewAuctionListing } from "../types/marketplace/NewAuctionListing"; import { NewAuctionListing } from "../types/marketplace/NewAuctionListing";
@@ -32,6 +32,9 @@ function putInCache(
metadataCache[getCacheKey(address, chainId)] = metadata; metadataCache[getCacheKey(address, chainId)] = metadata;
} }
/**
* @internal
*/
export function getContractMetadataFromCache( export function getContractMetadataFromCache(
address: string, address: string,
chainId: number, chainId: number,
@@ -96,6 +99,9 @@ export async function fetchContractMetadataFromAddress(
return metadata; return metadata;
} }
/**
* @internal
*/
export async function fetchContractMetadataFromBytecode( export async function fetchContractMetadataFromBytecode(
address: Address, address: Address,
chainId: number, chainId: number,
@@ -2,7 +2,7 @@ import {
getAllExtensionsAbi, getAllExtensionsAbi,
getAllPluginsAbi, getAllPluginsAbi,
} from "../../constants/thirdweb-features"; } from "../../constants/thirdweb-features";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { Abi, AbiSchema } from "../../schema/contracts/custom"; import { Abi, AbiSchema } from "../../schema/contracts/custom";
import { SDKOptions } from "../../schema/sdk-options"; import { SDKOptions } from "../../schema/sdk-options";
import { isExtensionEnabled } from "../feature-detection/isFeatureEnabled"; import { isExtensionEnabled } from "../feature-detection/isFeatureEnabled";
@@ -58,6 +58,9 @@ export function isIncrementalVersion(current: string, next: string) {
return eqMajor && eqMinor && nextSemver.patch > currentSemver.patch; return eqMajor && eqMinor && nextSemver.patch > currentSemver.patch;
} }
/**
* @internal
*/
export function isDowngradeVersion(current: string, next: string) { export function isDowngradeVersion(current: string, next: string) {
const currentSemver = toSemver(current); const currentSemver = toSemver(current);
const nextSemver = toSemver(next); const nextSemver = toSemver(next);
+19
View File
@@ -79,6 +79,9 @@ export function getChainProvider(
return getProviderFromRpcUrl(rpcUrl, sdkOptions, chainId); return getProviderFromRpcUrl(rpcUrl, sdkOptions, chainId);
} }
/**
* @internal
*/
export function getChainIdFromNetwork( export function getChainIdFromNetwork(
network: ChainOrRpcUrl, network: ChainOrRpcUrl,
options: SDKOptionsOutput, options: SDKOptionsOutput,
@@ -109,6 +112,9 @@ export function getChainIdFromNetwork(
); );
} }
/**
* @internal
*/
export async function getChainIdOrName( export async function getChainIdOrName(
network: NetworkInput, network: NetworkInput,
): Promise<number | string> { ): Promise<number | string> {
@@ -134,6 +140,7 @@ export async function getChainIdOrName(
/** /**
* Check whether a NetworkInput value is a Chain config (naively, without parsing) * Check whether a NetworkInput value is a Chain config (naively, without parsing)
* @internal
*/ */
export function isChainConfig( export function isChainConfig(
network: NetworkInput, network: NetworkInput,
@@ -278,6 +285,16 @@ export function getProviderFromRpcUrl(
return 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 // Otherwise, create a new provider on the specific network
const newProvider = chainId const newProvider = chainId
? // If we know the chainId we should use the StaticJsonRpcBatchProvider ? // If we know the chainId we should use the StaticJsonRpcBatchProvider
@@ -285,6 +302,7 @@ export function getProviderFromRpcUrl(
{ {
url: rpcUrl, url: rpcUrl,
headers, headers,
skipFetchSetup: _skipFetchSetup,
}, },
chainId, chainId,
) )
@@ -292,6 +310,7 @@ export function getProviderFromRpcUrl(
new providers.JsonRpcBatchProvider({ new providers.JsonRpcBatchProvider({
url: rpcUrl, url: rpcUrl,
headers, headers,
skipFetchSetup: _skipFetchSetup,
}); });
// Save the provider in our cache // Save the provider in our cache
+72 -5
View File
@@ -60,6 +60,9 @@ type InitalizeParams = [
options?: SDKOptions, options?: SDKOptions,
]; ];
/**
* @internal
*/
export const EditionDropInitializer = { export const EditionDropInitializer = {
name: "DropERC1155" as const, name: "DropERC1155" as const,
contractType: prebuiltContractTypes["edition-drop"], contractType: prebuiltContractTypes["edition-drop"],
@@ -106,6 +109,9 @@ export const EditionDropInitializer = {
}, },
}; };
/**
* @internal
*/
export const EditionInitializer = { export const EditionInitializer = {
name: "TokenERC1155" as const, name: "TokenERC1155" as const,
contractType: prebuiltContractTypes["edition"], contractType: prebuiltContractTypes["edition"],
@@ -146,6 +152,9 @@ export const EditionInitializer = {
}, },
}; };
/**
* @internal
*/
export const MarketplaceInitializer = { export const MarketplaceInitializer = {
name: "Marketplace" as const, name: "Marketplace" as const,
contractType: prebuiltContractTypes.marketplace, contractType: prebuiltContractTypes.marketplace,
@@ -187,6 +196,9 @@ export const MarketplaceInitializer = {
}, },
}; };
/**
* @internal
*/
export const MarketplaceV3Initializer = { export const MarketplaceV3Initializer = {
name: "MarketplaceV3" as const, name: "MarketplaceV3" as const,
contractType: prebuiltContractTypes["marketplace-v3"], contractType: prebuiltContractTypes["marketplace-v3"],
@@ -256,6 +268,9 @@ export const MarketplaceV3Initializer = {
}, },
}; };
/**
* @internal
*/
export const MultiwrapInitializer = { export const MultiwrapInitializer = {
name: "Multiwrap" as const, name: "Multiwrap" as const,
contractType: prebuiltContractTypes.multiwrap, contractType: prebuiltContractTypes.multiwrap,
@@ -295,6 +310,9 @@ export const MultiwrapInitializer = {
}, },
}; };
/**
* @internal
*/
export const NFTCollectionInitializer = { export const NFTCollectionInitializer = {
name: "TokenERC721" as const, name: "TokenERC721" as const,
contractType: prebuiltContractTypes["nft-collection"], contractType: prebuiltContractTypes["nft-collection"],
@@ -336,6 +354,9 @@ export const NFTCollectionInitializer = {
}, },
}; };
/**
* @internal
*/
export const NFTDropInitializer = { export const NFTDropInitializer = {
name: "DropERC721" as const, name: "DropERC721" as const,
contractType: prebuiltContractTypes["nft-drop"], contractType: prebuiltContractTypes["nft-drop"],
@@ -382,6 +403,9 @@ export const NFTDropInitializer = {
}, },
}; };
/**
* @internal
*/
export const PackInitializer = { export const PackInitializer = {
name: "Pack" as const, name: "Pack" as const,
contractType: prebuiltContractTypes["pack"], contractType: prebuiltContractTypes["pack"],
@@ -424,6 +448,9 @@ export const PackInitializer = {
}, },
}; };
/**
* @internal
*/
export const SignatureDropInitializer = { export const SignatureDropInitializer = {
name: "SignatureDrop" as const, name: "SignatureDrop" as const,
contractType: prebuiltContractTypes["signature-drop"], contractType: prebuiltContractTypes["signature-drop"],
@@ -474,6 +501,9 @@ export const SignatureDropInitializer = {
}, },
}; };
/**
* @internal
*/
export const SplitInitializer = { export const SplitInitializer = {
name: "Split" as const, name: "Split" as const,
contractType: prebuiltContractTypes["split"], contractType: prebuiltContractTypes["split"],
@@ -514,6 +544,9 @@ export const SplitInitializer = {
}, },
}; };
/**
* @internal
*/
export const TokenDropInitializer = { export const TokenDropInitializer = {
name: "DropERC20" as const, name: "DropERC20" as const,
contractType: prebuiltContractTypes["token-drop"], contractType: prebuiltContractTypes["token-drop"],
@@ -558,6 +591,9 @@ export const TokenDropInitializer = {
}, },
}; };
/**
* @internal
*/
export const TokenInitializer = { export const TokenInitializer = {
name: "TokenERC20" as const, name: "TokenERC20" as const,
contractType: prebuiltContractTypes.token, contractType: prebuiltContractTypes.token,
@@ -598,6 +634,9 @@ export const TokenInitializer = {
}, },
}; };
/**
* @internal
*/
export const VoteInitializer = { export const VoteInitializer = {
name: "VoteERC20" as const, name: "VoteERC20" as const,
contractType: prebuiltContractTypes.vote, contractType: prebuiltContractTypes.vote,
@@ -666,6 +705,9 @@ export const PREBUILT_CONTRACTS_MAP = /* @__PURE__ */ {
[prebuiltContractTypes.vote]: VoteInitializer, [prebuiltContractTypes.vote]: VoteInitializer,
} as const; } as const;
/**
* @internal
*/
export const PREBUILT_CONTRACTS_APPURI_MAP = /* @__PURE__ */ { export const PREBUILT_CONTRACTS_APPURI_MAP = /* @__PURE__ */ {
[prebuiltContractTypes["edition-drop"]]: [prebuiltContractTypes["edition-drop"]]:
"ipfs://QmNm3wRzpKYWo1SRtJfgfxtvudp5p2nXD6EttcsQJHwTmk", "ipfs://QmNm3wRzpKYWo1SRtJfgfxtvudp5p2nXD6EttcsQJHwTmk",
@@ -695,6 +737,9 @@ const SmartContract = {
roles: ALL_ROLES, roles: ALL_ROLES,
}; };
/**
* @internal
*/
export const CONTRACTS_MAP = /* @__PURE__ */ { export const CONTRACTS_MAP = /* @__PURE__ */ {
...PREBUILT_CONTRACTS_MAP, ...PREBUILT_CONTRACTS_MAP,
[SmartContract.contractType]: SmartContract, [SmartContract.contractType]: SmartContract,
@@ -710,6 +755,9 @@ export function getContractTypeForRemoteName(name: string): ContractType {
); );
} }
/**
* @internal
*/
export function getContractName( export function getContractName(
type: PrebuiltContractType, type: PrebuiltContractType,
): string | undefined { ): string | undefined {
@@ -718,28 +766,47 @@ export function getContractName(
)?.name; )?.name;
} }
/**
* @internal
*/
export type PrebuiltContractsMap = typeof PREBUILT_CONTRACTS_MAP; export type PrebuiltContractsMap = typeof PREBUILT_CONTRACTS_MAP;
/**
* @internal
*/
export type PrebuiltContractsInstances = { export type PrebuiltContractsInstances = {
[K in keyof PrebuiltContractsMap]: Awaited< [K in keyof PrebuiltContractsMap]: Awaited<
ReturnType<(typeof PREBUILT_CONTRACTS_MAP)[K]["initialize"]> ReturnType<(typeof PREBUILT_CONTRACTS_MAP)[K]["initialize"]>
>; >;
}; };
/**
* @internal
*/
export type ContractsMap = typeof CONTRACTS_MAP; export type ContractsMap = typeof CONTRACTS_MAP;
/**
* @internal
*/
export type ValidContractInstance = export type ValidContractInstance =
| Awaited<ReturnType<ContractsMap[keyof PrebuiltContractsMap]["initialize"]>> | Awaited<ReturnType<ContractsMap[keyof PrebuiltContractsMap]["initialize"]>>
| SmartContractType; | SmartContractType;
/**
* @internal
*/
export type SchemaForPrebuiltContractType< export type SchemaForPrebuiltContractType<
TContractType extends PrebuiltContractType, TContractType extends PrebuiltContractType,
> = PrebuiltContractsMap[TContractType]["schema"]; > = PrebuiltContractsMap[TContractType]["schema"];
/**
* @internal
*/
export type ContractForPrebuiltContractType< export type ContractForPrebuiltContractType<
TContractType extends PrebuiltContractType, TContractType extends PrebuiltContractType,
> = PrebuiltContractsInstances[TContractType]; > = PrebuiltContractsInstances[TContractType];
/**
* @internal
*/
export type ContractType = keyof ContractsMap; export type ContractType = keyof ContractsMap;
/**
* @internal
*/
export type DeploySchemaForPrebuiltContractType< export type DeploySchemaForPrebuiltContractType<
TContractType extends PrebuiltContractType, TContractType extends PrebuiltContractType,
> = SchemaForPrebuiltContractType<TContractType>["deploy"]; > = SchemaForPrebuiltContractType<TContractType>["deploy"];
@@ -14,10 +14,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { DropErc1155ClaimConditions } from "../../core/classes/drop-erc1155-claim-conditions"; import { DropErc1155ClaimConditions } from "../../core/classes/drop-erc1155-claim-conditions";
import { DropErc1155History } from "../../core/classes/drop-erc1155-history"; import { DropErc1155History } from "../../core/classes/internal/erc1155/drop-erc1155-history";
import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput, TransactionResultWithId } from "../../core/types"; import { NetworkInput, TransactionResultWithId } from "../../core/types";
@@ -42,14 +42,15 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "edition-drop"); * const contract = await sdk.getContract("{{contract_address}}", "edition-drop");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc1155 instead
*/ */
export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> { export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> {
private static contractRoles = NFT_BASE_CONTRACT_ROLES; private static contractRoles = NFT_BASE_CONTRACT_ROLES;
public abi: Abi; public abi: Abi;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltEditionDrop>; public platformFees: ContractPlatformFee;
public encoder: ContractEncoder<PrebuiltEditionDrop>; public encoder: ContractEncoder<PrebuiltEditionDrop>;
public estimator: GasCostEstimator<PrebuiltEditionDrop>; public estimator: GasCostEstimator<PrebuiltEditionDrop>;
public events: ContractEvents<PrebuiltEditionDrop>; public events: ContractEvents<PrebuiltEditionDrop>;
@@ -117,7 +118,7 @@ export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> {
public history: DropErc1155History; public history: DropErc1155History;
public interceptor: ContractInterceptor<PrebuiltEditionDrop>; public interceptor: ContractInterceptor<PrebuiltEditionDrop>;
public owner: ContractOwner<PrebuiltEditionDrop>; public owner: ContractOwner;
constructor( constructor(
network: NetworkInput, network: NetworkInput,
@@ -15,9 +15,9 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { Erc1155SignatureMintable } from "../../core/classes/erc-1155-signature-mintable"; import { Erc1155SignatureMintable } from "../../core/classes/erc-1155-signature-mintable";
import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput, TransactionResultWithId } from "../../core/types"; import { NetworkInput, TransactionResultWithId } from "../../core/types";
@@ -41,7 +41,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "edition"); * const contract = await sdk.getContract("{{contract_address}}", "edition");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc1155 instead
*/ */
export class Edition extends StandardErc1155<TokenERC1155> { export class Edition extends StandardErc1155<TokenERC1155> {
static contractRoles = NFT_BASE_CONTRACT_ROLES; static contractRoles = NFT_BASE_CONTRACT_ROLES;
@@ -57,7 +58,7 @@ export class Edition extends StandardErc1155<TokenERC1155> {
(typeof Edition.contractRoles)[number] (typeof Edition.contractRoles)[number]
>; >;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<TokenERC1155>; public platformFees: ContractPlatformFee;
public encoder: ContractEncoder<TokenERC1155>; public encoder: ContractEncoder<TokenERC1155>;
public estimator: GasCostEstimator<TokenERC1155>; public estimator: GasCostEstimator<TokenERC1155>;
public events: ContractEvents<TokenERC1155>; public events: ContractEvents<TokenERC1155>;
@@ -98,7 +99,7 @@ export class Edition extends StandardErc1155<TokenERC1155> {
*/ */
public signature: Erc1155SignatureMintable; public signature: Erc1155SignatureMintable;
public interceptor: ContractInterceptor<TokenERC1155>; public interceptor: ContractInterceptor<TokenERC1155>;
public owner: ContractOwner<TokenERC1155>; public owner: ContractOwner;
constructor( constructor(
network: NetworkInput, network: NetworkInput,
@@ -18,10 +18,10 @@ import { ContractInterceptor } from "../../core/classes/contract-interceptor";
import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { MarketplaceAuction } from "../../core/classes/marketplace-auction"; import { MarketplaceAuction } from "../../core/classes/internal/marketplace/marketplace-auction";
import { MarketplaceDirect } from "../../core/classes/marketplace-direct"; import { MarketplaceDirect } from "../../core/classes/internal/marketplace/marketplace-direct";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { UpdateableNetwork } from "../../core/interfaces/contract"; import { UpdateableNetwork } from "../../core/interfaces/contract";
import { NetworkInput } from "../../core/types"; import { NetworkInput } from "../../core/types";
@@ -50,7 +50,8 @@ import { Offer } from "../../types/marketplace/Offer";
* const contract = await sdk.getContract("{{contract_address}}", "marketplace"); * const contract = await sdk.getContract("{{contract_address}}", "marketplace");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.directListings / contract.auctions / contract.offers instead
*/ */
export class Marketplace implements UpdateableNetwork { export class Marketplace implements UpdateableNetwork {
static contractRoles = MARKETPLACE_CONTRACT_ROLES; static contractRoles = MARKETPLACE_CONTRACT_ROLES;
@@ -62,7 +63,7 @@ export class Marketplace implements UpdateableNetwork {
public encoder: ContractEncoder<MarketplaceContract>; public encoder: ContractEncoder<MarketplaceContract>;
public events: ContractEvents<MarketplaceContract>; public events: ContractEvents<MarketplaceContract>;
public estimator: GasCostEstimator<MarketplaceContract>; public estimator: GasCostEstimator<MarketplaceContract>;
public platformFees: ContractPlatformFee<MarketplaceContract>; public platformFees: ContractPlatformFee;
public metadata: ContractMetadata< public metadata: ContractMetadata<
MarketplaceContract, MarketplaceContract,
typeof MarketplaceContractSchema typeof MarketplaceContractSchema
@@ -20,7 +20,7 @@ import { ContractInterceptor } from "../../core/classes/contract-interceptor";
import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { MarketplaceV3DirectListings } from "../../core/classes/marketplacev3-direct-listings"; import { MarketplaceV3DirectListings } from "../../core/classes/marketplacev3-direct-listings";
import { MarketplaceV3EnglishAuctions } from "../../core/classes/marketplacev3-english-auction"; import { MarketplaceV3EnglishAuctions } from "../../core/classes/marketplacev3-english-auction";
@@ -46,7 +46,8 @@ import { MARKETPLACE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "marketplace"); * const contract = await sdk.getContract("{{contract_address}}", "marketplace");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.directListings / contract.auctions / contract.offers instead
*/ */
export class MarketplaceV3 implements UpdateableNetwork { export class MarketplaceV3 implements UpdateableNetwork {
static contractRoles = MARKETPLACE_CONTRACT_ROLES; static contractRoles = MARKETPLACE_CONTRACT_ROLES;
@@ -58,7 +59,7 @@ export class MarketplaceV3 implements UpdateableNetwork {
public encoder: ContractEncoder<MarketplaceV3Contract>; public encoder: ContractEncoder<MarketplaceV3Contract>;
public events: ContractEvents<MarketplaceV3Contract>; public events: ContractEvents<MarketplaceV3Contract>;
public estimator: GasCostEstimator<MarketplaceV3Contract>; public estimator: GasCostEstimator<MarketplaceV3Contract>;
public platformFees: ContractPlatformFee<MarketplaceV3Contract>; public platformFees: ContractPlatformFee;
public metadata: ContractMetadata< public metadata: ContractMetadata<
MarketplaceV3Contract, MarketplaceV3Contract,
typeof MarketplaceContractSchema typeof MarketplaceContractSchema
@@ -20,8 +20,8 @@ import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractOwner } from "../../core/classes/contract-owner"; import { ContractOwner } from "../../core/classes/contract-owner";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { StandardErc721 } from "../../core/classes/erc-721-standard"; import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput, TransactionResultWithId } from "../../core/types"; import { NetworkInput, TransactionResultWithId } from "../../core/types";
@@ -52,6 +52,7 @@ import { MULTIWRAP_CONTRACT_ROLES } from "../contractRoles";
* *
* @beta * @beta
*/ */
// TODO create extension wrappers for this
export class Multiwrap extends StandardErc721<MultiwrapContract> { export class Multiwrap extends StandardErc721<MultiwrapContract> {
static contractRoles = MULTIWRAP_CONTRACT_ROLES; static contractRoles = MULTIWRAP_CONTRACT_ROLES;
@@ -90,7 +91,7 @@ export class Multiwrap extends StandardErc721<MultiwrapContract> {
MultiwrapContract, MultiwrapContract,
typeof MultiwrapContractSchema typeof MultiwrapContractSchema
>; >;
public owner: ContractOwner<MultiwrapContract>; public owner: ContractOwner;
constructor( constructor(
network: NetworkInput, network: NetworkInput,
@@ -14,8 +14,8 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { StandardErc721 } from "../../core/classes/erc-721-standard"; import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard";
import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable"; import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
@@ -39,7 +39,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "nft-collection"); * const contract = await sdk.getContract("{{contract_address}}", "nft-collection");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc721 instead
*/ */
export class NFTCollection extends StandardErc721<TokenERC721> { export class NFTCollection extends StandardErc721<TokenERC721> {
static contractRoles = NFT_BASE_CONTRACT_ROLES; static contractRoles = NFT_BASE_CONTRACT_ROLES;
@@ -59,7 +60,7 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
public estimator: GasCostEstimator<TokenERC721>; public estimator: GasCostEstimator<TokenERC721>;
public events: ContractEvents<TokenERC721>; public events: ContractEvents<TokenERC721>;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<TokenERC721>; public platformFees: ContractPlatformFee;
/** /**
* Configure royalties * Configure royalties
* @remarks Set your own royalties for the entire contract or per token * @remarks Set your own royalties for the entire contract or per token
@@ -81,7 +82,7 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
TokenERC721, TokenERC721,
typeof TokenErc721ContractSchema typeof TokenErc721ContractSchema
>; >;
public owner: ContractOwner<TokenERC721>; public owner: ContractOwner;
/** /**
* Signature Minting * Signature Minting
@@ -18,10 +18,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { DelayedReveal } from "../../core/classes/delayed-reveal"; import { DelayedReveal } from "../../core/classes/delayed-reveal";
import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions";
import { StandardErc721 } from "../../core/classes/erc-721-standard"; import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput, TransactionResultWithId } from "../../core/types"; import { NetworkInput, TransactionResultWithId } from "../../core/types";
@@ -47,7 +47,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "nft-drop"); * const contract = await sdk.getContract("{{contract_address}}", "nft-drop");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc721 instead
*/ */
export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> { export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
static contractRoles = NFT_BASE_CONTRACT_ROLES; static contractRoles = NFT_BASE_CONTRACT_ROLES;
@@ -61,7 +62,7 @@ export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
>; >;
public app: ContractAppURI<PrebuiltNFTDrop>; public app: ContractAppURI<PrebuiltNFTDrop>;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltNFTDrop>; public platformFees: ContractPlatformFee;
public events: ContractEvents<PrebuiltNFTDrop>; public events: ContractEvents<PrebuiltNFTDrop>;
public roles: ContractRoles< public roles: ContractRoles<
PrebuiltNFTDrop, PrebuiltNFTDrop,
@@ -154,7 +155,7 @@ export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
*/ */
public checkout: PaperCheckout<PrebuiltNFTDrop>; public checkout: PaperCheckout<PrebuiltNFTDrop>;
public owner: ContractOwner<PrebuiltNFTDrop>; public owner: ContractOwner;
constructor( constructor(
network: NetworkInput, network: NetworkInput,
@@ -37,8 +37,8 @@ import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractOwner } from "../../core/classes/contract-owner"; import { ContractOwner } from "../../core/classes/contract-owner";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { StandardErc1155 } from "../../core/classes/erc-1155-standard"; import { StandardErc1155 } from "../../core/classes/internal/erc1155/erc-1155-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { PackVRF } from "../../core/classes/pack-vrf"; import { PackVRF } from "../../core/classes/pack-vrf";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
@@ -71,6 +71,7 @@ import { PACK_CONTRACT_ROLES } from "../contractRoles";
* *
* @public * @public
*/ */
// TODO create extension wrappers
export class Pack extends StandardErc1155<PackContract> { export class Pack extends StandardErc1155<PackContract> {
static contractRoles = PACK_CONTRACT_ROLES; static contractRoles = PACK_CONTRACT_ROLES;
@@ -107,7 +108,7 @@ export class Pack extends StandardErc1155<PackContract> {
*/ */
public interceptor: ContractInterceptor<PackContract>; public interceptor: ContractInterceptor<PackContract>;
public owner: ContractOwner<PackContract>; public owner: ContractOwner;
private _vrf?: PackVRF; private _vrf?: PackVRF;
@@ -19,10 +19,10 @@ import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractRoyalty } from "../../core/classes/contract-royalty"; import { ContractRoyalty } from "../../core/classes/contract-royalty";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { DelayedReveal } from "../../core/classes/delayed-reveal"; import { DelayedReveal } from "../../core/classes/delayed-reveal";
import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions";
import { StandardErc721 } from "../../core/classes/erc-721-standard"; import { StandardErc721 } from "../../core/classes/internal/erc721/erc-721-standard";
import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable"; import { Erc721WithQuantitySignatureMintable } from "../../core/classes/erc-721-with-quantity-signature-mintable";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
@@ -51,13 +51,14 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "signature-drop"); * const contract = await sdk.getContract("{{contract_address}}", "signature-drop");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc721 instead
*/ */
export class SignatureDrop extends StandardErc721<SignatureDropContract> { export class SignatureDrop extends StandardErc721<SignatureDropContract> {
static contractRoles = NFT_BASE_CONTRACT_ROLES; static contractRoles = NFT_BASE_CONTRACT_ROLES;
public abi: Abi; public abi: Abi;
public owner: ContractOwner<SignatureDropContract>; public owner: ContractOwner;
public encoder: ContractEncoder<SignatureDropContract>; public encoder: ContractEncoder<SignatureDropContract>;
public estimator: GasCostEstimator<SignatureDropContract>; public estimator: GasCostEstimator<SignatureDropContract>;
public metadata: ContractMetadata< public metadata: ContractMetadata<
@@ -66,7 +67,7 @@ export class SignatureDrop extends StandardErc721<SignatureDropContract> {
>; >;
public app: ContractAppURI<SignatureDropContract>; public app: ContractAppURI<SignatureDropContract>;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<SignatureDropContract>; public platformFees: ContractPlatformFee;
public events: ContractEvents<SignatureDropContract>; public events: ContractEvents<SignatureDropContract>;
public roles: ContractRoles< public roles: ContractRoles<
SignatureDropContract, SignatureDropContract,
@@ -13,7 +13,7 @@ import { ContractEvents } from "../../core/classes/contract-events";
import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractInterceptor } from "../../core/classes/contract-interceptor";
import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { UpdateableNetwork } from "../../core/interfaces/contract"; import { UpdateableNetwork } from "../../core/interfaces/contract";
@@ -41,6 +41,7 @@ import { ADMIN_ROLE } from "../contractRoles";
* *
* @public * @public
*/ */
// TODO create extension wrappers for this
export class Split implements UpdateableNetwork { export class Split implements UpdateableNetwork {
static contractRoles = ADMIN_ROLE; static contractRoles = ADMIN_ROLE;
@@ -11,9 +11,9 @@ import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { DropClaimConditions } from "../../core/classes/drop-claim-conditions"; import { DropClaimConditions } from "../../core/classes/drop-claim-conditions";
import { StandardErc20 } from "../../core/classes/erc-20-standard"; import { StandardErc20 } from "../../core/classes/internal/erc20/erc-20-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput } from "../../core/types"; import { NetworkInput } from "../../core/types";
@@ -37,7 +37,8 @@ import { TOKEN_DROP_CONTRACT_ROLES } from "../contractRoles";
* const sdk = new ThirdwebSDK("{{chainName}}"); * const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = await sdk.getContract("{{contract_address}}", "token-drop"); * const contract = await sdk.getContract("{{contract_address}}", "token-drop");
* ``` * ```
* * @internal
* @deprecated use contract.erc20 instead
*/ */
export class TokenDrop extends StandardErc20<PrebuiltTokenDrop> { export class TokenDrop extends StandardErc20<PrebuiltTokenDrop> {
static contractRoles = TOKEN_DROP_CONTRACT_ROLES; static contractRoles = TOKEN_DROP_CONTRACT_ROLES;
@@ -55,7 +56,7 @@ export class TokenDrop extends StandardErc20<PrebuiltTokenDrop> {
public encoder: ContractEncoder<PrebuiltTokenDrop>; public encoder: ContractEncoder<PrebuiltTokenDrop>;
public estimator: GasCostEstimator<PrebuiltTokenDrop>; public estimator: GasCostEstimator<PrebuiltTokenDrop>;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
public platformFees: ContractPlatformFee<PrebuiltTokenDrop>; public platformFees: ContractPlatformFee;
public events: ContractEvents<PrebuiltTokenDrop>; public events: ContractEvents<PrebuiltTokenDrop>;
/** /**
* Configure claim conditions * Configure claim conditions
@@ -12,10 +12,10 @@ import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractPlatformFee } from "../../core/classes/contract-platform-fee"; import { ContractPlatformFee } from "../../core/classes/contract-platform-fee";
import { ContractRoles } from "../../core/classes/contract-roles"; import { ContractRoles } from "../../core/classes/contract-roles";
import { ContractPrimarySale } from "../../core/classes/contract-sales"; import { ContractPrimarySale } from "../../core/classes/contract-sales";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { TokenERC20History } from "../../core/classes/erc-20-history"; import { TokenERC20History } from "../../core/classes/internal/erc20/erc-20-history";
import { Erc20SignatureMintable } from "../../core/classes/erc-20-signature-mintable"; import { Erc20SignatureMintable } from "../../core/classes/erc-20-signature-mintable";
import { StandardErc20 } from "../../core/classes/erc-20-standard"; import { StandardErc20 } from "../../core/classes/internal/erc20/erc-20-standard";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { NetworkInput } from "../../core/types"; import { NetworkInput } from "../../core/types";
@@ -40,7 +40,8 @@ import { NFT_BASE_CONTRACT_ROLES } from "../contractRoles";
* const contract = await sdk.getContract("{{contract_address}}", "token"); * const contract = await sdk.getContract("{{contract_address}}", "token");
* ``` * ```
* *
* @public * @internal
* @deprecated use contract.erc20 instead
*/ */
export class Token extends StandardErc20<TokenERC20> { export class Token extends StandardErc20<TokenERC20> {
static contractRoles = NFT_BASE_CONTRACT_ROLES; static contractRoles = NFT_BASE_CONTRACT_ROLES;
@@ -57,7 +58,7 @@ export class Token extends StandardErc20<TokenERC20> {
public estimator: GasCostEstimator<TokenERC20>; public estimator: GasCostEstimator<TokenERC20>;
public history: TokenERC20History; public history: TokenERC20History;
public events: ContractEvents<TokenERC20>; public events: ContractEvents<TokenERC20>;
public platformFees: ContractPlatformFee<TokenERC20>; public platformFees: ContractPlatformFee;
public sales: ContractPrimarySale; public sales: ContractPrimarySale;
/** /**
* Signature Minting * Signature Minting
@@ -17,7 +17,7 @@ import { ContractEncoder } from "../../core/classes/contract-encoder";
import { ContractEvents } from "../../core/classes/contract-events"; import { ContractEvents } from "../../core/classes/contract-events";
import { ContractInterceptor } from "../../core/classes/contract-interceptor"; import { ContractInterceptor } from "../../core/classes/contract-interceptor";
import { ContractMetadata } from "../../core/classes/contract-metadata"; import { ContractMetadata } from "../../core/classes/contract-metadata";
import { ContractWrapper } from "../../core/classes/contract-wrapper"; import { ContractWrapper } from "../../core/classes/internal/contract-wrapper";
import { GasCostEstimator } from "../../core/classes/gas-cost-estimator"; import { GasCostEstimator } from "../../core/classes/gas-cost-estimator";
import { Transaction } from "../../core/classes/transactions"; import { Transaction } from "../../core/classes/transactions";
import { UpdateableNetwork } from "../../core/interfaces/contract"; import { UpdateableNetwork } from "../../core/interfaces/contract";
@@ -50,6 +50,7 @@ import { VoteType } from "../../enums/vote/Vote";
* *
* @public * @public
*/ */
// TODO create extension wrappers for this
export class Vote implements UpdateableNetwork { export class Vote implements UpdateableNetwork {
private contractWrapper: ContractWrapper<VoteERC20>; private contractWrapper: ContractWrapper<VoteERC20>;
private storage: ThirdwebStorage; private storage: ThirdwebStorage;
@@ -57,7 +57,7 @@ import { ContractPublishedMetadata } from "../core/classes/contract-published-me
import { ContractRoles } from "../core/classes/contract-roles"; import { ContractRoles } from "../core/classes/contract-roles";
import { ContractRoyalty } from "../core/classes/contract-royalty"; import { ContractRoyalty } from "../core/classes/contract-royalty";
import { ContractPrimarySale } from "../core/classes/contract-sales"; import { ContractPrimarySale } from "../core/classes/contract-sales";
import { ContractWrapper } from "../core/classes/contract-wrapper"; import { ContractWrapper } from "../core/classes/internal/contract-wrapper";
import { Erc1155 } from "../core/classes/erc-1155"; import { Erc1155 } from "../core/classes/erc-1155";
import { Erc20 } from "../core/classes/erc-20"; import { Erc20 } from "../core/classes/erc-20";
import { Erc721 } from "../core/classes/erc-721"; import { Erc721 } from "../core/classes/erc-721";
@@ -94,17 +94,17 @@ import { ExtensionManager } from "../core/classes/extension-manager";
* // call any function in your contract * // call any function in your contract
* await contract.call("myCustomFunction", [param1, param2]); * await contract.call("myCustomFunction", [param1, param2]);
* *
* // if your contract follows the ERC721 standard, contract.nft will be present * // if your contract follows an ERC standard, contract.ercXYZ will be present
* const allNFTs = await contract.erc721.query.all() * const allNFTs = await contract.erc721.getAll()
* *
* // if your contract extends IMintableERC721, contract.nft.mint() will be available * // if your contract extends a particular contract extension, the corresponding function will be available
* const tx = await contract.erc721.mint({ * const tx = await contract.erc721.mint({
* name: "Cool NFT", * name: "Cool NFT",
* image: readFileSync("some_image.png"), * image: readFileSync("some_image.png"),
* }); * });
* ``` * ```
* *
* @beta * @public
*/ */
export class SmartContract< export class SmartContract<
TContract extends BaseContractInterface = BaseContract, TContract extends BaseContractInterface = BaseContract,
@@ -118,7 +118,7 @@ export class SmartContract<
public interceptor: ContractInterceptor<TContract>; public interceptor: ContractInterceptor<TContract>;
public encoder: ContractEncoder<TContract>; public encoder: ContractEncoder<TContract>;
public estimator: GasCostEstimator<TContract>; public estimator: GasCostEstimator<TContract>;
public publishedMetadata: ContractPublishedMetadata<TContract>; public publishedMetadata: ContractPublishedMetadata;
public metadata: ContractMetadata<BaseContract, typeof CustomContractSchema>; public metadata: ContractMetadata<BaseContract, typeof CustomContractSchema>;
get abi(): Abi { get abi(): Abi {
@@ -149,14 +149,14 @@ export class SmartContract<
/** /**
* Handle platform fees * Handle platform fees
*/ */
get platformFees(): ContractPlatformFee<IPlatformFee> { get platformFees(): ContractPlatformFee {
return assertEnabled(this.detectPlatformFees(), FEATURE_PLATFORM_FEE); return assertEnabled(this.detectPlatformFees(), FEATURE_PLATFORM_FEE);
} }
/** /**
* Set and get the owner of the contract * Set and get the owner of the contract
*/ */
get owner(): ContractOwner<Ownable> { get owner(): ContractOwner {
return assertEnabled(this.detectOwnable(), FEATURE_OWNER); return assertEnabled(this.detectOwnable(), FEATURE_OWNER);
} }
@@ -352,12 +352,12 @@ export class SmartContract<
* const isAccountDeployed = await contract.accountFactory.isAccountDeployed(admin, extraData); * const isAccountDeployed = await contract.accountFactory.isAccountDeployed(admin, extraData);
* ``` * ```
*/ */
get accountFactory(): AccountFactory<IAccountFactory> { get accountFactory(): AccountFactory {
return assertEnabled(this.detectAccountFactory(), FEATURE_ACCOUNT_FACTORY); return assertEnabled(this.detectAccountFactory(), FEATURE_ACCOUNT_FACTORY);
} }
// TODO documentation // TODO documentation
get account(): Account<IAccountCore> { get account(): Account {
return assertEnabled(this.detectAccount(), FEATURE_ACCOUNT); return assertEnabled(this.detectAccount(), FEATURE_ACCOUNT);
} }
@@ -8,13 +8,20 @@ import { isContractDeployed } from "../../common/any-evm-utils/isContractDeploye
import { buildTransactionFunction } from "../../common/transactions"; import { buildTransactionFunction } from "../../common/transactions";
import { TransactionResultWithAddress } from "../types"; import { TransactionResultWithAddress } from "../types";
import { ContractEvents } from "./contract-events"; import { ContractEvents } from "./contract-events";
import { ContractWrapper } from "./contract-wrapper"; import { ContractWrapper } from "./internal/contract-wrapper";
import { Transaction } from "./transactions"; import { Transaction } from "./transactions";
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 /**
export class AccountFactory<TContract extends IAccountFactory> * Interact with ERC-4337 account factory contracts
implements DetectableFeature * @remarks Exposes useful functions available on the account factory contract.
{ * @example
* ```javascript
* const contract = await sdk.getContract("{{contract_address}}");
* await contract.accountFactory.predictAccountAddress(walletAddress);
* ```
* @public
*/
export class AccountFactory implements DetectableFeature {
featureName = FEATURE_ACCOUNT_FACTORY.name; featureName = FEATURE_ACCOUNT_FACTORY.name;
private contractWrapper: ContractWrapper<IAccountFactory>; private contractWrapper: ContractWrapper<IAccountFactory>;
+13 -6
View File
@@ -3,7 +3,7 @@ import {
FEATURE_ACCOUNT_PERMISSIONS, FEATURE_ACCOUNT_PERMISSIONS,
} from "../../constants/thirdweb-features"; } from "../../constants/thirdweb-features";
import { DetectableFeature } from "../interfaces/DetectableFeature"; import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper"; import { ContractWrapper } from "./internal/contract-wrapper";
import type { IAccountCore } from "@thirdweb-dev/contracts-js"; import type { IAccountCore } from "@thirdweb-dev/contracts-js";
import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema"; import { AddressOrEns } from "../../schema/shared/AddressOrEnsSchema";
@@ -13,14 +13,21 @@ import {
SignerWithPermissions, SignerWithPermissions,
} from "../../types/account"; } from "../../types/account";
import { buildTransactionFunction } from "../../common/transactions"; import { buildTransactionFunction } from "../../common/transactions";
import { AccountPermissions } from "./account-permissions"; import { AccountPermissions } from "./internal/erc4337/account-permissions";
import { detectContractFeature } from "../../common/feature-detection/detectContractFeature"; import { detectContractFeature } from "../../common/feature-detection/detectContractFeature";
import { assertEnabled } from "../../common/feature-detection/assertEnabled"; import { assertEnabled } from "../../common/feature-detection/assertEnabled";
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- TO BE REMOVED IN V4 /**
export class Account<TContract extends IAccountCore> * Interact with ERC-4337 accounts
implements DetectableFeature * @remarks Exposes useful functions available on account contracts.
{ * @example
* ```javascript
* const contract = await sdk.getContract("{{contract_address}}");
* await contract.account.getAllAdminsAndSigners();
* ```
* @public
*/
export class Account implements DetectableFeature {
featureName = FEATURE_ACCOUNT.name; featureName = FEATURE_ACCOUNT.name;
private contractWrapper: ContractWrapper<IAccountCore>; private contractWrapper: ContractWrapper<IAccountCore>;
private accountPermissions: AccountPermissions | undefined; private accountPermissions: AccountPermissions | undefined;
@@ -11,7 +11,7 @@ import {
Airdrop1155Output, Airdrop1155Output,
} from "../../types/airdrop/airdrop"; } from "../../types/airdrop/airdrop";
import { DetectableFeature } from "../interfaces/DetectableFeature"; import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper"; import { ContractWrapper } from "./internal/contract-wrapper";
import { Transaction } from "./transactions"; import { Transaction } from "./transactions";
/** /**
@@ -4,7 +4,7 @@ import { buildTransactionFunction } from "../../common/transactions";
import { FEATURE_AIRDROP_ERC20 } from "../../constants/thirdweb-features"; import { FEATURE_AIRDROP_ERC20 } from "../../constants/thirdweb-features";
import { Address } from "../../schema/shared/Address"; import { Address } from "../../schema/shared/Address";
import { DetectableFeature } from "../interfaces/DetectableFeature"; import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper"; import { ContractWrapper } from "./internal/contract-wrapper";
import { Transaction } from "./transactions"; import { Transaction } from "./transactions";
import { Airdrop20Content, Airdrop20Output } from "../../types/airdrop/airdrop"; import { Airdrop20Content, Airdrop20Output } from "../../types/airdrop/airdrop";
@@ -8,7 +8,7 @@ import {
Airdrop721Output, Airdrop721Output,
} from "../../types/airdrop/airdrop"; } from "../../types/airdrop/airdrop";
import { DetectableFeature } from "../interfaces/DetectableFeature"; import { DetectableFeature } from "../interfaces/DetectableFeature";
import { ContractWrapper } from "./contract-wrapper"; import { ContractWrapper } from "./internal/contract-wrapper";
import { Transaction } from "./transactions"; import { Transaction } from "./transactions";
/** /**

Some files were not shown because too many files have changed in this diff Show More