Skip to content

Commit

Permalink
[SDK] Fix creating listings with a magic.link wallet (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Dec 3, 2022
1 parent ad9b3fe commit 8c6cdaa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-balloons-bathe.md
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/react": patch
---

Fix magic link connector not connecting to the right chain
5 changes: 5 additions & 0 deletions .changeset/mean-eyes-hammer.md
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/sdk": patch
---

Fix signature minting from OpenSea Royalty Filter NFT collection contracts
12 changes: 12 additions & 0 deletions packages/react/src/evm/connectors/magic.ts
Expand Up @@ -62,6 +62,18 @@ export class MagicConnector extends Connector {
const { apiKey, ...options } = this.options;
const configuration = this.getConfiguration();

const chains = Object.entries(this.options.rpcUrls);
if (chains.length > 1) {
console.warn(
`Magic only supports connecting to one chain at a time. Using the first chain specified in rpcUrls: ${chains[0]}.`,
);
}
const [chainId, rpcUrl] = chains[0];
this.options.network = {
chainId: parseInt(chainId),
rpcUrl,
};

try {
invariant(
configuration,
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk/src/evm/common/marketplace.ts
Expand Up @@ -89,13 +89,18 @@ export async function handleTokenApproval(
tokenId: BigNumberish,
from: string,
): Promise<void> {
const erc165 = new Contract(
const erc165 = new ContractWrapper<IERC165>(
signerOrProvider,
assetContract,
ERC165Abi,
signerOrProvider,
) as IERC165;
const isERC721 = await erc165.supportsInterface(InterfaceId_IERC721);
const isERC1155 = await erc165.supportsInterface(InterfaceId_IERC1155);
{},
);
const isERC721 = await erc165.readContract.supportsInterface(
InterfaceId_IERC721,
);
const isERC1155 = await erc165.readContract.supportsInterface(
InterfaceId_IERC1155,
);
// check for token approval
if (isERC721) {
const asset = new ContractWrapper<IERC721>(
Expand Down
@@ -1,4 +1,4 @@
import { hasFunction } from "../../common";
import { detectContractFeature } from "../../common";
import { normalizePriceValue, setErc20Allowance } from "../../common/currency";
import { uploadOrExtractURIs } from "../../common/nft";
import { FEATURE_NFT_SIGNATURE_MINTABLE_V2 } from "../../constants/erc721-features";
Expand All @@ -22,7 +22,7 @@ import type {
} from "@thirdweb-dev/contracts-js";
import { TokensMintedWithSignatureEvent } from "@thirdweb-dev/contracts-js/dist/declarations/src/SignatureDrop";
import { ThirdwebStorage } from "@thirdweb-dev/storage";
import { BigNumber, ethers } from "ethers";
import { BigNumber } from "ethers";
import invariant from "tiny-invariant";

/**
Expand Down Expand Up @@ -397,17 +397,9 @@ export class Erc721WithQuantitySignatureMintable implements DetectableFeature {
}

private async isLegacyNFTContract() {
if (hasFunction<TokenERC721>("contractType", this.contractWrapper)) {
try {
const contractType = ethers.utils.toUtf8String(
await this.contractWrapper.readContract.contractType(),
);
return contractType.includes("TokenERC721");
} catch (e) {
return false;
}
} else {
return false;
}
return detectContractFeature<ISignatureMintERC721>(
this.contractWrapper,
"ERC721SignatureMintV1",
);
}
}

0 comments on commit 8c6cdaa

Please sign in to comment.