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

Spike through account balance #26

Open
KarishmaBothara opened this issue May 12, 2022 · 1 comment
Open

Spike through account balance #26

KarishmaBothara opened this issue May 12, 2022 · 1 comment

Comments

@KarishmaBothara
Copy link
Contributor

KarishmaBothara commented May 12, 2022

The way balance is updated on uncover is it checks the block that is being processed for all the accounts in it and gets balance for these accounts...

private extractAccounts(block: IChainBlock): string[] {
    const accounts: string[] = [];
    accounts.push(block.validator);
    for (const extrinsic of block.extrinsics) {
      if (extrinsic.isSigned && extrinsic.accountId) {
        accounts.push(extrinsic.accountId);
      }
      for (const param of extrinsic.params) {
        if (param.type === 'AccountId') {
          accounts.push(param.value as string);
        }
        if (param.type === 'Erc20DepositEvent') {
          const claim = param.value as unknown as Erc20DepositEvent;
          accounts.push(claim.beneficiary.toString());
        }
      }
    }
    for (const event of block.events) {
      for (const param of event.params) {
        if (param.type === 'AccountId') {
          accounts.push(param.value as string);
        }
      }
    }
    return uniq(accounts);
  }

One of the reason for incorrect balance or balance not being updated could be when nft is sold to an account when time expires, it updates the balance of nft holder if reserve is met.. but the system doesn't know about it or if there is Royalty that receiver receives should also be considered

[{"name":"collection_id","type":"CollectionId","value":55},{"name":"quantity","type":"TokenCount","value":1000},{"name":"owner","type":"Option<AccountId>","value":"5F4bqAuskqbRULcnD72songmAj9Rk2iWuE6QDeWTfiU3caR9"},{"name":"attributes","type":"Vec<NFTAttributeValue>","value":[]},{"name":"metadata_path","type":"Option<Bytes>","value":"0x697066733a2f2f516d5038795970444666346738694b5366414e4e5577536e396f6662716859563448314e5a54635657334365516a"},{"name":"royalties_schedule","type":"Option<RoyaltiesSchedule>","value":{"entitlements":[["5F4bqAuskqbRULcnD72songmAj9Rk2iWuE6QDeWTfiU3caR9",100000]]}}]

Also we need to check for Option type at if (param.type === 'AccountId') {

Need to check of these relevant areas and update the code to show user the right balance for their assets.

@KarishmaBothara
Copy link
Contributor Author

Account balance are provided directly from the chain now

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