Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix token supply on mint #160

Merged
2 commits merged into from
Dec 28, 2023
Merged

Fix token supply on mint #160

2 commits merged into from
Dec 28, 2023

Conversation

ghost
Copy link

@ghost ghost commented Dec 28, 2023

Purpose

On mint events an internal object CisEventTokenAddedUpdate was created in EventLogHandler. This was later used to update the total token supply in class EventLogWriter on method CreateTokenAddedCmd.

However the SQL query did nothing if the token already existed.

INSERT INTO graphql_tokens(contract_index, contract_sub_index, token_id, total_supply)
                VALUES (@ContractIndex, @ContractSubIndex, @TokenId, @TotalSupply)
                ON CONFLICT ON CONSTRAINT graphql_tokens_pkey
                DO NOTHING";

Because of this, whenever token was minted on id’s which already existed, the total amount wouldn’t increase.

OBS: The total token supply data is currently corrupted and a separate PR with a clean up job will be created.

Changes

Object CisEventTokenAddedUpdate and method CreateTokenAddedCmd has been removed, such that now CisEventTokenAmountUpdate is used for both mint and burn events. The SQL used updates the total supply in case token id already exists.

INSERT INTO graphql_tokens(contract_index, contract_sub_index, token_id, total_supply)
                VALUES (@ContractIndex, @ContractSubIndex, @TokenId, @AmountDelta)
                ON CONFLICT ON CONSTRAINT graphql_tokens_pkey
                DO UPDATE SET total_supply = graphql_tokens.total_supply + @AmountDelta

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

@ghost ghost requested a review from TouHouNo December 28, 2023 12:17
@ghost ghost merged commit bbd03b0 into main Dec 28, 2023
1 check passed
@ghost ghost deleted the fix-token-supply-on-mint branch December 28, 2023 13:27
@ghost ghost mentioned this pull request Jan 8, 2024
5 tasks
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant