Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sdk.amount.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Represents a currency amount already formatted. ie. "1" for 1 ether.
<b>Signature:</b>

```typescript
export declare type Amount = z.input<typeof PriceSchema>;
export declare type Amount = z.input<typeof AmountSchema>;
```
2 changes: 1 addition & 1 deletion docs/sdk.price.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Represents a currency price already formatted. ie. "1" for 1 ether.
<b>Signature:</b>

```typescript
export declare type Price = z.input<typeof PriceSchema>;
export declare type Price = z.input<typeof AmountSchema>;
```
6 changes: 3 additions & 3 deletions etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ export type AirdropInput = z.input<typeof AirdropInputSchema>;
// @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<typeof PriceSchema>;
export type Amount = z.input<typeof AmountSchema>;

// Warning: (ae-internal-missing-underscore) The name "AssetNotFoundError" should be prefixed with an underscore because the declaration is marked as @internal
//
Expand Down Expand Up @@ -4827,7 +4827,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
}>;

// @public
export type Price = z.input<typeof PriceSchema>;
export type Price = z.input<typeof AmountSchema>;

// @public (undocumented)
export type ProfileMetadata = z.infer<typeof ProfileSchemaOutput>;
Expand Down
6 changes: 3 additions & 3 deletions src/common/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was PriceSchema - why is it changed?

}

export async function fetchCurrencyMetadata(
Expand Down Expand Up @@ -160,5 +160,5 @@ export async function normalizeAmount(
amount: Amount,
): Promise<BigNumber> {
const decimals = await contractWrapper.readContract.decimals();
return utils.parseUnits(PriceSchema.parse(amount), decimals);
return utils.parseUnits(AmountSchema.parse(amount), decimals);
}
4 changes: 2 additions & 2 deletions src/core/classes/drop-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -179,7 +179,7 @@ export class DropClaimConditions<

const decimals = await this.getTokenDecimals();
const quantityWithDecimals = ethers.utils.parseUnits(
PriceSchema.parse(quantity),
AmountSchema.parse(quantity),
decimals,
);

Expand Down
4 changes: 2 additions & 2 deletions src/core/classes/erc-20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -341,7 +341,7 @@ export class Erc20<
*/
public async normalizeAmount(amount: Amount): Promise<BigNumber> {
const decimals = await this.contractWrapper.readContract.decimals();
return ethers.utils.parseUnits(PriceSchema.parse(amount), decimals);
return ethers.utils.parseUnits(AmountSchema.parse(amount), decimals);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/schema/contracts/common/airdrop.ts
Original file line number Diff line number Diff line change
@@ -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),
});

/**
Expand Down
6 changes: 3 additions & 3 deletions src/schema/contracts/common/claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
BigNumberishSchema,
BigNumberSchema,
BytesLikeSchema,
PriceSchema,
AmountSchema,
StartDateSchema,
} from "../../shared";

Expand All @@ -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");

/**
Expand All @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions src/schema/contracts/common/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
BigNumberishSchema,
BigNumberSchema,
EndDateSchema,
PriceSchema,
AmountSchema,
StartDateSchema,
} from "../../shared";
import { z } from "zod";
Expand All @@ -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,
Expand All @@ -32,7 +32,7 @@ export const BaseSignaturePayloadInput = z.object({
* @internal
*/
export const Signature20PayloadInput = BaseSignaturePayloadInput.extend({
quantity: PriceSchema,
quantity: AmountSchema,
});

/**
Expand Down
4 changes: 2 additions & 2 deletions src/schema/contracts/common/snapshots.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { AddressSchema, PriceSchema } from "../../shared";
import { AddressSchema, AmountSchema } from "../../shared";

/**
* @internal
Expand All @@ -13,7 +13,7 @@ export const MerkleSchema = z.object({
*/
export const SnapshotAddressInput = z.object({
address: AddressSchema,
maxClaimable: PriceSchema.default(0),
maxClaimable: AmountSchema.default(0),
});

/**
Expand Down
6 changes: 3 additions & 3 deletions src/schema/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions src/schema/tokens/common/wrap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { AddressSchema, BigNumberishSchema, PriceSchema } from "../../shared";
import { AddressSchema, BigNumberishSchema, AmountSchema } from "../../shared";

/**
* @internal
Expand All @@ -12,7 +12,7 @@ const CommonWrappableSchema = z.object({
* @internal
*/
export const ERC20WrappableSchema = CommonWrappableSchema.extend({
quantity: PriceSchema,
quantity: AmountSchema,
});

/**
Expand Down
4 changes: 2 additions & 2 deletions src/schema/tokens/pack.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -13,7 +13,7 @@ import {
const ERC20RewardSchema = ERC20WrappableSchema.omit({
quantity: true,
}).extend({
quantityPerReward: PriceSchema,
quantityPerReward: AmountSchema,
});

/**
Expand Down
4 changes: 2 additions & 2 deletions src/schema/tokens/token.ts
Original file line number Diff line number Diff line change
@@ -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,
});

/**
Expand Down
6 changes: 3 additions & 3 deletions src/types/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CurrencySchema,
CurrencyValueSchema,
} from "../schema/contracts/common/currency";
import { PriceSchema } from "../schema/shared";
import { AmountSchema } from "../schema/shared";

/**
* @public
Expand Down Expand Up @@ -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<typeof PriceSchema>;
export type Price = z.input<typeof AmountSchema>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change this one? this should not be changed


/**
* Represents a currency amount already formatted. ie. "1" for 1 ether.
* @public
*/
export type Amount = z.input<typeof PriceSchema>;
export type Amount = z.input<typeof AmountSchema>;