Skip to content

Commit

Permalink
Revert "migrate TreasuryWithdrawDaoProposal to DAOSpace TreasuryPlugin (
Browse files Browse the repository at this point in the history
#175)"

This reverts commit f44fd34.
  • Loading branch information
nkysg committed Mar 2, 2023
1 parent a5bd35b commit a1c02f8
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 222 deletions.
Binary file modified build/StarcoinFramework/bytecode_modules/BlockReward.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/StdlibUpgradeScripts.mv
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions build/StarcoinFramework/docs/BlockReward.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The module provide block rewarding calculation logic.
<b>use</b> <a href="Timestamp.md#0x1_Timestamp">0x1::Timestamp</a>;
<b>use</b> <a href="Token.md#0x1_Token">0x1::Token</a>;
<b>use</b> <a href="Treasury.md#0x1_Treasury">0x1::Treasury</a>;
<b>use</b> <a href="TreasuryPlugin.md#0x1_TreasuryPlugin">0x1::TreasuryPlugin</a>;
<b>use</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal">0x1::TreasuryWithdrawDaoProposal</a>;
<b>use</b> <a href="Vector.md#0x1_Vector">0x1::Vector</a>;
</code></pre>

Expand Down Expand Up @@ -317,7 +317,7 @@ Process the given block rewards.
block_reward = treasury_balance;
};
<b>if</b> (block_reward &gt; 0) {
<b>let</b> reward = <a href="TreasuryPlugin.md#0x1_TreasuryPlugin_withdraw_for_block_reward">TreasuryPlugin::withdraw_for_block_reward</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(account, block_reward);
<b>let</b> reward = <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_withdraw_for_block_reward">TreasuryWithdrawDaoProposal::withdraw_for_block_reward</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(account, block_reward);
<a href="Token.md#0x1_Token_deposit">Token::deposit</a>(&<b>mut</b> total_reward, reward);
};
};
Expand Down
1 change: 0 additions & 1 deletion build/StarcoinFramework/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::TransactionTimeoutConfig`](TransactionTimeoutConfig.md#0x1_TransactionTimeoutConfig)
- [`0x1::TransferScripts`](TransferScripts.md#0x1_TransferScripts)
- [`0x1::Treasury`](Treasury.md#0x1_Treasury)
- [`0x1::TreasuryPlugin`](TreasuryPlugin.md#0x1_TreasuryPlugin)
- [`0x1::TreasuryScripts`](TreasuryScripts.md#0x1_TreasuryScripts)
- [`0x1::TreasuryWithdrawDaoProposal`](TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal)
- [`0x1::TypeInfo`](TypeInfo.md#0x1_TypeInfo)
Expand Down
6 changes: 0 additions & 6 deletions build/StarcoinFramework/docs/StdlibUpgradeScripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ The module for StdlibUpgrade init scripts
<b>use</b> <a href="Timestamp.md#0x1_Timestamp">0x1::Timestamp</a>;
<b>use</b> <a href="Token.md#0x1_Token">0x1::Token</a>;
<b>use</b> <a href="Treasury.md#0x1_Treasury">0x1::Treasury</a>;
<b>use</b> <a href="TreasuryPlugin.md#0x1_TreasuryPlugin">0x1::TreasuryPlugin</a>;
<b>use</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal">0x1::TreasuryWithdrawDaoProposal</a>;
<b>use</b> <a href="UpgradeModulePlugin.md#0x1_UpgradeModulePlugin">0x1::UpgradeModulePlugin</a>;
</code></pre>
Expand Down Expand Up @@ -369,18 +368,13 @@ deprecated, use <code>do_upgrade_from_v6_to_v7_with_language_version</code>.
<a href="StakeToSBTPlugin.md#0x1_StakeToSBTPlugin_initialize">StakeToSBTPlugin::initialize</a>(&genessis_signer);
<a href="UpgradeModulePlugin.md#0x1_UpgradeModulePlugin_initialize">UpgradeModulePlugin::initialize</a>(&genessis_signer);
<a href="GasOracleProposalPlugin.md#0x1_GasOracleProposalPlugin_initialize">GasOracleProposalPlugin::initialize</a>(&genessis_signer);
<a href="TreasuryPlugin.md#0x1_TreasuryPlugin_initialize">TreasuryPlugin::initialize</a>(&genessis_signer);

//TODO : config rate need mind
// voting_delay: 60000 ms
// voting_period: 3600000 ms
// voting_quorum_rate: 4
// min_action_delay: 3600000 ms
<a href="StarcoinDAO.md#0x1_StarcoinDAO_create_dao">StarcoinDAO::create_dao</a>( <a href="Dao.md#0x1_Dao_voting_delay">Dao::voting_delay</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(), <a href="Dao.md#0x1_Dao_voting_period">Dao::voting_period</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(), <a href="Dao.md#0x1_Dao_voting_quorum_rate">Dao::voting_quorum_rate</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(), <a href="Dao.md#0x1_Dao_min_action_delay">Dao::min_action_delay</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(), 1000 * 1000 * 1000 * 1000);

<b>let</b> signer = <a href="GenesisSignerCapability.md#0x1_GenesisSignerCapability_get_genesis_signer">GenesisSignerCapability::get_genesis_signer</a>();
<b>let</b> cap = <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_takeout_withdraw_capability">TreasuryWithdrawDaoProposal::takeout_withdraw_capability</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(&signer);
<a href="TreasuryPlugin.md#0x1_TreasuryPlugin_delegate_capability">TreasuryPlugin::delegate_capability</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(&signer, cap);
}
</code></pre>

Expand Down
47 changes: 3 additions & 44 deletions build/StarcoinFramework/docs/TreasuryWithdrawDaoProposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ TreasuryWithdrawDaoProposal is a dao proposal for withdraw Token from Treasury.
- [Struct `WithdrawToken`](#0x1_TreasuryWithdrawDaoProposal_WithdrawToken)
- [Constants](#@Constants_0)
- [Function `plugin`](#0x1_TreasuryWithdrawDaoProposal_plugin)
- [Function `takeout_withdraw_capability`](#0x1_TreasuryWithdrawDaoProposal_takeout_withdraw_capability)
- [Function `propose_withdraw`](#0x1_TreasuryWithdrawDaoProposal_propose_withdraw)
- [Function `execute_withdraw_proposal`](#0x1_TreasuryWithdrawDaoProposal_execute_withdraw_proposal)
- [Function `withdraw_for_block_reward`](#0x1_TreasuryWithdrawDaoProposal_withdraw_for_block_reward)
Expand Down Expand Up @@ -109,11 +108,12 @@ WithdrawToken request.



<a name="0x1_TreasuryWithdrawDaoProposal_ERR_CAPABILITY_NOT_EXIST"></a>
<a name="0x1_TreasuryWithdrawDaoProposal_ERR_NEED_RECEIVER_TO_EXECUTE"></a>

Only receiver can execute TreasuryWithdrawDaoProposal


<pre><code><b>const</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_ERR_CAPABILITY_NOT_EXIST">ERR_CAPABILITY_NOT_EXIST</a>: u64 = 104;
<pre><code><b>const</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_ERR_NEED_RECEIVER_TO_EXECUTE">ERR_NEED_RECEIVER_TO_EXECUTE</a>: u64 = 102;
</code></pre>


Expand All @@ -128,16 +128,6 @@ The withdraw amount of propose is too many.



<a name="0x1_TreasuryWithdrawDaoProposal_ERR_NEED_RECEIVER_TO_EXECUTE"></a>

Only receiver can execute TreasuryWithdrawDaoProposal


<pre><code><b>const</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_ERR_NEED_RECEIVER_TO_EXECUTE">ERR_NEED_RECEIVER_TO_EXECUTE</a>: u64 = 102;
</code></pre>



<a name="0x1_TreasuryWithdrawDaoProposal_plugin"></a>

## Function `plugin`
Expand Down Expand Up @@ -182,37 +172,6 @@ Should be called by token issuer.



</details>

<a name="0x1_TreasuryWithdrawDaoProposal_takeout_withdraw_capability"></a>

## Function `takeout_withdraw_capability`

withdraw Treasury::WithdrawCapability


<pre><code><b>public</b> <b>fun</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_takeout_withdraw_capability">takeout_withdraw_capability</a>&lt;TokenT: store&gt;(sender: &signer): <a href="Treasury.md#0x1_Treasury_WithdrawCapability">Treasury::WithdrawCapability</a>&lt;TokenT&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_takeout_withdraw_capability">takeout_withdraw_capability</a>&lt;TokenT: store&gt;(sender: &signer): <a href="Treasury.md#0x1_Treasury_WithdrawCapability">Treasury::WithdrawCapability</a>&lt;TokenT&gt;
<b>acquires</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_WrappedWithdrawCapability">WrappedWithdrawCapability</a> {
<b>let</b> token_issuer = <a href="Token.md#0x1_Token_token_address">Token::token_address</a>&lt;TokenT&gt;();
<b>assert</b>!(<a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(sender) == token_issuer, <a href="Errors.md#0x1_Errors_requires_address">Errors::requires_address</a>(<a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_ERR_NOT_AUTHORIZED">ERR_NOT_AUTHORIZED</a>));

<b>assert</b>!(<b>exists</b>&lt;<a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_WrappedWithdrawCapability">WrappedWithdrawCapability</a>&lt;TokenT&gt;&gt;(<a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(sender)), <a href="Errors.md#0x1_Errors_not_published">Errors::not_published</a>(<a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_ERR_CAPABILITY_NOT_EXIST">ERR_CAPABILITY_NOT_EXIST</a>));
<b>let</b> <a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_WrappedWithdrawCapability">WrappedWithdrawCapability</a>&lt;TokenT&gt; { cap } = <b>move_from</b>&lt;<a href="TreasuryWithdrawDaoProposal.md#0x1_TreasuryWithdrawDaoProposal_WrappedWithdrawCapability">WrappedWithdrawCapability</a>&lt;TokenT&gt;&gt;(<a href="Signer.md#0x1_Signer_address_of">Signer::address_of</a>(sender));
cap
}
</code></pre>



</details>

<a name="0x1_TreasuryWithdrawDaoProposal_propose_withdraw"></a>
Expand Down
Binary file modified build/StarcoinFramework/source_maps/BlockReward.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/StdlibUpgradeScripts.mvsm
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ task 8 'run'. lines 66-74:

task 9 'view'. lines 76-76:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down Expand Up @@ -63,7 +63,7 @@ task 10 'run'. lines 78-91:

task 11 'view'. lines 93-93:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down Expand Up @@ -154,7 +154,7 @@ task 12 'run'. lines 95-103:

task 13 'view'. lines 105-105:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ task 10 'run'. lines 87-95:

task 11 'view'. lines 97-97:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin2::TestPlugin2> {
id: 12
id: 11
name: 54657374506c7567696e32
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ task 9 'run'. lines 82-93:

task 10 'view'. lines 95-95:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand All @@ -57,7 +57,7 @@ task 11 'run'. lines 98-109:

task 12 'view'. lines 111-111:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task 6 'run'. lines 46-54:

task 7 'view'. lines 56-56:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e
labels: [
Expand Down Expand Up @@ -45,7 +45,7 @@ task 9 'run'. lines 68-76:

task 10 'view'. lines 78-78:
store key 0x00000000000000000000000000000001::DAOPluginMarketplace::PluginEntry<0x662ba5a1a1da0f1c70a9762c7eeb7aaf::TestPlugin::TestPlugin> {
id: 11
id: 10
name: 54657374506c7567696e
description: 697066733a2f2f6465736372697074696f6e32
labels: [
Expand Down
4 changes: 2 additions & 2 deletions sources/BlockReward.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module BlockReward {
use StarcoinFramework::Config;
use StarcoinFramework::Event;
use StarcoinFramework::Treasury;
use StarcoinFramework::TreasuryPlugin;
use StarcoinFramework::TreasuryWithdrawDaoProposal;

spec module {
pragma verify = false;
Expand Down Expand Up @@ -122,7 +122,7 @@ module BlockReward {
block_reward = treasury_balance;
};
if (block_reward > 0) {
let reward = TreasuryPlugin::withdraw_for_block_reward<STC>(account, block_reward);
let reward = TreasuryWithdrawDaoProposal::withdraw_for_block_reward<STC>(account, block_reward);
Token::deposit(&mut total_reward, reward);
};
};
Expand Down
2 changes: 0 additions & 2 deletions sources/StarcoinDAO.move
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module StarcoinFramework::StarcoinDAO{
use StarcoinFramework::TransactionTimeoutConfig;
use StarcoinFramework::GasOracleProposalPlugin::GasOracleProposalPlugin;
use StarcoinFramework::GasOracleProposalPlugin;
use StarcoinFramework::TreasuryPlugin::{Self, TreasuryPlugin};

friend StarcoinFramework::Genesis;
friend StarcoinFramework::StdlibUpgradeScripts;
Expand Down Expand Up @@ -60,7 +59,6 @@ module StarcoinFramework::StarcoinDAO{
DAOSpace::install_plugin_with_root_cap<StarcoinDAO, ConfigProposalPlugin>(&dao_root_cap, ConfigProposalPlugin::required_caps());
DAOSpace::install_plugin_with_root_cap<StarcoinDAO, StakeToSBTPlugin>(&dao_root_cap, StakeToSBTPlugin::required_caps());
DAOSpace::install_plugin_with_root_cap<StarcoinDAO, GasOracleProposalPlugin>(&dao_root_cap, GasOracleProposalPlugin::required_caps());
DAOSpace::install_plugin_with_root_cap<StarcoinDAO, TreasuryPlugin>(&dao_root_cap, TreasuryPlugin::required_caps());

StakeToSBTPlugin::accept_token_with_root_cap<StarcoinDAO, STC>(&dao_root_cap);
StakeToSBTPlugin::set_sbt_weight_with_root_cap<StarcoinDAO, STC>(&dao_root_cap, 60000, 1000);
Expand Down
8 changes: 1 addition & 7 deletions sources/StdlibUpgradeScripts.move
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ module StdlibUpgradeScripts {
use StarcoinFramework::StarcoinDAO;
use StarcoinFramework::GasOracleProposalPlugin;
use StarcoinFramework::Dao;
use StarcoinFramework::TreasuryPlugin;


spec module {
pragma verify = false;
pragma aborts_if_is_strict = true;
Expand Down Expand Up @@ -137,18 +136,13 @@ module StdlibUpgradeScripts {
StakeToSBTPlugin::initialize(&genessis_signer);
UpgradeModulePlugin::initialize(&genessis_signer);
GasOracleProposalPlugin::initialize(&genessis_signer);
TreasuryPlugin::initialize(&genessis_signer);

//TODO : config rate need mind
// voting_delay: 60000 ms
// voting_period: 3600000 ms
// voting_quorum_rate: 4
// min_action_delay: 3600000 ms
StarcoinDAO::create_dao( Dao::voting_delay<STC>(), Dao::voting_period<STC>(), Dao::voting_quorum_rate<STC>(), Dao::min_action_delay<STC>(), 1000 * 1000 * 1000 * 1000);

let signer = GenesisSignerCapability::get_genesis_signer();
let cap = TreasuryWithdrawDaoProposal::takeout_withdraw_capability<STC>(&signer);
TreasuryPlugin::delegate_capability<STC>(&signer, cap);
}
}
}
12 changes: 0 additions & 12 deletions sources/TreasuryWithdrawDaoProposal.move
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module TreasuryWithdrawDaoProposal {
const ERR_NEED_RECEIVER_TO_EXECUTE: u64 = 102;
/// The withdraw amount of propose is too many.
const ERR_TOO_MANY_WITHDRAW_AMOUNT: u64 = 103;
const ERR_CAPABILITY_NOT_EXIST: u64 = 104;

/// Plugin method of the module.
/// Should be called by token issuer.
Expand All @@ -44,17 +43,6 @@ module TreasuryWithdrawDaoProposal {
move_to(signer, WrappedWithdrawCapability<TokenT> { cap: cap });
}

/// withdraw Treasury::WithdrawCapability
public fun takeout_withdraw_capability<TokenT: store>(sender: &signer): Treasury::WithdrawCapability<TokenT>
acquires WrappedWithdrawCapability {
let token_issuer = Token::token_address<TokenT>();
assert!(Signer::address_of(sender) == token_issuer, Errors::requires_address(ERR_NOT_AUTHORIZED));

assert!(exists<WrappedWithdrawCapability<TokenT>>(Signer::address_of(sender)), Errors::not_published(ERR_CAPABILITY_NOT_EXIST));
let WrappedWithdrawCapability<TokenT> { cap } = move_from<WrappedWithdrawCapability<TokenT>>(Signer::address_of(sender));
cap
}

spec plugin {
pragma aborts_if_is_partial = false;
let sender = Signer::address_of(signer);
Expand Down
Loading

0 comments on commit a1c02f8

Please sign in to comment.