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: getLiveCells returns specified change type cells #183

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

zhangyouxin
Copy link
Contributor

@zhangyouxin zhangyouxin commented Apr 3, 2023

What Changed

This PR resolves #164

Motivation

For now, wallet_fullOwnership_getLiveCells returns both external and internal cells, we need to support the change filter.

refer to current code:

getLiveCells: async ({ cursor: encodedCursor } = {}) => {
const db = await getDb();
const backend = await backendProvider.resolve();
const infos = await db.getAll();
const queryCursor: CellCursor = encodedCursor ? decodeCursor(encodedCursor) : { indexerCursor: '', localId: 0 };
const onChainLocks = infos
.filter(
(info) =>
info.status === 'OnChain' &&
// only fetch cells after or containing this lock
info.id >= queryCursor.localId,
)
.map((info) => info.lock);
const { objects, cursor, lastLock } = await backend.getLiveCellsByLocks({
locks: onChainLocks,
cursor: queryCursor.indexerCursor,
});
if (!lastLock) {
asserts.asserts(!objects.length, "Can't find last lock when cells are returned");
return { objects, cursor };
}
const lastLockInfo = infos.find((info) => info.scriptHash === utils.computeScriptHash(lastLock));
asserts.asserts(lastLockInfo, 'no lastLockInfo found');
return { objects, cursor: encodeCursor({ indexerCursor: cursor, localId: lastLockInfo.id }) };
},

Change Type

Indicate the type of change your pull request is:

  • documentation
  • patch
  • minor
  • major

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #183 (c244cba) into main (de66611) will decrease coverage by 0.10%.
The diff coverage is 50.00%.

❗ Current head c244cba differs from pull request most recent head 24e137e. Consider uploading reports for the commit 24e137e to get more accurate results

@@            Coverage Diff             @@
##             main     #183      +/-   ##
==========================================
- Coverage   86.82%   86.72%   -0.10%     
==========================================
  Files          41       41              
  Lines         774      776       +2     
  Branches       95       96       +1     
==========================================
+ Hits          672      673       +1     
  Misses         20       20              
- Partials       82       83       +1     
Impacted Files Coverage Δ
...ion-chrome/src/services/ownership/fullOwnership.ts 86.66% <50.00%> (-1.01%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zhangyouxin zhangyouxin marked this pull request as ready for review April 3, 2023 06:05
@homura homura added patch Increment the patch version when merged skip-release Preserve the current version when merged labels Apr 7, 2023
@homura homura merged commit 66a1d11 into ckb-js:main Apr 7, 2023
@github-actions
Copy link

🚀 PR was released in v0.0.10 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released. skip-release Preserve the current version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wallet_fullOwnership_getLiveCells] Change is different, but the result is the same
2 participants