XLNT / gnarly

🤙 A blockchain ETL tool to make your life better. Now that’s fuckin’ gnarly.
https://xlnt.co
Apache License 2.0
119 stars 9 forks source link

implement erc20 reducer, transfers #35

Closed nionis closed 6 years ago

nionis commented 6 years ago

This implementation is only for transfers, we need to discuss on what is the best way to handle mints / burns / totalSupply

shrugs commented 6 years ago

For handing mint/burn mechanics, lets implement the minimum viable concept of

  1. If Transfer to 0x0 or Mint, add the value to the addr and emit a ERC20_MINT reason.
  2. If Transfer from 0x0 or Burn, subtract the value from the addr and emit an ERC20_BURN reason.

That should get us 90% of compatibility, I think. Let's use the OpenZeppelin Burn and Mint event abis.

nionis commented 6 years ago

@shrugs should we make 0x0 balance to remain 0 when there its Transfer from 0x0 to X address ?

shrugs commented 6 years ago

@nionis It seems like an arbitrary thing, but I do prefer the idea of keeping burns literal. That way we should be able to get totalSuppy by doing something like SELECT SUM(balance) as totalSupply where address = '0xabcd'.

nionis commented 6 years ago

@shrugs Mint / Burn always emit Transfer function, so there is no need to check for those events unless we want to specifically store the MINT_REASON or BURN_REASON

so I would just look for Transfer event, and then check from / to values, if they are 0x0 then I do MINT_REASON / BURN_REASON

sounds good?

shrugs commented 6 years ago

Yup! There might be edge cases with some tokens that don't emit the correct transfer event, but I expect it's not something we have to worry about yet.

Let's definitely note that the reason being different between transfers mints and burns; that's something i expect people would like to query directly, instead of inferring it from the fact that the _to is 0 or vise versa.

-matt

On Fri, Aug 3, 2018, 11:32 Steve notifications@github.com wrote:

@shrugs https://github.com/shrugs Mint / Burn always emit Transfer function, so there is no need to check for those events unless we want to specifically store the MINT_REASON or BURN_REASON

so I would just look for Transfer event, and then check from / to values, if they are 0x0 then I do MINT_REASON / BURN_REASON

sounds good?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/XLNT/gnarly/pull/35#issuecomment-410339557, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdsGYsgSqngW47mK5Y8VSXHQk0DImBfks5uNJdFgaJpZM4VdQEB .