What happens if you disconnect and reconnect to ganache after you redeploy? Probably not easy to test now.
Nothing happens. I’ve tried disconnected and re connecting and restarting the server. I’ve tried lots of things but the only thing that seems to work is setting up a new instance
setting up new instance doens’t work for me at all, I have tried 3-4 times now.
What exactly do you do when you set a new instance, I tested yesterday and it worked for me
It was a time when I waited some minutes to see the data in dashboard, and you’ll have to authenticate with an address to the new server before seeing any data.
- Create new instance
- Add events for Sold Items and Item Added to Marketplace
- Update Cloud Functions with BeforeSave methods.
for User
- Authenticate User with Ropsten network
- Create NFT metadata Data with Image URL
- Mint NFT
- Approve for Marketplace
- Add to Marketplace
Nothing shows up in EthNFTOwnersPending or EthNftOwners
If its new server, these tables never gets created.
This was all working fine with the earlier version and only recently have stopped working. without any changes in code this end.
When did you test this last time? Asking because it should have been fixed ~1-2 days ago.
I just did it again on new server created about 15 minutes back
https://wceb5gycvcho.grandmoralis.com:2053/server
and its still not populating the EthNFTOwners and EthNFTOwnersPending
ok, you could try on bsc testnet until we figure it out why is not working
Can you try again now?
It shows up now. NICE! .
This is broken again, it’s not updating EthNFTOwners or EthNFTOwnersPending
Same issue here … Not creating EthNFTOwners
do you have users on that server with NFTs on eth, or did you add to watch address an address that has?
I added to watch address and also minted some items on the same server
Another thing that is happening is that the row inserted is not being updated with the user and token set by my cloud beforeSave function then when I mint another item the previous row is updated.
strage, are you sure, did you refresh the dashboard page?
what is the server url that has that problem with EthNFTOwners?
Yes, I’m struggled to do that since yesterday.
The server is very slow too, I don’t know why … I keep creating new servers because every time there is a new problem.
on a dev server (Ganache) you also have EthNFTOwnersPending
where the transactions will stay until you make more transactions
I see that there are 2 rows now in EthNFTOwners
table on that server
Yes, should I try getting from EthNFTOwnersPending first then?
In our application the user mints an item and then when he wants to sell it he lists the item.
That’s why I realized I should have these 3 events. Does that makes sense?
Here is how my beforeSave functions are:
Moralis.Cloud.beforeSave("ItemsPublished", async (request) => {
const query = new Moralis.Query("EthNFTOwners");
query.equalTo("token_id", request.object.get("uid"));
query.equalTo("token_address", request.object.get("tokenAddress"));
query.equalTo("owner_of", request.object.get("from"));
const object = await query.first({ useMasterKey: true });
logger.info(`OBJECT -> ${JSON.stringify(object)}`);
if (object) {
logger.info(`OBJECT ->>>> ${JSON.stringify(object)}`);
const owner = object.attributes.owner_of;
const userQuery = new Moralis.Query(Moralis.User);
userQuery.equalTo("accounts", owner);
const userObject = await userQuery.first({ useMasterKey: true });
if (userObject) {
logger.info(`SET USER ->>>> ${JSON.stringify(userObject)}`);
request.object.set("user", userObject);
}
request.object.set("token", object);
}
});
Moralis.Cloud.beforeSave("ItemsForSale", async (request) => {
const query = new Moralis.Query("EthNFTOwners");
query.equalTo("token_id", request.object.get("uid"));
//query.equalTo("token_address", request.object.get("tokenAddress"));
query.equalTo("owner_of", request.object.get("owner"));
const object = await query.first({ useMasterKey: true });
if (object) {
const owner = object.attributes.owner_of;
const userQuery = new Moralis.Query(Moralis.User);
userQuery.equalTo("accounts", owner);
const userObject = userQuery.first({ useMasterKey: true });
if (userObject) {
request.object.set("user", userObject);
}
request.object.set("token", object);
}
});
Moralis.Cloud.beforeSave("SoldItems", async (request) => {
// Item published
const queryPublishedItems = new Moralis.Query("ItemsPublished");
queryPublishedItems.equalTo("uid", request.object.get("uid"));
const itemPublished = await queryPublishedItems.first();
if (itemPublished) {
itemPublished.set("isSold", true);
itemPublished.set("owner", request.object.get("buyer"));
await itemPublished.save();
}
// Item for sale
const queryItemsForSale = new Moralis.Query("ItemsForSale");
queryItemsForSale.equalTo("uid", request.object.get("uid"));
const item = await queryItemsForSale.first();
if (item) {
item.set("isSold", true);
item.set("owner", request.object.get("buyer"));
await item.save();
}
if (item || itemPublished) {
request.object.set("item", item);
const userQuery = new Moralis.Query(Moralis.User);
userQuery.equalTo("accounts", request.object.get("buyer"));
const userObject = userQuery.first({ useMasterKey: true });
if (userObject) {
request.object.set("user", userObject);
}
}
});
when you are on mainnet or testnet, what is in EthNFTOwnersPending
will move fast to EthNFTOwners
because there are many other transactions made on that chain.
Now, on local devchain you could see a delay when a row is in EthNFTOwnersPending
and then moved in EthNFTOwners
when another new transaction is made on chain.