Compare commits

..
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
7129aef6e1 Version Packages (#370)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-11-11 08:51:19 -08:00
Joaquim VergesandGitHub f50b74819d [SDK] make isConnected sync, remove useless fn (#381) 2022-11-11 06:14:24 +00:00
Joaquim VergesandGitHub 3eba69afd7 [SDK] expose signer's chain id via sdk.wallet (#380) 2022-11-11 00:42:05 +00:00
Jarrod WattsandGitHub 98c2253e8f [SDK] Docs - Add await before sdk.getContract snippets (#379) 2022-11-10 16:08:31 -08:00
32d91ef709 [REACT] Fix Border Radius for Safari (#378)
Co-authored-by: Jarrod Watts <[email protected]>
2022-11-10 09:53:17 -08:00
Adam MajmudarandGitHub b79dc18f7a Add event filtering on topics (#377) 2022-11-09 11:51:13 -05:00
Adam MajmudarandGitHub 4af785c37c Add TokensClaimed event to tiered-drop (#376) 2022-11-08 20:34:45 +00:00
Adam MajmudarandGitHub 6f818f393e Updated tiered-drop contract (#373) 2022-11-03 17:03:00 -07:00
Adam MajmudarandGitHub 97ed4779a9 Update nft drop claimTo documentation (#372) 2022-11-03 22:42:42 +00:00
Nacho IacovinoandGitHub 2d3fca5237 [React] Add useClaimerProofs hook (#369) 2022-11-03 01:17:15 +01:00
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
7016019f2a Version Packages (#366)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-11-02 15:16:25 -07:00
Joaquim VergesandGitHub 4e7b293c54 [SDK] Fix handling of old allowlist proof format (#368) 2022-11-02 14:11:13 -07:00
Jonas DanielsandGitHub c9c0e4ff39 [SDK] - make EVM side react native compatible (#365) 2022-11-02 05:38:56 +00:00
70 changed files with 1583 additions and 320 deletions
+2 -1
View File
@@ -16,4 +16,5 @@ public/dist
.yalc/
yalc.lock
build/
playwright-report/
playwright-report/
.vscode/
+3 -3
View File
@@ -15,8 +15,8 @@
"scripts": {
"test": "turbo run test test:evm test:solana",
"e2e": "turbo run e2e",
"build": "turbo run build",
"build:release": "turbo run build --force",
"build": "turbo run build --filter=./packages/*",
"build:release": "turbo run build --force --filter=./packages/*",
"dev": "turbo run dev --no-cache --parallel --continue",
"fix:repo": "manypkg fix",
"lint": "turbo run lint",
@@ -28,7 +28,7 @@
"release": "node ./scripts/pre-release.mjs && changeset publish",
"version-packages:nightly": "changeset version --snapshot nightly",
"release:nightly": "node ./scripts/pre-release.mjs && changeset publish --tag nightly",
"push": "turbo run push"
"push": "turbo run push --filter=./packages/*"
},
"packageManager": "[email protected]",
"dependencies": {
+4
View File
@@ -1,5 +1,9 @@
# @thirdweb-dev/auth
## 2.0.29
## 2.0.28
## 2.0.27
## 2.0.26
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "2.0.27",
"version": "2.0.29",
"exports": {
"./next": {
"module": "./next/dist/thirdweb-dev-auth-next.esm.js",
+14
View File
@@ -1,5 +1,19 @@
# thirdweb
## 0.8.15
### Patch Changes
- Updated dependencies [[`3eba69a`](https://github.com/thirdweb-dev/js/commit/3eba69afd78b7aa472a9c00c9d4220bb69ad1d3e), [`4af785c`](https://github.com/thirdweb-dev/js/commit/4af785c37c831ecd7087c1c9eb9095922cac0855), [`6f818f3`](https://github.com/thirdweb-dev/js/commit/6f818f393eb9023b53a3358d62d60ec23a9246bd), [`b79dc18`](https://github.com/thirdweb-dev/js/commit/b79dc18f7ab5155bbf4af02dc1a953546160bad0)]:
- @thirdweb-dev/sdk@3.5.2
## 0.8.14
### Patch Changes
- Updated dependencies [[`4e7b293`](https://github.com/thirdweb-dev/js/commit/4e7b293c543244de79c150ca8c37d941221fc9a3), [`c9c0e4f`](https://github.com/thirdweb-dev/js/commit/c9c0e4ff39b054af746f3aec75fcbd0a3ef7239d)]:
- @thirdweb-dev/sdk@3.5.1
## 0.8.13
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.8.13",
"version": "0.8.15",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+8
View File
@@ -1,5 +1,13 @@
# @thirdweb-dev/contracts-js
## 1.2.1
### Patch Changes
- [#376](https://github.com/thirdweb-dev/js/pull/376) [`4af785c`](https://github.com/thirdweb-dev/js/commit/4af785c37c831ecd7087c1c9eb9095922cac0855) Thanks [@adam-maj](https://github.com/adam-maj)! - Update tiered-drop with tokens claimed
- [#373](https://github.com/thirdweb-dev/js/pull/373) [`6f818f3`](https://github.com/thirdweb-dev/js/commit/6f818f393eb9023b53a3358d62d60ec23a9246bd) Thanks [@adam-maj](https://github.com/adam-maj)! - Update tiered-drop contract version
## 1.2.0
### Minor Changes
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@thirdweb-dev/contracts-js",
"version": "1.2.0",
"version": "1.2.1",
"main": "dist/thirdweb-dev-contracts-js.cjs.js",
"module": "dist/thirdweb-dev-contracts-js.esm.js",
"license": "Apache-2.0",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
"dependencies": {
"@thirdweb-dev/contracts": "3.2.0-4"
"@thirdweb-dev/contracts": "^3.2.2"
},
"devDependencies": {
"@babel/preset-env": "^7.18.10",
+12
View File
@@ -1,5 +1,17 @@
# @thirdweb-dev/react
## 3.5.2
### Patch Changes
- [#369](https://github.com/thirdweb-dev/js/pull/369) [`2d3fca5`](https://github.com/thirdweb-dev/js/commit/2d3fca52373046c88392139922e9c9da79f9a2d4) Thanks [@nachoiacovino](https://github.com/nachoiacovino)! - Add useClaimerProofs hook
- [#378](https://github.com/thirdweb-dev/js/pull/378) [`32d91ef`](https://github.com/thirdweb-dev/js/commit/32d91ef709c8fb92a903e52c65b27538a80ea4eb) Thanks [@mykcryptodev](https://github.com/mykcryptodev)! - round borders for buttons and menus on safari
- [#377](https://github.com/thirdweb-dev/js/pull/377) [`b79dc18`](https://github.com/thirdweb-dev/js/commit/b79dc18f7ab5155bbf4af02dc1a953546160bad0) Thanks [@adam-maj](https://github.com/adam-maj)! - Add event filters
## 3.5.1
## 3.5.0
## 3.4.5
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.5.0",
"version": "3.5.2",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
@@ -37,8 +37,19 @@ const BaseButton = styled.button<BaseButtonProps>`
cursor: not-allowed;
}
&:focus {
outline: 2px solid ${(props) => (props.theme as TwUiTheme).colors.accent};
outline-offset: 1px;
position: relative;
border-radius: 0.5em;
outline: 0;
}
&:focus:after {
content: "";
position: absolute;
top: -5px;
right: -5px;
bottom: -5px;
left: -5px;
border: 2px solid ${(props) => (props.theme as TwUiTheme).colors.accent};
border-radius: 11px;
}
`;
@@ -8,10 +8,23 @@ export const Menu = styled.ul<MenuProps>`
margin: 0;
background: ${(props) => (props.theme as TwUiTheme).colors.background};
color: ${(props) => (props.theme as TwUiTheme).colors.text};
outline-color: ${(props) => (props.theme as TwUiTheme).colors.accent};
outline-style: solid;
outline-offset: 0px;
list-style: none;
border-radius: 0.5em;
overflow: hidden;
position: relative;
pointer-events: auto;
&:focus {
outline: 0;
}
&:after {
content: "";
position: absolute;
border: 1px solid ${(props) => (props.theme as TwUiTheme).colors.accent};
border-radius: 0.5em;
pointer-events: none;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
`;
@@ -45,7 +45,7 @@ export type SetClaimConditionsParams = {
/** **********************/
/**
* Use this to get the active claim conditon for ERC20, ERC721 or ERC1155 based contracts. They need to extend the `claimCondition` extension for this hook to work.
* Use this to get the active claim condition for ERC20, ERC721 or ERC1155 based contracts. They need to extend the `claimCondition` extension for this hook to work.
*
* @example
* ```javascript
@@ -60,7 +60,7 @@ export type SetClaimConditionsParams = {
* const { data: activeClaimCondition, isLoading, error } = useActiveClaimCondition(<YourERC1155ContractInstance>, <tokenId>);
* ```
*
* @param contract - an instance of a contract that extends the ERC721 or ERC1155 spec and implements the `claimConditions` extension.
* @param contract - an instance of a contract that extends the ERC721, ERC1155 or ERC20 spec and implements the `claimConditions` extension.
* @param tokenId - the id of the token to fetch the claim conditions for (if the contract is an ERC1155 contract)
* @returns a response object with the currently active claim condition
* @twfeature ERC721ClaimableWithConditions | ERC1155ClaimableWithConditions | ERC20ClaimableWithConditions
@@ -106,7 +106,70 @@ export function useActiveClaimCondition(
}
/**
* Use this to get all claim conditons for ERC20, ERC721 or ERC1155 based contracts. They need to extend the `claimCondition` extension for this hook to work.
* Use this to get the claimer proofs for an adddress for ERC20, ERC721 or ERC1155 based contracts. They need to extend the `claimCondition` extension for this hook to work.
*
* @example
* ```javascript
* const { data: claimerProofs, isLoading, error } = useClaimerProofs(<YourERC20ContractInstance>);
* ```
* @example
* ```javascript
* const { data: claimerProofs, isLoading, error } = useClaimerProofs(<YourERC721ContractInstance>);
* ```
* @example
* ```javascript
* const { data: claimerProofs, isLoading, error } = useClaimerProofs(<YourERC1155ContractInstance>, <tokenId>);
* ```
*
* @param contract - an instance of a contract that extends the ERC721, ERC1155 or ERC20 spec and implements the `claimConditions` extension.
* @param claimerAddress - the address of the claimer to fetch the claimer proofs for
* @param tokenId - the id of the token to fetch the claimer proofs for (if the contract is an ERC1155 contract)
* @param claimConditionId - optional the claim condition id to get the proofs for
* @returns a response object with the snapshot for the provided address
* @twfeature ERC721ClaimableWithConditions | ERC1155ClaimableWithConditions | ERC20ClaimableWithConditions
* @beta
*/
export function useClaimerProofs(
contract: RequiredParam<DropContract>,
claimerAddress: string,
tokenId?: BigNumberish,
claimConditionId?: BigNumberish,
) {
const contractAddress = contract?.getAddress();
const { erc1155, erc721, erc20 } = getErcs(contract);
return useQueryWithNetwork(
cacheKeys.extensions.claimConditions.getClaimerProofs(
contractAddress,
tokenId,
),
() => {
if (erc1155) {
requiredParamInvariant(
tokenId,
"tokenId is required for ERC1155 claim conditions",
);
return erc1155.claimConditions.getClaimerProofs(tokenId, claimerAddress, claimConditionId);
}
if (erc721) {
return erc721.claimConditions.getClaimerProofs(claimerAddress, claimConditionId);
}
if (erc20) {
return erc20.claimConditions.getClaimerProofs(claimerAddress, claimConditionId);
}
throw new Error("Contract must be ERC721, ERC1155 or ERC20");
},
{
// Checks that happen here:
// 1. if the contract is based on ERC1155 contract => tokenId cannot be `undefined`
// 2. if the contract is NOT based on ERC1155 => we have to have either an ERC721 or ERC20 contract
enabled: erc1155 ? tokenId !== undefined : !!erc721 || !!erc20,
},
);
}
/**
* Use this to get all claim conditions for ERC20, ERC721 or ERC1155 based contracts. They need to extend the `claimCondition` extension for this hook to work.
*
* @example
* ```javascript
@@ -121,7 +184,7 @@ export function useActiveClaimCondition(
* const { data: claimConditions, isLoading, error } = useClaimConditions(<YourERC1155ContractInstance>, <tokenId>);
* ```
*
* @param contract - an instance of a contract that extends the ERC721 or ERC1155 spec and implements the `claimConditions` extension.
* @param contract - an instance of a contract that extends the ERC721, ERC1155 or ERC20 spec and implements the `claimConditions` extension.
* @param tokenId - the id of the token to fetch the claim conditions for (if the contract is an ERC1155 contract)
* @returns a response object with the list of claim conditions
* @twfeature ERC721ClaimableWithConditions | ERC1155ClaimableWithConditions | ERC20ClaimableWithConditions
@@ -23,7 +23,7 @@ import {
ContractEvent,
ContractForPrebuiltContractType,
ContractType,
EventQueryFilter,
EventQueryOptions,
PrebuiltContractType,
SUPPORTED_CHAIN_ID,
ThirdwebSDK,
@@ -346,7 +346,7 @@ export function useContractMetadataUpdate(
export function useContractEvents(
contract: RequiredParam<ValidContractInstance>,
eventName?: string,
options: { queryFilter?: EventQueryFilter; subscribe?: boolean } = {
options: { queryFilter?: EventQueryOptions; subscribe?: boolean } = {
subscribe: true,
},
) {
@@ -11,7 +11,7 @@ import { useContract } from "../async/contracts";
* import { useContract } from '@thirdweb-dev/react'
*
* export default function Component() {
* const { contract } = useNFTCollection("<YOUR-CONTRACT-ADDRESS>", "nft-collection")
* const { contract, isLoading, error } = useContract("<YOUR-CONTRACT-ADDRESS>", "nft-collection")
*
* // Now you can use the nftCollection contract in the rest of the component
*
@@ -287,6 +287,16 @@ export const cacheKeys = {
? ["claimConditions", "getAll", { tokenId }, options]
: ["claimConditions", "getAll", options],
),
getClaimerProofs: (
contractAddress: RequiredParam<ContractAddress>,
tokenId?: BigNumberish,
) =>
createContractCacheKey(
contractAddress,
tokenId
? ["claimConditions", "getClaimerProofs", { tokenId }]
: ["claimConditions", "getClaimerProofs"],
),
getClaimIneligibilityReasons: (
contractAddress: RequiredParam<ContractAddress>,
params: { walletAddress?: WalletAddress; quantity: string | number },
@@ -4,7 +4,8 @@ import {
RequiredParam,
} from "../../../core/query-utils/required-param";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import type { Amount, Token } from "@thirdweb-dev/sdk/solana";
import type { Amount } from "@thirdweb-dev/sdk";
import type { Token } from "@thirdweb-dev/sdk/solana";
export type TransferTokenMutationParams = {
amount: Amount;
+23
View File
@@ -1,5 +1,28 @@
# @thirdweb-dev/sdk
## 3.5.2
### Patch Changes
- [#380](https://github.com/thirdweb-dev/js/pull/380) [`3eba69a`](https://github.com/thirdweb-dev/js/commit/3eba69afd78b7aa472a9c00c9d4220bb69ad1d3e) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Expose sdk.wallet.getChainId()
- [#376](https://github.com/thirdweb-dev/js/pull/376) [`4af785c`](https://github.com/thirdweb-dev/js/commit/4af785c37c831ecd7087c1c9eb9095922cac0855) Thanks [@adam-maj](https://github.com/adam-maj)! - Update tiered-drop with tokens claimed
- [#373](https://github.com/thirdweb-dev/js/pull/373) [`6f818f3`](https://github.com/thirdweb-dev/js/commit/6f818f393eb9023b53a3358d62d60ec23a9246bd) Thanks [@adam-maj](https://github.com/adam-maj)! - Update tiered-drop contract version
- [#377](https://github.com/thirdweb-dev/js/pull/377) [`b79dc18`](https://github.com/thirdweb-dev/js/commit/b79dc18f7ab5155bbf4af02dc1a953546160bad0) Thanks [@adam-maj](https://github.com/adam-maj)! - Add event filters
- Updated dependencies [[`4af785c`](https://github.com/thirdweb-dev/js/commit/4af785c37c831ecd7087c1c9eb9095922cac0855), [`6f818f3`](https://github.com/thirdweb-dev/js/commit/6f818f393eb9023b53a3358d62d60ec23a9246bd)]:
- @thirdweb-dev/contracts-js@1.2.1
## 3.5.1
### Patch Changes
- [#368](https://github.com/thirdweb-dev/js/pull/368) [`4e7b293`](https://github.com/thirdweb-dev/js/commit/4e7b293c543244de79c150ca8c37d941221fc9a3) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Fix handling of old allowlist proof format
- [#365](https://github.com/thirdweb-dev/js/pull/365) [`c9c0e4f`](https://github.com/thirdweb-dev/js/commit/c9c0e4ff39b054af746f3aec75fcbd0a3ef7239d) Thanks [@jnsdls](https://github.com/jnsdls)! - [EVM] - now React Native compatible
## 3.5.0
### Minor Changes
+1 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.5.0",
"version": "3.5.2",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -108,7 +108,6 @@
"@thirdweb-dev/storage": "*",
"bn.js": "^5.2.1",
"bs58": "^5.0.0",
"cbor-x": "^1.4.1",
"cross-fetch": "^3.1.5",
"eventemitter3": "^4.0.7",
"fast-deep-equal": "^3.1.3",
+13 -2
View File
@@ -2,8 +2,14 @@ import BN from "bn.js";
import { BigNumber } from "ethers";
import { z } from "zod";
const isBrowser = () => typeof window !== "undefined";
const FileOrBufferUnionSchema = isBrowser()
/**
* @internal
*/
export const isBrowser = () => typeof window !== "undefined";
/**
* @internal
*/
export const FileOrBufferUnionSchema = isBrowser()
? (z.instanceof(File) as z.ZodType<InstanceType<typeof File>>)
: (z.instanceof(Buffer) as z.ZodTypeAny); // @fixme, this is a hack to make browser happy for now
@@ -96,6 +102,11 @@ export const AmountSchema = z
])
.transform((arg) => (typeof arg === "number" ? arg.toString() : arg));
/**
* @internal
*/
export type Amount = z.input<typeof AmountSchema>;
/**
* @internal
*/
@@ -92,14 +92,16 @@ export async function prepareClaim(
tokenDecimals,
);
priceInProof =
snapshotEntry.price === undefined ||
snapshotEntry.price === "unlimited"
? ethers.constants.MaxUint256
: await normalizePriceValue(
contractWrapper.getProvider(),
snapshotEntry.price,
snapshotEntry.currencyAddress,
snapshotEntry.currencyAddress || ethers.constants.AddressZero,
);
currencyAddressInProof = snapshotEntry.currencyAddress;
currencyAddressInProof =
snapshotEntry.currencyAddress || ethers.constants.AddressZero;
} else {
// if no snapshot entry, and it's a v1 format (exclusive allowlist) then address can't claim
if (snapshotFormatVersion === SnapshotFormatVersion.V1) {
@@ -323,9 +325,13 @@ export async function getClaimerProofs(
return undefined;
}
const price =
claim.price === "unlimited"
claim.price === "unlimited" || claim.price === undefined
? ethers.constants.MaxUint256
: await normalizePriceValue(provider, claim.price, claim.currencyAddress);
: await normalizePriceValue(
provider,
claim.price,
claim.currencyAddress || ethers.constants.AddressZero,
);
const maxClaimable =
claim.maxClaimable === "unlimited"
? ethers.constants.MaxUint256
@@ -334,7 +340,7 @@ export async function getClaimerProofs(
proof: claim.proof,
maxClaimable,
price,
currencyAddress: claim.currencyAddress,
currencyAddress: claim.currencyAddress || ethers.constants.AddressZero,
};
}
+1 -1
View File
@@ -1,9 +1,9 @@
import { AmountSchema } from "../../core/schema/shared";
import {
getNativeTokenByChainId,
NATIVE_TOKEN_ADDRESS,
} from "../constants/currency";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { AmountSchema } from "../schema/shared";
import { Amount, Currency, CurrencyValue, Price } from "../types/currency";
import { BaseERC20 } from "../types/eips";
import type { IERC20, IERC20Metadata } from "@thirdweb-dev/contracts-js";
@@ -6,6 +6,7 @@ import {
} from "../constants/contract-features";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { DetectableFeature } from "../core/interfaces/DetectableFeature";
import { decode } from "../lib/cbor-decode.js";
import {
AbiEvent,
AbiFunction,
@@ -23,7 +24,6 @@ import {
import { ExtensionNotImplementedError } from "./error";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import bs58 from "bs58";
import { decode } from "cbor-x";
import { BaseContract, BigNumber, ethers } from "ethers";
import { z } from "zod";
+1 -1
View File
@@ -1,10 +1,10 @@
import { MAX_BPS } from "../../core/schema/shared";
import {
InterfaceId_IERC1155,
InterfaceId_IERC721,
} from "../constants/contract";
import { SignerOrProvider } from "../core";
import { ContractWrapper } from "../core/classes/contract-wrapper";
import { MAX_BPS } from "../schema/shared";
import {
NewAuctionListing,
NewDirectListing,
@@ -101,8 +101,11 @@ export class ShardedMerkleTree {
[
entry.address,
convertQuantityToBigNumber(entry.maxClaimable, tokenDecimals),
convertQuantityToBigNumber(entry.price, currencyDecimals),
entry.currencyAddress,
convertQuantityToBigNumber(
entry.price || "unlimited",
currencyDecimals,
),
entry.currencyAddress || ethers.constants.AddressZero,
],
);
}
@@ -111,11 +114,14 @@ export class ShardedMerkleTree {
static async fetchAndCacheDecimals(
cache: Record<string, number>,
provider: ethers.providers.Provider,
currencyAddress: string,
currencyAddress?: string,
): Promise<number> {
if (!currencyAddress) {
return 18;
}
// cache decimals for each currency to avoid refetching for every address
let currencyDecimals = cache[currencyAddress];
if (!currencyDecimals) {
if (currencyDecimals === undefined) {
const currencyMetadata = await fetchCurrencyMetadata(
provider,
currencyAddress,
@@ -22,7 +22,7 @@ import {
TransactionResult,
TransactionResultWithId,
} from "../../core/types";
import { PaperCheckout } from "../../integrations/checkout";
import { PaperCheckout } from "../../integrations/thirdweb-checkout";
import { DropErc1155ContractSchema } from "../../schema/contracts/drop-erc1155";
import { SDKOptions } from "../../schema/sdk-options";
import { PrebuiltEditionDrop } from "../../types/eips";
@@ -39,7 +39,7 @@ import { BigNumber, BigNumberish, CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "edition-drop");
* const contract = await sdk.getContract("{{contract_address}}", "edition-drop");
* ```
*
* @public
@@ -37,7 +37,7 @@ import { BigNumber, BigNumberish, CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "edition");
* const contract = await sdk.getContract("{{contract_address}}", "edition");
* ```
*
* @public
@@ -3,10 +3,7 @@ import { ListingNotFoundError } from "../../common";
import { isNativeToken } from "../../common/currency";
import { mapOffer } from "../../common/marketplace";
import { getRoleHash } from "../../common/role";
import {
NATIVE_TOKENS,
SUPPORTED_CHAIN_ID,
} from "../../constants";
import { NATIVE_TOKENS, SUPPORTED_CHAIN_ID } from "../../constants";
import { ContractEncoder } from "../../core/classes/contract-encoder";
import { ContractEvents } from "../../core/classes/contract-events";
import { ContractInterceptor } from "../../core/classes/contract-interceptor";
@@ -42,7 +39,7 @@ import invariant from "tiny-invariant";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "marketplace");
* const contract = await sdk.getContract("{{contract_address}}", "marketplace");
* ```
*
* @public
@@ -47,7 +47,7 @@ import { BigNumberish, CallOverrides, ethers } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "multiwrap");
* const contract = await sdk.getContract("{{contract_address}}", "multiwrap");
* ```
*
* @beta
@@ -35,7 +35,7 @@ import { BigNumberish, CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "nft-collection");
* const contract = await sdk.getContract("{{contract_address}}", "nft-collection");
* ```
*
* @public
@@ -26,7 +26,7 @@ import {
TransactionResult,
TransactionResultWithId,
} from "../../core/types";
import { PaperCheckout } from "../../integrations/checkout";
import { PaperCheckout } from "../../integrations/thirdweb-checkout";
import { DropErc721ContractSchema } from "../../schema/contracts/drop-erc721";
import { SDKOptions } from "../../schema/sdk-options";
import { PrebuiltNFTDrop } from "../../types/eips";
@@ -44,7 +44,7 @@ import { BigNumber, BigNumberish, CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "nft-drop");
* const contract = await sdk.getContract("{{contract_address}}", "nft-drop");
* ```
*
* @public
@@ -409,9 +409,9 @@ export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
* const quantity = 1; // how many unique NFTs you want to claim
*
* const tx = await contract.claimTo(address, quantity);
* const receipt = tx.receipt; // the transaction receipt
* const claimedTokenId = tx.id; // the id of the NFT claimed
* const claimedNFT = await tx.data(); // (optional) get the claimed NFT metadata
* const receipt = tx[0].receipt; // the transaction receipt
* const claimedTokenId = tx[0].id; // the id of the NFT claimed
* const claimedNFT = await tx[0].data(); // (optional) get the claimed NFT metadata
* ```
*
* @param destinationAddress - Address you want to send the token to
@@ -52,7 +52,7 @@ import { BigNumber, BigNumberish, CallOverrides, ethers } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "pack");
* const contract = await sdk.getContract("{{contract_address}}", "pack");
* ```
*
* @public
@@ -27,7 +27,7 @@ import {
TransactionResult,
TransactionResultWithId,
} from "../../core/types";
import { PaperCheckout } from "../../integrations/checkout";
import { PaperCheckout } from "../../integrations/thirdweb-checkout";
import { DropErc721ContractSchema } from "../../schema/contracts/drop-erc721";
import { SDKOptions } from "../../schema/sdk-options";
import { ClaimOptions, UploadProgressEvent } from "../../types";
@@ -47,7 +47,7 @@ import { BigNumber, BigNumberish, CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "signature-drop");
* const contract = await sdk.getContract("{{contract_address}}", "signature-drop");
* ```
*
* @public
@@ -30,7 +30,7 @@ import { BigNumber, CallOverrides, Contract } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "split");
* const contract = await sdk.getContract("{{contract_address}}", "split");
* ```
*
* @public
@@ -28,7 +28,7 @@ import { CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "token-drop");
* const contract = await sdk.getContract("{{contract_address}}", "token-drop");
* ```
*
*/
@@ -30,7 +30,7 @@ import { CallOverrides, constants } from "ethers";
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "token");
* const contract = await sdk.getContract("{{contract_address}}", "token");
* ```
*
* @public
@@ -46,7 +46,7 @@ import {
* import { ThirdwebSDK } from "@thirdweb-dev/sdk";
*
* const sdk = new ThirdwebSDK("{{chainName}}");
* const contract = sdk.getContract("{{contract_address}}", "vote");
* const contract = await sdk.getContract("{{contract_address}}", "vote");
* ```
*
* @public
@@ -1,5 +1,5 @@
import { EventType } from "../../constants";
import { ContractEvent, EventQueryFilter } from "../../types/index";
import { ContractEvent, EventQueryOptions } from "../../types/index";
import { ContractWrapper } from "./contract-wrapper";
import { EventFragment } from "@ethersproject/abi";
import { BaseContract, Event, providers } from "ethers";
@@ -198,7 +198,7 @@ export class ContractEvents<TContract extends BaseContract> {
* @returns The event objects of the events emitted with event names and data for each event
*/
public async getAllEvents<TEvent extends Record<string, any>>(
filters: EventQueryFilter = {
filters: Omit<EventQueryOptions, "filters"> = {
fromBlock: 0,
toBlock: "latest",
order: "desc",
@@ -226,23 +226,34 @@ export class ContractEvents<TContract extends BaseContract> {
* ```javascript
* // The name of the event to get logs for
* const eventName = "Transfer";
* // Optionally pass in filters to limit the blocks from which events are retrieved
* const filters = {
*
* // Optionally pass in options to limit the blocks from which events are retrieved
* const options = {
* fromBlock: 0,
* toBlock: 1000000,
* }
* const events = await contract.events.getEvents(eventName, filters);
* toBlock: 1000000, // can also pass "latest"
* order: "desc",
* // Configure event filters (filter on indexed event parameters)
* filters: {
* from: "0x...",
* to: "0x..."
* }
* };
*
* const events = await contract.events.getEvents(eventName, options);
* console.log(events[0].eventName);
* console.log(events[0].data);
* ```
*
* @param eventName - The name of the event to get logs for
* @param filters - Specify the from and to block numbers to get events for, defaults to all blocks. @see EventQueryFilter
* @param options - Specify the from and to block numbers to get events for, defaults to all blocks. @see EventQueryOptions
* @returns The requested event objects with event data
*/
public async getEvents<TEvent extends Record<string, any>>(
public async getEvents<
TEvent extends Record<string, any> = Record<string, any>,
TFilter extends Record<string, any> = Record<string, any>,
>(
eventName: string,
filters: EventQueryFilter = {
options: EventQueryOptions<TFilter> = {
fromBlock: 0,
toBlock: "latest",
order: "desc",
@@ -251,24 +262,32 @@ export class ContractEvents<TContract extends BaseContract> {
const event = this.contractWrapper.readContract.interface.getEvent(
eventName as string,
);
const filter = this.contractWrapper.readContract.filters[event.name];
const eventInterface =
this.contractWrapper.readContract.interface.getEvent(eventName);
const args = options.filters
? eventInterface.inputs.map((e) => (options.filters as TFilter)[e.name])
: [];
const filter = this.contractWrapper.readContract.filters[event.name](
...args,
);
const events = await this.contractWrapper.readContract.queryFilter(
filter(),
filters.fromBlock,
filters.toBlock,
filter,
options.fromBlock,
options.toBlock,
);
const orderedEvents = events.sort((a, b) => {
return filters.order === "desc"
return options.order === "desc"
? b.blockNumber - a.blockNumber
: a.blockNumber - b.blockNumber;
});
return this.parseEvents(orderedEvents);
return this.parseEvents<TEvent>(orderedEvents);
}
private parseEvents<TEvent extends Record<string, any>>(
private parseEvents<TEvent = Record<string, any>>(
events: Event[],
): ContractEvent<TEvent>[] {
return events.map((e) => {
@@ -1,3 +1,4 @@
import { AmountSchema } from "../../../core/schema/shared";
import { includesErrorMessage } from "../../common";
import {
abstractContractModelToLegacy,
@@ -22,7 +23,6 @@ import { isNode } from "../../common/utils";
import { ClaimEligibility } from "../../enums";
import {
AbstractClaimConditionContractStruct,
AmountSchema,
SnapshotEntryWithProof,
} from "../../schema";
import {
+2 -1
View File
@@ -1,4 +1,5 @@
import { NetworkOrSignerOrProvider, TransactionResult } from "..";
import { AmountSchema } from "../../../core/schema/shared";
import { assertEnabled, detectContractFeature } from "../../common";
import {
fetchCurrencyMetadata,
@@ -12,7 +13,7 @@ import {
FEATURE_TOKEN_SIGNATURE_MINTABLE,
FEATURE_TOKEN_CLAIMABLE_WITH_CONDITIONS,
} from "../../constants/erc20-features";
import { TokenMintInput, AmountSchema } from "../../schema";
import { TokenMintInput } from "../../schema";
import { Currency, CurrencyValue, Amount, ClaimOptions } from "../../types";
import {
BaseERC20,
@@ -77,7 +77,7 @@ export class Erc721Claimable implements DetectableFeature {
* const quantity = 1; // how many NFTs you want to claim
*
* const tx = await contract.erc721.claimTo(address, tokenId, quantity);
* const receipt = tx.receipt; // the transaction receipt
* const receipt = tx[0].receipt; // the transaction receipt
* ```
*
* @param destinationAddress - Address you want to send the token to
@@ -21,7 +21,10 @@ import { TransactionResult, TransactionResultWithId } from "../types";
import { ContractWrapper } from "./contract-wrapper";
import { Erc721 } from "./erc-721";
import type { TieredDrop, ISignatureAction } from "@thirdweb-dev/contracts-js";
import { TokensLazyMintedEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/TieredDrop";
import {
TokensLazyMintedEvent,
TokensClaimedEvent,
} from "@thirdweb-dev/contracts-js/dist/declarations/src/TieredDrop";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { BigNumberish, ethers } from "ethers";
import invariant from "tiny-invariant";
@@ -46,12 +49,16 @@ export class Erc721TieredDrop implements DetectableFeature {
public async getMetadataInTier(
tier: string,
): Promise<Omit<NFTMetadata, "id">[]> {
const batches = await this.contractWrapper.readContract.getMetadataInTier(
tier,
);
const tiers =
await this.contractWrapper.readContract.getMetadataForAllTiers();
const batches = tiers.find((t) => t.tier === tier);
if (!batches) {
throw new Error("Tier not found in contract.");
}
const nfts = await Promise.all(
batches.tokens
batches.ranges
.map((range, i) => {
const nftsInRange = [];
const baseUri = batches.baseURIs[i];
@@ -133,8 +140,9 @@ export class Erc721TieredDrop implements DetectableFeature {
"TokensLazyMinted",
receipt?.logs,
);
const startingIndex = event[0].args.startTokenId;
const endingIndex = event[0].args.endTokenId;
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({
@@ -214,8 +222,8 @@ export class Erc721TieredDrop implements DetectableFeature {
"TokensLazyMinted",
receipt?.logs,
);
const startingIndex = event[0].args.startTokenId;
const endingIndex = event[0].args.endTokenId;
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({
@@ -314,7 +322,7 @@ export class Erc721TieredDrop implements DetectableFeature {
public async claimWithSignature(
signedPayload: TieredDropPayloadWithSignature,
): Promise<TransactionResult> {
): Promise<TransactionResultWithId<NFT>[]> {
const message = await this.mapPayloadToContractStruct(
signedPayload.payload,
);
@@ -338,9 +346,22 @@ export class Erc721TieredDrop implements DetectableFeature {
[message, signedPayload.signature],
overrides,
);
const event = this.contractWrapper.parseLogs<TokensClaimedEvent>(
"TokensClaimed",
receipt?.logs,
);
const startingIndex = event[0].args.startTokenId;
const endingIndex = startingIndex.add(event[0].args.quantityClaimed);
const results: TransactionResultWithId<NFT>[] = [];
for (let id = startingIndex; id.lt(endingIndex); id = id.add(1)) {
results.push({
id,
receipt,
data: () => this.erc721.get(id),
});
}
// TODO: Listen for TokensClaimed event once it gets emitted
return { receipt };
return results;
}
private async mapPayloadToContractStruct(
+24 -3
View File
@@ -139,10 +139,31 @@ export class UserWallet {
* const address = await sdk.wallet.getAddress();
* ```
*/
async getAddress(): Promise<string> {
public async getAddress(): Promise<string> {
return await this.requireWallet().getAddress();
}
/**
* Get the currently connected wallet's chainId
* @internal
*/
public async getChainId(): Promise<number> {
return await this.requireWallet().getChainId();
}
/**
* Checks whether there's a signer connected with the SDK
* @internal
*/
public isConnected(): boolean {
try {
this.requireWallet();
return true;
} catch (e) {
return false;
}
}
/**
* Sign any message with the connected wallet private key
* @param message - the message to sign
@@ -157,7 +178,7 @@ export class UserWallet {
* const signature = await sdk.wallet.sign(message);
* ```
*/
async sign(message: string): Promise<string> {
public async sign(message: string): Promise<string> {
const signer = this.requireWallet();
return await signer.signMessage(message);
}
@@ -187,7 +208,7 @@ export class UserWallet {
* Send a raw transaction to the blockchain from the connected wallet
* @param transactionRequest - raw transaction data to send to the blockchain
*/
async sendRawTransaction(
public async sendRawTransaction(
transactionRequest: providers.TransactionRequest,
): Promise<TransactionResult> {
const signer = this.requireWallet();
+1 -1
View File
@@ -29,7 +29,7 @@ export * from "./constants";
export * from "./contracts";
// export integration things
export * from "./integrations/checkout";
export * from "./integrations/thirdweb-checkout";
// explcitly export the *TYPES* of prebuilt contracts
export type { Edition } from "./contracts/prebuilt-implementations/edition";
@@ -3,7 +3,7 @@ import { ContractWrapper } from "../core/classes/contract-wrapper";
import { SignedPayload721WithQuantitySignature } from "../schema/contracts/common/signature";
import { PrebuiltEditionDrop, PrebuiltNFTDrop } from "../types/eips";
import { SignatureDrop } from "@thirdweb-dev/contracts-js/dist/declarations/src/SignatureDrop";
import fetch from "cross-fetch";
// import fetch from "cross-fetch";
import invariant from "tiny-invariant";
const PAPER_API_BASE = `https://paper.xyz/api` as const;
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,5 @@
import { AddressSchema, AmountSchema } from "../../shared";
import { AmountSchema } from "../../../../core/schema/shared";
import { AddressSchema } from "../../shared";
import { z } from "zod";
/**
@@ -1,10 +1,12 @@
import { QuantitySchema } from "../../../../core/schema/shared";
import {
AmountSchema,
BytesLikeSchema,
QuantitySchema,
} from "../../../../core/schema/shared";
import { NATIVE_TOKEN_ADDRESS } from "../../../constants/currency";
import {
BigNumberishSchema,
BigNumberSchema,
BytesLikeSchema,
AmountSchema,
StartDateSchema,
} from "../../shared";
import { CurrencyValueSchema } from "./currency";
@@ -1,8 +1,8 @@
import {
AddressSchema,
BasisPointsSchema,
FileOrBufferOrStringSchema,
} from "../../shared";
} from "../../../../core/schema/shared";
import { AddressSchema } from "../../shared";
import { constants } from "ethers";
import { z } from "zod";
@@ -1,12 +1,14 @@
import { NFTInputOrUriSchema } from "../../../../core/schema/nft";
import {
AmountSchema,
BasisPointsSchema,
} from "../../../../core/schema/shared";
import { resolveOrGenerateId } from "../../../common/signature-minting";
import { NATIVE_TOKEN_ADDRESS } from "../../../constants/currency";
import {
BasisPointsSchema,
BigNumberishSchema,
BigNumberSchema,
EndDateSchema,
AmountSchema,
StartDateSchema,
} from "../../shared";
import { constants } from "ethers";
@@ -13,8 +13,10 @@ export const MerkleSchema = z.object({
export const SnapshotEntryInput = z.object({
address: AddressSchema,
maxClaimable: QuantitySchema.default(0), // defaults to 0
price: QuantitySchema, // defaults to unlimited
currencyAddress: AddressSchema.default(ethers.constants.AddressZero),
price: QuantitySchema.optional(), // defaults to unlimited, but can be undefined in old snapshots
currencyAddress: AddressSchema.default(
ethers.constants.AddressZero,
).optional(), // defaults to AddressZero, but can be undefined for old snapshots
});
export type SnapshotEntry = z.output<typeof SnapshotEntryInput>;
@@ -1,9 +1,9 @@
import { FileOrBufferOrStringSchema } from "../../../core/schema/shared";
import { toSemver } from "../../common/index";
import {
AddressSchema,
BigNumberishSchema,
BigNumberTransformSchema,
FileOrBufferOrStringSchema,
} from "../shared";
import {
CommonContractOutputSchema,
@@ -1,4 +1,5 @@
import { AddressSchema, BasisPointsSchema } from "../shared";
import { BasisPointsSchema } from "../../../core/schema/shared";
import { AddressSchema } from "../shared";
import {
CommonContractOutputSchema,
CommonContractSchema,
@@ -1,4 +1,5 @@
import { BasisPointsSchema, BigNumberSchema } from "../shared";
import { BasisPointsSchema } from "../../../core/schema/shared";
import { BigNumberSchema } from "../shared";
import { BaseSignaturePayloadInput } from "./common";
import { constants } from "ethers";
import { z } from "zod";
@@ -1,9 +1,5 @@
import {
AddressSchema,
BigNumberishSchema,
BigNumberSchema,
PercentSchema,
} from "../shared";
import { PercentSchema } from "../../../core/schema/shared";
import { AddressSchema, BigNumberishSchema, BigNumberSchema } from "../shared";
import {
CommonContractOutputSchema,
CommonContractSchema,
-45
View File
@@ -1,34 +1,6 @@
import { BigNumber, CallOverrides, utils } from "ethers";
import { z } from "zod";
const isBrowser = () => typeof window !== "undefined";
const FileOrBufferUnionSchema = isBrowser()
? (z.instanceof(File) as z.ZodType<InstanceType<typeof File>>)
: (z.instanceof(Buffer) as z.ZodTypeAny); // @fixme, this is a hack to make browser happy for now
/**
* @internal
*/
export const FileOrBufferSchema = z.union([
FileOrBufferUnionSchema,
z.object({
data: z.union([FileOrBufferUnionSchema, z.string()]),
name: z.string(),
}),
]);
/**
* @internal
*/
export const FileOrBufferOrStringSchema = z.union([
FileOrBufferSchema,
z.string(),
]);
export const MAX_BPS = 10000;
export const BytesLikeSchema = z.union([z.array(z.number()), z.string()]);
export const BigNumberSchema = z
.union([
z.string(),
@@ -55,16 +27,6 @@ export const BigNumberTransformSchema = z
return BigNumber.from(arg).toString();
});
export const BasisPointsSchema = z
.number()
.max(MAX_BPS, "Cannot exceed 100%")
.min(0, "Cannot be below 0%");
export const PercentSchema = z
.number()
.max(100, "Cannot exceed 100%")
.min(0, "Cannot be below 0%");
export const AddressSchema = z.string().refine(
(arg) => utils.isAddress(arg),
(out) => {
@@ -74,13 +36,6 @@ export const AddressSchema = z.string().refine(
},
);
export const AmountSchema = z
.union([
z.string().regex(/^([0-9]+\.?[0-9]*|\.[0-9]+)$/, "Invalid amount"),
z.number().min(0, "Amount cannot be negative"),
])
.transform((arg) => (typeof arg === "number" ? arg.toString() : arg));
export const RawDateSchema = z.date().transform((i) => {
return BigNumber.from(Math.floor(i.getTime() / 1000));
});
@@ -1,4 +1,5 @@
import { AddressSchema, BigNumberishSchema, AmountSchema } from "../../shared";
import { AmountSchema } from "../../../../core/schema/shared";
import { AddressSchema, BigNumberishSchema } from "../../shared";
import { z } from "zod";
/**
+2 -1
View File
@@ -1,5 +1,6 @@
import { NFTInputOrUriSchema } from "../../../core/schema/nft";
import { BigNumberishSchema, AmountSchema, RawDateSchema } from "../shared";
import { AmountSchema } from "../../../core/schema/shared";
import { BigNumberishSchema, RawDateSchema } from "../shared";
import {
ERC1155WrappableSchema,
ERC20WrappableSchema,
+2 -1
View File
@@ -1,4 +1,5 @@
import { AddressSchema, AmountSchema } from "../shared";
import { AmountSchema } from "../../../core/schema/shared";
import { AddressSchema } from "../shared";
import { z } from "zod";
/**
+1 -1
View File
@@ -2,11 +2,11 @@
* Currency metadata.
* @public
*/
import { AmountSchema } from "../../core/schema/shared";
import {
CurrencySchema,
CurrencyValueSchema,
} from "../schema/contracts/common/currency";
import { AmountSchema } from "../schema/shared";
import { z } from "zod";
/**
+4 -1
View File
@@ -37,8 +37,11 @@ export type ContractEvent<TEvent = Record<string, any>> = {
/**
* Filters for querying past events
*/
export interface EventQueryFilter {
export interface EventQueryOptions<
TFilter extends Record<string, any> = Record<string, any>,
> {
fromBlock?: string | number;
toBlock?: string | number;
order?: "asc" | "desc";
filters?: TFilter;
}
@@ -1,11 +1,12 @@
import { QueryAllParams } from "../../core/schema/QueryParams";
import { NFT, NFTMetadata, NFTMetadataOrUri } from "../../core/schema/nft";
import { Amount } from "../../core/schema/shared";
import {
enforceCreator,
parseCreators,
} from "../classes/helpers/creators-helper";
import { NFTHelper } from "../classes/helpers/nft-helper";
import { Amount, TransactionResult } from "../types/common";
import { TransactionResult } from "../types/common";
import { CreatorInput, CreatorOutput } from "../types/programs";
import { sendMultipartTransaction } from "../utils/transactions";
import { getNework } from "../utils/urls";
+2 -1
View File
@@ -4,13 +4,14 @@ import {
NFTMetadata,
NFTMetadataInput,
} from "../../core/schema/nft";
import { Amount } from "../../core/schema/shared";
import { ClaimConditions } from "../classes/claim-conditions";
import {
enforceCreator,
parseCreators,
} from "../classes/helpers/creators-helper";
import { NFTHelper } from "../classes/helpers/nft-helper";
import { Amount, TransactionResult } from "../types/common";
import { TransactionResult } from "../types/common";
import { CreatorInput, CreatorOutput } from "../types/programs";
import { sendMultipartTransaction } from "../utils/transactions";
import { getNework } from "../utils/urls";
+2 -1
View File
@@ -1,5 +1,6 @@
import { Amount, AmountSchema } from "../../core/schema/shared";
import { CurrencyValue, TokenMetadata } from "../../core/schema/token";
import { Amount, AmountSchema, TransactionResult } from "../types/common";
import { TransactionResult } from "../types/common";
import { toCurrencyValue } from "../utils/token";
import { getNework } from "../utils/urls";
import {
-85
View File
@@ -2,52 +2,6 @@ import { Signer, WalletAdapter } from "@metaplex-foundation/js";
import { PublicKey } from "@solana/web3.js";
import { z } from "zod";
/**
* @internal
*/
export const MAX_BPS = 10000;
/**
* @internal
*/
export const BasisPointsSchema = z
.number()
.max(MAX_BPS, "Cannot exceed 100%")
.min(0, "Cannot be below 0%");
/**
* @internal
*/
export const PercentSchema = z
.number()
.max(100, "Cannot exceed 100%")
.min(0, "Cannot be below 0%");
/**
* @internal
*/
export const JsonLiteral = z.union([
z.string(),
z.number(),
z.boolean(),
z.null(),
]);
/**
* @internal
*/
export type JsonLiteral = number | string | null | boolean;
/**
* @internal
*/
export type Json = JsonLiteral | JsonObject | Json[];
/**
* @internal
*/
export type JsonObject = { [key: string]: Json };
/**
* @internal
*/
@@ -60,16 +14,6 @@ export const OptionalPropertiesInput = z
.union([z.array(PropertiesInput), PropertiesInput])
.optional();
/**
* @internal
*/
export const AmountSchema = z
.union([
z.string().regex(/^([0-9]+\.?[0-9]*|\.[0-9]+)$/, "Invalid amount"),
z.number().min(0, "Amount cannot be negative"),
])
.transform((arg) => (typeof arg === "number" ? arg.toString() : arg));
/**
* @internal
*/
@@ -77,11 +21,6 @@ export const RawDateSchema = z.date().transform((i) => {
return Math.floor(i.getTime() / 1000);
});
/**
* @internal
*/
export type Amount = z.input<typeof AmountSchema>;
/**
* @internal
*/
@@ -115,27 +54,3 @@ export const AddressSchema = z.union([
z.string(),
z.instanceof(PublicKey).transform((key) => key.toBase58()),
]);
const isBrowser = () => typeof window !== "undefined";
const FileOrBufferUnionSchema = isBrowser()
? (z.instanceof(File) as z.ZodType<InstanceType<typeof File>>)
: (z.instanceof(Buffer) as z.ZodTypeAny); // @fixme, this is a hack to make browser happy for now
/**
* @internal
*/
export const FileOrBufferSchema = z.union([
FileOrBufferUnionSchema,
z.object({
data: z.union([FileOrBufferUnionSchema, z.string()]),
name: z.string(),
}),
]);
/**
* @internal
*/
export const FileOrBufferOrStringSchema = z.union([
FileOrBufferSchema,
z.string(),
]);
@@ -1,4 +1,8 @@
import { AmountSchema, FileOrBufferOrStringSchema, PercentSchema } from "../common";
import {
AmountSchema,
FileOrBufferOrStringSchema,
PercentSchema,
} from "../../../core/schema/shared";
import { Creator } from "@metaplex-foundation/js";
import { z } from "zod";
@@ -1,7 +1,10 @@
import { NFTCollectionMetadataInputSchema } from ".";
import { BasisPointsSchema, QuantitySchema } from "../../../core/schema/shared";
import {
AmountSchema,
BasisPointsSchema,
QuantitySchema,
} from "../../../core/schema/shared";
import { CurrencyValueSchema } from "../../../core/schema/token";
import { AmountSchema } from "../common";
import { z } from "zod";
/**
+5 -2
View File
@@ -13,7 +13,7 @@ describe("Tiered Drop Contract", async () => {
async function deployTieredDrop() {
// This needs to match the release for the currently used ABI
const releaseUri =
"ipfs://QmTK2dpcDMiePacs6bNh6LhQdPB9RkxXHmx9CtrPLPRBuS/0";
"ipfs://QmXu9ezFNgXBX1juLZ7kwdf5KpTD1x9GPHnk14QB2NpUvK/0";
const address = await sdk.deployer.deployContractFromUri(releaseUri, [], {
forceDirectDeploy: true,
});
@@ -103,7 +103,10 @@ describe("Tiered Drop Contract", async () => {
assert.isTrue(isValid);
sdk.updateSignerOrProvider(claimerWallet);
await contract.erc721.tieredDrop.claimWithSignature(signedPayload);
const txs = await contract.erc721.tieredDrop.claimWithSignature(
signedPayload,
);
expect((await txs[0].data()).metadata.name).to.equal("NFT #1");
});
it("Should get tokens in tier", async () => {
+4 -1
View File
@@ -1,5 +1,8 @@
{
"extends": "@thirdweb-dev/tsconfig/sdk.json",
"include": ["src", "types"],
"exclude": ["dist", "build", "node_modules"]
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"allowJs": true
}
}
+4 -60
View File
@@ -1475,36 +1475,6 @@
near-api-js "^0.44.2"
near-seed-phrase "^0.2.0"
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-darwin-arm64/-/cbor-extract-darwin-arm64-2.0.0.tgz#cf0667e4c22111c9d45e16c29964892b12460a76"
integrity sha512-jebtLrruvsBbGMsUn0QxZW/8Z7caS9OkszVKZ64WTWajUkyohmolUdKL2nbfaTyyi3ABJrxVNM4YO1pvMsNI1g==
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-darwin-x64/-/cbor-extract-darwin-x64-2.0.0.tgz#7bc01e7911b97eee4c78ae074bd3108f2ff208c3"
integrity sha512-LGYjdlyqANBqCDzBujCqXpPcK70rvaQgw98/aquzBuEmK0KXS7i579CoVG1yS/eb3bMqiVPevBri45jbR6Tlsg==
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-linux-arm64/-/cbor-extract-linux-arm64-2.0.0.tgz#e40608afed5f373091560fa9dcd19c7f52f510b0"
integrity sha512-c1rbQcSF01yVgbG60zEfHNsUkXiEEQRNdYqm5qpqEAkLx4gA6DDU91IQbalkqXfwDuQzcMovOc1TC3uJJIi2OQ==
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-linux-arm/-/cbor-extract-linux-arm-2.0.0.tgz#f52a7580fb23e305370e66ae9ff136de3729c4b8"
integrity sha512-cOGHEIif5rPbpix6qhpuatrZzm6HeC5rT0nXt8ynLTc7PzfXmovswD9x6d9h5NcHswkV5y3PbkNbpel/tLADYg==
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-linux-x64/-/cbor-extract-linux-x64-2.0.0.tgz#8c936b8a93f915bf3c2459d5b4b78d244bda0f26"
integrity sha512-WYeE1b5WGf9pbbQH3qeNBXq710gGsuVFUiP148RY8In+2pCp/fxjBpe701ngam9/fF5D+gJs8B1i5wv/PN7JZA==
"@cbor-extract/[email protected]":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@cbor-extract/cbor-extract-win32-x64/-/cbor-extract-win32-x64-2.0.0.tgz#4d4ad91527a8313c3db1e2167a8821dfae9d6211"
integrity sha512-XqVuJEnE0jpl/RkuSp04FF2UE73gY52Y4nZaIE6j9GAeSH2cHYU5CCd4TaVMDi2M18ZpZv7XhL/k+nneQzyJpQ==
"@changesets/apply-release-plan@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@changesets/apply-release-plan/-/apply-release-plan-6.1.0.tgz#97d755a7725bdcc1152aa54d8c7fbc85a5bf1e40"
@@ -4467,10 +4437,10 @@
"@tanstack/query-core" "4.3.4"
use-sync-external-store "^1.2.0"
"@thirdweb-dev/[email protected].0-4":
version "3.2.0-4"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-3.2.0-4.tgz#b696bdaae1dee7cf448549ac10bb78e55c622272"
integrity sha512-Mc3VvBB6rqTMKKH04UQbDabAlVPT7PiKBQrJDuhAPjOxBYWwn9pHi7amXJt2tJOkmHAj+w+oT76q7IqWv3QHhw==
"@thirdweb-dev/contracts@^3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-3.2.2.tgz#dac0587337258369081fa1e2edb2570f79d61e95"
integrity sha512-s5ZHZBF8iyoWtEKFJJDdpdwQ2TMuF0sCGdvIYxLLdoRsEtW1gPOp2icis+LTtdvly5+uaSF8ZW3RVdX9A/b4Nw==
"@tootallnate/once@1":
version "1.1.2"
@@ -7128,27 +7098,6 @@ catering@^2.1.0, catering@^2.1.1:
resolved "https://registry.yarnpkg.com/catering/-/catering-2.1.1.tgz#66acba06ed5ee28d5286133982a927de9a04b510"
integrity sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==
cbor-extract@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/cbor-extract/-/cbor-extract-2.0.2.tgz#8e45339627fb8b47071e8e71138c630019125939"
integrity sha512-QoLGEgPff03ad/L66P91ci5Zmf7Woq8bh4H5XT3+D5annlrPH5ObHf2Yvo53eDQaDkQtF9tJwMKSWANGXDmwUA==
dependencies:
node-gyp-build-optional-packages "5.0.3"
optionalDependencies:
"@cbor-extract/cbor-extract-darwin-arm64" "2.0.0"
"@cbor-extract/cbor-extract-darwin-x64" "2.0.0"
"@cbor-extract/cbor-extract-linux-arm" "2.0.0"
"@cbor-extract/cbor-extract-linux-arm64" "2.0.0"
"@cbor-extract/cbor-extract-linux-x64" "2.0.0"
"@cbor-extract/cbor-extract-win32-x64" "2.0.0"
cbor-x@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/cbor-x/-/cbor-x-1.4.1.tgz#1cada332cf5b7d1f940b494c0e88f2f1439bbcf3"
integrity sha512-qp6nM61RaamDJWsDGHzMIQ4+XBtg7/QIoBi5Lra4IDU65eP8lHcgkkJ9t2yIU8EvRThBfFCh6+S1Qkrmq93J3Q==
optionalDependencies:
cbor-extract "^2.0.2"
chai@^4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c"
@@ -13955,11 +13904,6 @@ node-forge@^1:
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==
[email protected]:
version "5.0.3"
resolved "https://registry.yarnpkg.com/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.0.3.tgz#92a89d400352c44ad3975010368072b41ad66c17"
integrity sha512-k75jcVzk5wnnc/FMxsf4udAoTEUv2jY3ycfdSd3yWu6Cnd1oee6/CfZJApyscA4FJOmdoixWwiwOyf16RzD5JA==
node-gyp-build@^4.2.0, node-gyp-build@^4.3.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.5.0.tgz#7a64eefa0b21112f89f58379da128ac177f20e40"