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

BREAKING CHANGE: change ckb decimal to 18 #675

Merged
merged 19 commits into from
May 7, 2022

Conversation

zeroqn
Copy link
Contributor

@zeroqn zeroqn commented Apr 25, 2022

Purpose

This PR unified layer2 fungible token representation as u256.

This PR also changes the decimal of CKB, in layer1 CKB is represented in 8 decimal, but when user deposit CKB into layer2, we changed the representation to 18 decimal. Thus, layer2 CKB can play the same role as ETH, developers can operate CKB as 18 decimal asset(like ETH) in their contract without modification. This change also improve the compatibility between Metamask and the native token CKB.

@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch 3 times, most recently from 8b67bda to 9597b6d Compare April 27, 2022 10:36
@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch from 9597b6d to 8950ef4 Compare April 27, 2022 10:38
@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch 2 times, most recently from 99412c8 to afc4c7a Compare April 27, 2022 14:03
@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch from a9ece23 to 08f3fab Compare April 27, 2022 14:15
crates/common/src/ckb_decimal.rs Outdated Show resolved Hide resolved
crates/common/src/ckb_decimal.rs Outdated Show resolved Hide resolved
crates/common/src/ckb_decimal.rs Outdated Show resolved Hide resolved
crates/common/src/state.rs Outdated Show resolved Hide resolved
crates/common/src/state.rs Outdated Show resolved Hide resolved
@jjyr
Copy link
Collaborator

jjyr commented Apr 29, 2022

We should also change SUDTTransfer#amount to Uint256, since the layer2 is using decimal 18. The burn / mint interface should also be updated.

@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch from 4ab866c to 8d32a46 Compare April 29, 2022 07:31
crates/generator/src/traits.rs Outdated Show resolved Hide resolved
Flouse
Flouse previously approved these changes Apr 29, 2022
Flouse
Flouse previously approved these changes May 5, 2022
@zeroqn zeroqn force-pushed the feat-change-ckb-decimal-to-18 branch from 72dd582 to fb6a073 Compare May 5, 2022 03:36
Flouse
Flouse previously approved these changes May 5, 2022
crates/common/src/ckb_decimal.rs Outdated Show resolved Hide resolved
jjyr
jjyr previously approved these changes May 5, 2022
CHANGELOG.md Outdated
@@ -19,6 +19,8 @@ In the new version, we improve the compatibility of Godwoken:
- Support Ethereum signature format and EIP-712. User can view the transaction before signing, instead of signing a random 32 bytes message. [#561](https://github.com/nervosnetwork/godwoken/pull/561)
- Fix the total supply interface of sUDT ERC-20 proxy contract [#560](https://github.com/nervosnetwork/godwoken/pull/560)
- Support interactive with eth address that haven't been registered to Godwoken.
- Unify layer 2 fungible token represatation as uint256.
- Change layer 2 ckb decimal from 8 to 18, improve compatibility between metamask and native ckb. [#675](https://github.com/nervosnetwork/godwoken/pull/675)

In short, as a developer, you can use Godwoken v1 just like anyother Ethereum compatible chain, all you need to do is to switch the network to Godwoken. The polyjuice-provider web3 plugin is removed in the v1 version.
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@zeroqn zeroqn dismissed stale reviews from jjyr and Flouse via 571f546 May 5, 2022 08:02
keroro520
keroro520 previously approved these changes May 5, 2022
Flouse
Flouse previously approved these changes May 5, 2022
keroro520
keroro520 previously approved these changes May 6, 2022
@Flouse Flouse dismissed stale reviews from keroro520 and themself via e5add77 May 7, 2022 13:46
@Flouse Flouse merged commit f3cdd47 into godwokenrises:develop May 7, 2022
keroro520 added a commit to keroro520/godwoken-examples that referenced this pull request May 11, 2022
Why: godwokenrises/godwoken#675 change the
precision of units.

How: Adjust the molecule types

New types definition: https://github.com/zeroqn/godwoken/blob/e5add779d0f5a5b460e3154859880fab8906f21f/crates/types/schemas/godwoken.mol

```
moleculec --language - --schema-file godwoken.mol  --format json
moleculec-es -inputFile 1.json -outputFile generated.js -generateTypeScriptDefinition
./node_modules/.bin/babel --plugins @babel/plugin-transform-modules-commonjs src/schema/generated.js
```

Tags:
Flouse added a commit to Flouse/godwoken-docker-prebuilds that referenced this pull request Jun 6, 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.

7 participants