Skip to content

Commit 4794f6c

Browse files
Merge pull request AtomicIP#387 from mgtmdccix-oss/feat/ip-suggested-price
feat: add suggested_price to ip_registry
2 parents 657f4e3 + eae519d commit 4794f6c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • contracts/ip_registry/src

contracts/ip_registry/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,24 @@ impl IpRegistry {
787787
.unwrap_or(Vec::new(&env))
788788
}
789789

790+
/// Set or update the suggested price for an IP. Owner-only. Pass 0 to clear.
791+
pub fn set_ip_suggested_price(env: Env, ip_id: u64, price: i128) {
792+
let record = require_ip_exists(&env, ip_id);
793+
record.owner.require_auth();
794+
if price == 0 {
795+
env.storage().persistent().remove(&DataKey::SuggestedPrice(ip_id));
796+
} else {
797+
env.storage().persistent().set(&DataKey::SuggestedPrice(ip_id), &price);
798+
env.storage().persistent().extend_ttl(&DataKey::SuggestedPrice(ip_id), LEDGER_BUMP, LEDGER_BUMP);
799+
}
800+
}
801+
802+
/// Get the suggested price for an IP. Returns None if no price has been set.
803+
pub fn get_ip_suggested_price(env: Env, ip_id: u64) -> Option<i128> {
804+
require_ip_exists(&env, ip_id);
805+
env.storage().persistent().get(&DataKey::SuggestedPrice(ip_id))
806+
}
807+
790808
/// Add a co-owner to an IP. Owner-only.
791809
/// Co-owners can verify commitments but cannot transfer or revoke the IP.
792810
pub fn add_co_owner(env: Env, ip_id: u64, co_owner: Address) {

0 commit comments

Comments
 (0)