Skip to content

Commit

Permalink
rebase main and set scale factor of TreasuryPlugin for StarcoinDAO
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 committed Oct 17, 2022
1 parent 89e7e77 commit b4eedde
Show file tree
Hide file tree
Showing 34 changed files with 78 additions and 68 deletions.
Binary file modified build/StarcoinFramework/bytecode_modules/Genesis.mv
Binary file not shown.
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/MemberProposalPlugin.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/StdlibUpgradeScripts.mv
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/TransactionManager.mv
Binary file not shown.
1 change: 1 addition & 0 deletions build/StarcoinFramework/docs/Genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ The module for init Genesis
<a href="Config.md#0x1_Config_extract_modify_config_capability">Config::extract_modify_config_capability</a>&lt;<a href="TransactionTimeoutConfig.md#0x1_TransactionTimeoutConfig_TransactionTimeoutConfig">TransactionTimeoutConfig::TransactionTimeoutConfig</a>&gt;(&genesis_account));
<a href="StarcoinDAO.md#0x1_StarcoinDAO_delegate_config_capability">StarcoinDAO::delegate_config_capability</a>&lt;<a href="STC.md#0x1_STC">STC</a>, <a href="LanguageVersion.md#0x1_LanguageVersion_LanguageVersion">LanguageVersion::LanguageVersion</a>&gt;(
<a href="Config.md#0x1_Config_extract_modify_config_capability">Config::extract_modify_config_capability</a>&lt;<a href="LanguageVersion.md#0x1_LanguageVersion_LanguageVersion">LanguageVersion::LanguageVersion</a>&gt;(&genesis_account));
<a href="StarcoinDAO.md#0x1_StarcoinDAO_set_treasury_withdraw_proposal_scale">StarcoinDAO::set_treasury_withdraw_proposal_scale</a>(100);

//Start time, <a href="Timestamp.md#0x1_Timestamp_is_genesis">Timestamp::is_genesis</a>() will <b>return</b> <b>false</b>. this call should at the end of genesis init.
<a href="Timestamp.md#0x1_Timestamp_set_time_has_started">Timestamp::set_time_has_started</a>(&genesis_account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
required_caps,
};

<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, title, introduction, description, action_delay);
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, title, introduction, description, action_delay, <a href="Option.md#0x1_Option_none">Option::none</a>&lt;u8&gt;());
}
</code></pre>

Expand Down
2 changes: 1 addition & 1 deletion build/StarcoinFramework/docs/MemberProposalPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
};
<b>assert</b>!(!<a href="DAOSpace.md#0x1_DAOSpace_is_exist_member_offer">DAOSpace::is_exist_member_offer</a>&lt;DAOT&gt;(member), <a href="Errors.md#0x1_Errors_already_published">Errors::already_published</a>(<a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_ERR_MEMBER_OFFER_EXIST">ERR_MEMBER_OFFER_EXIST</a>));
<b>assert</b>!(!<a href="DAOSpace.md#0x1_DAOSpace_is_member">DAOSpace::is_member</a>&lt;DAOT&gt;(member), <a href="Errors.md#0x1_Errors_already_published">Errors::already_published</a>(<a href="MemberProposalPlugin.md#0x1_MemberProposalPlugin_ERR_MEMBER_EXIST">ERR_MEMBER_EXIST</a>));
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, title, introduction, description, action_delay);
<a href="DAOSpace.md#0x1_DAOSpace_create_proposal">DAOSpace::create_proposal</a>(&cap, sender, action, title, introduction, description, action_delay, <a href="Option.md#0x1_Option_none">Option::none</a>&lt;u8&gt;());
}
</code></pre>

Expand Down
1 change: 1 addition & 0 deletions build/StarcoinFramework/docs/StdlibUpgradeScripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ deprecated, use <code>do_upgrade_from_v6_to_v7_with_language_version</code>.
<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);
<a href="StarcoinDAO.md#0x1_StarcoinDAO_set_treasury_withdraw_proposal_scale">StarcoinDAO::set_treasury_withdraw_proposal_scale</a>(100);

// clean <b>old</b> DAO resources
<a href="ModifyDaoConfigProposal.md#0x1_ModifyDaoConfigProposal_destroy_modify_config_capability">ModifyDaoConfigProposal::destroy_modify_config_capability</a>&lt;<a href="STC.md#0x1_STC">STC</a>&gt;(&genessis_signer);
Expand Down
Binary file modified build/StarcoinFramework/source_maps/Genesis.mvsm
Binary file not shown.
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/MemberProposalPlugin.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/StdlibUpgradeScripts.mvsm
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal.exp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ task 22 'run'. lines 299-310:

task 23 'run'. lines 313-337:
{
"gas_used": 480715,
"gas_used": 492779,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal.move
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module creator::DAOHelper {
total,
receiver,
};
let proposal_id = DAOSpace::create_proposal(&cap, sender, action,b"title",b"ipfs://introduction", b"ipfs://extend", action_delay);
let proposal_id = DAOSpace::create_proposal(&cap, sender, action,b"title",b"ipfs://introduction", b"ipfs://extend", action_delay, Option::none<u8>());
checkpoint<DAOT>(proposal_id);

proposal_id
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_proposal_rejected.move
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module creator::DAOHelper {
total,
receiver,
};
let proposal_id = DAOSpace::create_proposal(&cap, sender, action,b"title",b"ipfs://introduction", b"ipfs://extend", action_delay);
let proposal_id = DAOSpace::create_proposal(&cap, sender, action,b"title",b"ipfs://introduction", b"ipfs://extend", action_delay, Option::none<u8>());
checkpoint<DAOT>(proposal_id);

proposal_id
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/gas_oracle_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ task 16 'run'. lines 140-149:

task 17 'run'. lines 152-177:
{
"gas_used": 459302,
"gas_used": 471366,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/mint_proposal_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ task 19 'run'. lines 164-173:

task 20 'run'. lines 175-206:
{
"gas_used": 456366,
"gas_used": 468430,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospaceplugin/salary_gov_plugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module creator::SalaryGovPlugin {
let action = BossProposalAction<DAOT> {
boss: Signer::address_of(&sender)
};
DAOSpace::create_proposal(&cap, &sender, action, title, introduction, description, action_delay);
DAOSpace::create_proposal(&cap, &sender, action, title, introduction, description, action_delay, Option::none<u8>());
}

public(script) fun execute_proposal<DAOT: store>(sender: signer, proposal_id: u64) {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/starcoin_dao/starcoin_onchain_config.exp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ task 21 'run'. lines 111-120:

task 22 'run'. lines 123-132:
{
"gas_used": 455697,
"gas_used": 467761,
"status": "Executed"
}

Expand Down
12 changes: 6 additions & 6 deletions integration-tests/starcoin_dao/starcoin_treasury_withdraw.exp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ task 21 'run'. lines 111-120:

task 22 'run'. lines 122-142:
{
"gas_used": 89497,
"gas_used": 90735,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -54,7 +54,7 @@ task 22 'run'. lines 122-142:

task 23 'run'. lines 144-155:
{
"gas_used": 677731,
"gas_used": 537949,
"status": "Executed"
}

Expand Down Expand Up @@ -94,25 +94,25 @@ task 36 'run'. lines 219-229:
"status": "Executed"
}

task 38 'run'. lines 233-242:
task 38 'run'. lines 233-243:
{
"gas_used": 72220,
"status": "Executed"
}

task 39 'run'. lines 244-253:
task 39 'run'. lines 245-255:
{
"gas_used": 173612,
"status": "Executed"
}

task 41 'run'. lines 257-270:
task 41 'run'. lines 259-272:
{
"gas_used": 456032,
"status": "Executed"
}

task 43 'run'. lines 274-290:
task 43 'run'. lines 276-292:
{
"gas_used": 124032,
"status": "Executed"
Expand Down
62 changes: 32 additions & 30 deletions integration-tests/starcoin_dao/starcoin_treasury_withdraw.move
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ script {
// check: EXECUTED

//# run --signers alice
script{
script {
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
use StarcoinFramework::TreasuryPlugin;
use StarcoinFramework::STC::STC;
Expand All @@ -129,27 +129,27 @@ script{
use StarcoinFramework::DAOSpace;

//alice create proposal
fun create_proposal(sender: signer){
fun create_proposal(sender: signer) {
let market_cap = Token::market_cap<STC>();
let balance_in_treasury = Treasury::balance<STC>();
let supply = market_cap - balance_in_treasury;
let rate = DAOSpace::voting_quorum_rate<StarcoinDAO>();
let rate = (rate as u128);
let amount = supply * rate / 100 + 1;
TreasuryPlugin::create_withdraw_proposal<StarcoinDAO, STC>(&sender, b"Withdraw treasury", @alice, amount, 1000, 3600000);
TreasuryPlugin::create_withdraw_proposal<StarcoinDAO, STC>(&sender, b"Withdraw treasury", b"Withdraw treasury", b"Withdraw treasury", @alice, amount, 1000, 3600000);
}
}
// check: ABORT, code: 26375, reason:withdraw amount out of limit.

//# run --signers alice
script{
script {
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
use StarcoinFramework::TreasuryPlugin;
use StarcoinFramework::STC::STC;

//alice create proposal
fun create_proposal(sender: signer){
TreasuryPlugin::create_withdraw_proposal<StarcoinDAO, STC>(&sender, b"Withdraw treasury", @alice, 246800, 1000, 3600000);
fun create_proposal(sender: signer) {
TreasuryPlugin::create_withdraw_proposal<StarcoinDAO, STC>(&sender, b"Withdraw treasury", b"Withdraw treasury", b"Withdraw treasury", @alice, 246800, 1000, 3600000);
}
}
// check: EXECUTED
Expand All @@ -162,12 +162,12 @@ script{
//# call-api state.get_with_proof_by_root_raw ["{{$.call[0]}}","{{$.call-api[1].header.state_root}}"]

//# run --signers alice --args {{$.call-api[2]}}
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>){

// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>) {
DAOSpace::cast_vote_entry<StarcoinDAO>(sender, 1, snpashot_raw_proofs, 1);
}
}
Expand All @@ -180,12 +180,12 @@ script{
//# call-api state.get_with_proof_by_root_raw ["{{$.call[1]}}","{{$.call-api[1].header.state_root}}"]

//# run --signers bob --args {{$.call-api[3]}}
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>){

// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>) {
DAOSpace::cast_vote_entry<StarcoinDAO>(sender, 1, snpashot_raw_proofs, 1);
}
}
Expand All @@ -198,12 +198,12 @@ script{
//# call-api state.get_with_proof_by_root_raw ["{{$.call[2]}}","{{$.call-api[1].header.state_root}}"]

//# run --signers carol --args {{$.call-api[4]}}
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>){

// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>) {
DAOSpace::cast_vote_entry<StarcoinDAO>(sender, 1, snpashot_raw_proofs, 1);
}
}
Expand All @@ -217,12 +217,12 @@ script{


//# run --signers dave --args {{$.call-api[5]}}
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>){

// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>) {
DAOSpace::cast_vote_entry<StarcoinDAO>(sender, 1, snpashot_raw_proofs, 1);
}
}
Expand All @@ -231,55 +231,57 @@ script{
//# block --author=0x3 --timestamp 90240000

//# run --signers alice
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
fun state(_sender: signer){

fun state(_sender: signer) {
let state = DAOSpace::proposal_state<StarcoinDAO>(1);
assert!(state == 5 , 103);
assert!(state == 5, 103);
}
}
// check: EXECUTED

//# run --signers alice
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
fun queue_proposal_action(_sender: signer){

fun queue_proposal_action(_sender: signer) {
DAOSpace::queue_proposal_action<StarcoinDAO>(1);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 6 , 103);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 6, 103);
}
}
// check: EXECUTED

//# block --author=0x3 --timestamp 93860000

//# run --signers alice
script{
script {
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
use StarcoinFramework::TreasuryPlugin;
use StarcoinFramework::STC::STC;

fun execute_proposal(sender: signer){
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 7 , 103);
fun execute_proposal(sender: signer) {
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 7, 103);
TreasuryPlugin::execute_withdraw_proposal<StarcoinDAO, STC>(&sender, 1);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 8 , 104);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 8, 104);
}
}
// check: EXECUTED

//# block --author=0x3 --timestamp 94360000

//# run --signers alice
script{
script {
use StarcoinFramework::Treasury;
use StarcoinFramework::STC::STC;
use StarcoinFramework::Token;
use StarcoinFramework::Account;
use StarcoinFramework::Signer;

fun withdraw_token(sender: signer){
fun withdraw_token(sender: signer) {
let token = Treasury::withdraw_by_linear<STC>(&sender);
let amount = Token::value(&token);
assert!(amount == 123400, 101);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/starcoin_dao/starcoin_upgrade_module.exp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ task 21 'run'. lines 111-120:

task 23 'run'. lines 127-137:
{
"gas_used": 441669,
"gas_used": 453733,
"status": "Executed"
}

Expand Down
1 change: 1 addition & 0 deletions sources/Genesis.move
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ module StarcoinFramework::Genesis {
Config::extract_modify_config_capability<TransactionTimeoutConfig::TransactionTimeoutConfig>(&genesis_account));
StarcoinDAO::delegate_config_capability<STC, LanguageVersion::LanguageVersion>(
Config::extract_modify_config_capability<LanguageVersion::LanguageVersion>(&genesis_account));
StarcoinDAO::set_treasury_withdraw_proposal_scale(100);

//Start time, Timestamp::is_genesis() will return false. this call should at the end of genesis init.
Timestamp::set_time_has_started(&genesis_account);
Expand Down
Loading

0 comments on commit b4eedde

Please sign in to comment.