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

implement rpc calculate_dao_maximum_withdraw in sdk #578

Merged
merged 8 commits into from
Mar 2, 2022

Conversation

yanguoyu
Copy link
Collaborator

No description provided.

@yanguoyu
Copy link
Collaborator Author

@Keith-CY Help to see if it is reasonable.

@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2022

Codecov Report

Merging #578 (8cd4f45) into develop (b18ae36) will decrease coverage by 0.29%.
The diff coverage is 85.71%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #578      +/-   ##
===========================================
- Coverage    96.28%   95.98%   -0.30%     
===========================================
  Files           49       50       +1     
  Lines         1533     1571      +38     
  Branches       301      306       +5     
===========================================
+ Hits          1476     1508      +32     
- Misses          57       63       +6     
Impacted Files Coverage Δ
packages/ckb-sdk-core/src/index.ts 70.73% <68.75%> (-0.22%) ⬇️
packages/ckb-sdk-utils/src/index.ts 97.95% <93.33%> (-2.05%) ⬇️
packages/ckb-sdk-utils/src/convertors/index.ts 100.00% <100.00%> (ø)
packages/ckb-sdk-utils/src/occupiedCapacity.ts 100.00% <100.00%> (ø)

const withDrawHeader = await this.rpc.getHeader(withdrawBlockHash)
const withdrawAr = this.#extracDaoData(withDrawHeader.dao).ar
const { JSBI } = this.utils
const occupiedCapacity = JSBI.asUintN(64, JSBI.BigInt(10200000000));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The occupied capacity is dynamic according to
image
10200000000 is just for the default lock in the example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to ckb-explorer, the occupied capacity is determined by withdraw cell, when the withdrawal doesn't occur, we can assume the cell won't change and use deposit cell instead of withdraw cell.

packages/ckb-sdk-core/src/index.ts Outdated Show resolved Hide resolved
@yanguoyu yanguoyu marked this pull request as ready for review February 28, 2022 11:01
@Keith-CY
Copy link
Member

Keith-CY commented Mar 1, 2022

With this set of parameters

{index: '0x0', txHash: '0xabd4f1b9e914cd859cb7ecf4f57009ef7cd2d84a799ed61acff904bdf5fea91a'}, '0x04914c83fa9ea4126279ebe2d2cdff74235f63227821882e4e16f6a908f43691'

I've got a result 30000000070 which is different from that 30000000155 returned by RPC

1: cal occupied capacity don't use serialize data
2: calculateDaoMaximumWithdraw second params accept two kind
@yanguoyu
Copy link
Collaborator Author

yanguoyu commented Mar 2, 2022

image

i have fixed it. Now js-sdk result is same as rust.

@Keith-CY Keith-CY merged commit 674dfa5 into ckb-js:develop Mar 2, 2022
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.

None yet

3 participants