Can't fulfill order with Seaport 1.4
NFT-Trades opened this issue · comments
Hi,
I've upgraded to the latest version so I can work with the new seaport version but when trying to fulfill an order I get the following error:
TypeError: Cannot read properties of null (reading 'toHexString')
at isHexable /node_modules/@ethersproject/bytes/lib/index.js:9:21)
| at arrayify /node_modules/@ethersproject/bytes/lib/index.js:69:9)
| at BytesCoder.DynamicBytesCoder.encode /node_modules/@ethersproject/abi/lib/coders/bytes.js:30:38)
| at /node_modules/@ethersproject/abi/lib/coders/array.js:66:19
| at Array.forEach ()
| at pack /node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
| at TupleCoder.encode /node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
| at /node_modules/@ethersproject/abi/lib/coders/array.js:66:19
| at Array.forEach ()
| at pack /node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
| at TupleCoder.encode /node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
| at AbiCoder.encode /node_modules/@ethersproject/abi/lib/abi-coder.js:91:15)
| at Interface._encodeParams /node_modules/@ethersproject/abi/lib/interface.js:296:31)
| at Interface.encodeFunctionData /node_modules/@ethersproject/abi/lib/interface.js:338:18)
| at /node_modules/@ethersproject/contracts/lib/index.js:201:47
| at step /node_modules/@ethersproject/contracts/lib/index.js:48:23)
| [2023-03-09T16:18:18.022Z] TypeError: Cannot read properties of null (reading 'toHexString')
| at isHexable /node_modules/@ethersproject/bytes/lib/index.js:9:21)
| at arrayify /node_modules/@ethersproject/bytes/lib/index.js:69:9)
| at BytesCoder.DynamicBytesCoder.encode /node_modules/@ethersproject/abi/lib/coders/bytes.js:30:38)
| at /node_modules/@ethersproject/abi/lib/coders/array.js:66:19
| at Array.forEach ()
| at pack /node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
| at TupleCoder.encode /node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
| at /node_modules/@ethersproject/abi/lib/coders/array.js:66:19
| at Array.forEach ()
| at pack /node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
| at TupleCoder.encode /node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
| at AbiCoder.encode /node_modules/@ethersproject/abi/lib/abi-coder.js:91:15)
| at Interface._encodeParams /node_modules/@ethersproject/abi/lib/interface.js:296:31)
| at Interface.encodeFunctionData /node_modules/@ethersproject/abi/lib/interface.js:338:18)
| at /node_modules/@ethersproject/contracts/lib/index.js:201:47
| at step /node_modules/@ethersproject/contracts/lib/index.js:48:23)
The code I'm using is the following:
const provider = new ethers.providers.Web3Provider(web3.currentProvider);
const wallet = new ethers.Wallet(walletPrivateKey, provider);
const seaport = new Seaport(wallet, { seaportVersion: '1.4' });
const trade = async (listing) => {
const { executeAllActions: executeAllFulfillActions } =
await seaport.fulfillOrder({
order: listing.protocol_data,
accountAddress: walletAddress,
});
const transaction = executeAllFulfillActions();
}
The listing is one that I get directly from the API: https://api.opensea.io/v2/listings/collection//all?limit=100
Previous version worked well with Seaport 1.1
Can anyone help me?
Thanks!
I used @opensea/seaport-js v1.0.8 before and updated it to v1.1.0 to support breaking change. Then I encountered the same error but I managed to resolve it.
- My code gets listings and offers via listings API and offers API
- In order to fulfill them, my code calls
seaport.fulfillOrder
which takes a listing or an offer obtained by above API. - Due to the breaking change,
listing['protocol_data']['signature']
isnull
which causes the error you reported.
I notice that I needed to use Fulfillment API to get the full protocol_data
which contains signature
. Fulfillment API returns as same data structure as listing['protocol_data']
. You can use it for seaport.fulfillOrder
.
So,
- Get Fulfillment and pass
fulfillment['orders'][0]
toseaport.fulfillOrder
I hope this help you solve the issue 😄
@OttyLab thank you, this helped me 🙂