-
Notifications
You must be signed in to change notification settings - Fork 290
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
[sip5] Implement Treasury #2465
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2465 +/- ##
==========================================
+ Coverage 33.23% 33.26% +0.03%
==========================================
Files 493 496 +3
Lines 43143 42995 -148
Branches 19635 19452 -183
==========================================
- Hits 14335 14298 -37
- Misses 13870 14015 +145
+ Partials 14938 14682 -256
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Benchmark for 8467547Click to view benchmark
|
Benchmark for 38a47cdClick to view benchmark
|
Benchmark for f74e4bdClick to view benchmark
|
Benchmark for 71d435fClick to view benchmark
|
Benchmark for 585cb05Click to view benchmark
|
Benchmark for 02e2c55Click to view benchmark
|
amount: u128, | ||
} | ||
|
||
const ERR_INVALID_PERIOD: u64 = 1; |
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.
error code 1~4 is already used by other errors. It's suggested to use 101, 102, 103, 104 instead.
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.
当前 error 有点乱,有的从 1 开始,有的从 101 开始,有的从 1401 开始,我们用 category 来区分 error code type后,1~4 实际上也不会冲突,是不是没必要跳号了?
…lity, and cap to capability.
Benchmark for 38b3093Click to view benchmark
|
@@ -25,6 +26,8 @@ module Collection { | |||
items: Option<vector<T>>, | |||
} | |||
|
|||
const EDEPRECATED_FUNCTION: u64 = 11; |
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.
19 is used in another module, it's better use same one.
Benchmark for bdb77d4Click to view benchmark
|
/// Provider a port for get block reward STC from Treasury, only genesis account can invoke this function. | ||
/// The TreasuryWithdrawCapability is locked in TreasuryWithdrawDaoProposal, and only can withdraw by DAO proposal. | ||
/// This approach is not graceful, but restricts the operation to genesis accounts only, so there are no security issues either. | ||
public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128):Token<TokenT> acquires WrappedWithdrawCapability { |
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.
这里的设计确实有点奇怪。
withdraw block reward 不属于 dao proposal的范畴,却需要放在这个 module 里。另外方法也不应该有范型,链发币只发 stc,不会涉及其他 token。
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.
其他的看起来没啥问题。
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.
嗯,没想到更好的办法。本来想给 BlockReward 设置一个 capability,但 block reward 的额度不固定,也没法用 LinearCap,最后和 WithdrawCap 类似了。这里的 TokenT 如果直接写 STC,会有依赖顺序问题,所以只能先保持泛型。
* [stdlib] Implement Treasury module. * [stdib] Impl load upgrade package between version and enhancement upgrade test * [statedb] Implement get token info function for state reader. * [stdlib] Release stdlib v3 * [stdlib] Deprecated MintKey and Collection. * [stdlib] Check compat with previous latest stable version. * [types] Define more on chain resource in rust.
实现了 Treasury 的主要逻辑