Skip to content

Commit

Permalink
Use FungibleBuckets when claiming royalties
Browse files Browse the repository at this point in the history
  • Loading branch information
lrubasze committed Apr 30, 2024
1 parent 5012f8e commit 3fc7c63
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions radix-engine-tests/assets/blueprints/royalty-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ mod royalty_test {
.globalize()
}

pub fn claim_package_royalty(package: Package, proof: Proof) -> Bucket {
pub fn claim_package_royalty(package: Package, proof: Proof) -> FungibleBucket {
proof.authorize(|| package.claim_royalties())
}

pub fn claim_component_royalty(component: Global<AnyComponent>, proof: Proof) -> Bucket {
pub fn claim_component_royalty(
component: Global<AnyComponent>,
proof: Proof,
) -> FungibleBucket {
proof.authorize(|| component.claim_component_royalties())
}
}
Expand Down
4 changes: 2 additions & 2 deletions scrypto/src/component/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use radix_common::ScryptoSbor;
use radix_engine_interface::api::object_api::ModuleId;
use radix_engine_interface::api::{AttachedModuleId, FieldValue};
use radix_engine_interface::blueprints::resource::{
AccessRule, Bucket, MethodAccessibility, OwnerRole, OwnerRoleEntry, RoleAssignmentInit,
AccessRule, FungibleBucket, MethodAccessibility, OwnerRole, OwnerRoleEntry, RoleAssignmentInit,
};
use radix_engine_interface::object_modules::metadata::{
MetadataConversionError, MetadataInit, MetadataVal, METADATA_GET_IDENT, METADATA_REMOVE_IDENT,
Expand Down Expand Up @@ -474,7 +474,7 @@ where
self.component_royalties().lock_royalty(method);
}

fn claim_component_royalties(&self) -> Bucket {
fn claim_component_royalties(&self) -> FungibleBucket {
self.component_royalties().claim_royalties()
}
}
Expand Down
4 changes: 2 additions & 2 deletions scrypto/src/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use radix_common::prelude::PACKAGE_PACKAGE;
use radix_engine_interface::blueprints::package::{
PackageClaimRoyaltiesInput, PACKAGE_BLUEPRINT, PACKAGE_CLAIM_ROYALTIES_IDENT,
};
use radix_engine_interface::blueprints::resource::Bucket;
use radix_engine_interface::blueprints::resource::FungibleBucket;
use radix_engine_interface::types::*;
use sbor::rust::prelude::*;

Expand Down Expand Up @@ -40,7 +40,7 @@ impl ObjectStub for PackageStub {
}

impl PackageStub {
pub fn claim_royalties(&self) -> Bucket {
pub fn claim_royalties(&self) -> FungibleBucket {
self.call(
PACKAGE_CLAIM_ROYALTIES_IDENT,
&PackageClaimRoyaltiesInput {},
Expand Down
6 changes: 3 additions & 3 deletions scrypto/src/modules/royalty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use radix_common::constants::ROYALTY_MODULE_PACKAGE;
use radix_common::data::scrypto::{scrypto_decode, scrypto_encode};
use radix_common::types::RoyaltyAmount;
use radix_engine_interface::api::AttachedModuleId;
use radix_engine_interface::blueprints::resource::Bucket;
use radix_engine_interface::blueprints::resource::FungibleBucket;
use radix_engine_interface::object_modules::royalty::{
ComponentClaimRoyaltiesInput, ComponentRoyaltyCreateInput, ComponentRoyaltyLockInput,
ComponentRoyaltySetInput, COMPONENT_ROYALTY_BLUEPRINT, COMPONENT_ROYALTY_CLAIMER_ROLE,
Expand All @@ -25,7 +25,7 @@ use scrypto::modules::Attachable;
pub trait HasComponentRoyalties {
fn set_royalty<M: ToString>(&self, method: M, amount: RoyaltyAmount);
fn lock_royalty<M: ToString>(&self, method: M);
fn claim_component_royalties(&self) -> Bucket;
fn claim_component_royalties(&self) -> FungibleBucket;
}

#[derive(Debug, PartialEq, Eq, Hash, Clone)]
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Royalty {
);
}

pub fn claim_royalties(&self) -> Bucket {
pub fn claim_royalties(&self) -> FungibleBucket {
self.call(
COMPONENT_ROYALTY_CLAIM_ROYALTIES_IDENT,
&ComponentClaimRoyaltiesInput {},
Expand Down

0 comments on commit 3fc7c63

Please sign in to comment.