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

[Feature]DAOAccount Todo : add exists_upgrade_plan_cap #160

Merged
merged 6 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 2AD2AE7E71652A66A26833D40AE407B8999CCA28FA16FF7FBBC34E73A73FA704
source_digest: BD2B12E8D55CF30ABCADA4204A2C2AEBC8838EDFA1DCE3E462C1CDBEF5A40A7D
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file modified build/StarcoinFramework/bytecode_modules/PackageTxnManager.mv
Binary file not shown.
37 changes: 37 additions & 0 deletions build/StarcoinFramework/docs/PackageTxnManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The module provides strategies for module upgrading.
- [Function `package_txn_prologue`](#0x1_PackageTxnManager_package_txn_prologue)
- [Function `package_txn_prologue_v2`](#0x1_PackageTxnManager_package_txn_prologue_v2)
- [Function `package_txn_epilogue`](#0x1_PackageTxnManager_package_txn_epilogue)
- [Function `exists_upgrade_plan_cap`](#0x1_PackageTxnManager_exists_upgrade_plan_cap)
- [Module Specification](#@Module_Specification_1)


Expand Down Expand Up @@ -1540,6 +1541,42 @@ Package txn finished, and clean UpgradePlan



</details>

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

## Function `exists_upgrade_plan_cap`



<pre><code><b>public</b> <b>fun</b> <a href="PackageTxnManager.md#0x1_PackageTxnManager_exists_upgrade_plan_cap">exists_upgrade_plan_cap</a>(addr: <b>address</b>): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="PackageTxnManager.md#0x1_PackageTxnManager_exists_upgrade_plan_cap">exists_upgrade_plan_cap</a>(addr :<b>address</b>):bool{
<b>exists</b>&lt;<a href="PackageTxnManager.md#0x1_PackageTxnManager_UpgradePlanCapability">UpgradePlanCapability</a>&gt;(addr)
}
</code></pre>



</details>

<details>
<summary>Specification</summary>



<pre><code><b>aborts_if</b> <b>false</b>;
</code></pre>



</details>

<a name="@Module_Specification_1"></a>
Expand Down
Binary file modified build/StarcoinFramework/source_maps/PackageTxnManager.mvsm
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_upgrade.exp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ task 9 'run'. lines 130-144:

task 10 'run'. lines 145-154:
{
"gas_used": 1047820,
"gas_used": 1051127,
"status": "Executed"
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/daospace/dao_upgrade_incompatible.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task 8 'run'. lines 121-136:

task 9 'run'. lines 138-147:
{
"gas_used": 1047820,
"gas_used": 1051127,
"status": "Executed"
}

Expand Down
8 changes: 8 additions & 0 deletions sources/PackageTxnManager.move
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,13 @@ address StarcoinFramework {
&& success && Option::is_some(global<TwoPhaseUpgrade>(package_address).plan)
&& !exists<Config::Config<Version::Version>>(global<TwoPhaseUpgrade>(package_address).version_cap.account_address);
}

public fun exists_upgrade_plan_cap(addr :address):bool{
exists<UpgradePlanCapability>(addr)
}

spec exists_upgrade_plan_cap {
aborts_if false;
}
}
}
3 changes: 2 additions & 1 deletion sources/daospace/DAOAccount.move
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module StarcoinFramework::DAOAccount{
const ERR_ACCOUNT_CAP_NOT_EXISTS:u64 = 100;
const ERR_ACCOUNT_CAP_EXISTS: u64 = 101;
const ERR_ACCOUNT_IS_NOT_SAME:u64 = 102;
const ERR_UPGARDE_PLAN_CAP_NOT_EXISTS:u64 = 103;

/// DAOAccount
struct DAOAccount has key{
Expand Down Expand Up @@ -70,7 +71,7 @@ module StarcoinFramework::DAOAccount{
let dao_address = Signer::address_of(&dao_signer);

let upgrade_plan_cap = if(Config::config_exist_by_address<Version::Version>(dao_address)){
//TODO if the account has extract the upgrade plan cap
assert!(PackageTxnManager::exists_upgrade_plan_cap(dao_address), Errors::already_published(ERR_UPGARDE_PLAN_CAP_NOT_EXISTS));
Copy link
Contributor

Choose a reason for hiding this comment

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

用的是Errors::already_published(ERR_UPGARDE_PLAN_CAP_NOT_EXISTS)),意味着 publish之后会会销毁upgrade plan cap?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

本意表达 not_published已经修改

PackageTxnManager::extract_submit_upgrade_plan_cap(&dao_signer)
}else{
Config::publish_new_config<Version::Version>(&dao_signer, Version::new_version(1));
Expand Down