Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25ef4be50f | ||
|
|
ab1f8bb6f6 | ||
|
|
5f8ec45af7 | ||
|
|
b45d761f8f | ||
|
|
04de5b2783 | ||
|
|
dee4596549 | ||
|
|
3547901ddd |
@@ -38,6 +38,7 @@
|
||||
"@manypkg/get-packages": "^1.1.3",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
|
||||
"eslint": "^8.21.0",
|
||||
"mocha": "^10.2.0",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"turbo": "^1.4.6",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#533](https://github.com/thirdweb-dev/js/pull/533) [`dee4596`](https://github.com/thirdweb-dev/js/commit/dee45965496d5d0298944031dd13a4345f9e1683) Thanks [@adam-maj](https://github.com/adam-maj)! - Remove next major version pin on auth
|
||||
|
||||
## 3.0.2
|
||||
|
||||
## 3.0.1
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
Install the latest version of the SDK with either `npm` or `yarn`:
|
||||
|
||||
```shell
|
||||
npm install @thirdweb-dev/auth @thirdweb-dev/sdk ethers
|
||||
npm install @thirdweb-dev/auth
|
||||
```
|
||||
|
||||
```shell
|
||||
yarn add @thirdweb-dev/auth @thirdweb-dev/sdk ethers
|
||||
yarn add @thirdweb-dev/auth
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Auth Docs](https://portal.thirdweb.com/auth)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"exports": {
|
||||
@@ -66,7 +66,6 @@
|
||||
"@solana/web3.js": "^1.73.0",
|
||||
"@swc-node/register": "^1.5.4",
|
||||
"@swc/core": "^1.3.23",
|
||||
"@thirdweb-dev/sdk": "*",
|
||||
"@thirdweb-dev/wallets": "*",
|
||||
"@types/bs58": "^4.0.1",
|
||||
"@types/chai": "^4.3.4",
|
||||
@@ -97,13 +96,12 @@
|
||||
"peerDependencies": {
|
||||
"@noble/ed25519": "^1.7.1",
|
||||
"@solana/web3.js": "^1.73.0",
|
||||
"@thirdweb-dev/sdk": "*",
|
||||
"bs58": "^5.0.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"ethers": ">=5.5.1",
|
||||
"express": "^4.18.1",
|
||||
"next": "^12.2.0",
|
||||
"next-auth": "^4.10.3",
|
||||
"ethers": "^5",
|
||||
"express": "^4",
|
||||
"next": "^12 || ^13",
|
||||
"next-auth": "^4",
|
||||
"tweetnacl": "^1.0.3"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -140,4 +138,4 @@
|
||||
"uuid": "^9.0.0",
|
||||
"zod": "^3.20.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.9.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#528](https://github.com/thirdweb-dev/js/pull/528) [`ab1f8bb`](https://github.com/thirdweb-dev/js/commit/ab1f8bb6f658dadbca2cb53decbc893050217407) Thanks [@adam-maj](https://github.com/adam-maj)! - Added --skip-update-check flag to CLI to prevent checking for new versions and automatically updating before running commands. Also, only check for check for updates every 24 hours.
|
||||
|
||||
- Updated dependencies [[`b45d761`](https://github.com/thirdweb-dev/js/commit/b45d761f8f2695b48312ec6eff15e0549e6a8a41), [`5f8ec45`](https://github.com/thirdweb-dev/js/commit/5f8ec45af7c81d075a84846098f38cad90d03fb9), [`04de5b2`](https://github.com/thirdweb-dev/js/commit/04de5b278362573991140c3a496de7451e5c770d)]:
|
||||
- @thirdweb-dev/sdk@3.7.3
|
||||
|
||||
## 0.9.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.9.13",
|
||||
"version": "0.9.14",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
@@ -41,6 +41,7 @@
|
||||
"prompts": "^2.4.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"solc": "0.8.17",
|
||||
"sync-disk-cache": "^2.1.0",
|
||||
"tar": "^6.1.11",
|
||||
"tslog": "^3.3.3",
|
||||
"update-notifier": "^6.0.2",
|
||||
|
||||
+161
-129
@@ -3,6 +3,7 @@ import { detectExtensions } from "../common/feature-detector";
|
||||
import { processProject } from "../common/processor";
|
||||
import { cliVersion, pkg } from "../constants/urls";
|
||||
import { info, logger, spinner } from "../core/helpers/logger";
|
||||
import { CacheEntry } from "../core/types/cache";
|
||||
import { twCreate } from "../create/command";
|
||||
import { deploy } from "../deploy";
|
||||
import { findPackageInstallation } from "../helpers/detect-local-packages";
|
||||
@@ -13,12 +14,14 @@ import { exec, spawn } from "child_process";
|
||||
import { Command } from "commander";
|
||||
import open from "open";
|
||||
import prompts from "prompts";
|
||||
import Cache from "sync-disk-cache";
|
||||
|
||||
const main = async () => {
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
const skipIntro = process.env.THIRDWEB_CLI_SKIP_INTRO === "true";
|
||||
|
||||
const program = new Command();
|
||||
const cache = new Cache("thirdweb:cli");
|
||||
|
||||
// yes this has to look like this, eliminates whitespace
|
||||
if (!skipIntro) {
|
||||
@@ -37,7 +40,164 @@ const main = async () => {
|
||||
program
|
||||
.name("thirdweb-cli")
|
||||
.description("Official thirdweb command line interface")
|
||||
.version(cliVersion, "-v, --version");
|
||||
.version(cliVersion, "-v, --version")
|
||||
.option("--skip-update-check", "Skip check for auto updates")
|
||||
.hook("preAction", async () => {
|
||||
if (skipIntro || program.opts().skipUpdateCheck) {
|
||||
return;
|
||||
}
|
||||
|
||||
let shouldCheckVersion = true;
|
||||
try {
|
||||
const lastCheckCache: CacheEntry = cache.get("last-version-check");
|
||||
|
||||
if (lastCheckCache.isCached) {
|
||||
const lastVersionCheck = new Date(lastCheckCache.value);
|
||||
// Don't check for updates if already checked within past 24 hours
|
||||
if (
|
||||
new Date().getTime() - lastVersionCheck.getTime() <
|
||||
1000 * 60 * 60 * 24
|
||||
) {
|
||||
shouldCheckVersion = false;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
||||
if (!shouldCheckVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
const versionSpinner = spinner("Checking for updates...");
|
||||
await import("update-notifier").then(
|
||||
async ({ default: updateNotifier }) => {
|
||||
const notifier = updateNotifier({
|
||||
pkg,
|
||||
shouldNotifyInNpmScript: true,
|
||||
// check every time while we're still building the CLI
|
||||
updateCheckInterval: 0,
|
||||
});
|
||||
|
||||
const versionInfo = await notifier.fetchInfo();
|
||||
versionSpinner.stop();
|
||||
|
||||
// Set cache to prevent checking for updates again for 24 hours
|
||||
cache.set("last-version-check", new Date().toISOString());
|
||||
|
||||
if (versionInfo.type !== "latest") {
|
||||
const res = await prompts({
|
||||
type: "toggle",
|
||||
name: "upgrade",
|
||||
message: `A new version of the CLI is available. Would you like to upgrade?`,
|
||||
initial: true,
|
||||
active: "yes",
|
||||
inactive: "no",
|
||||
});
|
||||
|
||||
if (res.upgrade) {
|
||||
const updateSpinner = spinner(
|
||||
`Upgrading CLI to version ${versionInfo.latest}...`,
|
||||
);
|
||||
|
||||
const clonedEnvironment = { ...process.env };
|
||||
clonedEnvironment.THIRDWEB_CLI_SKIP_INTRO = "true";
|
||||
|
||||
const installation = await findPackageInstallation();
|
||||
|
||||
// If the package isn't installed anywhere, just defer to npx thirdweb@latest
|
||||
if (!installation) {
|
||||
updateSpinner.succeed(
|
||||
`Now using CLI version ${versionInfo.latest}. Continuing execution...`,
|
||||
);
|
||||
|
||||
await new Promise((done, failed) => {
|
||||
const shell = spawn(
|
||||
`npx --yes thirdweb@latest ${process.argv
|
||||
.slice(2)
|
||||
.join(" ")}`,
|
||||
[],
|
||||
{ stdio: "inherit", shell: true, env: clonedEnvironment },
|
||||
);
|
||||
shell.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
done("");
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return process.exit(0);
|
||||
}
|
||||
|
||||
// Otherwise, get the correct command based on package manager and local vs. global
|
||||
let command = "";
|
||||
switch (installation.packageManager) {
|
||||
case "npm":
|
||||
command = installation.isGlobal
|
||||
? `npm install -g thirdweb`
|
||||
: `npm install thirdweb`;
|
||||
break;
|
||||
case "yarn":
|
||||
command = installation.isGlobal
|
||||
? `yarn global add thirdweb`
|
||||
: `yarn add thirdweb`;
|
||||
break;
|
||||
case "pnpm":
|
||||
command = installation.isGlobal
|
||||
? `pnpm add -g thirdweb@latest`
|
||||
: `pnpm add thirdweb@latest`;
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
`Could not detect package manager in use, aborting automatic upgrade.\nIf you want to upgrade the CLI, please do it manually with your package manager.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await new Promise((done, failed) => {
|
||||
exec(command, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
failed(err);
|
||||
return;
|
||||
}
|
||||
|
||||
done({ stdout, stderr });
|
||||
});
|
||||
});
|
||||
|
||||
updateSpinner.succeed(
|
||||
`Successfully upgraded CLI to version ${versionInfo.latest}. Continuing execution...`,
|
||||
);
|
||||
|
||||
// If the package is installed globally with yarn or pnpm, then npx won't recognize it
|
||||
// So we need to make sure to run the command directly
|
||||
const executionCommand =
|
||||
!installation.isGlobal || installation.packageManager === "npm"
|
||||
? `npx thirdweb`
|
||||
: `thirdweb`;
|
||||
await new Promise((done, failed) => {
|
||||
const shell = spawn(
|
||||
`${executionCommand} ${process.argv.slice(2).join(" ")}`,
|
||||
[],
|
||||
{ stdio: "inherit", shell: true, env: clonedEnvironment },
|
||||
);
|
||||
shell.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
done("");
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
program
|
||||
.command("create [projectType] [projectPath]")
|
||||
@@ -201,134 +361,6 @@ const main = async () => {
|
||||
await detectExtensions(options);
|
||||
});
|
||||
|
||||
if (!skipIntro) {
|
||||
const versionSpinner = spinner("Checking for updates...");
|
||||
await import("update-notifier").then(
|
||||
async ({ default: updateNotifier }) => {
|
||||
const notifier = updateNotifier({
|
||||
pkg,
|
||||
shouldNotifyInNpmScript: true,
|
||||
// check every time while we're still building the CLI
|
||||
updateCheckInterval: 0,
|
||||
});
|
||||
|
||||
const versionInfo = await notifier.fetchInfo();
|
||||
versionSpinner.stop();
|
||||
|
||||
if (versionInfo.type !== "latest") {
|
||||
const res = await prompts({
|
||||
type: "toggle",
|
||||
name: "upgrade",
|
||||
message: `A new version of the CLI is available. Would you like to upgrade?`,
|
||||
initial: true,
|
||||
active: "yes",
|
||||
inactive: "no",
|
||||
});
|
||||
|
||||
if (res.upgrade) {
|
||||
const updateSpinner = spinner(
|
||||
`Upgrading CLI to version ${versionInfo.latest}...`,
|
||||
);
|
||||
|
||||
const clonedEnvironment = { ...process.env };
|
||||
clonedEnvironment.THIRDWEB_CLI_SKIP_INTRO = "true";
|
||||
|
||||
const installation = await findPackageInstallation();
|
||||
|
||||
// If the package isn't installed anywhere, just defer to npx thirdweb@latest
|
||||
if (!installation) {
|
||||
updateSpinner.succeed(
|
||||
`Now using CLI version ${versionInfo.latest}. Continuing execution...`,
|
||||
);
|
||||
|
||||
await new Promise((done, failed) => {
|
||||
const shell = spawn(
|
||||
`npx --yes thirdweb@latest ${process.argv
|
||||
.slice(2)
|
||||
.join(" ")}`,
|
||||
[],
|
||||
{ stdio: "inherit", shell: true, env: clonedEnvironment },
|
||||
);
|
||||
shell.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
done("");
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return process.exit(0);
|
||||
}
|
||||
|
||||
// Otherwise, get the correct command based on package manager and local vs. global
|
||||
let command = "";
|
||||
switch (installation.packageManager) {
|
||||
case "npm":
|
||||
command = installation.isGlobal
|
||||
? `npm install -g thirdweb`
|
||||
: `npm install thirdweb`;
|
||||
break;
|
||||
case "yarn":
|
||||
command = installation.isGlobal
|
||||
? `yarn global add thirdweb`
|
||||
: `yarn add thirdweb`;
|
||||
break;
|
||||
case "pnpm":
|
||||
command = installation.isGlobal
|
||||
? `pnpm add -g thirdweb@latest`
|
||||
: `pnpm add thirdweb@latest`;
|
||||
break;
|
||||
default:
|
||||
console.error(
|
||||
`Could not detect package manager in use, aborting automatic upgrade.\nIf you want to upgrade the CLI, please do it manually with your package manager.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await new Promise((done, failed) => {
|
||||
exec(command, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
failed(err);
|
||||
return;
|
||||
}
|
||||
|
||||
done({ stdout, stderr });
|
||||
});
|
||||
});
|
||||
|
||||
updateSpinner.succeed(
|
||||
`Successfully upgraded CLI to version ${versionInfo.latest}. Continuing execution...`,
|
||||
);
|
||||
|
||||
// If the package is installed globally with yarn or pnpm, then npx won't recognize it
|
||||
// So we need to make sure to run the command directly
|
||||
const executionCommand =
|
||||
!installation.isGlobal || installation.packageManager === "npm"
|
||||
? `npx thirdweb`
|
||||
: `thirdweb`;
|
||||
await new Promise((done, failed) => {
|
||||
const shell = spawn(
|
||||
`${executionCommand} ${process.argv.slice(2).join(" ")}`,
|
||||
[],
|
||||
{ stdio: "inherit", shell: true, env: clonedEnvironment },
|
||||
);
|
||||
shell.on("close", (code) => {
|
||||
if (code === 0) {
|
||||
done("");
|
||||
} else {
|
||||
failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
await program.parseAsync();
|
||||
};
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ export async function processProject(
|
||||
if (projectType === "none") {
|
||||
if (command === "deploy") {
|
||||
info(
|
||||
"No contracts detected in this directory. Redirecting to the thirdweb contract deployment page.",
|
||||
"No contracts detected in this directory. Redirecting to the thirdweb contract explore page.",
|
||||
);
|
||||
return "https://thirdweb.com/contracts";
|
||||
return "https://thirdweb.com/explore";
|
||||
}
|
||||
|
||||
error("No detected contracts in this directory.");
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export type CacheEntry = {
|
||||
isCached: boolean;
|
||||
key: string;
|
||||
value: string;
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare module 'sync-disk-cache';
|
||||
declare module "solc";
|
||||
-1
@@ -1 +0,0 @@
|
||||
declare module "solc";
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`dee4596`](https://github.com/thirdweb-dev/js/commit/dee45965496d5d0298944031dd13a4345f9e1683)]:
|
||||
- @thirdweb-dev/auth@3.0.3
|
||||
|
||||
## 3.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "3.7.2",
|
||||
"version": "3.7.3",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/react-core@3.7.3
|
||||
|
||||
## 3.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -305,3 +305,111 @@ const KitchenSinkExample = () => {
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
## Available hooks
|
||||
|
||||
### Main hooks
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useSDK`](https://portal.thirdweb.com/react/react.usesdk) | Access the instance of the thirdweb SDK created by the ThirdwebProvider. |
|
||||
| [`useContract`](https://portal.thirdweb.com/react/react.usecontract) | Use this resolve a contract address to a smart contract instance. |
|
||||
| [`useContractWrite`](https://portal.thirdweb.com/react/react.usecontractwrite) | Use this to get data from a contract read-function call. |
|
||||
| [`useContractRead`](https://portal.thirdweb.com/react/react.usecontractread) | Use this to get a function to make a write call to your contract. |
|
||||
| [`useContractEvents`](https://portal.thirdweb.com/react/react.usecontractevents) | Use this to get the contract metadata for a (built-in or custom) contract. |
|
||||
| [`useContractMetadata`](https://portal.thirdweb.com/react/react.usecontractmetadata) | Use this to get the contract metadata for a (built-in or custom) contract. |
|
||||
|
||||
### Wallet connection
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useAddress`](https://portal.thirdweb.com/react/react.useaddress) | Hook for accessing the address of the connected wallet. |
|
||||
| [`useMetamask`](https://portal.thirdweb.com/react/react.usemetamask) | Hook for connecting to a Metamask wallet. |
|
||||
| [`useWalletConnect`](https://portal.thirdweb.com/react/react.usewalletconnect) | Hook for connecting to a mobile wallet with Wallet Connect. |
|
||||
| [`useCoinbaseWallet`](https://portal.thirdweb.com/react/react.usecoinbasewallet) | Hook for connecting to a Coinbase wallet. |
|
||||
| [`useMagic`](https://portal.thirdweb.com/react/react.usemagic) | Hook for connecting to an email wallet using magic link. |
|
||||
| [`useGnosis`](https://portal.thirdweb.com/react/react.usegnosis) | Hook for connecting to a Gnosis Safe. |
|
||||
| [`useDisconnect`](https://portal.thirdweb.com/react/react.usedisconnect) | Hook for disconnecting the currently connected wallet. |
|
||||
|
||||
### Network connection
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useChainId`](https://portal.thirdweb.com/react/react.usechainid) | Hook for accessing the chain ID of the network the current wallet is connected to |
|
||||
| [`useNetwork`](https://portal.thirdweb.com/react/react.usenetwork) | Hook for getting metadata about the network the current wallet is connected to and switching networks. |
|
||||
| [`useNetworkMismatch`](https://portal.thirdweb.com/react/react.usenetworkmismatch) | Hook for checking whether the connected wallet is on the correct network specified by the desiredChainId passed to the <ThirdwebProvider />. |
|
||||
|
||||
### NFT
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useNFT`](https://portal.thirdweb.com/react/react.usenft) | Use this to get an individual NFT token of your NFTContract. |
|
||||
| [`useNFTs`](https://portal.thirdweb.com/react/react.usenfts) | Use this to get a list of NFT tokens of your NFTContract. |
|
||||
| [`useTotalCirculatingSupply`](https://portal.thirdweb.com/react/react.usetotalcirculatingsupply) | Use this to get a the total (minted) supply of your NFTContract. |
|
||||
| [`useOwnedNFTs`](https://portal.thirdweb.com/react/react.useownednfts) | Use this to get a the owned NFTs for a specific Erc721OrErc1155 and wallet address. |
|
||||
| [`useNFTBalance`](https://portal.thirdweb.com/react/react.usenftbalance) | Use this to get a the total balance of a NFTContract and wallet address. |
|
||||
| [`useTotalCount`](https://portal.thirdweb.com/react/react.usetotalcount) | Use this to get the total count of NFT tokens of your NFTContract. |
|
||||
| [`useMintNFT`](https://portal.thirdweb.com/react/react.usemintnft) | Use this to mint a new NFT on your Erc721OrErc1155. |
|
||||
| [`useMintNFTSupply`](https://portal.thirdweb.com/react/react.usemintnftsupply) | Use this mint extra supply on your Erc1155. |
|
||||
| [`useTransferNFT`](https://portal.thirdweb.com/react/react.usetransfernft) | Use this to transfer tokens on your NFTContract. |
|
||||
| [`useAirdropNFT`](https://portal.thirdweb.com/react/react.useairdropnft) | Use this to airdrop tokens on your Erc1155. |
|
||||
| [`useBurnNFT`](https://portal.thirdweb.com/react/react.useburnnft) | Use this to burn an NFT on your Erc721OrErc1155. |
|
||||
|
||||
|
||||
### Token
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useTokenSupply`](https://portal.thirdweb.com/react/react.usetokensupply) | Use this to get a the total supply of your contract. |
|
||||
| [`useTokenBalance`](https://portal.thirdweb.com/react/react.usetokenbalance) | Use this to get the balance of your contract for a given address. |
|
||||
| [`useTokenDecimals`](https://portal.thirdweb.com/react/react.usetokendecimals) | Use this to get the decimals of your contract for a given address. |
|
||||
| [`useMintToken`](https://portal.thirdweb.com/react/react.useminttoken) | Use this to mint new tokens on your contract. |
|
||||
| [`useClaimToken`](https://portal.thirdweb.com/react/react.useclaimtoken) | Use this to claim tokens from your contract. |
|
||||
| [`useTransferToken`](https://portal.thirdweb.com/react/react.usetransfertoken) | Use this to transfer tokens on your contract. |
|
||||
| [`useTransferBatchToken`](https://portal.thirdweb.com/react/react.usetransferbatchtoken) | Use this to transfer batch tokens on your contract. |
|
||||
| [`useBurnToken`](https://portal.thirdweb.com/react/react.useburntoken) | Use this to burn tokens on your contract. |
|
||||
|
||||
### Marketplace
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useListing`](https://portal.thirdweb.com/react/react.uselisting) | Use this to get a specific listing from the marketplace. |
|
||||
| [`useListings`](https://portal.thirdweb.com/react/react.uselistings) | Use this to get a list all listings from your marketplace contract. |
|
||||
| [`useListingsCount`](https://portal.thirdweb.com/react/react.uselistingscount) | Use this to get a count of all listings on your marketplace contract. |
|
||||
| [`useActiveListings`](https://portal.thirdweb.com/react/react.useactivelistings) | Use this to get a list active listings from your marketplace contract. |
|
||||
| [`useWinningBid`](https://portal.thirdweb.com/react/react.usewinningbid) | Use this to get a the winning bid for an auction listing from your marketplace contract. |
|
||||
| [`useAuctionWinner`](https://portal.thirdweb.com/react/react.useauctionwinner) | Use this to get the winner of an auction listing from your marketplace contract. |
|
||||
| [`useBidBuffer`](https://portal.thirdweb.com/react/react.usebidbuffer) | Use this to get the buffer in basis points between offers from your marketplace contract. |
|
||||
| [`useCreateDirectListing`](https://portal.thirdweb.com/react/react.usecreatedirectlisting) | Use this to create a new Direct Listing on your marketplace contract. |
|
||||
| [`useCreateAuctionListing`](https://portal.thirdweb.com/react/react.usecreateauctionlisting) | Use this to create a new Auction Listing on your marketplace contract. |
|
||||
| [`useCancelListing`](https://portal.thirdweb.com/react/react.usecancellisting) | Use this to cancel a listing on your marketplace contract. |
|
||||
| [`useMakeBid`](https://portal.thirdweb.com/react/react.usemakebid) | Use this to place a bid on an auction listing from your marketplace contract. |
|
||||
| [`useBuyNow`](https://portal.thirdweb.com/react/react.usebuynow) | Use this to buy out an auction listing from your marketplace contract. |
|
||||
|
||||
### Permissions Controls
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useAllRoleMembers`](https://portal.thirdweb.com/react/react.useallrolemembers) | Use this to get the roles of all members. |
|
||||
| [`useRoleMembers`](https://portal.thirdweb.com/react/react.userolemembers) | Use this to get the members of a role. |
|
||||
| [`useIsAddressRole`](https://portal.thirdweb.com/react/react.useisaddressrole) | Use this to check if a WalletAddress is a member of a role. |
|
||||
| [`useSetAllRoleMembers`](https://portal.thirdweb.com/react/react.usesetallrolemembers) | Use this to OVERWRITE the list of addresses that are members of specific roles. |
|
||||
| [`useGrantRole`](https://portal.thirdweb.com/react/react.usegrantrole) | Use this to grant a WalletAddress a specific role. |
|
||||
| [`useRevokeRole`](https://portal.thirdweb.com/react/react.userevokerole) | Use this to revoke a WalletAddress a specific role. |
|
||||
|
||||
### Drop
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useUnclaimedNFTs`](https://portal.thirdweb.com/react/react.useunclaimednfts) | Use this to get a list of unclaimed NFT tokens of your ERC721 Drop contract. |
|
||||
| [`useClaimedNFTs`](https://portal.thirdweb.com/react/react.useclaimednfts) | Use this to get a list of claimed (minted) NFT tokens of your ERC721 Drop contract.. |
|
||||
| [`useUnclaimedNFTSupply`](https://portal.thirdweb.com/react/react.useunclaimednftsupply) | Use this to get the total unclaimed NFT supply of your ERC721 Drop contract. |
|
||||
| [`useClaimedNFTSupply`](https://portal.thirdweb.com/react/react.useclaimednftsupply) | Use this to get the total claimed (minted) NFT supply of your ERC721 Drop contract. |
|
||||
| [`useBatchesToReveal`](https://portal.thirdweb.com/react/react.usebatchestoreveal) | Use this to get a list of batches that are ready to be revealed. |
|
||||
| [`useClaimNFT`](https://portal.thirdweb.com/react/react.useclaimnft) | Use this to claim a NFT on your DropContract |
|
||||
| [`useLazyMint`](https://portal.thirdweb.com/react/react.uselazymint) | Use this to lazy mint a batch of NFTs on your DropContract. |
|
||||
| [`useDelayedRevealLazyMint`](https://portal.thirdweb.com/react/react.usedelayedreveallazymint) | Use this to lazy mint a batch of delayed reveal NFTs on your DropContract. |
|
||||
| [`useRevealLazyMint`](https://portal.thirdweb.com/react/react.usereveallazymint) | Use this to reveal a batch of delayed reveal NFTs on your RevealableContract. |
|
||||
|
||||
### Claim Conditions
|
||||
| Hook | Description |
|
||||
| --- | --- |
|
||||
| [`useActiveClaimCondition`](https://portal.thirdweb.com/react/react.useactiveclaimcondition) | Use this to get the active claim condition for ERC20, ERC721 or ERC1155 based contracts. |
|
||||
| [`useClaimConditions`](https://portal.thirdweb.com/react/react.useclaimconditions) | Use this to get all claim conditions for ERC20, ERC721 or ERC1155 based contracts. |
|
||||
| [`useClaimIneligibilityReasons`](https://portal.thirdweb.com/react/react.useclaimineligibilityreasons) | Use this to check for reasons that prevent claiming for either ERC20, ERC721 or ERC1155 based contracts. |
|
||||
| [`useSetClaimConditions`](https://portal.thirdweb.com/react/react.usesetclaimconditions) | Use this to set claim conditions on your DropContract. |
|
||||
| [`useResetClaimConditions`](https://portal.thirdweb.com/react/react.useresetclaimconditions) | Use this to reset claim conditions on your DropContract. |
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "3.7.2",
|
||||
"version": "3.7.3",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,15 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#410](https://github.com/thirdweb-dev/js/pull/410) [`b45d761`](https://github.com/thirdweb-dev/js/commit/b45d761f8f2695b48312ec6eff15e0549e6a8a41) Thanks [@adam-maj](https://github.com/adam-maj)! - Add creator and royalty settings to drop
|
||||
|
||||
- [#535](https://github.com/thirdweb-dev/js/pull/535) [`5f8ec45`](https://github.com/thirdweb-dev/js/commit/5f8ec45af7c81d075a84846098f38cad90d03fb9) Thanks [@jnsdls](https://github.com/jnsdls)! - [Solana] - add `burnBatch()` and `getTransactions()` for NFTCollection and NFTDrop
|
||||
|
||||
- [#471](https://github.com/thirdweb-dev/js/pull/471) [`04de5b2`](https://github.com/thirdweb-dev/js/commit/04de5b278362573991140c3a496de7451e5c770d) Thanks [@adam-maj](https://github.com/adam-maj)! - Expose getSnapshotEntryForAddress
|
||||
|
||||
## 3.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "3.7.2",
|
||||
"version": "3.7.3",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -10,4 +10,7 @@ export {
|
||||
fetchCurrencyMetadata,
|
||||
normalizePriceValue,
|
||||
} from "./currency";
|
||||
export { convertToReadableQuantity } from "./claim-conditions";
|
||||
export {
|
||||
convertToReadableQuantity,
|
||||
fetchSnapshotEntryForAddress,
|
||||
} from "./claim-conditions";
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
Connection,
|
||||
ParsedAccountData,
|
||||
PublicKey,
|
||||
TransactionResponse,
|
||||
} from "@solana/web3.js";
|
||||
|
||||
/**
|
||||
@@ -174,7 +175,9 @@ export class NFTHelper {
|
||||
return nfts;
|
||||
}
|
||||
|
||||
private async getAllMetadataAddresses(collectionAddress: string) {
|
||||
async getTransactions(
|
||||
collectionAddress: string,
|
||||
): Promise<TransactionResponse[]> {
|
||||
const collectionKey = new PublicKey(collectionAddress);
|
||||
|
||||
// TODO cache signatures <> transactions mapping in memory so pagination doesn't re-request this everytime
|
||||
@@ -196,8 +199,7 @@ export class NFTHelper {
|
||||
allSignatures.push(...signatures);
|
||||
} while (signatures.length > 0);
|
||||
|
||||
const metadataAddresses: PublicKey[] = [];
|
||||
|
||||
let txns: TransactionResponse[] = [];
|
||||
// TODO RPC's will throttle this, need to do some optimizations here
|
||||
const batchSize = 1000; // alchemy RPC batch limit
|
||||
for (let i = 0; i < allSignatures.length; i += batchSize) {
|
||||
@@ -206,13 +208,27 @@ export class NFTHelper {
|
||||
Math.min(allSignatures.length, i + batchSize),
|
||||
);
|
||||
|
||||
const transactions = (
|
||||
await this.metaplex.connection.getTransactions(
|
||||
batch.map((s) => s.signature),
|
||||
)
|
||||
).reverse();
|
||||
txns = [
|
||||
...txns,
|
||||
...(
|
||||
(
|
||||
await this.metaplex.connection.getTransactions(
|
||||
batch.map((s) => s.signature),
|
||||
)
|
||||
).filter((tx) => !!tx) as TransactionResponse[]
|
||||
).reverse(),
|
||||
];
|
||||
}
|
||||
return txns;
|
||||
}
|
||||
|
||||
for (const tx of transactions) {
|
||||
async getAllMetadataAddresses(
|
||||
collectionAddress: string,
|
||||
): Promise<PublicKey[]> {
|
||||
const txns = await this.getTransactions(collectionAddress);
|
||||
|
||||
return txns
|
||||
.map((tx) => {
|
||||
if (tx) {
|
||||
const programIds = tx.transaction.message
|
||||
.programIds()
|
||||
@@ -230,9 +246,8 @@ export class NFTHelper {
|
||||
accountKeys[ix.programIdIndex] === METAPLEX_PROGRAM_ID
|
||||
) {
|
||||
const metadataAddressIndex = ix.accounts[0];
|
||||
const metadata_address =
|
||||
tx.transaction.message.accountKeys[metadataAddressIndex];
|
||||
metadataAddresses.push(metadata_address);
|
||||
|
||||
return tx.transaction.message.accountKeys[metadataAddressIndex];
|
||||
}
|
||||
}
|
||||
} else if (programIds.includes(CANDYMACHINE_PROGRAM_ID)) {
|
||||
@@ -243,17 +258,14 @@ export class NFTHelper {
|
||||
ix.data === "JEuNFGs7wrU"
|
||||
) {
|
||||
const metadataAddressIndex = ix.accounts[1];
|
||||
const metadata_address =
|
||||
tx.transaction.message.accountKeys[metadataAddressIndex];
|
||||
metadataAddresses.push(metadata_address);
|
||||
|
||||
return tx.transaction.message.accountKeys[metadataAddressIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return metadataAddresses;
|
||||
})
|
||||
.filter((a) => !!a) as PublicKey[];
|
||||
}
|
||||
|
||||
async toNFTMetadata(
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
toOriginalEditionAccount,
|
||||
TransactionBuilder,
|
||||
} from "@metaplex-foundation/js";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { PublicKey, TransactionResponse } from "@solana/web3.js";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import invariant from "tiny-invariant";
|
||||
|
||||
@@ -140,6 +140,14 @@ export class NFTCollection {
|
||||
return this.nft.getAll(this.publicKey.toBase58(), queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the all transactions for this program
|
||||
* @beta
|
||||
*/
|
||||
async getTransactions(): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of nfts minted on this program
|
||||
* @returns the total number of NFTs minted on this program
|
||||
@@ -420,14 +428,39 @@ export class NFTCollection {
|
||||
* ```
|
||||
*/
|
||||
async burn(nftAddress: string): Promise<TransactionResult> {
|
||||
const tx = await this.metaplex.nfts().delete({
|
||||
mintAddress: new PublicKey(nftAddress),
|
||||
collection: this.publicKey,
|
||||
});
|
||||
return this.burnBatch([nftAddress]).then((txs) => txs[0]);
|
||||
}
|
||||
|
||||
return {
|
||||
signature: tx.response.signature,
|
||||
};
|
||||
/**
|
||||
* Burn multiple NFTs
|
||||
* @param nftAddresses - the mint addresses of the NFT to burn
|
||||
* @returns the transaction signature
|
||||
*
|
||||
* @example
|
||||
* ```jsx
|
||||
* // Specify the address of the NFT to burn
|
||||
* const nftAddress1 = "..."
|
||||
* const nftAddress2 = "..."
|
||||
* // And send the actual burn transaction
|
||||
* const tx = await program.burnBatch([nftAddress1, nftAddress2]);
|
||||
* ```
|
||||
*/
|
||||
async burnBatch(nftAddresses: string[]): Promise<TransactionResult[]> {
|
||||
const txs: TransactionBuilder[] = [];
|
||||
|
||||
for (let nftAddress of nftAddresses) {
|
||||
txs.push(
|
||||
this.metaplex
|
||||
.nfts()
|
||||
.builders()
|
||||
.delete({
|
||||
mintAddress: new PublicKey(nftAddress),
|
||||
collection: this.publicKey,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return await sendMultipartTransaction(txs, this.metaplex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -472,7 +505,6 @@ export class NFTCollection {
|
||||
.nfts()
|
||||
.builders()
|
||||
.update({
|
||||
collection: this.publicKey,
|
||||
nftOrSft: metaplexNft,
|
||||
creators: enforceCreator(
|
||||
creators,
|
||||
@@ -530,7 +562,6 @@ export class NFTCollection {
|
||||
|
||||
txs.push(
|
||||
this.metaplex.nfts().builders().update({
|
||||
collection: this.publicKey,
|
||||
nftOrSft: metaplexNft,
|
||||
sellerFeeBasisPoints,
|
||||
}),
|
||||
|
||||
@@ -21,10 +21,12 @@ import { sendMultipartTransaction } from "../utils/transactions";
|
||||
import { getNework } from "../utils/urls";
|
||||
import {
|
||||
CandyMachineV2Item,
|
||||
findCandyMachineV2CreatorPda,
|
||||
Metaplex,
|
||||
toBigNumber,
|
||||
TransactionBuilder,
|
||||
} from "@metaplex-foundation/js";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { PublicKey, TransactionResponse } from "@solana/web3.js";
|
||||
import { ThirdwebStorage, UploadProgressEvent } from "@thirdweb-dev/storage";
|
||||
import invariant from "tiny-invariant";
|
||||
|
||||
@@ -218,6 +220,14 @@ export class NFTDrop {
|
||||
return [...claimedNfts, ...unclaimedNfts];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the all transactions for this program
|
||||
* @beta
|
||||
*/
|
||||
async getTransactions(): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata for all the claimed NFTs on this drop
|
||||
* @returns metadata for all claimed NFTs
|
||||
@@ -493,47 +503,176 @@ export class NFTDrop {
|
||||
* ```
|
||||
*/
|
||||
async burn(nftAddress: string): Promise<TransactionResult> {
|
||||
return this.burnBatch([nftAddress]).then((txs) => txs[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Burn multiple NFTs
|
||||
* @param nftAddresses - the mint addresses of the NFT to burn
|
||||
* @returns the transaction signature
|
||||
*
|
||||
* @example
|
||||
* ```jsx
|
||||
* // Specify the address of the NFT to burn
|
||||
* const nftAddress1 = "..."
|
||||
* const nftAddress2 = "..."
|
||||
* // And send the actual burn transaction
|
||||
* const tx = await program.burnBatch([nftAddress1, nftAddress2]);
|
||||
* ```
|
||||
*/
|
||||
async burnBatch(nftAddresses: string[]): Promise<TransactionResult[]> {
|
||||
const candyMachine = await this.getCandyMachine();
|
||||
const collection = candyMachine.collectionMintAddress
|
||||
? candyMachine.collectionMintAddress
|
||||
: undefined;
|
||||
const tx = await this.metaplex.nfts().delete({
|
||||
mintAddress: new PublicKey(nftAddress),
|
||||
collection,
|
||||
});
|
||||
return {
|
||||
signature: tx.response.signature,
|
||||
};
|
||||
const txs: TransactionBuilder[] = [];
|
||||
|
||||
for (let nftAddress of nftAddresses) {
|
||||
txs.push(
|
||||
this.metaplex
|
||||
.nfts()
|
||||
.builders()
|
||||
.delete({
|
||||
mintAddress: new PublicKey(nftAddress),
|
||||
collection,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return await sendMultipartTransaction(txs, this.metaplex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the creators of the collection
|
||||
* @param creators - the creators to update
|
||||
* @param updateAll - whether or not to retroactively update the creators of all past NFTs
|
||||
*/
|
||||
async updateCreators(creators: CreatorInput[]) {
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
creators: enforceCreator(creators, this.metaplex.identity().publicKey),
|
||||
});
|
||||
async updateCreators(
|
||||
creators: CreatorInput[],
|
||||
updateAll: boolean = false,
|
||||
): Promise<TransactionResult[]> {
|
||||
if (updateAll) {
|
||||
const txs: TransactionBuilder[] = [];
|
||||
|
||||
return {
|
||||
signature: tx.response.signature,
|
||||
};
|
||||
const candyMachine = await this.getCandyMachine();
|
||||
const collectionAddress = candyMachine.collectionMintAddress;
|
||||
invariant(collectionAddress, "Collection mint address not found");
|
||||
|
||||
// We need to find the candy machine creator PDA which is auto populated onto NFTs
|
||||
// minted with the candy machine, and add it to the list of creators for each NFT
|
||||
const candyMachineCreatorPda = findCandyMachineV2CreatorPda(
|
||||
candyMachine.address,
|
||||
);
|
||||
const nftCreators = [
|
||||
{
|
||||
address: candyMachineCreatorPda.toBase58(),
|
||||
share: 0,
|
||||
},
|
||||
...creators,
|
||||
];
|
||||
|
||||
const allNfts = await this.nft.getAll(collectionAddress.toBase58());
|
||||
await Promise.all(
|
||||
allNfts.map(async (nft) => {
|
||||
const metaplexNft = await this.metaplex
|
||||
.nfts()
|
||||
.findByMint({ mintAddress: new PublicKey(nft.metadata.id) });
|
||||
|
||||
txs.push(
|
||||
this.metaplex
|
||||
.nfts()
|
||||
.builders()
|
||||
.update({
|
||||
nftOrSft: metaplexNft,
|
||||
creators: enforceCreator(
|
||||
nftCreators,
|
||||
this.metaplex.identity().publicKey,
|
||||
),
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
const results = await sendMultipartTransaction(txs, this.metaplex);
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
creators: enforceCreator(creators, this.metaplex.identity().publicKey),
|
||||
});
|
||||
|
||||
return [
|
||||
{
|
||||
signature: tx.response.signature,
|
||||
},
|
||||
...results,
|
||||
];
|
||||
} else {
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
creators: enforceCreator(creators, this.metaplex.identity().publicKey),
|
||||
});
|
||||
|
||||
return [
|
||||
{
|
||||
signature: tx.response.signature,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the royalty basis points of the collection
|
||||
* @param sellerFeeBasisPoints - the royalty basis points of the collection
|
||||
* @param updateAll - whether or not to retroactively update the royalty basis points of all past NFTs
|
||||
*/
|
||||
async updateRoyalty(sellerFeeBasisPoints: number) {
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
sellerFeeBasisPoints,
|
||||
});
|
||||
async updateRoyalty(
|
||||
sellerFeeBasisPoints: number,
|
||||
updateAll: boolean = false,
|
||||
) {
|
||||
if (updateAll) {
|
||||
const txs: TransactionBuilder[] = [];
|
||||
|
||||
return {
|
||||
signature: tx.response.signature,
|
||||
};
|
||||
const candyMachine = await this.getCandyMachine();
|
||||
const collectionAddress = candyMachine.collectionMintAddress;
|
||||
invariant(collectionAddress, "Collection mint address not found");
|
||||
|
||||
const allNfts = await this.nft.getAll(collectionAddress.toBase58());
|
||||
await Promise.all(
|
||||
allNfts.map(async (nft) => {
|
||||
const metaplexNft = await this.metaplex
|
||||
.nfts()
|
||||
.findByMint({ mintAddress: new PublicKey(nft.metadata.id) });
|
||||
|
||||
txs.push(
|
||||
this.metaplex.nfts().builders().update({
|
||||
nftOrSft: metaplexNft,
|
||||
sellerFeeBasisPoints,
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
const results = await sendMultipartTransaction(txs, this.metaplex);
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
sellerFeeBasisPoints,
|
||||
});
|
||||
|
||||
return [
|
||||
{
|
||||
signature: tx.response.signature,
|
||||
},
|
||||
...results,
|
||||
];
|
||||
} else {
|
||||
const tx = await this.metaplex.candyMachinesV2().update({
|
||||
candyMachine: await this.getCandyMachine(),
|
||||
sellerFeeBasisPoints,
|
||||
});
|
||||
|
||||
return {
|
||||
signature: tx.response.signature,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async getCandyMachine() {
|
||||
|
||||
@@ -40,6 +40,11 @@ describe("NFTCollection", async () => {
|
||||
expect(all[0].metadata.name).to.eq("Test NFT");
|
||||
});
|
||||
|
||||
it("should fetch transactions", async () => {
|
||||
const txns = await collection.getTransactions();
|
||||
expect(txns.length).to.eq(2);
|
||||
});
|
||||
|
||||
it("should fetch balance of NFTs", async () => {
|
||||
const all = await collection.getAll();
|
||||
const balance = await collection.balanceOf(
|
||||
@@ -148,14 +153,19 @@ describe("NFTCollection", async () => {
|
||||
expect(creators[0].address).to.equal(sdk.wallet.getAddress());
|
||||
expect(creators[0].share).to.equal(100);
|
||||
|
||||
const numNfts = (await collection.getAll()).length;
|
||||
|
||||
const newCreator = Keypair.generate().publicKey.toBase58();
|
||||
await collection.updateCreators([
|
||||
{
|
||||
address: sdk.wallet.getAddress() as string,
|
||||
share: 75,
|
||||
},
|
||||
{ address: newCreator, share: 25 },
|
||||
]);
|
||||
await collection.updateCreators(
|
||||
[
|
||||
{
|
||||
address: sdk.wallet.getAddress() as string,
|
||||
share: 75,
|
||||
},
|
||||
{ address: newCreator, share: 25 },
|
||||
],
|
||||
true,
|
||||
);
|
||||
|
||||
creators = await collection.getCreators();
|
||||
expect(creators.length).to.equal(2);
|
||||
@@ -164,36 +174,36 @@ describe("NFTCollection", async () => {
|
||||
expect(creators[1].address).to.equal(newCreator);
|
||||
expect(creators[1].share).to.equal(25);
|
||||
|
||||
// TODO (adam): fix this test
|
||||
// const all = await collection.getAll();
|
||||
// for (const nft of all) {
|
||||
// // @ts-ignore
|
||||
// const creatorsOfNft = await collection.nft.creatorsOf(nft.metadata.id);
|
||||
// expect(creatorsOfNft.length).to.equal(2);
|
||||
// expect(creatorsOfNft[0].address).to.equal(sdk.wallet.getAddress());
|
||||
// expect(creatorsOfNft[0].share).to.equal(75);
|
||||
// expect(creatorsOfNft[1].address).to.equal(newCreator);
|
||||
// expect(creatorsOfNft[1].share).to.equal(25);
|
||||
// }
|
||||
const all = await collection.getAll();
|
||||
expect(all.length).to.equal(numNfts);
|
||||
for (const nft of all) {
|
||||
// @ts-ignore
|
||||
const creatorsOfNft = await collection.nft.creatorsOf(nft.metadata.id);
|
||||
expect(creatorsOfNft.length).to.equal(2);
|
||||
expect(creatorsOfNft[0].address).to.equal(sdk.wallet.getAddress());
|
||||
expect(creatorsOfNft[0].share).to.equal(75);
|
||||
expect(creatorsOfNft[1].address).to.equal(newCreator);
|
||||
expect(creatorsOfNft[1].share).to.equal(25);
|
||||
}
|
||||
});
|
||||
|
||||
it("Should update royalty", async () => {
|
||||
let royalty = await collection.getRoyalty();
|
||||
expect(royalty).to.equal(0);
|
||||
|
||||
const mintAddress = (await collection.getAll())[0].metadata.id;
|
||||
// @ts-ignore
|
||||
let nft = await collection.nft.getRaw(mintAddress);
|
||||
expect(nft.isMutable).to.equal(true);
|
||||
expect(nft.sellerFeeBasisPoints).to.equal(0);
|
||||
const numNfts = (await collection.getAll()).length;
|
||||
|
||||
await collection.updateRoyalty(100);
|
||||
await collection.updateRoyalty(100, true);
|
||||
|
||||
royalty = await collection.getRoyalty();
|
||||
expect(royalty).to.equal(100);
|
||||
|
||||
// TODO (adam): fix this test
|
||||
// nft = await collection.nft.getRaw(mintAddress);
|
||||
// expect(nft.sellerFeeBasisPoints).to.equal(100);
|
||||
const all = await collection.getAll();
|
||||
expect(all.length).to.equal(numNfts);
|
||||
for (const singleNft of all) {
|
||||
// @ts-ignore
|
||||
const royaltyOfNft = await collection.nft.getRaw(singleNft.metadata.id);
|
||||
expect(royaltyOfNft.sellerFeeBasisPoints).to.equal(100);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -131,11 +131,20 @@ describe("NFTDrop", async () => {
|
||||
expect(creators[0].address).to.equal(sdk.wallet.getAddress());
|
||||
expect(creators[0].share).to.equal(100);
|
||||
|
||||
const numNfts = (await drop.getAllClaimed()).length;
|
||||
const newCreator = Keypair.generate().publicKey.toBase58();
|
||||
await drop.updateCreators([
|
||||
{ address: sdk.wallet.getAddress() as string, share: 75 },
|
||||
{ address: newCreator, share: 25 },
|
||||
]);
|
||||
|
||||
await drop.updateCreators(
|
||||
[
|
||||
{
|
||||
address: sdk.wallet.getAddress() as string,
|
||||
share: 75,
|
||||
verified: true,
|
||||
},
|
||||
{ address: newCreator, share: 25, verified: true },
|
||||
],
|
||||
true,
|
||||
);
|
||||
|
||||
creators = await drop.getCreators();
|
||||
expect(creators.length).to.equal(2);
|
||||
@@ -143,14 +152,39 @@ describe("NFTDrop", async () => {
|
||||
expect(creators[0].share).to.equal(75);
|
||||
expect(creators[1].address).to.equal(newCreator);
|
||||
expect(creators[1].share).to.equal(25);
|
||||
|
||||
const all = await drop.getAllClaimed();
|
||||
expect(all.length).to.equal(numNfts);
|
||||
for (const nft of all) {
|
||||
// @ts-ignore
|
||||
const creatorsOfNft = await drop.nft.creatorsOf(nft.metadata.id);
|
||||
expect(creatorsOfNft.length).to.equal(3);
|
||||
// Skip checking the first creator which is the candy machine creator pda
|
||||
expect(creatorsOfNft[1].address).to.equal(sdk.wallet.getAddress());
|
||||
expect(creatorsOfNft[1].share).to.equal(75);
|
||||
expect(creatorsOfNft[2].address).to.equal(newCreator);
|
||||
expect(creatorsOfNft[2].share).to.equal(25);
|
||||
}
|
||||
});
|
||||
|
||||
it("Should update royalty", async () => {
|
||||
let royalty = await drop.getRoyalty();
|
||||
expect(royalty).to.equal(0);
|
||||
await drop.updateRoyalty(100);
|
||||
|
||||
const mintAddress = (await drop.getAll())[0].metadata.id;
|
||||
// @ts-ignore
|
||||
let nft = await drop.nft.getRaw(mintAddress);
|
||||
expect(nft.isMutable).to.equal(true);
|
||||
expect(nft.sellerFeeBasisPoints).to.equal(0);
|
||||
|
||||
await drop.updateRoyalty(100, true);
|
||||
|
||||
royalty = await drop.getRoyalty();
|
||||
expect(royalty).to.equal(100);
|
||||
|
||||
// @ts-ignore
|
||||
nft = await drop.nft.getRaw(mintAddress);
|
||||
expect(nft.sellerFeeBasisPoints).to.equal(100);
|
||||
});
|
||||
|
||||
it("Should get all correctly", async () => {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`b45d761`](https://github.com/thirdweb-dev/js/commit/b45d761f8f2695b48312ec6eff15e0549e6a8a41), [`5f8ec45`](https://github.com/thirdweb-dev/js/commit/5f8ec45af7c81d075a84846098f38cad90d03fb9), [`04de5b2`](https://github.com/thirdweb-dev/js/commit/04de5b278362573991140c3a496de7451e5c770d)]:
|
||||
- @thirdweb-dev/sdk@3.7.3
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -12527,6 +12527,13 @@ [email protected], he@^1.2.0:
|
||||
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||
|
||||
heimdalljs@^0.2.6:
|
||||
version "0.2.6"
|
||||
resolved "https://registry.yarnpkg.com/heimdalljs/-/heimdalljs-0.2.6.tgz#b0eebabc412813aeb9542f9cc622cb58dbdcd9fe"
|
||||
integrity sha512-o9bd30+5vLBvBtzCPwwGqpry2+n0Hi6H1+qwt6y+0kwRHGGF8TFIhJPmnuM0xO97zaKrDZMwO/V56fAnn8m/tA==
|
||||
dependencies:
|
||||
rsvp "~3.2.1"
|
||||
|
||||
hey-listen@^1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68"
|
||||
@@ -15214,18 +15221,18 @@ mixme@^0.5.1:
|
||||
resolved "https://registry.yarnpkg.com/mixme/-/mixme-0.5.4.tgz#8cb3bd0cd32a513c161bf1ca99d143f0bcf2eff3"
|
||||
integrity sha512-3KYa4m4Vlqx98GPdOHghxSdNtTvcP8E0kkaJ5Dlh+h2DRzF7zpuVVcA8B0QpKd11YJeP9QQ7ASkKzOeu195Wzw==
|
||||
|
||||
mkdirp@^1.0.3, mkdirp@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||
|
||||
mkdirp@~0.5.1:
|
||||
mkdirp@^0.5.0, mkdirp@~0.5.1:
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6"
|
||||
integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==
|
||||
dependencies:
|
||||
minimist "^1.2.6"
|
||||
|
||||
mkdirp@^1.0.3, mkdirp@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||
|
||||
mnemonist@^0.38.0:
|
||||
version "0.38.5"
|
||||
resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade"
|
||||
@@ -17900,6 +17907,11 @@ rpc-websockets@^7.5.0:
|
||||
bufferutil "^4.0.1"
|
||||
utf-8-validate "^5.0.2"
|
||||
|
||||
rsvp@~3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.2.1.tgz#07cb4a5df25add9e826ebc67dcc9fd89db27d84a"
|
||||
integrity sha512-Rf4YVNYpKjZ6ASAmibcwTNciQ5Co5Ztq6iZPEykHpkoflnD/K5ryE/rHehFsTm4NJj8nKDhbi3eKBWGogmNnkg==
|
||||
|
||||
rtcpeerconnection-shim@^1.2.15:
|
||||
version "1.2.15"
|
||||
resolved "https://registry.yarnpkg.com/rtcpeerconnection-shim/-/rtcpeerconnection-shim-1.2.15.tgz#e7cc189a81b435324c4949aa3dfb51888684b243"
|
||||
@@ -19025,6 +19037,17 @@ symbol-tree@^3.2.4:
|
||||
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
|
||||
integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==
|
||||
|
||||
sync-disk-cache@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/sync-disk-cache/-/sync-disk-cache-2.1.0.tgz#01e879edc41c34a01fcdda5b39d47dd496e154a6"
|
||||
integrity sha512-vngT2JmkSapgq0z7uIoYtB9kWOOzMihAAYq/D3Pjm/ODOGMgS4r++B+OZ09U4hWR6EaOdy9eqQ7/8ygbH3wehA==
|
||||
dependencies:
|
||||
debug "^4.1.1"
|
||||
heimdalljs "^0.2.6"
|
||||
mkdirp "^0.5.0"
|
||||
rimraf "^3.0.0"
|
||||
username-sync "^1.0.2"
|
||||
|
||||
table-layout@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04"
|
||||
@@ -19831,6 +19854,11 @@ [email protected], use-sync-external-store@^1.2.0:
|
||||
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"
|
||||
integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==
|
||||
|
||||
username-sync@^1.0.2:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/username-sync/-/username-sync-1.0.3.tgz#ae41c5c8a4c8c2ecc1443a7d0742742bd7e36732"
|
||||
integrity sha512-m/7/FSqjJNAzF2La448c/aEom0gJy7HY7Y509h6l0ePvEkFictAGptwWaj1msWJ38JbfEDOUoE8kqFee9EHKdA==
|
||||
|
||||
utf-8-validate@^5.0.2:
|
||||
version "5.0.10"
|
||||
resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2"
|
||||
|
||||
Reference in New Issue
Block a user