sablier-labs / v2-subgraphs

Subgraphs for Sablier V2 token streaming protocol
7 stars 4 forks source link

[Minor bug] - False error message on Transfer event #18

Closed DenhamPreen closed 10 months ago

DenhamPreen commented 10 months ago

Current behaviour: An error is logged when a Transfer event is emitted and a stream doesn't already exist, this will occur everytime a new stream is created as when a StreamNFT is created the action of minting an NFT results in a Transfer event being emitted, this Transfer event is emitted before the CreateLockupLinearStream event is emitted

Solution: Treat mints and transfer differently by identifying a mint by the from address being equal to the zero address ( 0x0000000000000000000000000000000000000000)

Example pseudo code fix:

  if (stream == null && event.params.from != zeroAddress) {
    log.info(
      "[SABLIER] Stream hasn't been registered before this transfer event: {}",
      [id.toHexString()],
    );
    log.error("[SABLIER]", []);
    return;
  }

Example transaction: https://etherscan.io/tx/0x8255c56151b47382aea1e3b255339d0ed9934e4a384fb346a37dd1e62f8393b3#eventlog Relevant code: https://github.com/sablier-labs/v2-subgraphs/blob/2e1a92c8b39a13a2ea91f3a3cbed34c09c3a8c27/packages/protocol/src/mappings/handle-stream.ts#L119

cc: @woosungd

razgraf commented 10 months ago

Great catch @DenhamPreen and thank you for suggesting a solution too! I'll include it in a PR today (or if you'd like to, you can submit one yourself).

Would love to hear if you guys discovered any other similar conflicts we may be able to fix, especially with the transitions from #17 being merged soon.