Skip to content

Commit

Permalink
reuse has_upgrade_permission by change private to public
Browse files Browse the repository at this point in the history
  • Loading branch information
baichuan3 committed Sep 14, 2024
1 parent 2ae3f40 commit 5b1f408
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions frameworks/bitcoin-move/sources/pending_block.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module bitcoin_move::pending_block{
use std::option::{Self, Option};
use moveos_std::signer;
use moveos_std::signer::module_signer;
use moveos_std::module_store::has_update_permission;
use moveos_std::module_store::has_upgrade_permission;

use moveos_std::object::{Self, Object, ObjectID};
use moveos_std::simple_map::{Self, SimpleMap};
Expand Down Expand Up @@ -336,7 +336,7 @@ module bitcoin_move::pending_block{
public entry fun update_reorg_block_count(signer: &signer, count: u64){
let module_signer = module_signer<PendingStore>();
let package_id = signer::address_of(&module_signer);
assert!(has_update_permission(package_id, signer), ErrorHasNoPermission);
assert!(has_upgrade_permission(package_id, signer::address_of(signer)), ErrorHasNoPermission);

let store = borrow_mut_store();
store.reorg_block_count = count;
Expand Down
10 changes: 5 additions & 5 deletions frameworks/moveos-stdlib/doc/module_store.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- [Function `add_to_allowlist`](#0x2_module_store_add_to_allowlist)
- [Function `remove_from_allowlist`](#0x2_module_store_remove_from_allowlist)
- [Function `is_in_allowlist`](#0x2_module_store_is_in_allowlist)
- [Function `has_update_permission`](#0x2_module_store_has_update_permission)
- [Function `has_upgrade_permission`](#0x2_module_store_has_upgrade_permission)


<pre><code><b>use</b> <a href="">0x1::string</a>;
Expand Down Expand Up @@ -362,12 +362,12 @@ Check if a package id is in the allowlist.



<a name="0x2_module_store_has_update_permission"></a>
<a name="0x2_module_store_has_upgrade_permission"></a>

## Function `has_update_permission`
## Function `has_upgrade_permission`

Check if the account has the permission to update with the package_id.
Check if the account has the permission to upgrade the package with the package_id.


<pre><code><b>public</b> <b>fun</b> <a href="module_store.md#0x2_module_store_has_update_permission">has_update_permission</a>(package_id: <b>address</b>, <a href="account.md#0x2_account">account</a>: &<a href="">signer</a>): bool
<pre><code><b>public</b> <b>fun</b> <a href="module_store.md#0x2_module_store_has_upgrade_permission">has_upgrade_permission</a>(package_id: <b>address</b>, <a href="account.md#0x2_account">account</a>: <b>address</b>): bool
</code></pre>
7 changes: 1 addition & 6 deletions frameworks/moveos-stdlib/sources/module_store.move
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ module moveos_std::module_store {
}

/// Check if the account has the permission to upgrade the package with the package_id.
fun has_upgrade_permission(package_id: address, account: address): bool {
public fun has_upgrade_permission(package_id: address, account: address): bool {
let id = object::account_named_object_id<UpgradeCap>(package_id);
if (!object::exists_object(id)) {
return false
Expand All @@ -328,11 +328,6 @@ module moveos_std::module_store {
object::owner(cap) == account
}

/// Check if the account has the permission to update with the package_id.
public fun has_update_permission(package_id: address, account: &signer): bool {
Self::has_upgrade_permission(package_id, signer::address_of(account))
}

//The following is the bytes and hex of the compiled module: example/counter/sources/counter.move with account 0x42
// Run the follow commands to get the bytecode of the module
//./target/debug/rooch move build -p examples/counter -d
Expand Down

0 comments on commit 5b1f408

Please sign in to comment.