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

Commit 084556e

Browse files
Catch calling contractType on custom contracts with signature drop (#533)
1 parent d60b9ea commit 084556e

File tree

5 files changed

+11
-24
lines changed

5 files changed

+11
-24
lines changed

docs/sdk.erc721withquantitysignaturemintable._constructor_.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Constructs a new instance of the `Erc721WithQuantitySignatureMintable` class
99
<b>Signature:</b>
1010

1111
```typescript
12-
constructor(contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>, storage: IStorage, roles?: ContractRoles<TokenERC721, typeof NFTCollection.contractRoles[number]>);
12+
constructor(contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>, storage: IStorage);
1313
```
1414

1515
## Parameters
@@ -18,5 +18,4 @@ constructor(contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>,
1818
| --- | --- | --- |
1919
| contractWrapper | ContractWrapper&lt;SignatureMintERC721 \| TokenERC721&gt; | |
2020
| storage | [IStorage](./sdk.istorage.md) | |
21-
| roles | [ContractRoles](./sdk.contractroles.md)<!-- -->&lt;TokenERC721, typeof [NFTCollection.contractRoles](./sdk.nftcollection.contractroles.md)<!-- -->\[number\]&gt; | <i>(Optional)</i> |
2221

docs/sdk.erc721withquantitysignaturemintable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export declare class Erc721WithQuantitySignatureMintable implements DetectableFe
1717
1818
| Constructor | Modifiers | Description |
1919
| --- | --- | --- |
20-
| [(constructor)(contractWrapper, storage, roles)](./sdk.erc721withquantitysignaturemintable._constructor_.md) | | Constructs a new instance of the <code>Erc721WithQuantitySignatureMintable</code> class |
20+
| [(constructor)(contractWrapper, storage)](./sdk.erc721withquantitysignaturemintable._constructor_.md) | | Constructs a new instance of the <code>Erc721WithQuantitySignatureMintable</code> class |
2121
2222
## Properties
2323

etc/sdk.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ export class Erc721Supply implements DetectableFeature {
26502650
// @public
26512651
export class Erc721WithQuantitySignatureMintable implements DetectableFeature {
26522652
// Warning: (ae-forgotten-export) The symbol "SignatureMintERC721" needs to be exported by the entry point index.d.ts
2653-
constructor(contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>, storage: IStorage, roles?: ContractRoles<TokenERC721, typeof NFTCollection.contractRoles[number]>);
2653+
constructor(contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>, storage: IStorage);
26542654
// (undocumented)
26552655
featureName: "ERC721SignatureMint";
26562656
generate(mintRequest: PayloadToSign721withQuantity): Promise<SignedPayload721WithQuantitySignature>;

src/contracts/nft-collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ export class NFTCollection extends Erc721<TokenERC721> {
133133
this.signature = new Erc721WithQuantitySignatureMintable(
134134
this.contractWrapper,
135135
this.storage,
136-
this.roles,
137136
);
138137
this.events = new ContractEvents(this.contractWrapper);
139138
this.platformFees = new ContractPlatformFee(this.contractWrapper);

src/core/classes/erc-721-with-quantity-signature-mintable.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import {
1818
TokenERC721,
1919
} from "contracts";
2020
import { IStorage } from "../interfaces";
21-
import { ContractRoles } from "./contract-roles";
22-
import { NFTCollection } from "../../contracts";
2321
import { BigNumber, ethers } from "ethers";
2422
import { uploadOrExtractURIs } from "../../common/nft";
2523
import { TokensMintedWithSignatureEvent } from "contracts/SignatureDrop";
@@ -37,22 +35,13 @@ export class Erc721WithQuantitySignatureMintable implements DetectableFeature {
3735
private contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>;
3836

3937
private storage: IStorage;
40-
private roles?: ContractRoles<
41-
TokenERC721,
42-
typeof NFTCollection.contractRoles[number]
43-
>;
4438

4539
constructor(
4640
contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>,
4741
storage: IStorage,
48-
roles?: ContractRoles<
49-
TokenERC721,
50-
typeof NFTCollection.contractRoles[number]
51-
>,
5242
) {
5343
this.contractWrapper = contractWrapper;
5444
this.storage = storage;
55-
this.roles = roles;
5645
}
5746

5847
/**
@@ -263,10 +252,6 @@ export class Erc721WithQuantitySignatureMintable implements DetectableFeature {
263252
): Promise<SignedPayload721WithQuantitySignature[]> {
264253
const isLegacyNFTContract = await this.isLegacyNFTContract();
265254

266-
await this.roles?.verify(
267-
["minter"],
268-
await this.contractWrapper.getSignerAddress(),
269-
);
270255
const parsedRequests = payloadsToSign.map((m) =>
271256
Signature721WithQuantityInput.parse(m),
272257
);
@@ -380,10 +365,14 @@ export class Erc721WithQuantitySignatureMintable implements DetectableFeature {
380365

381366
private async isLegacyNFTContract() {
382367
if (hasFunction<TokenERC721>("contractType", this.contractWrapper)) {
383-
const contractType = ethers.utils.toUtf8String(
384-
await this.contractWrapper.readContract.contractType(),
385-
);
386-
return contractType.includes("TokenERC721");
368+
try {
369+
const contractType = ethers.utils.toUtf8String(
370+
await this.contractWrapper.readContract.contractType(),
371+
);
372+
return contractType.includes("TokenERC721");
373+
} catch (e) {
374+
return false;
375+
}
387376
} else {
388377
return false;
389378
}

0 commit comments

Comments
 (0)