Skip to content

Commit

Permalink
feat: add support for personal_kiosk_rule
Browse files Browse the repository at this point in the history
  • Loading branch information
thounyy committed Dec 10, 2024
1 parent 83d9531 commit 4f59882
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/actions/sources/kiosk.move
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sui::{
kiosk::{Self, Kiosk, KioskOwnerCap},
transfer_policy::{TransferPolicy, TransferRequest},
};
use kiosk::{kiosk_lock_rule, royalty_rule};
use kiosk::{kiosk_lock_rule, royalty_rule, personal_kiosk_rule};
use account_protocol::{
account::Account,
proposals::{Proposal, Expired},
Expand Down Expand Up @@ -132,6 +132,9 @@ public fun place<Config, Outcome, Nft: key + store>(
royalty_rule::pay(policy, &mut request, coin::zero<SUI>(ctx));
};

if (policy.has_rule<Nft, personal_kiosk_rule::Rule>()) {
personal_kiosk_rule::prove(account_kiosk, &mut request);
};
// the request can be filled with arbitrary rules and must be confirmed afterwards
request
}
Expand Down Expand Up @@ -335,6 +338,10 @@ public fun do_take<Config, Outcome, Nft: key + store, W: copy + drop>(
if (policy.has_rule<Nft, royalty_rule::Rule>()) {
royalty_rule::pay(policy, &mut request, coin::zero<SUI>(ctx));
};

if (policy.has_rule<Nft, personal_kiosk_rule::Rule>()) {
personal_kiosk_rule::prove(account_kiosk, &mut request);
};
// the request can be filled with arbitrary rules and must be confirmed afterwards
request
}
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/sources/auth.move
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public fun verify_with_role<Role>(
addr: address,
name: String,
) {
let mut r = type_name::get<Role>().into_string().to_string();
let mut full_role = type_name::get<Role>().into_string().to_string();

if (!name.is_empty()) {
r.append_utf8(b"::");
r.append(name);
full_role.append_utf8(b"::");
full_role.append(name);
};

let Auth { role, account_addr } = auth;

assert!(addr == account_addr, EWrongAccount);
assert!(role == r, EWrongRole);
assert!(role == full_role, EWrongRole);
}

0 comments on commit 4f59882

Please sign in to comment.