Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b4b6a5b4e | ||
|
|
b3d57949bd | ||
|
|
1cf1f866d5 | ||
|
|
602d8cbcfa |
@@ -5,10 +5,10 @@ export default {
|
||||
"shortName": "Camelark",
|
||||
"chain": "ETHW",
|
||||
"icon": {
|
||||
"url": "ipfs://QmbXDcCWHh8jExE1tAUkUKzXyTb8srpC75ogZq1QYkMMRW",
|
||||
"url": "ipfs://QmeJerrsURFNt2LL7DE7TxeunjrQXiuezdfHyqmsbwX3MZ",
|
||||
"width": 128,
|
||||
"height": 128,
|
||||
"format": "svg"
|
||||
"format": "png"
|
||||
},
|
||||
"networkId": 20001,
|
||||
"nativeCurrency": {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"name": "Canto Testnet",
|
||||
"chain": "Canto Tesnet",
|
||||
"rpc": [
|
||||
"https://canto-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://eth.plexnode.wtf/"
|
||||
],
|
||||
"faucets": [],
|
||||
"nativeCurrency": {
|
||||
"name": "Canto",
|
||||
"symbol": "CANTO",
|
||||
"decimals": 18
|
||||
},
|
||||
"infoURL": "https://canto.io",
|
||||
"shortName": "tcanto",
|
||||
"chainId": 740,
|
||||
"networkId": 740,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "Canto Tesnet Explorer (Neobase)",
|
||||
"url": "https://testnet-explorer.canto.neobase.one",
|
||||
"standard": "none"
|
||||
}
|
||||
],
|
||||
"testnet": true,
|
||||
"slug": "canto-testnet"
|
||||
} as const satisfies Chain;
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { Chain } from "../src/types";
|
||||
export default {
|
||||
"name": "BeOne Chain Mainnet",
|
||||
"chain": "BOC",
|
||||
"icon": {
|
||||
"url": "ipfs://QmbVLQnaMDu86bPyKgCvTGhFBeYwjr15hQnrCcsp1EkAGL",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"format": "png"
|
||||
},
|
||||
"rpc": [
|
||||
"https://beone-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
|
||||
"https://dataseed1.beonechain.com",
|
||||
"https://dataseed2.beonechain.com",
|
||||
"https://dataseed-us1.beonechain.com",
|
||||
"https://dataseed-us2.beonechain.com",
|
||||
"https://dataseed-uk1.beonechain.com",
|
||||
"https://dataseed-uk2.beonechain.com"
|
||||
],
|
||||
"faucets": [],
|
||||
"nativeCurrency": {
|
||||
"name": "BeOne Chain Mainnet",
|
||||
"symbol": "BOC",
|
||||
"decimals": 18
|
||||
},
|
||||
"infoURL": "https://beonechain.com",
|
||||
"shortName": "BOC",
|
||||
"chainId": 818,
|
||||
"networkId": 818,
|
||||
"slip44": 8181,
|
||||
"explorers": [
|
||||
{
|
||||
"name": "BeOne Chain Mainnet",
|
||||
"url": "https://beonescan.com",
|
||||
"standard": "EIP3091"
|
||||
}
|
||||
],
|
||||
"testnet": false,
|
||||
"slug": "beone-chain"
|
||||
} as const satisfies Chain;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,12 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.10.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5), [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe)]:
|
||||
- @thirdweb-dev/sdk@3.10.9
|
||||
|
||||
## 0.10.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.10.9",
|
||||
"version": "0.10.10",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 3.11.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5), [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe)]:
|
||||
- @thirdweb-dev/sdk@3.10.9
|
||||
|
||||
## 3.11.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "3.11.5",
|
||||
"version": "3.11.6",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-native-compat
|
||||
|
||||
## 0.2.6
|
||||
|
||||
## 0.2.5
|
||||
|
||||
## 0.2.4
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native-compat",
|
||||
"description": "Shims for Thirdweb in React Native Projects",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/react-native
|
||||
|
||||
## 0.2.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5), [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe)]:
|
||||
- @thirdweb-dev/sdk@3.10.9
|
||||
- @thirdweb-dev/react-core@3.11.6
|
||||
|
||||
## 0.2.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-native",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.6",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 3.11.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5), [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe)]:
|
||||
- @thirdweb-dev/sdk@3.10.9
|
||||
- @thirdweb-dev/react-core@3.11.6
|
||||
|
||||
## 3.11.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "3.11.5",
|
||||
"version": "3.11.6",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -11,6 +11,7 @@ export const ChainIcon: React.FC<{
|
||||
chain?: Chain;
|
||||
size: string;
|
||||
active?: boolean;
|
||||
className?: string;
|
||||
}> = (props) => {
|
||||
const url = props.chain?.icon?.url;
|
||||
const src = url ? resolveIpfsUri(url) : defaultChainIcon;
|
||||
@@ -34,6 +35,7 @@ export const ChainIcon: React.FC<{
|
||||
alt=""
|
||||
width={props.size}
|
||||
height={props.size}
|
||||
className={props.className}
|
||||
/>
|
||||
{props.active && <ActiveDot />}
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@ export const Img: React.FC<{
|
||||
src: string;
|
||||
alt?: string;
|
||||
loading?: "eager" | "lazy";
|
||||
className?: string;
|
||||
}> = (props) => {
|
||||
return (
|
||||
<img
|
||||
@@ -19,6 +20,7 @@ export const Img: React.FC<{
|
||||
height: props.height + "px",
|
||||
width: props.width + "px",
|
||||
}}
|
||||
className={props.className}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -22,6 +22,8 @@ import invariant from "tiny-invariant";
|
||||
|
||||
type ActionFn = (contract: SmartContract) => any;
|
||||
|
||||
const TW_WEB3BUTTON = "tw-web3button";
|
||||
|
||||
interface Web3ButtonProps<TActionFn extends ActionFn> {
|
||||
className?: string;
|
||||
contractAddress: `0x${string}` | `${string}.eth` | string;
|
||||
@@ -121,7 +123,12 @@ export const Web3Button = <TAction extends ActionFn>({
|
||||
);
|
||||
|
||||
if (!address) {
|
||||
return <ConnectWallet theme={theme} />;
|
||||
return (
|
||||
<ConnectWallet
|
||||
theme={theme}
|
||||
className={`${className || ""} ${TW_WEB3BUTTON}--connect-wallet`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// let onClick = () => actionMutation.mutate();
|
||||
@@ -152,9 +159,11 @@ export const Web3Button = <TAction extends ActionFn>({
|
||||
<Button
|
||||
variant="inverted"
|
||||
type={type}
|
||||
className={className}
|
||||
className={`${className || ""} ${TW_WEB3BUTTON}--switch-network`}
|
||||
onClick={handleSwitchChain}
|
||||
style={btnStyle}
|
||||
data-is-loading={confirmStatus === "waiting"}
|
||||
data-theme={theme}
|
||||
>
|
||||
{confirmStatus === "waiting" ? (
|
||||
<Spinner size="sm" color={"inverted"} />
|
||||
@@ -195,10 +204,11 @@ export const Web3Button = <TAction extends ActionFn>({
|
||||
<Button
|
||||
variant="inverted"
|
||||
type={type}
|
||||
className={className}
|
||||
className={`${className || ""} ${TW_WEB3BUTTON}`}
|
||||
disabled
|
||||
onClick={handleSwitchChain}
|
||||
style={btnStyle}
|
||||
data-is-loading
|
||||
data-theme={theme}
|
||||
>
|
||||
<Spinner size="md" color={"inverted"} />
|
||||
</Button>
|
||||
@@ -211,10 +221,12 @@ export const Web3Button = <TAction extends ActionFn>({
|
||||
<Button
|
||||
variant="inverted"
|
||||
type={type}
|
||||
className={className}
|
||||
className={`${className || ""} ${TW_WEB3BUTTON}`}
|
||||
onClick={() => actionMutation.mutate()}
|
||||
disabled={isDisabled}
|
||||
style={btnStyle}
|
||||
data-is-loading="false"
|
||||
data-theme={theme}
|
||||
>
|
||||
{children}
|
||||
</Button>
|
||||
|
||||
@@ -38,6 +38,8 @@ type ConnectWalletProps = {
|
||||
};
|
||||
};
|
||||
|
||||
const TW_CONNECT_WALLET = "tw-connect-wallet";
|
||||
|
||||
/**
|
||||
* A component that allows the user to connect their wallet.
|
||||
*
|
||||
@@ -98,7 +100,12 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
||||
|
||||
{/* Sign In Button */}
|
||||
{requiresSignIn && (
|
||||
<Button variant="inverted" onClick={signIn}>
|
||||
<Button
|
||||
variant="inverted"
|
||||
onClick={signIn}
|
||||
data-theme={theme}
|
||||
className={`${TW_CONNECT_WALLET}--sign-in`}
|
||||
>
|
||||
<Flex
|
||||
alignItems="center"
|
||||
gap="sm"
|
||||
@@ -120,7 +127,9 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
||||
// connect wallet button
|
||||
<AnimatedButton
|
||||
disabled={isLoading}
|
||||
className={props.className}
|
||||
className={`${props.className || ""} ${TW_CONNECT_WALLET}`}
|
||||
data-theme={theme}
|
||||
data-is-loading={isLoading}
|
||||
variant="inverted"
|
||||
type="button"
|
||||
style={{
|
||||
@@ -139,6 +148,7 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = (props) => {
|
||||
) : (
|
||||
<ConnectedWalletDetails
|
||||
dropdownPosition={props.dropdownPosition}
|
||||
theme={theme}
|
||||
onDisconnect={() => {
|
||||
if (authConfig?.authUrl) {
|
||||
logout();
|
||||
|
||||
@@ -44,9 +44,12 @@ export type DropDownPosition = {
|
||||
align: "start" | "center" | "end";
|
||||
};
|
||||
|
||||
const TW_CONNECTED_WALLET = "tw-connected-wallet";
|
||||
|
||||
export const ConnectedWalletDetails: React.FC<{
|
||||
dropdownPosition?: DropDownPosition;
|
||||
onDisconnect: () => void;
|
||||
theme: "dark" | "light";
|
||||
}> = (props) => {
|
||||
const disconnect = useDisconnect();
|
||||
const chains = useSupportedChains();
|
||||
@@ -101,12 +104,20 @@ export const ConnectedWalletDetails: React.FC<{
|
||||
}, [personalWallet]);
|
||||
|
||||
const trigger = (
|
||||
<WalletInfoButton type="button">
|
||||
<ChainIcon chain={chain} size={iconSize.lg} />
|
||||
<WalletInfoButton
|
||||
type="button"
|
||||
className={TW_CONNECTED_WALLET}
|
||||
data-theme={props.theme}
|
||||
>
|
||||
<ChainIcon
|
||||
chain={chain}
|
||||
size={iconSize.lg}
|
||||
className={`${TW_CONNECTED_WALLET}__network-icon`}
|
||||
/>
|
||||
|
||||
<ColFlex>
|
||||
{!balanceQuery.isLoading ? (
|
||||
<WalletBalance>
|
||||
<WalletBalance className={`${TW_CONNECTED_WALLET}__balance`}>
|
||||
{balanceQuery.data?.displayValue.slice(0, 5)}{" "}
|
||||
{balanceQuery.data?.symbol}
|
||||
</WalletBalance>
|
||||
@@ -114,10 +125,17 @@ export const ConnectedWalletDetails: React.FC<{
|
||||
<Skeleton height={fontSize.sm} width="82px" />
|
||||
)}
|
||||
<Spacer y="xs" />
|
||||
<WalletAddress>{shortenString(address || "")}</WalletAddress>
|
||||
<WalletAddress className={`${TW_CONNECTED_WALLET}__address`}>
|
||||
{shortenString(address || "")}
|
||||
</WalletAddress>
|
||||
</ColFlex>
|
||||
|
||||
<Img width={iconSize.lg} height={iconSize.lg} src={activeWalletIconURL} />
|
||||
<Img
|
||||
width={iconSize.lg}
|
||||
height={iconSize.lg}
|
||||
src={activeWalletIconURL}
|
||||
className={`${TW_CONNECTED_WALLET}__wallet-icon`}
|
||||
/>
|
||||
</WalletInfoButton>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 3.10.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#864](https://github.com/thirdweb-dev/js/pull/864) [`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5) Thanks [@ciaranightingale](https://github.com/ciaranightingale)! - Remove necessity for LazyMint to detect any of the claim extensions
|
||||
|
||||
- [#869](https://github.com/thirdweb-dev/js/pull/869) [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe) Thanks [@adam-maj](https://github.com/adam-maj)! - Add .prepare() syntax to tiered-drop
|
||||
|
||||
## 3.10.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "3.10.8",
|
||||
"version": "3.10.9",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -30,7 +30,7 @@ export const FEATURE_EDITION_CLAIM_CONDITIONS_V1 = {
|
||||
sdk: "sdk.erc1155claimable",
|
||||
contracts: "erc1155dropsinglephase",
|
||||
},
|
||||
abis: [Erc1155Abi, ILazyMintAbi, IDropSinglePhase1155_V1],
|
||||
abis: [Erc1155Abi, IDropSinglePhase1155_V1],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -41,7 +41,7 @@ export const FEATURE_EDITION_CLAIM_CONDITIONS_V2 = {
|
||||
sdk: "sdk.erc1155claimable",
|
||||
contracts: "erc1155claimconditions",
|
||||
},
|
||||
abis: [Erc1155Abi, ILazyMintAbi, IDropSinglePhase1155],
|
||||
abis: [Erc1155Abi, IDropSinglePhase1155],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -52,7 +52,7 @@ export const FEATURE_EDITION_CLAIM_PHASES_V2 = {
|
||||
sdk: "sdk.erc1155claimable",
|
||||
contracts: "erc1155claimphases",
|
||||
},
|
||||
abis: [Erc1155Abi, ILazyMintAbi, IDropMultiPhase1155],
|
||||
abis: [Erc1155Abi, IDropMultiPhase1155],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -74,7 +74,7 @@ export const FEATURE_EDITION_CLAIM_CUSTOM = {
|
||||
sdk: "sdk.erc1155claimable",
|
||||
contracts: "erc1155claimcustom",
|
||||
},
|
||||
abis: [Erc1155Abi, ILazyMintAbi, IClaimableERC1155],
|
||||
abis: [Erc1155Abi, IClaimableERC1155],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -99,12 +99,6 @@ export const FEATURE_EDITION_LAZY_MINTABLE_V2 = {
|
||||
abis: [Erc1155Abi, ILazyMintAbi],
|
||||
features: {
|
||||
[FEATURE_EDITION_REVEALABLE.name]: FEATURE_EDITION_REVEALABLE,
|
||||
[FEATURE_EDITION_CLAIM_CUSTOM.name]: FEATURE_EDITION_CLAIM_CUSTOM,
|
||||
[FEATURE_EDITION_CLAIM_CONDITIONS_V1.name]:
|
||||
FEATURE_EDITION_CLAIM_CONDITIONS_V1,
|
||||
[FEATURE_EDITION_CLAIM_CONDITIONS_V2.name]:
|
||||
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
||||
[FEATURE_EDITION_CLAIM_PHASES_V2.name]: FEATURE_EDITION_CLAIM_PHASES_V2,
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -195,5 +189,11 @@ export const FEATURE_EDITION = {
|
||||
[FEATURE_EDITION_REVEALABLE.name]: FEATURE_EDITION_REVEALABLE,
|
||||
[FEATURE_EDITION_SIGNATURE_MINTABLE.name]:
|
||||
FEATURE_EDITION_SIGNATURE_MINTABLE,
|
||||
[FEATURE_EDITION_CLAIM_CUSTOM.name]: FEATURE_EDITION_CLAIM_CUSTOM,
|
||||
[FEATURE_EDITION_CLAIM_CONDITIONS_V1.name]:
|
||||
FEATURE_EDITION_CLAIM_CONDITIONS_V1,
|
||||
[FEATURE_EDITION_CLAIM_CONDITIONS_V2.name]:
|
||||
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
||||
[FEATURE_EDITION_CLAIM_PHASES_V2.name]: FEATURE_EDITION_CLAIM_PHASES_V2,
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -56,7 +56,7 @@ export const FEATURE_NFT_CLAIM_CONDITIONS_V1 = {
|
||||
sdk: "sdk.erc721claimable",
|
||||
contracts: "erc721claimconditions",
|
||||
},
|
||||
abis: [Erc721Abi, ILazyMintAbi, IDropSinglePhaseV1],
|
||||
abis: [Erc721Abi, IDropSinglePhaseV1],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -67,7 +67,7 @@ export const FEATURE_NFT_CLAIM_CONDITIONS_V2 = {
|
||||
sdk: "sdk.erc721claimable",
|
||||
contracts: "erc721claimconditions",
|
||||
},
|
||||
abis: [Erc721Abi, ILazyMintAbi, IDropSinglePhase],
|
||||
abis: [Erc721Abi, IDropSinglePhase],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -89,7 +89,7 @@ export const FEATURE_NFT_CLAIM_PHASES_V2 = {
|
||||
sdk: "sdk.erc721claimable",
|
||||
contracts: "erc721claimphases",
|
||||
},
|
||||
abis: [Erc721Abi, ILazyMintAbi, IDrop],
|
||||
abis: [Erc721Abi, IDrop],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -100,7 +100,7 @@ export const FEATURE_NFT_CLAIM_CUSTOM = {
|
||||
sdk: "sdk.erc721claimable",
|
||||
contracts: "erc721claimcustom",
|
||||
},
|
||||
abis: [Erc721Abi, ILazyMintAbi, IClaimableERC721],
|
||||
abis: [Erc721Abi, IClaimableERC721],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
@@ -114,11 +114,6 @@ export const FEATURE_NFT_LAZY_MINTABLE = {
|
||||
abis: [Erc721Abi, ILazyMintAbi],
|
||||
features: {
|
||||
[FEATURE_NFT_REVEALABLE.name]: FEATURE_NFT_REVEALABLE,
|
||||
[FEATURE_NFT_CLAIM_CUSTOM.name]: FEATURE_NFT_CLAIM_CUSTOM,
|
||||
[FEATURE_NFT_CLAIM_CONDITIONS_V1.name]: FEATURE_NFT_CLAIM_CONDITIONS_V1,
|
||||
[FEATURE_NFT_CLAIM_CONDITIONS_V2.name]: FEATURE_NFT_CLAIM_CONDITIONS_V2,
|
||||
[FEATURE_NFT_CLAIM_PHASES_V1.name]: FEATURE_NFT_CLAIM_PHASES_V1,
|
||||
[FEATURE_NFT_CLAIM_PHASES_V2.name]: FEATURE_NFT_CLAIM_PHASES_V2,
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -208,5 +203,10 @@ export const FEATURE_NFT = {
|
||||
[FEATURE_NFT_SIGNATURE_MINTABLE_V1.name]: FEATURE_NFT_SIGNATURE_MINTABLE_V1,
|
||||
[FEATURE_NFT_SIGNATURE_MINTABLE_V2.name]: FEATURE_NFT_SIGNATURE_MINTABLE_V2,
|
||||
[FEATURE_NFT_TIERED_DROP.name]: FEATURE_NFT_TIERED_DROP,
|
||||
[FEATURE_NFT_CLAIM_CUSTOM.name]: FEATURE_NFT_CLAIM_CUSTOM,
|
||||
[FEATURE_NFT_CLAIM_CONDITIONS_V1.name]: FEATURE_NFT_CLAIM_CONDITIONS_V1,
|
||||
[FEATURE_NFT_CLAIM_CONDITIONS_V2.name]: FEATURE_NFT_CLAIM_CONDITIONS_V2,
|
||||
[FEATURE_NFT_CLAIM_PHASES_V1.name]: FEATURE_NFT_CLAIM_PHASES_V1,
|
||||
[FEATURE_NFT_CLAIM_PHASES_V2.name]: FEATURE_NFT_CLAIM_PHASES_V2,
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -7,24 +7,15 @@ import {
|
||||
FEATURE_EDITION_LAZY_MINTABLE_V2,
|
||||
FEATURE_EDITION_REVEALABLE,
|
||||
} from "../../constants/erc1155-features";
|
||||
import {
|
||||
BaseClaimConditionERC1155,
|
||||
BaseDelayedRevealERC1155,
|
||||
BaseDropERC1155,
|
||||
} from "../../types/eips";
|
||||
import { BaseDelayedRevealERC1155, BaseDropERC1155 } from "../../types/eips";
|
||||
import { UploadProgressEvent } from "../../types/events";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResultWithId } from "../types";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { DelayedReveal } from "./delayed-reveal";
|
||||
import { Erc1155 } from "./erc-1155";
|
||||
import { ERC1155Claimable } from "./erc-1155-claimable";
|
||||
import { Erc1155ClaimableWithConditions } from "./erc-1155-claimable-with-conditions";
|
||||
import { Transaction } from "./transactions";
|
||||
import type {
|
||||
DropERC1155_V2,
|
||||
IClaimableERC1155,
|
||||
} from "@thirdweb-dev/contracts-js";
|
||||
import type { DropERC1155_V2 } from "@thirdweb-dev/contracts-js";
|
||||
import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/LazyMint";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import { ethers } from "ethers";
|
||||
@@ -65,19 +56,6 @@ export class Erc1155LazyMintable implements DetectableFeature {
|
||||
*/
|
||||
public revealer: DelayedReveal<BaseDelayedRevealERC1155> | undefined;
|
||||
|
||||
/**
|
||||
* Claim tokens and configure claim conditions
|
||||
* @remarks Let users claim NFTs. Define who can claim NFTs in the collection, when and how many.
|
||||
* @example
|
||||
* ```javascript
|
||||
* const quantity = 10;
|
||||
* const tokenId = 0;
|
||||
* await contract.erc1155.claimTo("0x...", 0, quantity);
|
||||
* ```
|
||||
*/
|
||||
public claimWithConditions: Erc1155ClaimableWithConditions | undefined;
|
||||
public claim: ERC1155Claimable | undefined;
|
||||
|
||||
private contractWrapper: ContractWrapper<BaseDropERC1155>;
|
||||
private erc1155: Erc1155;
|
||||
private storage: ThirdwebStorage;
|
||||
@@ -91,8 +69,6 @@ export class Erc1155LazyMintable implements DetectableFeature {
|
||||
this.contractWrapper = contractWrapper;
|
||||
|
||||
this.storage = storage;
|
||||
this.claim = this.detectErc1155Claimable();
|
||||
this.claimWithConditions = this.detectErc1155ClaimableWithConditions();
|
||||
this.revealer = this.detectErc1155Revealable();
|
||||
}
|
||||
|
||||
@@ -201,47 +177,6 @@ export class Erc1155LazyMintable implements DetectableFeature {
|
||||
* PRIVATE FUNCTIONS
|
||||
*******************************/
|
||||
|
||||
private detectErc1155Claimable(): ERC1155Claimable | undefined {
|
||||
if (
|
||||
detectContractFeature<IClaimableERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimCustom",
|
||||
)
|
||||
) {
|
||||
return new ERC1155Claimable(this.contractWrapper);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc1155ClaimableWithConditions():
|
||||
| Erc1155ClaimableWithConditions
|
||||
| undefined {
|
||||
if (
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimConditionsV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimConditionsV2",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimPhasesV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimPhasesV2",
|
||||
)
|
||||
) {
|
||||
return new Erc1155ClaimableWithConditions(
|
||||
this.contractWrapper,
|
||||
this.storage,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc1155Revealable():
|
||||
| DelayedReveal<BaseDelayedRevealERC1155>
|
||||
| undefined {
|
||||
|
||||
@@ -28,6 +28,7 @@ import { EditionMetadataOrUri } from "../../schema/tokens/edition";
|
||||
import { ClaimOptions, UploadProgressEvent } from "../../types";
|
||||
import { AirdropInput } from "../../types/airdrop/airdrop";
|
||||
import {
|
||||
BaseClaimConditionERC1155,
|
||||
BaseDropERC1155,
|
||||
BaseERC1155,
|
||||
BaseSignatureMintERC1155,
|
||||
@@ -45,12 +46,15 @@ import { Transaction } from "./transactions";
|
||||
import type {
|
||||
DropERC1155,
|
||||
IBurnableERC1155,
|
||||
IClaimableERC1155,
|
||||
IERC1155Enumerable,
|
||||
IMintableERC1155,
|
||||
TokenERC1155,
|
||||
} from "@thirdweb-dev/contracts-js";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import { BigNumber, BigNumberish, BytesLike, ethers } from "ethers";
|
||||
import { ERC1155Claimable } from "./erc-1155-claimable";
|
||||
import { Erc1155ClaimableWithConditions } from "./erc-1155-claimable-with-conditions";
|
||||
|
||||
/**
|
||||
* Standard ERC1155 NFT functions
|
||||
@@ -74,6 +78,8 @@ export class Erc1155<
|
||||
private burnable: Erc1155Burnable | undefined;
|
||||
private lazyMintable: Erc1155LazyMintable | undefined;
|
||||
private signatureMintable: Erc1155SignatureMintable | undefined;
|
||||
private claimWithConditions: Erc1155ClaimableWithConditions | undefined;
|
||||
private claimCustom: ERC1155Claimable | undefined;
|
||||
|
||||
protected contractWrapper: ContractWrapper<T>;
|
||||
protected storage: ThirdwebStorage;
|
||||
@@ -95,6 +101,8 @@ export class Erc1155<
|
||||
this.burnable = this.detectErc1155Burnable();
|
||||
this.lazyMintable = this.detectErc1155LazyMintable();
|
||||
this.signatureMintable = this.detectErc1155SignatureMintable();
|
||||
this.claimCustom = this.detectErc1155Claimable();
|
||||
this.claimWithConditions = this.detectErc1155ClaimableWithConditions();
|
||||
this._chainId = chainId;
|
||||
}
|
||||
|
||||
@@ -853,8 +861,8 @@ export class Erc1155<
|
||||
quantity: BigNumberish,
|
||||
options?: ClaimOptions,
|
||||
): Promise<Transaction> {
|
||||
const claimWithConditions = this.lazyMintable?.claimWithConditions;
|
||||
const claim = this.lazyMintable?.claim;
|
||||
const claimWithConditions = this.claimWithConditions;
|
||||
const claim = this.claimCustom;
|
||||
if (claimWithConditions) {
|
||||
return claimWithConditions.conditions.getClaimTransaction(
|
||||
destinationAddress,
|
||||
@@ -940,8 +948,8 @@ export class Erc1155<
|
||||
quantity: BigNumberish,
|
||||
options?: ClaimOptions,
|
||||
) => {
|
||||
const claimWithConditions = this.lazyMintable?.claimWithConditions;
|
||||
const claim = this.lazyMintable?.claim;
|
||||
const claimWithConditions = this.claimWithConditions;
|
||||
const claim = this.claimCustom;
|
||||
if (claimWithConditions) {
|
||||
return claimWithConditions.to.prepare(
|
||||
destinationAddress,
|
||||
@@ -982,7 +990,7 @@ export class Erc1155<
|
||||
*/
|
||||
get claimConditions() {
|
||||
return assertEnabled(
|
||||
this.lazyMintable?.claimWithConditions,
|
||||
this.claimWithConditions,
|
||||
FEATURE_EDITION_CLAIM_CONDITIONS_V2,
|
||||
).conditions;
|
||||
}
|
||||
@@ -1132,4 +1140,45 @@ export class Erc1155<
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc1155Claimable(): ERC1155Claimable | undefined {
|
||||
if (
|
||||
detectContractFeature<IClaimableERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimCustom",
|
||||
)
|
||||
) {
|
||||
return new ERC1155Claimable(this.contractWrapper);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc1155ClaimableWithConditions():
|
||||
| Erc1155ClaimableWithConditions
|
||||
| undefined {
|
||||
if (
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimConditionsV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimConditionsV2",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimPhasesV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC1155>(
|
||||
this.contractWrapper,
|
||||
"ERC1155ClaimPhasesV2",
|
||||
)
|
||||
) {
|
||||
return new Erc1155ClaimableWithConditions(
|
||||
this.contractWrapper,
|
||||
this.storage,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,13 @@ import {
|
||||
FEATURE_NFT_REVEALABLE,
|
||||
} from "../../constants/erc721-features";
|
||||
import { UploadProgressEvent } from "../../types";
|
||||
import {
|
||||
BaseClaimConditionERC721,
|
||||
BaseDelayedRevealERC721,
|
||||
BaseDropERC721,
|
||||
} from "../../types/eips";
|
||||
import { BaseDelayedRevealERC721, BaseDropERC721 } from "../../types/eips";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResultWithId } from "../types";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { DelayedReveal } from "./delayed-reveal";
|
||||
import { Erc721 } from "./erc-721";
|
||||
import { Erc721Claimable } from "./erc-721-claimable";
|
||||
import { Erc721ClaimableWithConditions } from "./erc-721-claimable-with-conditions";
|
||||
import { Transaction } from "./transactions";
|
||||
import type { IClaimableERC721 } from "@thirdweb-dev/contracts-js";
|
||||
import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/LazyMint";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import { ethers } from "ethers";
|
||||
@@ -70,18 +63,6 @@ export class Erc721LazyMintable implements DetectableFeature {
|
||||
*/
|
||||
public revealer: DelayedReveal<BaseDelayedRevealERC721> | undefined;
|
||||
|
||||
/**
|
||||
* Claim tokens and configure claim conditions
|
||||
* @remarks Let users claim NFTs. Define who can claim NFTs in the collection, when and how many.
|
||||
* @example
|
||||
* ```javascript
|
||||
* const quantity = 10;
|
||||
* await contract.erc721.claim(quantity);
|
||||
* ```
|
||||
*/
|
||||
public claimWithConditions: Erc721ClaimableWithConditions | undefined;
|
||||
public claim: Erc721Claimable | undefined;
|
||||
|
||||
private contractWrapper: ContractWrapper<BaseDropERC721>;
|
||||
private erc721: Erc721;
|
||||
private storage: ThirdwebStorage;
|
||||
@@ -96,8 +77,6 @@ export class Erc721LazyMintable implements DetectableFeature {
|
||||
|
||||
this.storage = storage;
|
||||
this.revealer = this.detectErc721Revealable();
|
||||
this.claimWithConditions = this.detectErc721ClaimableWithConditions();
|
||||
this.claim = this.detectErc721Claimable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,46 +173,4 @@ export class Erc721LazyMintable implements DetectableFeature {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc721ClaimableWithConditions():
|
||||
| Erc721ClaimableWithConditions
|
||||
| undefined {
|
||||
if (
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimConditionsV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimConditionsV2",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimPhasesV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimPhasesV2",
|
||||
)
|
||||
) {
|
||||
return new Erc721ClaimableWithConditions(
|
||||
this.erc721,
|
||||
this.contractWrapper,
|
||||
this.storage,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc721Claimable(): Erc721Claimable | undefined {
|
||||
if (
|
||||
detectContractFeature<IClaimableERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimCustom",
|
||||
)
|
||||
) {
|
||||
return new Erc721Claimable(this.erc721, this.contractWrapper);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from "../../schema/contracts/tiered-drop";
|
||||
import { UploadProgressEvent } from "../../types/events";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResult, TransactionResultWithId } from "../types";
|
||||
import { TransactionResultWithId } from "../types";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { Erc721 } from "./erc-721";
|
||||
import type { TieredDrop, ISignatureAction } from "@thirdweb-dev/contracts-js";
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import { BigNumberish, ethers } from "ethers";
|
||||
import invariant from "tiny-invariant";
|
||||
import { Transaction } from "./transactions";
|
||||
import { buildTransactionFunction } from "../../common/transactions";
|
||||
|
||||
export class Erc721TieredDrop implements DetectableFeature {
|
||||
featureName = FEATURE_NFT_TIERED_DROP.name;
|
||||
@@ -112,164 +114,182 @@ export class Erc721TieredDrop implements DetectableFeature {
|
||||
return nfts;
|
||||
}
|
||||
|
||||
public async createBatchWithTier(
|
||||
metadatas: NFTMetadataOrUri[],
|
||||
tier: string,
|
||||
options?: {
|
||||
onProgress: (event: UploadProgressEvent) => void;
|
||||
},
|
||||
): Promise<TransactionResultWithId<NFTMetadata>[]> {
|
||||
// TODO: Change this to on extension
|
||||
const startFileNumber = await this.erc721.nextTokenIdToMint();
|
||||
const batch = await uploadOrExtractURIs(
|
||||
metadatas,
|
||||
this.storage,
|
||||
startFileNumber.toNumber(),
|
||||
options,
|
||||
);
|
||||
const baseUri = getBaseUriFromBatch(batch);
|
||||
createBatchWithTier = buildTransactionFunction(
|
||||
async (
|
||||
metadatas: NFTMetadataOrUri[],
|
||||
tier: string,
|
||||
options?: {
|
||||
onProgress: (event: UploadProgressEvent) => void;
|
||||
},
|
||||
): Promise<Transaction<TransactionResultWithId<NFTMetadata>[]>> => {
|
||||
// TODO: Change this to on extension
|
||||
const startFileNumber = await this.erc721.nextTokenIdToMint();
|
||||
const batch = await uploadOrExtractURIs(
|
||||
metadatas,
|
||||
this.storage,
|
||||
startFileNumber.toNumber(),
|
||||
options,
|
||||
);
|
||||
const baseUri = getBaseUriFromBatch(batch);
|
||||
|
||||
const receipt = await this.contractWrapper.sendTransaction("lazyMint", [
|
||||
batch.length,
|
||||
baseUri.endsWith("/") ? baseUri : `${baseUri}/`,
|
||||
tier,
|
||||
ethers.utils.toUtf8Bytes(""),
|
||||
]);
|
||||
return Transaction.fromContractWrapper({
|
||||
contractWrapper: this.contractWrapper,
|
||||
method: "lazyMint",
|
||||
args: [
|
||||
batch.length,
|
||||
baseUri.endsWith("/") ? baseUri : `${baseUri}/`,
|
||||
tier,
|
||||
ethers.utils.toUtf8Bytes(""),
|
||||
],
|
||||
parse: (receipt) => {
|
||||
const event = this.contractWrapper.parseLogs<TokensLazyMintedEvent>(
|
||||
"TokensLazyMinted",
|
||||
receipt?.logs,
|
||||
);
|
||||
|
||||
const event = this.contractWrapper.parseLogs<TokensLazyMintedEvent>(
|
||||
"TokensLazyMinted",
|
||||
receipt?.logs,
|
||||
);
|
||||
|
||||
const startingIndex = event[0].args[1];
|
||||
const endingIndex = event[0].args[2];
|
||||
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||
results.push({
|
||||
id,
|
||||
receipt,
|
||||
data: () => this.erc721.getTokenMetadata(id),
|
||||
const startingIndex = event[0].args[1];
|
||||
const endingIndex = event[0].args[2];
|
||||
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||
results.push({
|
||||
id,
|
||||
receipt,
|
||||
data: () => this.erc721.getTokenMetadata(id),
|
||||
});
|
||||
}
|
||||
return results;
|
||||
},
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public async createDelayedRevealBatchWithTier(
|
||||
placeholder: NFTMetadataInput,
|
||||
metadatas: NFTMetadataInput[],
|
||||
password: string,
|
||||
tier: string,
|
||||
options?: {
|
||||
onProgress: (event: UploadProgressEvent) => void;
|
||||
},
|
||||
): Promise<TransactionResultWithId<NFTMetadata>[]> {
|
||||
if (!password) {
|
||||
throw new Error("Password is required");
|
||||
}
|
||||
);
|
||||
|
||||
const placeholderUris = await this.storage.uploadBatch(
|
||||
[CommonNFTInput.parse(placeholder)],
|
||||
{
|
||||
rewriteFileNames: {
|
||||
fileStartNumber: 0,
|
||||
},
|
||||
createDelayedRevealBatchWithTier = buildTransactionFunction(
|
||||
async (
|
||||
placeholder: NFTMetadataInput,
|
||||
metadatas: NFTMetadataInput[],
|
||||
password: string,
|
||||
tier: string,
|
||||
options?: {
|
||||
onProgress: (event: UploadProgressEvent) => void;
|
||||
},
|
||||
);
|
||||
const placeholderUri = getBaseUriFromBatch(placeholderUris);
|
||||
const startFileNumber = await this.erc721.nextTokenIdToMint();
|
||||
const uris = await this.storage.uploadBatch(
|
||||
metadatas.map((m) => CommonNFTInput.parse(m)),
|
||||
{
|
||||
onProgress: options?.onProgress,
|
||||
rewriteFileNames: {
|
||||
fileStartNumber: startFileNumber.toNumber(),
|
||||
): Promise<Transaction<TransactionResultWithId<NFTMetadata>[]>> => {
|
||||
if (!password) {
|
||||
throw new Error("Password is required");
|
||||
}
|
||||
|
||||
const placeholderUris = await this.storage.uploadBatch(
|
||||
[CommonNFTInput.parse(placeholder)],
|
||||
{
|
||||
rewriteFileNames: {
|
||||
fileStartNumber: 0,
|
||||
},
|
||||
},
|
||||
);
|
||||
const placeholderUri = getBaseUriFromBatch(placeholderUris);
|
||||
const startFileNumber = await this.erc721.nextTokenIdToMint();
|
||||
const uris = await this.storage.uploadBatch(
|
||||
metadatas.map((m) => CommonNFTInput.parse(m)),
|
||||
{
|
||||
onProgress: options?.onProgress,
|
||||
rewriteFileNames: {
|
||||
fileStartNumber: startFileNumber.toNumber(),
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const baseUri = getBaseUriFromBatch(uris);
|
||||
const baseUriId = await this.contractWrapper.readContract.getBaseURICount();
|
||||
const chainId = await this.contractWrapper.getChainID();
|
||||
const hashedPassword = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256", "address"],
|
||||
[password, chainId, baseUriId, this.contractWrapper.readContract.address],
|
||||
);
|
||||
|
||||
const encryptedBaseUri =
|
||||
await this.contractWrapper.readContract.encryptDecrypt(
|
||||
ethers.utils.toUtf8Bytes(baseUri),
|
||||
hashedPassword,
|
||||
);
|
||||
|
||||
let data: string;
|
||||
const provenanceHash = ethers.utils.solidityKeccak256(
|
||||
["bytes", "bytes", "uint256"],
|
||||
[ethers.utils.toUtf8Bytes(baseUri), hashedPassword, chainId],
|
||||
);
|
||||
data = ethers.utils.defaultAbiCoder.encode(
|
||||
["bytes", "bytes32"],
|
||||
[encryptedBaseUri, provenanceHash],
|
||||
);
|
||||
const baseUri = getBaseUriFromBatch(uris);
|
||||
const baseUriId =
|
||||
await this.contractWrapper.readContract.getBaseURICount();
|
||||
const chainId = await this.contractWrapper.getChainID();
|
||||
const hashedPassword = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256", "address"],
|
||||
[
|
||||
password,
|
||||
chainId,
|
||||
baseUriId,
|
||||
this.contractWrapper.readContract.address,
|
||||
],
|
||||
);
|
||||
|
||||
const receipt = await this.contractWrapper.sendTransaction("lazyMint", [
|
||||
uris.length,
|
||||
placeholderUri.endsWith("/") ? placeholderUri : `${placeholderUri}/`,
|
||||
tier,
|
||||
data,
|
||||
]);
|
||||
const encryptedBaseUri =
|
||||
await this.contractWrapper.readContract.encryptDecrypt(
|
||||
ethers.utils.toUtf8Bytes(baseUri),
|
||||
hashedPassword,
|
||||
);
|
||||
|
||||
const event = this.contractWrapper.parseLogs<TokensLazyMintedEvent>(
|
||||
"TokensLazyMinted",
|
||||
receipt?.logs,
|
||||
);
|
||||
const startingIndex = event[0].args[1];
|
||||
const endingIndex = event[0].args[2];
|
||||
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||
results.push({
|
||||
id,
|
||||
receipt,
|
||||
data: () => this.erc721.getTokenMetadata(id),
|
||||
let data: string;
|
||||
const provenanceHash = ethers.utils.solidityKeccak256(
|
||||
["bytes", "bytes", "uint256"],
|
||||
[ethers.utils.toUtf8Bytes(baseUri), hashedPassword, chainId],
|
||||
);
|
||||
data = ethers.utils.defaultAbiCoder.encode(
|
||||
["bytes", "bytes32"],
|
||||
[encryptedBaseUri, provenanceHash],
|
||||
);
|
||||
|
||||
return Transaction.fromContractWrapper({
|
||||
contractWrapper: this.contractWrapper,
|
||||
method: "lazyMint",
|
||||
args: [
|
||||
uris.length,
|
||||
placeholderUri.endsWith("/") ? placeholderUri : `${placeholderUri}/`,
|
||||
tier,
|
||||
data,
|
||||
],
|
||||
parse: (receipt) => {
|
||||
const event = this.contractWrapper.parseLogs<TokensLazyMintedEvent>(
|
||||
"TokensLazyMinted",
|
||||
receipt?.logs,
|
||||
);
|
||||
const startingIndex = event[0].args[1];
|
||||
const endingIndex = event[0].args[2];
|
||||
const results: TransactionResultWithId<NFTMetadata>[] = [];
|
||||
for (let id = startingIndex; id.lte(endingIndex); id = id.add(1)) {
|
||||
results.push({
|
||||
id,
|
||||
receipt,
|
||||
data: () => this.erc721.getTokenMetadata(id),
|
||||
});
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public async reveal(
|
||||
batchId: BigNumberish,
|
||||
password: string,
|
||||
): Promise<TransactionResult> {
|
||||
if (!password) {
|
||||
throw new Error("Password is required");
|
||||
}
|
||||
const chainId = await this.contractWrapper.getChainID();
|
||||
const key = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256", "address"],
|
||||
[password, chainId, batchId, this.contractWrapper.readContract.address],
|
||||
);
|
||||
// performing the reveal locally to make sure it'd succeed before sending the transaction
|
||||
try {
|
||||
const decryptedUri = await this.contractWrapper
|
||||
.callStatic()
|
||||
.reveal(batchId, key);
|
||||
// basic sanity check for making sure decryptedUri is valid
|
||||
// this is optional because invalid decryption key would result in non-utf8 bytes and
|
||||
// ethers would throw when trying to decode it
|
||||
if (!decryptedUri.includes("://") || !decryptedUri.endsWith("/")) {
|
||||
reveal = buildTransactionFunction(
|
||||
async (batchId: BigNumberish, password: string) => {
|
||||
if (!password) {
|
||||
throw new Error("Password is required");
|
||||
}
|
||||
const chainId = await this.contractWrapper.getChainID();
|
||||
const key = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256", "address"],
|
||||
[password, chainId, batchId, this.contractWrapper.readContract.address],
|
||||
);
|
||||
// performing the reveal locally to make sure it'd succeed before sending the transaction
|
||||
try {
|
||||
const decryptedUri = await this.contractWrapper
|
||||
.callStatic()
|
||||
.reveal(batchId, key);
|
||||
// basic sanity check for making sure decryptedUri is valid
|
||||
// this is optional because invalid decryption key would result in non-utf8 bytes and
|
||||
// ethers would throw when trying to decode it
|
||||
if (!decryptedUri.includes("://") || !decryptedUri.endsWith("/")) {
|
||||
throw new Error("invalid password");
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error("invalid password");
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error("invalid password");
|
||||
}
|
||||
|
||||
return {
|
||||
receipt: await this.contractWrapper.sendTransaction("reveal", [
|
||||
batchId,
|
||||
key,
|
||||
]),
|
||||
};
|
||||
}
|
||||
return Transaction.fromContractWrapper({
|
||||
contractWrapper: this.contractWrapper,
|
||||
method: "reveal",
|
||||
args: [batchId, key],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
public async generate(
|
||||
payloadToSign: TieredDropPayloadInput,
|
||||
|
||||
@@ -25,7 +25,11 @@ import {
|
||||
} from "../../constants/erc721-features";
|
||||
import { Address, AddressOrEns } from "../../schema";
|
||||
import { ClaimOptions, UploadProgressEvent } from "../../types";
|
||||
import { BaseDropERC721, BaseERC721 } from "../../types/eips";
|
||||
import {
|
||||
BaseClaimConditionERC721,
|
||||
BaseDropERC721,
|
||||
BaseERC721,
|
||||
} from "../../types/eips";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { UpdateableNetwork } from "../interfaces/contract";
|
||||
import { NetworkInput, TransactionResultWithId } from "../types";
|
||||
@@ -40,6 +44,7 @@ import { Transaction } from "./transactions";
|
||||
import type {
|
||||
DropERC721,
|
||||
IBurnableERC721,
|
||||
IClaimableERC721,
|
||||
IERC721Supply,
|
||||
IMintableERC721,
|
||||
ISignatureMintERC721,
|
||||
@@ -50,6 +55,8 @@ import type {
|
||||
} from "@thirdweb-dev/contracts-js";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import { BigNumber, BigNumberish, constants } from "ethers";
|
||||
import { Erc721Claimable } from "./erc-721-claimable";
|
||||
import { Erc721ClaimableWithConditions } from "./erc-721-claimable-with-conditions";
|
||||
|
||||
/**
|
||||
* Standard ERC721 NFT functions
|
||||
@@ -77,6 +84,8 @@ export class Erc721<
|
||||
private lazyMintable: Erc721LazyMintable | undefined;
|
||||
private tieredDropable: Erc721TieredDrop | undefined;
|
||||
private signatureMintable: Erc721WithQuantitySignatureMintable | undefined;
|
||||
private claimWithConditions: Erc721ClaimableWithConditions | undefined;
|
||||
private claimCustom: Erc721Claimable | undefined;
|
||||
protected contractWrapper: ContractWrapper<T>;
|
||||
protected storage: ThirdwebStorage;
|
||||
|
||||
@@ -98,6 +107,8 @@ export class Erc721<
|
||||
this.lazyMintable = this.detectErc721LazyMintable();
|
||||
this.tieredDropable = this.detectErc721TieredDrop();
|
||||
this.signatureMintable = this.detectErc721SignatureMintable();
|
||||
this.claimWithConditions = this.detectErc721ClaimableWithConditions();
|
||||
this.claimCustom = this.detectErc721Claimable();
|
||||
this._chainId = chainId;
|
||||
}
|
||||
|
||||
@@ -654,8 +665,8 @@ export class Erc721<
|
||||
quantity: BigNumberish,
|
||||
options?: ClaimOptions,
|
||||
): Promise<Transaction<TransactionResultWithId<NFT>[]>> => {
|
||||
const claimWithConditions = this.lazyMintable?.claimWithConditions;
|
||||
const claim = this.lazyMintable?.claim;
|
||||
const claimWithConditions = this.claimWithConditions;
|
||||
const claim = this.claimCustom;
|
||||
if (claimWithConditions) {
|
||||
return claimWithConditions.to.prepare(
|
||||
destinationAddress,
|
||||
@@ -685,8 +696,8 @@ export class Erc721<
|
||||
quantity: BigNumberish,
|
||||
options?: ClaimOptions,
|
||||
): Promise<Transaction> {
|
||||
const claimWithConditions = this.lazyMintable?.claimWithConditions;
|
||||
const claim = this.lazyMintable?.claim;
|
||||
const claimWithConditions = this.claimWithConditions;
|
||||
const claim = this.claimCustom;
|
||||
if (claimWithConditions) {
|
||||
return claimWithConditions.conditions.getClaimTransaction(
|
||||
destinationAddress,
|
||||
@@ -770,7 +781,7 @@ export class Erc721<
|
||||
*/
|
||||
get claimConditions() {
|
||||
return assertEnabled(
|
||||
this.lazyMintable?.claimWithConditions,
|
||||
this.claimWithConditions,
|
||||
FEATURE_NFT_CLAIM_CONDITIONS_V2,
|
||||
).conditions;
|
||||
}
|
||||
@@ -960,4 +971,46 @@ export class Erc721<
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc721ClaimableWithConditions():
|
||||
| Erc721ClaimableWithConditions
|
||||
| undefined {
|
||||
if (
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimConditionsV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimConditionsV2",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimPhasesV1",
|
||||
) ||
|
||||
detectContractFeature<BaseClaimConditionERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimPhasesV2",
|
||||
)
|
||||
) {
|
||||
return new Erc721ClaimableWithConditions(
|
||||
this,
|
||||
this.contractWrapper,
|
||||
this.storage,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private detectErc721Claimable(): Erc721Claimable | undefined {
|
||||
if (
|
||||
detectContractFeature<IClaimableERC721>(
|
||||
this.contractWrapper,
|
||||
"ERC721ClaimCustom",
|
||||
)
|
||||
) {
|
||||
return new Erc721Claimable(this, this.contractWrapper);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.2.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b3d57949`](https://github.com/thirdweb-dev/js/commit/b3d57949bd047831fda7e600b4872200340903b5), [`602d8cbc`](https://github.com/thirdweb-dev/js/commit/602d8cbcfaa7c1e117c01f842f89508f7333fcfe)]:
|
||||
- @thirdweb-dev/sdk@3.10.9
|
||||
|
||||
## 0.2.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.2.23",
|
||||
"version": "0.2.24",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Reference in New Issue
Block a user