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 all 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.all_roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<b>Signature:</b>

```typescript
ALL_ROLES: ("transfer" | "unwrap" | "lister" | "admin" | "minter" | "pauser" | "asset")[]
ALL_ROLES: ("transfer" | "unwrap" | "factory" | "lister" | "admin" | "minter" | "pauser" | "asset")[]
```
16 changes: 11 additions & 5 deletions etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class AdminRoleMissingError extends Error {
export type AirdropInput = z.input<typeof AirdropInputSchema>;

// @public (undocumented)
export const ALL_ROLES: ("transfer" | "unwrap" | "lister" | "admin" | "minter" | "pauser" | "asset")[];
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
//
Expand Down Expand Up @@ -2851,6 +2851,7 @@ export const ExtraPublishMetadataSchema: z.ZodObject<{
license: z.ZodOptional<z.ZodString>;
changelog: z.ZodOptional<z.ZodString>;
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
audit: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodTypeAny, z.ZodString]>>>;
logo: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodTypeAny, z.ZodString]>>>;
isDeployableViaFactory: z.ZodOptional<z.ZodBoolean>;
factoryDeploymentData: z.ZodOptional<z.ZodObject<{
Expand All @@ -2874,6 +2875,7 @@ export const ExtraPublishMetadataSchema: z.ZodObject<{
license?: string | undefined;
changelog?: string | undefined;
tags?: string[] | undefined;
audit?: any;
logo?: any;
isDeployableViaFactory?: boolean | undefined;
factoryDeploymentData?: {
Expand All @@ -2890,6 +2892,7 @@ export const ExtraPublishMetadataSchema: z.ZodObject<{
license?: string | undefined;
changelog?: string | undefined;
tags?: string[] | undefined;
audit?: any;
logo?: any;
isDeployableViaFactory?: boolean | undefined;
factoryDeploymentData?: {
Expand Down Expand Up @@ -3070,6 +3073,7 @@ export const FullPublishMetadataSchema: z.ZodObject<z.extendShape<z.extendShape<
license: z.ZodOptional<z.ZodString>;
changelog: z.ZodOptional<z.ZodString>;
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
audit: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodTypeAny, z.ZodString]>>>;
logo: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodTypeAny, z.ZodString]>>>;
isDeployableViaFactory: z.ZodOptional<z.ZodBoolean>;
factoryDeploymentData: z.ZodOptional<z.ZodObject<{
Expand Down Expand Up @@ -3097,6 +3101,7 @@ export const FullPublishMetadataSchema: z.ZodObject<z.extendShape<z.extendShape<
license?: string | undefined;
changelog?: string | undefined;
tags?: string[] | undefined;
audit?: any;
logo?: any;
isDeployableViaFactory?: boolean | undefined;
factoryDeploymentData?: {
Expand All @@ -3118,6 +3123,7 @@ export const FullPublishMetadataSchema: z.ZodObject<z.extendShape<z.extendShape<
license?: string | undefined;
changelog?: string | undefined;
tags?: string[] | undefined;
audit?: any;
logo?: any;
isDeployableViaFactory?: boolean | undefined;
factoryDeploymentData?: {
Expand Down Expand Up @@ -7263,10 +7269,10 @@ export class WrongListingTypeError extends Error {

// Warnings were encountered during analysis:
//
// dist/src/schema/contracts/custom.d.ts:1361:5 - (ae-incompatible-release-tags) The symbol "inputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1362:5 - (ae-incompatible-release-tags) The symbol "outputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1369:5 - (ae-incompatible-release-tags) The symbol "inputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1370:5 - (ae-incompatible-release-tags) The symbol "outputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1367:5 - (ae-incompatible-release-tags) The symbol "inputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1368:5 - (ae-incompatible-release-tags) The symbol "outputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1375:5 - (ae-incompatible-release-tags) The symbol "inputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal
// dist/src/schema/contracts/custom.d.ts:1376:5 - (ae-incompatible-release-tags) The symbol "outputs" is marked as @public, but its signature references "AbiTypeSchema" which is marked as @internal

// (No @packageDocumentation comment for this package)

Expand Down
1 change: 1 addition & 0 deletions src/common/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const roleMap = {
lister: "LISTER_ROLE",
asset: "ASSET_ROLE",
unwrap: "UNWRAP_ROLE",
factory: "FACTORY_ROLE",
} as const;

/**
Expand Down
14 changes: 14 additions & 0 deletions src/common/version-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,17 @@ export function isIncrementalVersion(current: string, next: string) {
const eqMinor = nextSemver.minor === currentSemver.minor;
return eqMajor && eqMinor && nextSemver.patch > currentSemver.patch;
}

export function isDowngradeVersion(current: string, next: string) {
const currentSemver = toSemver(current);
const nextSemver = toSemver(next);
if (nextSemver.major < currentSemver.major) {
return true;
}
const eqMajor = nextSemver.major === currentSemver.major;
if (eqMajor && nextSemver.minor < currentSemver.minor) {
return true;
}
const eqMinor = nextSemver.minor === currentSemver.minor;
return eqMajor && eqMinor && nextSemver.patch < currentSemver.patch;
}
2 changes: 1 addition & 1 deletion src/constants/erc721-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Erc721EnumerableAbi from "../../abis/IERC721Enumerable.json";
import Erc721SupplyAbi from "../../abis/IERC721Supply.json";
import IMintableERC721Abi from "../../abis/IMintableERC721.json";
import MulticallAbi from "../../abis/IMulticall.json";
import DelayedRevealAbi from "../../abis/DelayedReveal.json";
import DelayedRevealAbi from "../../abis/IDelayedReveal.json";
import ILazyMintAbi from "../../abis/ILazyMint.json";
import IDropSinglePhase from "../../abis/IDropSinglePhase.json";
import SignatureMintERC721Abi from "../../abis/SignatureMintERC721.json";
Expand Down
2 changes: 2 additions & 0 deletions src/contracts/smart-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class SmartContract<TContract extends BaseContract = BaseContract>
public interceptor: ContractInterceptor<TContract>;
public estimator: GasCostEstimator<TContract>;
public publishedMetadata: ContractPublishedMetadata<TContract>;
public abi: ContractInterface;

// features
public metadata: ContractMetadata<BaseContract, any>;
Expand Down Expand Up @@ -111,6 +112,7 @@ export class SmartContract<TContract extends BaseContract = BaseContract>
this.options = options;
this.storage = storage;
this.contractWrapper = contractWrapper;
this.abi = abi;

this.events = new ContractEvents(this.contractWrapper);
this.interceptor = new ContractInterceptor(this.contractWrapper);
Expand Down
5 changes: 5 additions & 0 deletions src/core/classes/contract-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ export class ContractDeployer extends RPCConnectionHandler {
const release = await new ThirdwebSDK("polygon")
.getPublisher()
.getLatest(releaserAddress, contractName);
if (!release) {
throw new Error(
`No release found for '${contractName}' by ${releaserAddress}`,
);
}
return await this.deployContractFromUri(
release.metadataUri,
constructorParams,
Expand Down
7 changes: 5 additions & 2 deletions src/core/classes/contract-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,15 @@ export class ContractPublisher extends RPCConnectionHandler {
public async getLatest(
publisherAddress: string,
contractId: string,
): Promise<PublishedContract> {
): Promise<PublishedContract | undefined> {
const model = await this.publisher.readContract.getPublishedContract(
publisherAddress,
contractId,
);
return this.toPublishedContract(model);
if (model && model.publishMetadataUri) {
return this.toPublishedContract(model);
}
return undefined;
}

public async publish(
Expand Down
1 change: 1 addition & 0 deletions src/schema/contracts/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const ExtraPublishMetadataSchema = z
license: z.string().optional(),
changelog: z.string().optional(),
tags: z.array(z.string()).optional(),
audit: FileBufferOrStringSchema.nullable().optional(),
logo: FileBufferOrStringSchema.nullable().optional(),
isDeployableViaFactory: z.boolean().optional(),
factoryDeploymentData: FactoryDeploymentSchema.partial().optional(),
Expand Down
13 changes: 9 additions & 4 deletions test/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe("Custom Contracts", async () => {
let editionDropContractAddress: string;
let tokenDropContractAddress: string;
let sigDropContractAddress: string;
let nftDropContractAddress: string;
let adminWallet: SignerWithAddress,
samWallet: SignerWithAddress,
bobWallet: SignerWithAddress;
Expand Down Expand Up @@ -90,6 +91,10 @@ describe("Custom Contracts", async () => {
name: "sigdrop",
primary_sale_recipient: adminWallet.address,
});
nftDropContractAddress = await sdk.deployer.deployNFTDrop({
name: "nftdrop",
primary_sale_recipient: adminWallet.address,
});
});

it("should call raw ABI functions and read deployer address", async () => {
Expand Down Expand Up @@ -330,11 +335,11 @@ describe("Custom Contracts", async () => {
});

it("should detect feature: erc721 delay reveal", async () => {
const c = await sdk.getContract(sigDropContractAddress);
const c = await sdk.getContract(nftDropContractAddress);
invariant(c, "Contract undefined");
invariant(c.nft, "ERC721 undefined");
invariant(c.nft.drop, "ERC721 drop");
invariant(c.nft.drop.revealer, "ERC721 query undefined");
invariant(c.nft.drop.revealer, "ERC721 revealer undefined");

await c.nft.drop.revealer.createDelayedRevealBatch(
{
Expand Down Expand Up @@ -489,8 +494,8 @@ describe("Custom Contracts", async () => {

const batch = await c.token.signature.generateBatch(input);

for (const [_, v] of batch.entries()) {
await c.token.signature.mint(v);
for (const b of batch) {
await c.token.signature.mint(b);
}
const balance = await c.token.balanceOf(samWallet.address);
expect(balance.displayValue).to.eq("6.0");
Expand Down