Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 0a8183f

Browse files
Rename PriceSchema to AmountSchema (#529)
* Use custom schema for airdrop * Rename PriceSchema to AmountSchema
1 parent 05e7034 commit 0a8183f

File tree

15 files changed

+34
-34
lines changed

15 files changed

+34
-34
lines changed

docs/sdk.amount.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Represents a currency amount already formatted. ie. "1" for 1 ether.
99
<b>Signature:</b>
1010

1111
```typescript
12-
export declare type Amount = z.input<typeof PriceSchema>;
12+
export declare type Amount = z.input<typeof AmountSchema>;
1313
```

docs/sdk.price.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Represents a currency price already formatted. ie. "1" for 1 ether.
99
<b>Signature:</b>
1010

1111
```typescript
12-
export declare type Price = z.input<typeof PriceSchema>;
12+
export declare type Price = z.input<typeof AmountSchema>;
1313
```

etc/sdk.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ export type AirdropInput = z.input<typeof AirdropInputSchema>;
396396
// @public (undocumented)
397397
export const ALL_ROLES: ("transfer" | "unwrap" | "factory" | "lister" | "admin" | "minter" | "pauser" | "asset")[];
398398

399-
// Warning: (ae-forgotten-export) The symbol "PriceSchema" needs to be exported by the entry point index.d.ts
399+
// Warning: (ae-forgotten-export) The symbol "AmountSchema" needs to be exported by the entry point index.d.ts
400400
//
401401
// @public
402-
export type Amount = z.input<typeof PriceSchema>;
402+
export type Amount = z.input<typeof AmountSchema>;
403403

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

48294829
// @public
4830-
export type Price = z.input<typeof PriceSchema>;
4830+
export type Price = z.input<typeof AmountSchema>;
48314831

48324832
// @public (undocumented)
48334833
export type ProfileMetadata = z.infer<typeof ProfileSchemaOutput>;

src/common/currency.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
NATIVE_TOKEN_ADDRESS,
1414
} from "../constants/currency";
1515
import { Amount, Currency, CurrencyValue, Price } from "../types/currency";
16-
import { PriceSchema } from "../schema/shared";
16+
import { AmountSchema } from "../schema/shared";
1717
import ERC20Abi from "../../abis/IERC20.json";
1818
import ERC20MetadataAbi from "../../abis/IERC20Metadata.json";
1919
import { BaseERC20 } from "../types/eips";
@@ -32,7 +32,7 @@ export async function normalizePriceValue(
3232
currencyAddress: string,
3333
) {
3434
const metadata = await fetchCurrencyMetadata(provider, currencyAddress);
35-
return utils.parseUnits(PriceSchema.parse(inputPrice), metadata.decimals);
35+
return utils.parseUnits(AmountSchema.parse(inputPrice), metadata.decimals);
3636
}
3737

3838
export async function fetchCurrencyMetadata(
@@ -160,5 +160,5 @@ export async function normalizeAmount(
160160
amount: Amount,
161161
): Promise<BigNumber> {
162162
const decimals = await contractWrapper.readContract.decimals();
163-
return utils.parseUnits(PriceSchema.parse(amount), decimals);
163+
return utils.parseUnits(AmountSchema.parse(amount), decimals);
164164
}

src/core/classes/drop-claim-conditions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
detectContractFeature,
3232
hasFunction,
3333
} from "../../common/feature-detection";
34-
import { PriceSchema } from "../../schema";
34+
import { AmountSchema } from "../../schema";
3535
import { includesErrorMessage } from "../../common";
3636
import ERC20Abi from "../../../abis/IERC20.json";
3737
import { isNode } from "../../common/utils";
@@ -179,7 +179,7 @@ export class DropClaimConditions<
179179

180180
const decimals = await this.getTokenDecimals();
181181
const quantityWithDecimals = ethers.utils.parseUnits(
182-
PriceSchema.parse(quantity),
182+
AmountSchema.parse(quantity),
183183
decimals,
184184
);
185185

src/core/classes/erc-20.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
fetchCurrencyValue,
1717
} from "../../common/currency";
1818
import { TokenMintInput } from "../../schema/tokens/token";
19-
import { PriceSchema } from "../../schema";
19+
import { AmountSchema } from "../../schema";
2020
import {
2121
BaseDropERC20,
2222
BaseERC20,
@@ -341,7 +341,7 @@ export class Erc20<
341341
*/
342342
public async normalizeAmount(amount: Amount): Promise<BigNumber> {
343343
const decimals = await this.contractWrapper.readContract.decimals();
344-
return ethers.utils.parseUnits(PriceSchema.parse(amount), decimals);
344+
return ethers.utils.parseUnits(AmountSchema.parse(amount), decimals);
345345
}
346346

347347
/**

src/schema/contracts/common/airdrop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { z } from "zod";
2-
import { AddressSchema, PriceSchema } from "../../shared";
2+
import { AddressSchema, AmountSchema } from "../../shared";
33

44
/**
55
* @internal
66
*/
77
export const AirdropAddressInput = z.object({
88
address: AddressSchema,
9-
quantity: PriceSchema.default(1),
9+
quantity: AmountSchema.default(1),
1010
});
1111

1212
/**

src/schema/contracts/common/claim-conditions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
BigNumberishSchema,
55
BigNumberSchema,
66
BytesLikeSchema,
7-
PriceSchema,
7+
AmountSchema,
88
StartDateSchema,
99
} from "../../shared";
1010

@@ -16,7 +16,7 @@ import { SnapshotInputSchema } from "./snapshots";
1616
* @internal
1717
*/
1818
export const QuantitySchema = z
19-
.union([PriceSchema, z.literal("unlimited")])
19+
.union([AmountSchema, z.literal("unlimited")])
2020
.default("unlimited");
2121

2222
/**
@@ -25,7 +25,7 @@ export const QuantitySchema = z
2525
export const ClaimConditionInputSchema = z.object({
2626
startTime: StartDateSchema,
2727
currencyAddress: z.string().default(NATIVE_TOKEN_ADDRESS),
28-
price: PriceSchema.default(0),
28+
price: AmountSchema.default(0),
2929
maxQuantity: QuantitySchema,
3030
quantityLimitPerTransaction: QuantitySchema,
3131
waitInSeconds: BigNumberishSchema.default(0),

src/schema/contracts/common/signature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
BigNumberishSchema,
44
BigNumberSchema,
55
EndDateSchema,
6-
PriceSchema,
6+
AmountSchema,
77
StartDateSchema,
88
} from "../../shared";
99
import { z } from "zod";
@@ -17,7 +17,7 @@ import { resolveOrGenerateId } from "../../../common/signature-minting";
1717
*/
1818
export const BaseSignaturePayloadInput = z.object({
1919
to: z.string().default(constants.AddressZero),
20-
price: PriceSchema.default(0),
20+
price: AmountSchema.default(0),
2121
currencyAddress: z.string().default(NATIVE_TOKEN_ADDRESS),
2222
mintStartTime: StartDateSchema,
2323
mintEndTime: EndDateSchema,
@@ -32,7 +32,7 @@ export const BaseSignaturePayloadInput = z.object({
3232
* @internal
3333
*/
3434
export const Signature20PayloadInput = BaseSignaturePayloadInput.extend({
35-
quantity: PriceSchema,
35+
quantity: AmountSchema,
3636
});
3737

3838
/**

src/schema/contracts/common/snapshots.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from "zod";
2-
import { AddressSchema, PriceSchema } from "../../shared";
2+
import { AddressSchema, AmountSchema } from "../../shared";
33

44
/**
55
* @internal
@@ -13,7 +13,7 @@ export const MerkleSchema = z.object({
1313
*/
1414
export const SnapshotAddressInput = z.object({
1515
address: AddressSchema,
16-
maxClaimable: PriceSchema.default(0),
16+
maxClaimable: AmountSchema.default(0),
1717
});
1818

1919
/**

0 commit comments

Comments
 (0)