diff --git a/docs/sdk.amount.md b/docs/sdk.amount.md index 775048cff..bded209b4 100644 --- a/docs/sdk.amount.md +++ b/docs/sdk.amount.md @@ -9,5 +9,5 @@ Represents a currency amount already formatted. ie. "1" for 1 ether. Signature: ```typescript -export declare type Amount = z.input; +export declare type Amount = z.input; ``` diff --git a/docs/sdk.price.md b/docs/sdk.price.md index f7071c4ed..4d1705a4f 100644 --- a/docs/sdk.price.md +++ b/docs/sdk.price.md @@ -9,5 +9,5 @@ Represents a currency price already formatted. ie. "1" for 1 ether. Signature: ```typescript -export declare type Price = z.input; +export declare type Price = z.input; ``` diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 673553d73..ed8c850b7 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -396,10 +396,10 @@ export type AirdropInput = z.input; // @public (undocumented) export const ALL_ROLES: ("transfer" | "unwrap" | "factory" | "lister" | "admin" | "minter" | "pauser" | "asset")[]; -// Warning: (ae-forgotten-export) The symbol "PriceSchema" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "AmountSchema" needs to be exported by the entry point index.d.ts // // @public -export type Amount = z.input; +export type Amount = z.input; // Warning: (ae-internal-missing-underscore) The name "AssetNotFoundError" should be prefixed with an underscore because the declaration is marked as @internal // @@ -4827,7 +4827,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject; // @public -export type Price = z.input; +export type Price = z.input; // @public (undocumented) export type ProfileMetadata = z.infer; diff --git a/src/common/currency.ts b/src/common/currency.ts index 9ec3a55e2..fd5d2b24e 100644 --- a/src/common/currency.ts +++ b/src/common/currency.ts @@ -13,7 +13,7 @@ import { NATIVE_TOKEN_ADDRESS, } from "../constants/currency"; import { Amount, Currency, CurrencyValue, Price } from "../types/currency"; -import { PriceSchema } from "../schema/shared"; +import { AmountSchema } from "../schema/shared"; import ERC20Abi from "../../abis/IERC20.json"; import ERC20MetadataAbi from "../../abis/IERC20Metadata.json"; import { BaseERC20 } from "../types/eips"; @@ -32,7 +32,7 @@ export async function normalizePriceValue( currencyAddress: string, ) { const metadata = await fetchCurrencyMetadata(provider, currencyAddress); - return utils.parseUnits(PriceSchema.parse(inputPrice), metadata.decimals); + return utils.parseUnits(AmountSchema.parse(inputPrice), metadata.decimals); } export async function fetchCurrencyMetadata( @@ -160,5 +160,5 @@ export async function normalizeAmount( amount: Amount, ): Promise { const decimals = await contractWrapper.readContract.decimals(); - return utils.parseUnits(PriceSchema.parse(amount), decimals); + return utils.parseUnits(AmountSchema.parse(amount), decimals); } diff --git a/src/core/classes/drop-claim-conditions.ts b/src/core/classes/drop-claim-conditions.ts index 1e3bad476..f2f8c149a 100644 --- a/src/core/classes/drop-claim-conditions.ts +++ b/src/core/classes/drop-claim-conditions.ts @@ -31,7 +31,7 @@ import { detectContractFeature, hasFunction, } from "../../common/feature-detection"; -import { PriceSchema } from "../../schema"; +import { AmountSchema } from "../../schema"; import { includesErrorMessage } from "../../common"; import ERC20Abi from "../../../abis/IERC20.json"; import { isNode } from "../../common/utils"; @@ -179,7 +179,7 @@ export class DropClaimConditions< const decimals = await this.getTokenDecimals(); const quantityWithDecimals = ethers.utils.parseUnits( - PriceSchema.parse(quantity), + AmountSchema.parse(quantity), decimals, ); diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index feb3dd11a..67586d20a 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -16,7 +16,7 @@ import { fetchCurrencyValue, } from "../../common/currency"; import { TokenMintInput } from "../../schema/tokens/token"; -import { PriceSchema } from "../../schema"; +import { AmountSchema } from "../../schema"; import { BaseDropERC20, BaseERC20, @@ -341,7 +341,7 @@ export class Erc20< */ public async normalizeAmount(amount: Amount): Promise { const decimals = await this.contractWrapper.readContract.decimals(); - return ethers.utils.parseUnits(PriceSchema.parse(amount), decimals); + return ethers.utils.parseUnits(AmountSchema.parse(amount), decimals); } /** diff --git a/src/schema/contracts/common/airdrop.ts b/src/schema/contracts/common/airdrop.ts index 7dc455b62..3bfbf585d 100644 --- a/src/schema/contracts/common/airdrop.ts +++ b/src/schema/contracts/common/airdrop.ts @@ -1,12 +1,12 @@ import { z } from "zod"; -import { AddressSchema, PriceSchema } from "../../shared"; +import { AddressSchema, AmountSchema } from "../../shared"; /** * @internal */ export const AirdropAddressInput = z.object({ address: AddressSchema, - quantity: PriceSchema.default(1), + quantity: AmountSchema.default(1), }); /** diff --git a/src/schema/contracts/common/claim-conditions.ts b/src/schema/contracts/common/claim-conditions.ts index 45a44df9e..8ae0395d0 100644 --- a/src/schema/contracts/common/claim-conditions.ts +++ b/src/schema/contracts/common/claim-conditions.ts @@ -4,7 +4,7 @@ import { BigNumberishSchema, BigNumberSchema, BytesLikeSchema, - PriceSchema, + AmountSchema, StartDateSchema, } from "../../shared"; @@ -16,7 +16,7 @@ import { SnapshotInputSchema } from "./snapshots"; * @internal */ export const QuantitySchema = z - .union([PriceSchema, z.literal("unlimited")]) + .union([AmountSchema, z.literal("unlimited")]) .default("unlimited"); /** @@ -25,7 +25,7 @@ export const QuantitySchema = z export const ClaimConditionInputSchema = z.object({ startTime: StartDateSchema, currencyAddress: z.string().default(NATIVE_TOKEN_ADDRESS), - price: PriceSchema.default(0), + price: AmountSchema.default(0), maxQuantity: QuantitySchema, quantityLimitPerTransaction: QuantitySchema, waitInSeconds: BigNumberishSchema.default(0), diff --git a/src/schema/contracts/common/signature.ts b/src/schema/contracts/common/signature.ts index 04cef57d3..26288cc16 100644 --- a/src/schema/contracts/common/signature.ts +++ b/src/schema/contracts/common/signature.ts @@ -3,7 +3,7 @@ import { BigNumberishSchema, BigNumberSchema, EndDateSchema, - PriceSchema, + AmountSchema, StartDateSchema, } from "../../shared"; import { z } from "zod"; @@ -17,7 +17,7 @@ import { resolveOrGenerateId } from "../../../common/signature-minting"; */ export const BaseSignaturePayloadInput = z.object({ to: z.string().default(constants.AddressZero), - price: PriceSchema.default(0), + price: AmountSchema.default(0), currencyAddress: z.string().default(NATIVE_TOKEN_ADDRESS), mintStartTime: StartDateSchema, mintEndTime: EndDateSchema, @@ -32,7 +32,7 @@ export const BaseSignaturePayloadInput = z.object({ * @internal */ export const Signature20PayloadInput = BaseSignaturePayloadInput.extend({ - quantity: PriceSchema, + quantity: AmountSchema, }); /** diff --git a/src/schema/contracts/common/snapshots.ts b/src/schema/contracts/common/snapshots.ts index 727dd3ed7..2828a158b 100644 --- a/src/schema/contracts/common/snapshots.ts +++ b/src/schema/contracts/common/snapshots.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { AddressSchema, PriceSchema } from "../../shared"; +import { AddressSchema, AmountSchema } from "../../shared"; /** * @internal @@ -13,7 +13,7 @@ export const MerkleSchema = z.object({ */ export const SnapshotAddressInput = z.object({ address: AddressSchema, - maxClaimable: PriceSchema.default(0), + maxClaimable: AmountSchema.default(0), }); /** diff --git a/src/schema/shared.ts b/src/schema/shared.ts index 9a51ff420..57a82a4e9 100644 --- a/src/schema/shared.ts +++ b/src/schema/shared.ts @@ -73,10 +73,10 @@ export const AddressSchema = z.string().refine( }, ); -export const PriceSchema = z +export const AmountSchema = z .union([ - z.string().regex(/^([0-9]+\.?[0-9]*|\.[0-9]+)$/, "Invalid price"), - z.number().min(0, "Price cannot be negative"), + 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)); diff --git a/src/schema/tokens/common/wrap.ts b/src/schema/tokens/common/wrap.ts index 2bababd6b..a7464afe5 100644 --- a/src/schema/tokens/common/wrap.ts +++ b/src/schema/tokens/common/wrap.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { AddressSchema, BigNumberishSchema, PriceSchema } from "../../shared"; +import { AddressSchema, BigNumberishSchema, AmountSchema } from "../../shared"; /** * @internal @@ -12,7 +12,7 @@ const CommonWrappableSchema = z.object({ * @internal */ export const ERC20WrappableSchema = CommonWrappableSchema.extend({ - quantity: PriceSchema, + quantity: AmountSchema, }); /** diff --git a/src/schema/tokens/pack.ts b/src/schema/tokens/pack.ts index dc4fcda89..1de27a5b9 100644 --- a/src/schema/tokens/pack.ts +++ b/src/schema/tokens/pack.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { BigNumberishSchema, PriceSchema, RawDateSchema } from "../shared"; +import { BigNumberishSchema, AmountSchema, RawDateSchema } from "../shared"; import { NFTInputOrUriSchema } from "./common"; import { ERC1155WrappableSchema, @@ -13,7 +13,7 @@ import { const ERC20RewardSchema = ERC20WrappableSchema.omit({ quantity: true, }).extend({ - quantityPerReward: PriceSchema, + quantityPerReward: AmountSchema, }); /** diff --git a/src/schema/tokens/token.ts b/src/schema/tokens/token.ts index b557b945f..ce00c8384 100644 --- a/src/schema/tokens/token.ts +++ b/src/schema/tokens/token.ts @@ -1,12 +1,12 @@ import { z } from "zod"; -import { AddressSchema, PriceSchema } from "../shared"; +import { AddressSchema, AmountSchema } from "../shared"; /** * @internal */ export const TokenMintInputSchema = z.object({ toAddress: AddressSchema, - amount: PriceSchema, + amount: AmountSchema, }); /** diff --git a/src/types/currency.ts b/src/types/currency.ts index 380c6142d..8ee21740d 100644 --- a/src/types/currency.ts +++ b/src/types/currency.ts @@ -7,7 +7,7 @@ import { CurrencySchema, CurrencyValueSchema, } from "../schema/contracts/common/currency"; -import { PriceSchema } from "../schema/shared"; +import { AmountSchema } from "../schema/shared"; /** * @public @@ -39,10 +39,10 @@ export type TokenHolderBalance = { holder: string; balance: CurrencyValue }; * Represents a currency price already formatted. ie. "1" for 1 ether. * @public */ -export type Price = z.input; +export type Price = z.input; /** * Represents a currency amount already formatted. ie. "1" for 1 ether. * @public */ -export type Amount = z.input; +export type Amount = z.input;