Cannot read property 'EIP712Domain' error on Version 4.0.0
There was an error about signing data after migrating to V 2.0.0 based on issue #372 .
I'm facing with same issue again after trying to use 4.0.0-beta.1 version. @truffle/hdwallet-provider throws same error again.
/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/dist/index.js:172
if (results.includes(primaryType) || types[primaryType] === undefined) {
^
TypeError: Cannot read properties of undefined (reading 'EIP712Domain')
Using a eth_signTypedData fallback should fix this issue but I see that it's implemented already.
export async function signTypedDataAsync(
web3: Web3,
message: object,
signerAddress: string
): Promise<ECSignature> {
let signature: JsonRpcResponse | undefined;
try {
// Using sign typed data V4 works with a stringified message, used by browser providers i.e. Metamask
signature = await promisify<JsonRpcResponse | undefined>((c) =>
(web3.currentProvider as AbstractProvider).sendAsync(
{
method: "eth_signTypedData_v4",
params: [signerAddress, JSON.stringify(message)],
from: signerAddress,
id: new Date().getTime(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
c
)
);
} catch {
// Fallback to normal sign typed data for node providers, without using stringified message
// https://github.com/coinbase/coinbase-wallet-sdk/issues/60
signature = await promisify<JsonRpcResponse | undefined>((c) =>
(web3.currentProvider as AbstractProvider).sendAsync(
{
method: "eth_signTypedData",
params: [signerAddress, message],
from: signerAddress,
id: new Date().getTime(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
c
)
);
}
Did you see this?
https://github.com/ProjectOpenSea/opensea-js/issues/372#issuecomment-1093117092
@esteban-OpenSea Hey, I checked out mentioned comment but couldn't find any solution.
@esteban-OpenSea Hey, I checked out mentioned comment but couldn't find any solution.
Hey did you end up finding a solution ? I can’t make any buy orders without this error ?
same issue @4.0.1 downgrade to @3.0.4 solves this issue
the new protocol isnt available on that version though, anyone got any other solutions?
Getting same error while trying to make bid on an asset using the sdk version 4.0.2
I am also seeing the same error with the hardware wallet. 3.0.4 works still, but for how long?
Getting this error when I run createBuyOrder with 4.0.0-beta.2, @truffle/hdwallet-provider.
The fallback function createSellOrderLegacyWyvern is still currently working, but when will the old contract be mothballed?
The fallback function createSellOrderLegacyWyvern is still currently working, but when will the old contract be mothballed?
On June 21, offers and listings can no longer be posted to the Wyvern 2.3 contract using OpenSea - and on July 13, offers and listings can no longer be fetched from the Wyvern 2.3 contract using OpenSea. https://twitter.com/apiopensea/status/1536822790354894848
@esteban-OpenSea any update on this ? there's only 1 day left before endpoint deprecated.
same issue @4.0.1
The fallback function createSellOrderLegacyWyvern is still currently working, but when will the old contract be mothballed?
On June 21, offers and listings can no longer be posted to the Wyvern 2.3 contract using OpenSea - and on July 13, offers and listings can no longer be fetched from the Wyvern 2.3 contract using OpenSea. https://twitter.com/apiopensea/status/1536822790354894848
I really hope we can find a way forward on this. 1 day left before we can't make orders anymore.
@esteban-OpenSea Hey, I checked out mentioned comment but couldn't find any solution.
Hey did you end up finding a solution ? I can’t make any buy orders without this error ?
Hey Matthew. Would you mind contacting me re graphql? Se my profile for email. Cheers, Mark
I get the same issue with 4.0.3.
I used @3.0.4.
However, when I run the script, I get the following error.
Error: API Error 400: Invalid request: "['Wyvern orders posted to the API are deprecated, except for shared storefront orders']"
So I updated @4.0.3 and ran the script one more time. However, I got the following error.
TypeError: Cannot read properties of undefined (reading 'EIP712Domain')
The following is the actual script in which the error occurred.
import Web3 from "web3";
import { Network, OpenSeaSDK } from 'opensea-js'
import HDWalletProvider from "@truffle/hdwallet-provider";
import { Asset } from "opensea-js/lib/types";
async function main(): Promise<void> {
const provider = new HDWalletProvider({privateKeys: ["0x0"], providerOrUrl: "https://rinkeby.infura.io/v3/hoge"})
const openseaSDK = new OpenSeaSDK(provider, {networkName: Network.Rinkeby});
const assets: Asset[] = [
{
tokenAddress: "0x0",
tokenId: "2",
},
{
tokenAddress: "0x0",
tokenId: "1"
}
]
const expirationTime = new Date("2022-07-31 23:59:59").getTime() / 1000;
await openseaSDK.createSellOrder({
asset: assets[0],
accountAddress: "0x0",
startAmount: 5,
endAmount: 0.1,
expirationTime,
})
console.log("done");
}
main();
process.on("unhandledRejection", (reason) => {
console.error(reason);
process.exit(1);
});
I found a more minimal reproducible example.
import * as ethers from "ethers";
import HDWalletProvider from "@truffle/hdwallet-provider";
const RPC_URL = "";
const PRIVATE_KEY =
"";
async function main() {
const hdWalletProvider = new HDWalletProvider({
privateKeys: [PRIVATE_KEY],
providerOrUrl: RPC_URL,
});
hdWalletProvider.engine["stop"]();
const provider = new ethers.providers.Web3Provider(hdWalletProvider);
const signer = provider.getSigner();
const domain = {
name: "Ether Mail",
version: "1",
chainId: 1,
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
};
// The named list of all type definitions
const types = {
Person: [
{ name: "name", type: "string" },
{ name: "wallet", type: "address" },
],
Mail: [
{ name: "from", type: "Person" },
{ name: "to", type: "Person" },
{ name: "contents", type: "string" },
],
};
// The data to sign
const value = {
from: {
name: "Cow",
wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
},
to: {
name: "Bob",
wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
},
contents: "Hello, Bob!",
};
const signature = await signer._signTypedData(domain, types, value);
console.log(signature);
}
main();
Error
TypeError: Cannot read properties of undefined (reading 'EIP712Domain')
at Object.findTypeDependencies (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:230:47)
at Object.encodeType (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:200:21)
at Object.hashType (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:267:32)
at Object.encodeData (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:96:33)
at Object.hashStruct (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:256:32)
at Object.sign (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:304:12)
at Object.signTypedData (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/node_modules/eth-sig-util/src/index.ts:600:34)
at HookedWalletSubprovider.signTypedMessage (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/@truffle/hdwallet-provider/src/index.ts:231:23)
at /Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/web3-provider-engine/subproviders/hooked-wallet.js:390:18
at nextTask (/Users/odan/source/github.com/odan-sandbox/opensea-js-issues-550/node_modules/async/waterfall.js:16:14)
ethers is stringifying the eth_signTypedData_v4 payload with JSON.stringify.
https://github.com/ethers-io/ethers.js/blob/6807a76b8ddfdd121f98b21e269de3b195a7673e/packages/providers/src.ts/json-rpc-provider.ts#L271-L274
@truffle/hdwallet-provider is calling eth-sig-util methods on received requests without doing anything.
https://github.com/trufflesuite/truffle/blob/ea62e1f5b007dabefb98cf7eacd1cd193dbdd769/packages/hdwallet-provider/src/index.ts#L222-L233
On the other hand, the msgParams.data argument of the signTypedData function of eth-sig-util expects an object, so an error occurs.
https://github.com/MetaMask/eth-sig-util/blob/8c6112f1dc831ba4ced675b5229274242328abe1/src/index.ts#L596-L603
Specifically, sanitizedData is {}.
https://github.com/MetaMask/eth-sig-util/blob/8c6112f1dc831ba4ced675b5229274242328abe1/src/index.ts#L301
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.