From 05937d07905442bab72dc27f73425a56d2f5431e Mon Sep 17 00:00:00 2001 From: runtianz Date: Tue, 14 Jan 2025 20:37:38 -0800 Subject: [PATCH] Update aptos-move/framework/aptos-framework/sources/permissioned_signer.move Co-authored-by: Aaron --- .../framework/aptos-framework/doc/permissioned_signer.md | 5 +++-- .../aptos-framework/sources/permissioned_signer.move | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/permissioned_signer.md b/aptos-move/framework/aptos-framework/doc/permissioned_signer.md index b864184d3a242..9b2b68e399f2d 100644 --- a/aptos-move/framework/aptos-framework/doc/permissioned_signer.md +++ b/aptos-move/framework/aptos-framework/doc/permissioned_signer.md @@ -949,7 +949,7 @@ check if StoredPermission has at least threshold capacity.
fun is_above(perm: &StoredPermission, threshold: u256): bool {
     match (perm) {
-        StoredPermission::Capacity(capacity) => *capacity > threshold,
+        StoredPermission::Capacity(capacity) => *capacity >= threshold,
         StoredPermission::Unlimited => true,
     }
 }
@@ -1298,7 +1298,8 @@ to bypass the checks.
 
public(package) fun check_permission_exists<PermKey: copy + drop + store>(
     s: &signer, perm: PermKey
 ): bool acquires PermissionStorage {
-    check_permission_capacity_above(s, 0, perm)
+    // 0 capacity permissions will be treated as non-existant.
+    check_permission_capacity_above(s, 1, perm)
 }
 
diff --git a/aptos-move/framework/aptos-framework/sources/permissioned_signer.move b/aptos-move/framework/aptos-framework/sources/permissioned_signer.move index a85a418f1b7d9..bc513a412adb7 100644 --- a/aptos-move/framework/aptos-framework/sources/permissioned_signer.move +++ b/aptos-move/framework/aptos-framework/sources/permissioned_signer.move @@ -321,7 +321,7 @@ module aptos_framework::permissioned_signer { /// check if StoredPermission has at least `threshold` capacity. fun is_above(perm: &StoredPermission, threshold: u256): bool { match (perm) { - StoredPermission::Capacity(capacity) => *capacity > threshold, + StoredPermission::Capacity(capacity) => *capacity >= threshold, StoredPermission::Unlimited => true, } } @@ -491,7 +491,8 @@ module aptos_framework::permissioned_signer { public(package) fun check_permission_exists( s: &signer, perm: PermKey ): bool acquires PermissionStorage { - check_permission_capacity_above(s, 0, perm) + // 0 capacity permissions will be treated as non-existant. + check_permission_capacity_above(s, 1, perm) } public(package) fun check_permission_capacity_above(