-
Notifications
You must be signed in to change notification settings - Fork 38
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
BREAKING CHANGE: change ckb decimal to 18 #675
Merged
Flouse
merged 19 commits into
godwokenrises:develop
from
zeroqn:feat-change-ckb-decimal-to-18
May 7, 2022
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f70fcf2
feat!: change deposit ckb to 18 decimal
zeroqn 2a960f2
feat!: change fee to U256
zeroqn 76e2dd9
fix(tools): godwoken rpc get_balance return u128
zeroqn 2b415c9
feat!: change all sudt to U256
zeroqn 9b0a090
feat(godwoken.mol): change SUDTTransfer amount to Uint256
zeroqn c91973e
fix(bench): smt
zeroqn e14e1d2
chore(devtools): switch to pr prebuilds
zeroqn 1355b6c
chore(ci): kicker_ref and tests_ref
zeroqn 60e5248
fix: rebase develop
zeroqn afc4c7a
chore(ci): godwoken-tests workflow commit
zeroqn 08f3fab
chore(ci): use prebuild godwoken-scripts and godwoken-polyjuice
zeroqn 8d32a46
refactor!: change fee to u128
zeroqn 65fde23
format code
zeroqn b8f7fd3
Update crates/generator/src/traits.rs
zeroqn fb6a073
chore(changelog): update compatibility improvements
zeroqn 571f546
refactor(common): add CKBCapacity, remove manual conversion
zeroqn 91c3245
format code
zeroqn 448b7c2
base on reviews
zeroqn e5add77
Merge branch 'develop' into feat-change-ckb-decimal-to-18
Flouse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use gw_types::U256; | ||
|
||
// NOTE: u64::MAX is about 10^18, U256::MAX is about 10^77. Multiple 10 pow | ||
// `CKB_DECIMAL_POW_EXP` should not overflow. | ||
pub const CKB_DECIMAL_POW_EXP: u32 = 10; | ||
pub const CKB_DECIMAL_POWER_TEN: u64 = 10u64.pow(CKB_DECIMAL_POW_EXP); | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
pub struct CKBCapacity(U256); | ||
|
||
impl CKBCapacity { | ||
pub fn from_layer1(amount: u64) -> Self { | ||
CKBCapacity(U256::from(amount) * CKB_DECIMAL_POWER_TEN) | ||
} | ||
|
||
pub fn from_layer2(amount: U256) -> Self { | ||
CKBCapacity(amount) | ||
} | ||
|
||
pub fn to_layer1(&self) -> Option<u64> { | ||
let truncated = self.0 / CKB_DECIMAL_POWER_TEN; | ||
if truncated.bits() > u64::BITS as usize { | ||
None | ||
} else { | ||
Some(truncated.as_u64()) | ||
} | ||
} | ||
|
||
pub fn to_layer2(&self) -> U256 { | ||
self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In short, developers can use Godwoken v1 the same way as other ethereum compatible chains, all that has to be done is to switch the network to Godwoken. The polyjuice-provider web3 plugin has been removed in v1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes