Contract event not syncing from EventSync

We’ve come across an issue when trying to sync a contract event. After loading the event sync through the admin portal and it appears to be loaded in correctly into MoralisDB, we find that the events are not being picked up by the contract. We think this might have to do with the fact that the contract in question takes a struct and a list of structs as a parameter, and emits those types in the event. Our other contract event syncs with Moralis work fine with native Solidity types. The EventSync Moralis table shows that the object is loaded in, but with the fields last_synced_block, synced, last_historical_block, and total as undefined.

The Event is called ListingCreated, and the ABI is

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "uint256",
          "name": "listingId",
          "type": "uint256"
        },
        {
          "components": [
            {
              "internalType": "enum MediaEyeOrders.NftTokenType",
              "name": "nftTokenType",
              "type": "uint8"
            },
            {
              "internalType": "address",
              "name": "nftTokenAddress",
              "type": "address"
            },
            {
              "internalType": "uint256",
              "name": "nftTokenId",
              "type": "uint256"
            },
            {
              "internalType": "uint256",
              "name": "nftNumTokens",
              "type": "uint256"
            }
          ],
          "internalType": "struct MediaEyeOrders.Nft[]",
          "name": "nfts",
          "type": "tuple[]"
        },
        {
          "internalType": "string",
          "name": "label",
          "type": "string"
        },
        {
          "internalType": "address payable",
          "name": "seller",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "timestamp",
          "type": "uint256"
        },
        {
          "components": [
            {
              "internalType": "address payable",
              "name": "recipient",
              "type": "address"
            },
            {
              "internalType": "uint256",
              "name": "splitBasisPoint",
              "type": "uint256"
            },
            {
              "internalType": "address payable",
              "name": "charity",
              "type": "address"
            },
            {
              "internalType": "uint256",
              "name": "charityBasisPoint",
              "type": "uint256"
            }
          ],
          "internalType": "struct MediaEyeOrders.Split",
          "name": "split",
          "type": "tuple"
        }
      ],
      "indexed": false,
      "internalType": "struct MediaEyeOrders.Listing",
      "name": "listing",
      "type": "tuple"
    },
    {
      "components": [
        {
          "internalType": "address",
          "name": "paymentMethod",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "indexed": false,
      "internalType": "struct MediaEyeOrders.ListingPayment[]",
      "name": "listingPayments",
      "type": "tuple[]"
    }
  ],
  "name": "ListingCreated",
  "type": "event"
}
1 Like

It may not work with a variable number of nfts as parameter, we will also need the address of that smart contract to do some tests.

I believe the response is just two structs

1 Like

can you give an example if you found a solution?

Sorry, was spinning up a mock contract that’s more barebones and easier to look at.
No solution so far and same issue with this test contract on Rinkeby.
https://rinkeby.etherscan.io/address/0x3ddC7dF5b42c76eF506C189aa521135505b7F546
The event is still called ListingCreated.

You can modify in abi the type of parameters, but that tuple[] may cause some problems.
would it be possible to emit more than one event instead of using that variable length array?

After changing the contract to emit multiple events, so that there is no longer a need for the tuples, same issue occurs. Unable to receive data in the db after we sync the general listing struct, or the nft events following. All other event syncs thus far still work fine.

ok, it should be easier where there isn’t a variable length array, can you paste the new contract address in this configuration?

so here is a new test contract where we tested the variable length array, there are 3 test functions we tested here
https://rinkeby.etherscan.io/address/0x01B9a582B192e4042834523A404be6bF9E6B463b

testEmit just emits 1,2,3, worked without issue
testEmit2 returns the struct Nft
testEmit3 returns a variable length array of struct Nft

both 2 and 3 did not pick up with eventsync
we don’t believe the issue is related to the variable length array but rather to the struct

ok, related to the struct, you could modify in the ABI (in the event sync interface) to have a different equivalent form, like removing the struct and using only parameters

changing the abi without changing the contract? can you give me an example.

=>


        {
          "internalType": "address",
          "name": "paymentMethod1",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "price1",
          "type": "uint256"
        },
        {
          "internalType": "address",
          "name": "paymentMethod2",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "price2",
          "type": "uint256"
        }

you can do something like this directly in a new invented ABI that you can use to sync events

can you get a working copy of the abi with test emit 2 in my previous comment? modifying inputs, and internal types has not done anything for me thus far. I’ve tried several variations of this and perhaps you may be able to point out my mistake.

from:

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "enum TestList.NftTokenType",
          "name": "nftTokenType",
          "type": "uint8"
        },
        {
          "internalType": "address",
          "name": "nftTokenAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "nftTokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "nftNumTokens",
          "type": "uint256"
        }
      ],
      "indexed": false,
      "internalType": "struct TestList.Nft",
      "name": "nft",
      "type": "tuple"
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}

=> To:

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "uint8",
          "name": "nftTokenType",
          "type": "uint8"
        },
        {
          "internalType": "address",
          "name": "nftTokenAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "nftTokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "nftNumTokens",
          "type": "uint256"
        }
      ]
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}

I need the topics for those 3 events:

testEmit just emits 1,2,3, worked without issue
testEmit2 returns the struct Nft
testEmit3 returns a variable length array of struct Nft

for testEmit2, I have tried the topics
TestEmit2(Nft)
and later on
TestEmit2(uint8,address,uint256,uint256)

it looks like Web3.utils.sha3('TestEmit2(uint8,address,uint256,uint256)') doesn’t give the right value for that topic that it should be: 0x33b0faabcc485e4d173ca94be91e075cb1d9b3a6fdfb96c1b061ab7ecf112bab

what is the original abi for TestEmit2?

As stated before:

{
    "anonymous": false,
    "inputs": [
      {
        "components": [
          {
            "internalType": "enum TestList.NftTokenType",
            "name": "nftTokenType",
            "type": "uint8"
          },
          {
            "internalType": "address",
            "name": "nftTokenAddress",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "nftTokenId",
            "type": "uint256"
          },
          {
            "internalType": "uint256",
            "name": "nftNumTokens",
            "type": "uint256"
          }
        ],
        "indexed": false,
        "internalType": "struct TestList.Nft",
        "name": "nft",
        "type": "tuple"
      }
    ],
    "name": "TestEmit2",
    "type": "event"
  }

taken directly from etherscan.


=>
Web3.utils.sha3('TestEmit2((uint8,address,uint256,uint256))') => 0x33b0faabcc485e4d173ca94be91e075cb1d9b3a6fdfb96c1b061ab7ecf112bab

this works fine for me:

topic: TestEmit2((uint8,address,uint256,uint256))
abi:

{
  "anonymous": false,
  "inputs": [
    {
      "internalType": "uint8",
      "name": "nftTokenType",
      "type": "uint8"
    },
    {
      "internalType": "address",
      "name": "nftTokenAddress",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "nftTokenId",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "nftNumTokens",
      "type": "uint256"
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}