orca-so / orca-sdks

Open-sourced typescript SDKs for Orca
MIT License
43 stars 10 forks source link

Add token repository method to clear tags #65

Closed terranmoccasin closed 5 months ago

terranmoccasin commented 6 months ago

We ran into an issue where the TokenRepository did not handle a mint changing mintlists properly.

Usage of the repository is like the following:

      this.repository
        .tagMintlist(defaultList, [Tag.Whitelisted])
        .tagMintlist(extended, [Tag.Whitelisted])
        .tagMintlist(unsupported, [Tag.Unsupported])
        .setOverrides(overrides);

Code path that uncovered a bug in usage:

  1. Add mint to unsupported mintlist
  2. Repository picks up the mint and tags it with the unsupported tag
  3. Remove mint from unsupported, add to extended list
  4. Repository picks up mint and tags it with the whitelisted tag. However, the unsupported tag was never removed.

This patch adds a .clearTags() method which clears all tags in the token repository. This is the proposed usage which should address the error outlined above:

      this.repository
        .clearTags()
        .tagMintlist(defaultList, [Tag.Whitelisted])
        .tagMintlist(extended, [Tag.Whitelisted])
        .tagMintlist(unsupported, [Tag.Unsupported])
        .setOverrides(overrides);