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

refactor(rgbpp): calculate XUDT amount separately in AssetSummarizer #275

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

ShookLyngs
Copy link
Collaborator

@ShookLyngs ShookLyngs commented Aug 12, 2024

Changes

  • Calculate XUDT amount separately in AssetSummarizer instead of mixing the data of XUDT/DOB cells

The XUDT/DOB summary issue

Previously, when calculating AssetSummary, DOBs were treated as regular XUDT cells. This led to inaccuracies in the calculation of the total containing amount of an XUDT asset because the data for DOBs was treated as XUDT amounts and added to the summary result, while in reality, the data for DOBs differs from that of XUDT cells.

For example, the following asset summary includes a very large amount that looks unusual at first glance:

result.summary.excluded.assets {
  '0xdec25e81ad1d5b909926265b0cdf404e270250b9885d436852b942d56d06be38': { utxoCount: 1, cellCount: 1, amount: 1000000000n },
  '0x578ff15dfe17f0896cfa05501aaa400aa1cb1bbb519e96ae4077e7f61b5d894a': {
    utxoCount: 1,
    cellCount: 1,
    amount: 3644495476209561851583027740754n
  }
}

This PR ensures the accuracy of the XUDT total containing amount calculation by adding a check statement while iterating through each cell related to a UTXO. However, the summary calculation for those non-XUDT assets has not been implemented:

for (const cell of cells) {
  const isXudt = !!cell.cellOutput.type && isUDTTypeSupported(cell.cellOutput.type, this.isMainnet);
  if (isXudt) {
    // If the cell type is a supported xUDT type, record its asset information
    ...
  } else {
    // TODO: If the cell type is empty or not xUDT, how should we handle/record its info?
  }
}

@Flouse Flouse merged commit 2d1c834 into develop Aug 13, 2024
3 checks passed
@Flouse Flouse deleted the ref/asset-summary-xudt branch August 13, 2024 01:45
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.

4 participants