Skip to content

Commit

Permalink
[Feature]DAOAccount Todo : add exists_upgrade_plan_cap (#160)
Browse files Browse the repository at this point in the history
* fix eventutil

* DAOAccount TODO

* DAOAccount Todo : add exists_upgrade_plan_cap

* ready_publish -> not_published
  • Loading branch information
WGB5445 authored Sep 27, 2022
1 parent d2c4f5c commit 1fb3b8a
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 5 deletions.
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: A155383ABA4B2CECDADAD666C4E012F372A73E64B9B0EA9CA977261219D8ED8E
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;
}
}
}
5 changes: 3 additions & 2 deletions sources/daospace/DAOAccount.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ 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_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::not_published(ERR_UPGARDE_PLAN_CAP_NOT_EXISTS));
PackageTxnManager::extract_submit_upgrade_plan_cap(&dao_signer)
}else{
Config::publish_new_config<Version::Version>(&dao_signer, Version::new_version(1));
Expand Down

0 comments on commit 1fb3b8a

Please sign in to comment.