From 570e483a40089f0bf5268676f293dd70f663b956 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Fri, 10 Jun 2022 13:40:52 -0700 Subject: [PATCH 01/20] add optimism / arbitrum chains --- src/constants/chains.ts | 14 +++++++++++++- src/constants/urls.ts | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/constants/chains.ts b/src/constants/chains.ts index 03f25eefc..c8a384ae2 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -19,6 +19,10 @@ export enum ChainId { FantomTestnet = 4002, Avalanche = 43114, AvalancheFujiTestnet = 43113, + Optimism = 10, + OptimismTestnet = 69, + Arbitrum = 42161, + ArbitrumTestnet = 421611, } /** @@ -33,7 +37,11 @@ export type SUPPORTED_CHAIN_ID = | ChainId.Fantom | ChainId.FantomTestnet | ChainId.Avalanche - | ChainId.AvalancheFujiTestnet; + | ChainId.AvalancheFujiTestnet + | ChainId.Optimism + | ChainId.OptimismTestnet + | ChainId.Arbitrum + | ChainId.ArbitrumTestnet; /** * @public @@ -48,4 +56,8 @@ export const SUPPORTED_CHAIN_IDS: SUPPORTED_CHAIN_ID[] = [ ChainId.FantomTestnet, ChainId.Avalanche, ChainId.AvalancheFujiTestnet, + ChainId.Optimism, + ChainId.OptimismTestnet, + ChainId.Arbitrum, + ChainId.ArbitrumTestnet, ]; diff --git a/src/constants/urls.ts b/src/constants/urls.ts index 4f155ce7d..42139f51a 100644 --- a/src/constants/urls.ts +++ b/src/constants/urls.ts @@ -36,6 +36,10 @@ export type ChainOrRpc = | "ethereum" | "fantom" | "avalanche" + | "optimism" + | "optimism-kovan" + | "arbitrum" + | "arbitrum-rinkeby" // ideally we could use `https://${string}` notation here, but doing that causes anything that is a generic string to throw a type error => not worth the hassle for now | (string & {}); @@ -67,6 +71,14 @@ export function getProviderForNetwork(network: ChainOrRpc | SignerOrProvider) { case "mainnet": case "ethereum": return `https://eth-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; + case "optimism": + return `https://opt-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; + case "optimism-kovan": + return `https://opt-kovan.g.alchemy.com/v2/${DEFAULT_API_KEY}`; + case "arbitrum": + return `https://arb-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; + case "arbirum-rinkeby": + return `https://arb-rinkeby.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "fantom": return "https://rpc.ftm.tools"; case "avalanche": From 00a8ba8efd85c399a033db91ab870fa80d05e97b Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 11:20:31 -0700 Subject: [PATCH 02/20] add L2 chain info --- docs/sdk.chainid.md | 4 ++++ docs/sdk.supported_chain_id.md | 4 ++-- etc/sdk.api.md | 12 ++++++++-- src/constants/addresses.ts | 36 ++++++++++++++++++++++++++++++ src/constants/currency.ts | 40 ++++++++++++++++++++++++++++++++++ src/constants/urls.ts | 6 ++++- 6 files changed, 97 insertions(+), 5 deletions(-) diff --git a/docs/sdk.chainid.md b/docs/sdk.chainid.md index 05748e1a2..5fb4d3aff 100644 --- a/docs/sdk.chainid.md +++ b/docs/sdk.chainid.md @@ -15,6 +15,8 @@ export declare enum ChainId | Member | Value | Description | | --- | --- | --- | +| Arbitrum | 42161 | | +| ArbitrumTestnet | 421611 | | | Avalanche | 43114 | | | AvalancheFujiTestnet | 43113 | | | BSC | 56 | | @@ -28,6 +30,8 @@ export declare enum ChainId | Mainnet | 1 | | | Moonriver | 1285 | | | Mumbai | 80001 | | +| Optimism | 10 | | +| OptimismTestnet | 69 | | | Polygon | 137 | | | Rinkeby | 4 | | | Ropsten | 3 | | diff --git a/docs/sdk.supported_chain_id.md b/docs/sdk.supported_chain_id.md index 5493b3dd8..35b2cc1d1 100644 --- a/docs/sdk.supported_chain_id.md +++ b/docs/sdk.supported_chain_id.md @@ -8,7 +8,7 @@ Signature: ```typescript -export declare type SUPPORTED_CHAIN_ID = ChainId.Mainnet | ChainId.Rinkeby | ChainId.Goerli | ChainId.Mumbai | ChainId.Polygon | ChainId.Fantom | ChainId.FantomTestnet | ChainId.Avalanche | ChainId.AvalancheFujiTestnet; +export declare type SUPPORTED_CHAIN_ID = ChainId.Mainnet | ChainId.Rinkeby | ChainId.Goerli | ChainId.Mumbai | ChainId.Polygon | ChainId.Fantom | ChainId.FantomTestnet | ChainId.Avalanche | ChainId.AvalancheFujiTestnet | ChainId.Optimism | ChainId.OptimismTestnet | ChainId.Arbitrum | ChainId.ArbitrumTestnet; ``` -References: [ChainId.Mainnet](./sdk.chainid.md), [ChainId.Rinkeby](./sdk.chainid.md), [ChainId.Goerli](./sdk.chainid.md), [ChainId.Mumbai](./sdk.chainid.md), [ChainId.Polygon](./sdk.chainid.md), [ChainId.Fantom](./sdk.chainid.md), [ChainId.FantomTestnet](./sdk.chainid.md), [ChainId.Avalanche](./sdk.chainid.md), [ChainId.AvalancheFujiTestnet](./sdk.chainid.md) +References: [ChainId.Mainnet](./sdk.chainid.md), [ChainId.Rinkeby](./sdk.chainid.md), [ChainId.Goerli](./sdk.chainid.md), [ChainId.Mumbai](./sdk.chainid.md), [ChainId.Polygon](./sdk.chainid.md), [ChainId.Fantom](./sdk.chainid.md), [ChainId.FantomTestnet](./sdk.chainid.md), [ChainId.Avalanche](./sdk.chainid.md), [ChainId.AvalancheFujiTestnet](./sdk.chainid.md), [ChainId.Optimism](./sdk.chainid.md), [ChainId.OptimismTestnet](./sdk.chainid.md), [ChainId.Arbitrum](./sdk.chainid.md), [ChainId.ArbitrumTestnet](./sdk.chainid.md) diff --git a/etc/sdk.api.md b/etc/sdk.api.md index c5748e623..c91649f13 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -154,6 +154,10 @@ export type BufferOrStringWithName = { // @public (undocumented) export enum ChainId { + // (undocumented) + Arbitrum = 42161, + // (undocumented) + ArbitrumTestnet = 421611, // (undocumented) Avalanche = 43114, // (undocumented) @@ -181,6 +185,10 @@ export enum ChainId { // (undocumented) Mumbai = 80001, // (undocumented) + Optimism = 10, + // (undocumented) + OptimismTestnet = 69, + // (undocumented) Polygon = 137, // (undocumented) Rinkeby = 4, @@ -208,7 +216,7 @@ export const ChainlinkVrf: Record; // Warning: (ae-internal-missing-underscore) The name "ChainOrRpc" should be prefixed with an underscore because the declaration is marked as @internal // // @internal (undocumented) -export type ChainOrRpc = "mumbai" | "polygon" | "matic" | "rinkeby" | "goerli" | "mainnet" | "ethereum" | "fantom" | "avalanche" | (string & {}); +export type ChainOrRpc = "mumbai" | "polygon" | "matic" | "rinkeby" | "goerli" | "mainnet" | "ethereum" | "fantom" | "avalanche" | "optimism" | "optimism-kovan" | "arbitrum" | "arbitrum-rinkeby" | (string & {}); // Warning: (ae-internal-missing-underscore) The name "CidWithFileName" should be prefixed with an underscore because the declaration is marked as @internal // @@ -4914,7 +4922,7 @@ export interface SplitRecipientInput { } // @public (undocumented) -export type SUPPORTED_CHAIN_ID = ChainId.Mainnet | ChainId.Rinkeby | ChainId.Goerli | ChainId.Mumbai | ChainId.Polygon | ChainId.Fantom | ChainId.FantomTestnet | ChainId.Avalanche | ChainId.AvalancheFujiTestnet; +export type SUPPORTED_CHAIN_ID = ChainId.Mainnet | ChainId.Rinkeby | ChainId.Goerli | ChainId.Mumbai | ChainId.Polygon | ChainId.Fantom | ChainId.FantomTestnet | ChainId.Avalanche | ChainId.AvalancheFujiTestnet | ChainId.Optimism | ChainId.OptimismTestnet | ChainId.Arbitrum | ChainId.ArbitrumTestnet; // @public (undocumented) export const SUPPORTED_CHAIN_IDS: SUPPORTED_CHAIN_ID[]; diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 225ee1e97..92d9ef23c 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -107,6 +107,42 @@ export const CONTRACT_ADDRESSES: Record< contractMetadataRegistry: "0x1e474395f58418e9c594a79abb0152D04C229E8e", sigMint: constants.AddressZero, }, + [ChainId.Arbitrum]: { + biconomyForwarder: constants.AddressZero, + twFactory: "", // TODO + twRegistry: "", // TODO + twBYOCRegistry: constants.AddressZero, + contractDeployer: constants.AddressZero, + contractMetadataRegistry: constants.AddressZero, + sigMint: constants.AddressZero, + }, + [ChainId.ArbitrumTestnet]: { + biconomyForwarder: constants.AddressZero, + twFactory: "", // TODO + twRegistry: "", // TODO + twBYOCRegistry: constants.AddressZero, + contractDeployer: constants.AddressZero, + contractMetadataRegistry: constants.AddressZero, + sigMint: constants.AddressZero, + }, + [ChainId.Optimism]: { + biconomyForwarder: constants.AddressZero, + twFactory: "", // TODO + twRegistry: "", // TODO + twBYOCRegistry: constants.AddressZero, + contractDeployer: constants.AddressZero, + contractMetadataRegistry: constants.AddressZero, + sigMint: constants.AddressZero, + }, + [ChainId.OptimismTestnet]: { + biconomyForwarder: constants.AddressZero, + twFactory: "0x3805FF4740F47c5F3206223af6e7D5d99e58a2E7", // TODO from shared deployer wallet + twRegistry: "0xc7B5A95ee69c3384F97edcDEb31F29ed0078bF52", // TODO from shared deployer wallet + twBYOCRegistry: constants.AddressZero, + contractDeployer: constants.AddressZero, + contractMetadataRegistry: constants.AddressZero, + sigMint: constants.AddressZero, + }, }; /** diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 3678f7fe7..75968ff83 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -104,6 +104,46 @@ export const NATIVE_TOKENS: Record< symbol: "WFTM", }, }, + [ChainId.Arbitrum]: { + name: "Arbitrum", + symbol: "ETH", + decimals: 18, + wrapped: { + address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", + name: "Wrapped Ether", + symbol: "WETH", + }, + }, + [ChainId.ArbitrumTestnet]: { + name: "Arbitrum Testnet", + symbol: "ETH", + decimals: 18, + wrapped: { + address: "0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9", + name: "Wrapped Ether", + symbol: "WETH", + }, + }, + [ChainId.Optimism]: { + name: "Optimism", + symbol: "ETH", + decimals: 18, + wrapped: { + address: "0x4200000000000000000000000000000000000006", + name: "Wrapped Ether", + symbol: "WETH", + }, + }, + [ChainId.OptimismTestnet]: { + name: "Optimism Testnet", + symbol: "ETH", + decimals: 18, + wrapped: { + address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", + name: "Wrapped Ether", + symbol: "WETH", + }, + }, [ChainId.Hardhat]: { name: "Ether", symbol: "ETH", diff --git a/src/constants/urls.ts b/src/constants/urls.ts index 42139f51a..05897264a 100644 --- a/src/constants/urls.ts +++ b/src/constants/urls.ts @@ -72,12 +72,16 @@ export function getProviderForNetwork(network: ChainOrRpc | SignerOrProvider) { case "ethereum": return `https://eth-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "optimism": + // TODO test this RPC return `https://opt-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "optimism-kovan": - return `https://opt-kovan.g.alchemy.com/v2/${DEFAULT_API_KEY}`; + // alchemy optimism kovan rpc doesn't link to the testnet sequencer... + return "https://kovan.optimism.io"; case "arbitrum": + // TODO test this RPC return `https://arb-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "arbirum-rinkeby": + // TODO test this RPC return `https://arb-rinkeby.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "fantom": return "https://rpc.ftm.tools"; From 60e40f93950d4dc174a88c6f3926ef3675a83093 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 11:28:38 -0700 Subject: [PATCH 03/20] v2.3.13-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f6a58fec..a82f14dcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "2.3.12", + "version": "2.3.13-0", "description": "The main thirdweb SDK.", "repository": { "type": "git", From d644ae8a3bc7bcbddbe0791cf3e1d415e82a410c Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 12:43:58 -0700 Subject: [PATCH 04/20] Fix currency names --- src/constants/currency.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 75968ff83..39eae0851 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -105,7 +105,7 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Arbitrum]: { - name: "Arbitrum", + name: "Ether", symbol: "ETH", decimals: 18, wrapped: { @@ -115,7 +115,7 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.ArbitrumTestnet]: { - name: "Arbitrum Testnet", + name: "Ether", symbol: "ETH", decimals: 18, wrapped: { @@ -125,7 +125,7 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Optimism]: { - name: "Optimism", + name: "Ether", symbol: "ETH", decimals: 18, wrapped: { @@ -135,7 +135,7 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.OptimismTestnet]: { - name: "Optimism Testnet", + name: "Ether", symbol: "ETH", decimals: 18, wrapped: { From 261531e9d02c096b09e24da57cf1c603212f94d8 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 12:47:59 -0700 Subject: [PATCH 05/20] Fix symbols for testnets --- src/constants/currency.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 39eae0851..57375e22f 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -25,8 +25,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Rinkeby]: { - name: "Ether", - symbol: "ETH", + name: "Rinkeby Ether", + symbol: "rETH", decimals: 18, wrapped: { address: "0xc778417E063141139Fce010982780140Aa0cD5Ab", @@ -35,8 +35,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Goerli]: { - name: "Ether", - symbol: "ETH", + name: "Goerli Ether", + symbol: "gETH", decimals: 18, wrapped: { address: "0x0bb7509324ce409f7bbc4b701f932eaca9736ab7", @@ -105,8 +105,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Arbitrum]: { - name: "Ether", - symbol: "ETH", + name: "ArbitrumEther", + symbol: "ARETH", decimals: 18, wrapped: { address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", @@ -135,8 +135,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.OptimismTestnet]: { - name: "Ether", - symbol: "ETH", + name: "Kovan Ether", + symbol: "KETH", decimals: 18, wrapped: { address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", From c16d52be8607b05bf7d01545616b3a455ddedfc0 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 13:21:01 -0700 Subject: [PATCH 06/20] Fix name/symbol --- src/constants/chain.ts | 0 src/constants/currency.ts | 10 +++++----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 src/constants/chain.ts diff --git a/src/constants/chain.ts b/src/constants/chain.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 57375e22f..71c130cee 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -105,8 +105,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Arbitrum]: { - name: "ArbitrumEther", - symbol: "ARETH", + name: "Ether", + symbol: "AETH", decimals: 18, wrapped: { address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", @@ -115,8 +115,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.ArbitrumTestnet]: { - name: "Ether", - symbol: "ETH", + name: "Arbitrum Rinkeby Ether", + symbol: "ARETH", decimals: 18, wrapped: { address: "0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9", @@ -136,7 +136,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.OptimismTestnet]: { name: "Kovan Ether", - symbol: "KETH", + symbol: "KOR", decimals: 18, wrapped: { address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", From 0b09a41a9beb24fa4de186d4df92df375766a689 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 13:32:00 -0700 Subject: [PATCH 07/20] add arbitrum testnet registry/factory --- src/constants/addresses.ts | 4 ++-- src/constants/currency.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 92d9ef23c..a48ce266e 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -118,8 +118,8 @@ export const CONTRACT_ADDRESSES: Record< }, [ChainId.ArbitrumTestnet]: { biconomyForwarder: constants.AddressZero, - twFactory: "", // TODO - twRegistry: "", // TODO + twFactory: "0xeb8de81F1eFA6523f72ad0cd0a1e6E5C0908b3Ce", // TODO from shared deployer wallet + twRegistry: "0x6D340cc8bF255d05aCad6c3d820D8B0d8905542c", // TODO from shared deployer wallet twBYOCRegistry: constants.AddressZero, contractDeployer: constants.AddressZero, contractMetadataRegistry: constants.AddressZero, diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 57375e22f..39eae0851 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -25,8 +25,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Rinkeby]: { - name: "Rinkeby Ether", - symbol: "rETH", + name: "Ether", + symbol: "ETH", decimals: 18, wrapped: { address: "0xc778417E063141139Fce010982780140Aa0cD5Ab", @@ -35,8 +35,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Goerli]: { - name: "Goerli Ether", - symbol: "gETH", + name: "Ether", + symbol: "ETH", decimals: 18, wrapped: { address: "0x0bb7509324ce409f7bbc4b701f932eaca9736ab7", @@ -105,8 +105,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Arbitrum]: { - name: "ArbitrumEther", - symbol: "ARETH", + name: "Ether", + symbol: "ETH", decimals: 18, wrapped: { address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", @@ -135,8 +135,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.OptimismTestnet]: { - name: "Kovan Ether", - symbol: "KETH", + name: "Ether", + symbol: "ETH", decimals: 18, wrapped: { address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", From 8243a901abd3121358cbd2464cfe9628a9c1e4fd Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 13:34:53 -0700 Subject: [PATCH 08/20] Use ETH symbol --- src/constants/currency.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 71c130cee..bdbfbdf5b 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -26,7 +26,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.Rinkeby]: { name: "Rinkeby Ether", - symbol: "rETH", + symbol: "ETH", decimals: 18, wrapped: { address: "0xc778417E063141139Fce010982780140Aa0cD5Ab", @@ -36,7 +36,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.Goerli]: { name: "Goerli Ether", - symbol: "gETH", + symbol: "ETH", decimals: 18, wrapped: { address: "0x0bb7509324ce409f7bbc4b701f932eaca9736ab7", @@ -106,7 +106,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.Arbitrum]: { name: "Ether", - symbol: "AETH", + symbol: "ETH", decimals: 18, wrapped: { address: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", @@ -116,7 +116,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.ArbitrumTestnet]: { name: "Arbitrum Rinkeby Ether", - symbol: "ARETH", + symbol: "ETH", decimals: 18, wrapped: { address: "0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9", @@ -136,7 +136,7 @@ export const NATIVE_TOKENS: Record< }, [ChainId.OptimismTestnet]: { name: "Kovan Ether", - symbol: "KOR", + symbol: "ETH", decimals: 18, wrapped: { address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", From 53ed5299bfaab1d96a2e04c9839264c473475252 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 13:36:35 -0700 Subject: [PATCH 09/20] Replace missing one --- src/constants/currency.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 11a4e0d2e..39eae0851 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -115,7 +115,7 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.ArbitrumTestnet]: { - name: "Arbitrum Rinkeby Ether", + name: "Ether", symbol: "ETH", decimals: 18, wrapped: { From dac790fcf5adac37c5c97f27ec89cf48d3ac9fef Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 13:41:50 -0700 Subject: [PATCH 10/20] rename rpc aliases --- src/constants/urls.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/urls.ts b/src/constants/urls.ts index 05897264a..83c16fc65 100644 --- a/src/constants/urls.ts +++ b/src/constants/urls.ts @@ -37,9 +37,9 @@ export type ChainOrRpc = | "fantom" | "avalanche" | "optimism" - | "optimism-kovan" + | "optimism-testnet" | "arbitrum" - | "arbitrum-rinkeby" + | "arbitrum-testnet" // ideally we could use `https://${string}` notation here, but doing that causes anything that is a generic string to throw a type error => not worth the hassle for now | (string & {}); @@ -74,13 +74,13 @@ export function getProviderForNetwork(network: ChainOrRpc | SignerOrProvider) { case "optimism": // TODO test this RPC return `https://opt-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; - case "optimism-kovan": + case "optimism-testnet": // alchemy optimism kovan rpc doesn't link to the testnet sequencer... return "https://kovan.optimism.io"; case "arbitrum": // TODO test this RPC return `https://arb-mainnet.g.alchemy.com/v2/${DEFAULT_API_KEY}`; - case "arbirum-rinkeby": + case "arbitrum-testnet": // TODO test this RPC return `https://arb-rinkeby.g.alchemy.com/v2/${DEFAULT_API_KEY}`; case "fantom": From c307ad210dc4c34813e935b2a4b23382d835fb24 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 13:46:40 -0700 Subject: [PATCH 11/20] update docs --- etc/sdk.api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/sdk.api.md b/etc/sdk.api.md index f6efe13e4..9816ebd52 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -216,7 +216,7 @@ export const ChainlinkVrf: Record; // Warning: (ae-internal-missing-underscore) The name "ChainOrRpc" should be prefixed with an underscore because the declaration is marked as @internal // // @internal (undocumented) -export type ChainOrRpc = "mumbai" | "polygon" | "matic" | "rinkeby" | "goerli" | "mainnet" | "ethereum" | "fantom" | "avalanche" | "optimism" | "optimism-kovan" | "arbitrum" | "arbitrum-rinkeby" | (string & {}); +export type ChainOrRpc = "mumbai" | "polygon" | "matic" | "rinkeby" | "goerli" | "mainnet" | "ethereum" | "fantom" | "avalanche" | "optimism" | "optimism-testnet" | "arbitrum" | "arbitrum-testnet" | (string & {}); // Warning: (ae-internal-missing-underscore) The name "CidWithFileName" should be prefixed with an underscore because the declaration is marked as @internal // From e130b1908ff261440ba9f448caac19ec4299d686 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 13:47:34 -0700 Subject: [PATCH 12/20] remove empty file --- src/constants/chain.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/constants/chain.ts diff --git a/src/constants/chain.ts b/src/constants/chain.ts deleted file mode 100644 index e69de29bb..000000000 From 49ccfc463149138de6cd1e264d9297d026b0e261 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 13:47:59 -0700 Subject: [PATCH 13/20] v2.3.13-1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a82f14dcf..86a9a9371 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "2.3.13-0", + "version": "2.3.13-1", "description": "The main thirdweb SDK.", "repository": { "type": "git", From 276bc91aaa1e59f19fb4de930216f946f344ec04 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 16:20:52 -0700 Subject: [PATCH 14/20] Update testnets name/symbols --- src/constants/currency.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 39eae0851..87608bf3b 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -115,8 +115,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.ArbitrumTestnet]: { - name: "Ether", - symbol: "ETH", + name: "Arbitrum Rinkeby Ether", + symbol: "ARETH", decimals: 18, wrapped: { address: "0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9", @@ -135,8 +135,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.OptimismTestnet]: { - name: "Ether", - symbol: "ETH", + name: "Kovan Ether", + symbol: "KOR", decimals: 18, wrapped: { address: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", From a7c86b7511ffc0b6f3b4c0705caf03c72fc84ffb Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 16:23:04 -0700 Subject: [PATCH 15/20] Update testnets name/symbols --- src/constants/currency.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/currency.ts b/src/constants/currency.ts index 87608bf3b..6fbc5af94 100644 --- a/src/constants/currency.ts +++ b/src/constants/currency.ts @@ -25,8 +25,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Rinkeby]: { - name: "Ether", - symbol: "ETH", + name: "Rinkeby Ether", + symbol: "RIN", decimals: 18, wrapped: { address: "0xc778417E063141139Fce010982780140Aa0cD5Ab", @@ -35,8 +35,8 @@ export const NATIVE_TOKENS: Record< }, }, [ChainId.Goerli]: { - name: "Ether", - symbol: "ETH", + name: "Görli Ether", + symbol: "GOR", decimals: 18, wrapped: { address: "0x0bb7509324ce409f7bbc4b701f932eaca9736ab7", From 2d4d0dcf7cc41777432fec7931c0669105863961 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Mon, 13 Jun 2022 16:32:59 -0700 Subject: [PATCH 16/20] v2.3.13-2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86a9a9371..dadbfa897 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "2.3.13-1", + "version": "2.3.13-2", "description": "The main thirdweb SDK.", "repository": { "type": "git", From 02095825fe754451e3b716ba22dfcd22fc9c2d0b Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 16:13:05 -0700 Subject: [PATCH 17/20] expose edition.claimConditions.setBatch() to set claim conditions on multiple tokenIds at once (#468) expoer edition.claimConditions.setBatch() to set claim conditions on multiple tokenIds at once --- docs/sdk.droperc1155claimconditions.md | 3 +- docs/sdk.droperc1155claimconditions.set.md | 4 +- ...sdk.droperc1155claimconditions.setbatch.md | 55 +++++++++++++++++ etc/sdk.api.md | 3 + .../classes/drop-erc1155-claim-conditions.ts | 61 ++++++++++++++++--- test/edition-drop.test.ts | 23 +++++++ 6 files changed, 137 insertions(+), 12 deletions(-) create mode 100644 docs/sdk.droperc1155claimconditions.setbatch.md diff --git a/docs/sdk.droperc1155claimconditions.md b/docs/sdk.droperc1155claimconditions.md index 881f2a4cf..a1a894586 100644 --- a/docs/sdk.droperc1155claimconditions.md +++ b/docs/sdk.droperc1155claimconditions.md @@ -26,6 +26,7 @@ export declare class DropErc1155ClaimConditions | [getActive(tokenId)](./sdk.droperc1155claimconditions.getactive.md) | | Get the currently active claim condition | | [getAll(tokenId)](./sdk.droperc1155claimconditions.getall.md) | | Get all the claim conditions | | [getClaimIneligibilityReasons(tokenId, quantity, addressToCheck)](./sdk.droperc1155claimconditions.getclaimineligibilityreasons.md) | | For any claim conditions that a particular wallet is violating, this function returns human-readable information about the breaks in the condition that can be used to inform the user. | -| [set(tokenId, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.set.md) | | Set public mint conditions on a NFT | +| [set(tokenId, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.set.md) | | Set claim conditions on a single NFT | +| [setBatch(tokenIds, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.setbatch.md) | | Set claim conditions on multiple NFTs at once | | [update(tokenId, index, claimConditionInput)](./sdk.droperc1155claimconditions.update.md) | | Update a single claim condition with new data. | diff --git a/docs/sdk.droperc1155claimconditions.set.md b/docs/sdk.droperc1155claimconditions.set.md index 26d91ce75..d7823ce55 100644 --- a/docs/sdk.droperc1155claimconditions.set.md +++ b/docs/sdk.droperc1155claimconditions.set.md @@ -4,7 +4,7 @@ ## DropErc1155ClaimConditions.set() method -Set public mint conditions on a NFT +Set claim conditions on a single NFT Signature: @@ -26,7 +26,7 @@ Promise<[TransactionResult](./sdk.transactionresult.md)> ## Remarks -Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this bundle. +Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this contract. ## Example diff --git a/docs/sdk.droperc1155claimconditions.setbatch.md b/docs/sdk.droperc1155claimconditions.setbatch.md new file mode 100644 index 000000000..f3ad054ed --- /dev/null +++ b/docs/sdk.droperc1155claimconditions.setbatch.md @@ -0,0 +1,55 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [DropErc1155ClaimConditions](./sdk.droperc1155claimconditions.md) > [setBatch](./sdk.droperc1155claimconditions.setbatch.md) + +## DropErc1155ClaimConditions.setBatch() method + +Set claim conditions on multiple NFTs at once + +Signature: + +```typescript +setBatch(tokenIds: BigNumberish[], claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise<{ + receipt: ethers.providers.TransactionReceipt; + }>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| tokenIds | BigNumberish\[\] | the token ids to set the claim conditions on | +| claimConditionInputs | [ClaimConditionInput](./sdk.claimconditioninput.md)\[\] | The claim conditions | +| resetClaimEligibilityForAll | boolean | (Optional) Whether to reset the state of who already claimed NFTs previously | + +Returns: + +Promise<{ receipt: ethers.providers.TransactionReceipt; }> + +## Remarks + +Sets the claim conditions that need to be fulfilled by users to claim the given NFTs in this contract. + +## Example + + +```javascript +const presaleStartTime = new Date(); +const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000); +const claimConditions = [ + { + startTime: presaleStartTime, // start the presale now + maxQuantity: 2, // limit how many mints for this presale + price: 0.01, // presale price + snapshot: ['0x...', '0x...'], // limit minting to only certain addresses + }, + { + startTime: publicSaleStartTime, // 24h after presale, start public sale + price: 0.08, // public sale price + } +]); + +const tokenIds = [0,1,2]; // the ids of the NFTs to set claim conditions on +await dropContract.claimConditions.setBatch(tokenIds, claimConditions); +``` + diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 9816ebd52..4f8c0533e 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -943,6 +943,9 @@ export class DropErc1155ClaimConditions { getAll(tokenId: BigNumberish): Promise; getClaimIneligibilityReasons(tokenId: BigNumberish, quantity: BigNumberish, addressToCheck?: string): Promise; set(tokenId: BigNumberish, claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise; + setBatch(tokenIds: BigNumberish[], claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise<{ + receipt: ethers.providers.TransactionReceipt; + }>; update(tokenId: BigNumberish, index: number, claimConditionInput: ClaimConditionInput): Promise; } diff --git a/src/core/classes/drop-erc1155-claim-conditions.ts b/src/core/classes/drop-erc1155-claim-conditions.ts index 4205e0781..ef330a9bf 100644 --- a/src/core/classes/drop-erc1155-claim-conditions.ts +++ b/src/core/classes/drop-erc1155-claim-conditions.ts @@ -267,9 +267,9 @@ export class DropErc1155ClaimConditions { *****************************************/ /** - * Set public mint conditions on a NFT + * Set claim conditions on a single NFT * - * @remarks Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this bundle. + * @remarks Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this contract. * * @example * ```javascript @@ -301,6 +301,48 @@ export class DropErc1155ClaimConditions { claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll = false, ): Promise { + return this.setBatch( + [tokenId], + claimConditionInputs, + resetClaimEligibilityForAll, + ); + } + + /** + * Set claim conditions on multiple NFTs at once + * + * @remarks Sets the claim conditions that need to be fulfilled by users to claim the given NFTs in this contract. + * + * @example + * ```javascript + * const presaleStartTime = new Date(); + * const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000); + * const claimConditions = [ + * { + * startTime: presaleStartTime, // start the presale now + * maxQuantity: 2, // limit how many mints for this presale + * price: 0.01, // presale price + * snapshot: ['0x...', '0x...'], // limit minting to only certain addresses + * }, + * { + * startTime: publicSaleStartTime, // 24h after presale, start public sale + * price: 0.08, // public sale price + * } + * ]); + * + * const tokenIds = [0,1,2]; // the ids of the NFTs to set claim conditions on + * await dropContract.claimConditions.setBatch(tokenIds, claimConditions); + * ``` + * + * @param tokenIds - the token ids to set the claim conditions on + * @param claimConditionInputs - The claim conditions + * @param resetClaimEligibilityForAll - Whether to reset the state of who already claimed NFTs previously + */ + public async setBatch( + tokenIds: BigNumberish[], + claimConditionInputs: ClaimConditionInput[], + resetClaimEligibilityForAll = false, + ) { // process inputs const { snapshotInfos, sortedConditions } = await processClaimConditionInputs( @@ -340,13 +382,14 @@ export class DropErc1155ClaimConditions { ); } - encoded.push( - this.contractWrapper.readContract.interface.encodeFunctionData( - "setClaimConditions", - [tokenId, sortedConditions, resetClaimEligibilityForAll], - ), - ); - + tokenIds.forEach((tokenId) => { + encoded.push( + this.contractWrapper.readContract.interface.encodeFunctionData( + "setClaimConditions", + [tokenId, sortedConditions, resetClaimEligibilityForAll], + ), + ); + }); return { receipt: await this.contractWrapper.multiCall(encoded), }; diff --git a/test/edition-drop.test.ts b/test/edition-drop.test.ts index 2711bd7f1..bddce7895 100644 --- a/test/edition-drop.test.ts +++ b/test/edition-drop.test.ts @@ -376,6 +376,29 @@ describe("Edition Drop Contract", async () => { await bdContract.claim("0", 1); }); + it("should set multiple claim conditions at once", async () => { + await bdContract.createBatch([ + { + name: "test1", + description: "test1", + }, + { + name: "test2", + description: "test2", + }, + ]); + await bdContract.claimConditions.setBatch( + [0, 1], + [ + { + price: 1, + }, + ], + ); + await bdContract.claim("0", 1); + await bdContract.claim("1", 1); + }); + describe("eligibility", () => { beforeEach(async () => { await bdContract.createBatch([ From 20fc947f19edfb4eb5cdddfc6de6d688ecf355dd Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 13 Jun 2022 16:51:18 -0700 Subject: [PATCH 18/20] v2.3.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dadbfa897..0060dd764 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "2.3.13-2", + "version": "2.3.13", "description": "The main thirdweb SDK.", "repository": { "type": "git", From 08841399c5f9a0209a9fb47465ba90c7a137421c Mon Sep 17 00:00:00 2001 From: Jonas Daniels Date: Tue, 14 Jun 2022 08:50:05 -0700 Subject: [PATCH 19/20] remove unusupported chains from chainId enum, make nativetoken always have 18 decimals in type --- docs/sdk.chainid.md | 5 ----- docs/sdk.nativetoken.md | 1 + etc/sdk.api.md | 14 +++----------- src/constants/chains.ts | 5 ----- src/types/currency.ts | 2 ++ 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/docs/sdk.chainid.md b/docs/sdk.chainid.md index 5fb4d3aff..e73ccf293 100644 --- a/docs/sdk.chainid.md +++ b/docs/sdk.chainid.md @@ -19,21 +19,16 @@ export declare enum ChainId | ArbitrumTestnet | 421611 | | | Avalanche | 43114 | | | AvalancheFujiTestnet | 43113 | | -| BSC | 56 | | | Fantom | 250 | | | FantomTestnet | 4002 | | | Goerli | 5 | | | Hardhat | 31337 | | | Harmony | 1666600000 | | -| Kovan | 42 | | | Localhost | 1337 | | | Mainnet | 1 | | -| Moonriver | 1285 | | | Mumbai | 80001 | | | Optimism | 10 | | | OptimismTestnet | 69 | | | Polygon | 137 | | | Rinkeby | 4 | | -| Ropsten | 3 | | -| xDai | 100 | | diff --git a/docs/sdk.nativetoken.md b/docs/sdk.nativetoken.md index 0afb5570c..06dde39fa 100644 --- a/docs/sdk.nativetoken.md +++ b/docs/sdk.nativetoken.md @@ -15,5 +15,6 @@ export interface NativeToken extends Currency | Property | Type | Description | | --- | --- | --- | +| [decimals](./sdk.nativetoken.decimals.md) | 18 | | | [wrapped](./sdk.nativetoken.wrapped.md) | { address: string; name: string; symbol: string; } | | diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 4f8c0533e..eb68266ee 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -163,8 +163,6 @@ export enum ChainId { // (undocumented) AvalancheFujiTestnet = 43113, // (undocumented) - BSC = 56, - // (undocumented) Fantom = 250, // (undocumented) FantomTestnet = 4002, @@ -175,14 +173,10 @@ export enum ChainId { // (undocumented) Harmony = 1666600000, // (undocumented) - Kovan = 42, - // (undocumented) Localhost = 1337, // (undocumented) Mainnet = 1, // (undocumented) - Moonriver = 1285, - // (undocumented) Mumbai = 80001, // (undocumented) Optimism = 10, @@ -191,11 +185,7 @@ export enum ChainId { // (undocumented) Polygon = 137, // (undocumented) - Rinkeby = 4, - // (undocumented) - Ropsten = 3, - // (undocumented) - xDai = 100 + Rinkeby = 4 } // Warning: (ae-internal-missing-underscore) The name "ChainlinkInfo" should be prefixed with an underscore because the declaration is marked as @internal @@ -2546,6 +2536,8 @@ export const NATIVE_TOKENS: Record; export interface NativeToken extends Currency { + // native tokens all have 18 decimals + decimals: 18; wrapped: { address: string; name: string; From dd20cba1ec1fa39e268211a822e297d1d019e3e4 Mon Sep 17 00:00:00 2001 From: Jonas Daniels Date: Tue, 14 Jun 2022 08:50:22 -0700 Subject: [PATCH 20/20] check in docs usage --- docs/sdk.nativetoken.decimals.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/sdk.nativetoken.decimals.md diff --git a/docs/sdk.nativetoken.decimals.md b/docs/sdk.nativetoken.decimals.md new file mode 100644 index 000000000..a61b61827 --- /dev/null +++ b/docs/sdk.nativetoken.decimals.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [NativeToken](./sdk.nativetoken.md) > [decimals](./sdk.nativetoken.decimals.md) + +## NativeToken.decimals property + +Signature: + +```typescript +decimals: 18; +```