kodadot / snek

Implementation of Basilisk NFT pallet
GNU General Public License v3.0
3 stars 11 forks source link

missing `offer` event from event entity #169

Open roiLeo opened 1 year ago

roiLeo commented 1 year ago

Tested on https://squid.subsquid.io/snekk/v/004/graphql & https://squid.subsquid.io/snekk/v/005/graphql

query MyQuery {
  events(where: {interaction_eq: OFFER}) {
    interaction
    id
  }
}

result []

roiLeo commented 1 year ago

@vikiival any idea how to bypass [PROBLEM] Entity needs to be real from ensure(<NE>), not the first time I'm facing this fatal error on indexer

vikiival commented 1 year ago

@vikiival any idea how to bypass [PROBLEM] Entity needs to be real from ensure(<NE>), not the first time I'm facing this fatal error on indexer

Hey It means that NFT you are requesting is not in the DB. If you want simple hack just do

if (!entity) {
  console.warn('Entity not found.. Skipping')
  return
}
vikiival commented 1 year ago

I have it as fatal error because I want to ensure that everything is validated

roiLeo commented 1 year ago

Hey It means that NFT you are requesting is not in the DB. If you want simple hack just do

if (!entity) {
  console.warn('Entity not found.. Skipping')
  return
}

This hack doesn't work for me. I have same issue as https://github.com/kodadot/snek/issues/127#issuecomment-1369803964 as it try to withdraw offer on non-existing NFT (weird flex but ok)

It break when ensure nftEntity in handleOfferWithdraw

const nftEntity = ensure<NE>(await get(context.store, NE, tokenId));
if (!nftEntity) {
    return logger.warn(`[WITHDRAW OFFER] ${tokenId} entity not found.. Skipping`);
}
[WITHDRAW OFFER]: 679692
MarketplaceOfferWithdrawnEvent {
  _chain: Chain {
    description: {
      types: [Array],
      call: 182,
      digest: 11,
      digestItem: 13,
      event: 17,
      eventRecord: 16,
      eventRecordList: 15,
      signature: 494,
      storage: [Object],
      constants: [Object]
    },
    getClient: [Function (anonymous)],
    storageHashCache: Map(0) {},
    constantValueCache: Map(0) {},
    jsonCodec: JsonCodec { types: [Array] },
    scaleCodec: Codec { types: [Array] },
    events: Registry {
      types: [Array],
      definitions: [Object],
      hashes: [Object]
    },
    calls: Registry { types: [Array], definitions: [Object], hashes: {} }
  },
  event: {
    args: {
      class: '3132385849',
      instance: '1',
      who: '0x8cc1b91e8946862c2c79915a4bc004926510fcf71c422fde977c0b0e9d9be40e'
    },
    id: '0000679692-000006-bf5a6',
    indexInBlock: 6,
    name: 'Marketplace.OfferWithdrawn',
    phase: 'ApplyExtrinsic',
    pos: 10,
    extrinsic: {
      error: null,
      hash: '0x74dba45696daa745ed362caf66e9ef96100db5d75c2224737f87e251a7773dcb',
      id: '0000679692-000002-bf5a6',
      indexInBlock: 2,
      pos: 14,
      signature: [Object],
      success: true,
      version: 4,
      tip: 0n,
      call: [Object]
    },
    call: {
      args: [Object],
      error: null,
      id: '0000679692-000002-bf5a6',
      name: 'Marketplace.withdraw_offer',
      origin: [Object],
      pos: 13,
      success: true
    }
  }
}
vikiival commented 1 year ago

Ensure does not throw errors 👀 It just casts any to T.

Wondering why do you have error for this? Which one do you use main or other release?

roiLeo commented 1 year ago

Ensure does not throw errors 👀 It just casts any to T.

hmmmm not sure about since one since it's the line I'm blocking on.

  const tokenId = tokenIdOf(event);
  logger.debug(`token: ${tokenId}`); //  token: 3132385849-1

  // IMO this line throw error
  const nftEntity = ensure<NE>(await get(context.store, NE, tokenId));

  if (!nftEntity) {
    logger.warn(`[WITHDRAW OFFER] ${tokenId} entity not found.. Skipping`);
    return;
  }

Wondering why do you have error for this?

because there is a block on chain with a WITHDRAW OFFER event that is related on a non-existing Nft Entity

Which one do you use main or other release?

Start from release-004 since main is outdated.

edit: don't you think it could come from getWithdrawOfferEvent? since we're handling only isV55 & isV81 event type

vikiival commented 1 year ago

My bet is that your indexer is indexing basilisk instead of snek

{
  nftEntityById(id: "3132385849-1") {
    name
    blockNumber
  }
}

Snek

Screenshot 2023-04-04 at 11 43 23

Basilisk

Screenshot 2023-04-04 at 11 44 25

My .env

ARCHIVE_URL=https://basilisk-rococo-firesquid.play.hydration.cloud/graphql
NODE_URL=wss://rococo-basilisk-rpc.hydration.dev
vikiival commented 1 year ago

since we're handling only isV55 & isV81 event type

Are there more types?

roiLeo commented 1 year ago

My bet is that your indexer is indexing basilisk instead of snek

lol I was afraid that was it

but my file is the default one set on repo (same as you)

ARCHIVE_URL=https://basilisk-rococo-firesquid.play.hydration.cloud/graphql
NODE_URL=wss://rococo-basilisk-rpc.hydration.dev

&

No migrations are pending
●  note      Welcome to the Processor! ROCOCO
08:59:47 INFO  sqd:processor last processed block was 679289
08:59:47 INFO  sqd:processor processing blocks from 679290
08:59:48 INFO  sqd:processor prometheus metrics are served at port 64728

Maybe someone withdraw offer on snek but token Id is on bsx.

Are there more types?

what about v71, v92