I am trying to call an async function in a POST handler.
The function I am trying to call is as follows (this code works):
const seaport = require("./seaport.js");
// This function creates a fixed price sell order (FPSO)
async function createFPSO(ownerAddress, contractAddress, tokenId, startAmount, expirationTime = 0) {
const fixedPriceSellOrder = await seaport.createSellOrder({
asset: {
tokenId: tokenId,
tokenAddress: contractAddress,
},
startAmount: startAmount,
expirationTime: expirationTime,
accountAddress: ownerAddress,
});
console.log(`Successfully created a fixed-price sell order! ${fixedPriceSellOrder.asset.openseaLink}n`);
}
createFPSO(MY_ADDRESS, NFT_CONTRACT_ADDRESS, "2", 0.01);
Since the code above works, I now try to transfer it to a POST handler, as follows:
const express = require('express');
const app = express();
app.use(express.json());
const seaport = require("./seaport.js");
app.post('/create/fixedprice', async (req, res, next)=> {
try {
const fixedPriceSellOrder = await seaport.createSellOrder({
asset: {
tokenId: req.body.tokenId,
tokenAddress: req.body.contractAddress,
},
startAmount: req.body.startAmount,
expirationTime: req.body.expirationTime,
accountAddress: req.body.ownerAddress,
});
console.log(`Successfully created a fixed-price sell order! ${fixedPriceSellOrder.asset.openseaLink}n`);
res.send(fixedPriceSellOrder);
} catch (error) {
return next(error);
}
});
const port = process.env.PORT || 13579;
app.listen(port, () => console.log(`Service is listening on port ${port}..`));
However, this results in an error (I doubt the error message is relevant, but sharing it nonetheless):
Error: No wallet address found
at Object.validateAndFormatWalletAddress (/root/opensea/opensea-creatures/node_modules/opensea-js/src/utils/utils.ts:928:11)
at OpenSeaPort.<anonymous> (/root/opensea/opensea-creatures/node_modules/opensea-js/src/seaport.ts:1994:22)
at step (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:40:23)
at Object.next (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:21:53)
at /root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:15:71
at new Promise (<anonymous>)
at __awaiter (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:11:12)
at OpenSeaPort._makeSellOrder (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:2038:16)
at OpenSeaPort.<anonymous> (/root/opensea/opensea-creatures/node_modules/opensea-js/src/seaport.ts:625:30)
at step (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:40:23)
at Object.next (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:21:53)
at /root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:15:71
at new Promise (<anonymous>)
at __awaiter (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:11:12)
at OpenSeaPort.createSellOrder (/root/opensea/opensea-creatures/node_modules/opensea-js/lib/seaport.js:604:16)
at /root/opensea/opensea-creatures/scripts/service.js:58:47
The point I am making is, the same functionality that is working in the first listing now breaks down when I transfer it to the POST handler, so I doubt it has anything to do with the OpenSea SDK being broken.