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

SetDelegate can be deleted by ClearDelegate which in is in fact should not be #1

Open
davaymne opened this issue Oct 23, 2023 · 0 comments

Comments

@davaymne
Copy link

There is could be a case when Delegation with given ID is in DB, and then there are multiple ClearDelegate followed by SetDelegate with the same ID.

Example:
https://etherscan.io/txs?a=0xef8305e140ac520225daf050e2f71d5fbcc543e7&p=9
(around tx https://etherscan.io/tx/0xcc8525f8b227674e5216ce2fd7c4fc3f63c7cd62b0f3912e9c09054a6e358978#eventlog)

In such case Delegation will be deleted by code below:

        let isExistOnDB = await ctx.store.get(Delegation, id);
          // let isExistOnMap = delegations.get(id);
          if (isExistOnDB) {
            clearDelegations.set(id, id);

...

  await ctx.store.upsert([...delegations.values()]);
  await ctx.store.upsert([...sigs.values()]);
  if (clearDelegations.size != 0) {
    await ctx.store.remove(Delegation, [...clearDelegations.values()]);
  }
});
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

No branches or pull requests

1 participant