Struct pallet_ip_pallet::pallet::Pallet
source · pub struct Pallet<T>(/* private fields */);Expand description
The Pallet struct, the main type that implements traits and standalone
functions within the pallet.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn mint_nft(
origin: OriginFor<T>,
name: String,
description: String,
filing_date: String,
jurisdiction: String,
) -> DispatchResult
pub fn mint_nft( origin: OriginFor<T>, name: String, description: String, filing_date: String, jurisdiction: String, ) -> DispatchResult
Creates a new NFT representing intellectual property
§Arguments
origin- The account creating the NFTname- Name of the intellectual property (max length:Config::MaxNameLength)description- Detailed description (max length:Config::MaxDescriptionLength)filing_date- When the IP was filed (max length:Config::MaxNameLength)jurisdiction- Where the IP is registered (max length:Config::MaxNameLength)
§Events
Event::NftMinted- When NFT is successfully created
§Errors
Error::NameTooLong- If name exceeds maximum lengthError::DescriptionTooLong- If description exceeds maximum lengthError::FilingDateTooLong- If filing date exceeds maximum lengthError::JurisdictionTooLong- If jurisdiction exceeds maximum length
sourcepub fn offer_license(
origin: OriginFor<T>,
nft_id: T::NFTId,
payment_type: PaymentType<T>,
is_exclusive: bool,
duration: BlockNumberFor<T>,
) -> DispatchResult
pub fn offer_license( origin: OriginFor<T>, nft_id: T::NFTId, payment_type: PaymentType<T>, is_exclusive: bool, duration: BlockNumberFor<T>, ) -> DispatchResult
Creates a license offer for an NFT
Allows other accounts to license the NFT under specified terms.
§Arguments
origin- Must be signed by the NFT ownernft_id- ID of the NFT to licensepayment_type- Payment terms (seePaymentType)is_exclusive- Whether this is an exclusive licenseduration- How long the license lasts (in blocks)
§Events
Event::LicenseOffered- When offer is created
§Errors
Error::NftNotFound- If NFT doesn’t existError::NotNftOwner- If caller doesn’t own the NFTError::NftInEscrow- If NFT is in escrowError::ExclusiveLicenseExists- If trying to create offer while exclusive license exists
sourcepub fn offer_purchase(
origin: OriginFor<T>,
nft_id: T::NFTId,
payment_type: PaymentType<T>,
) -> DispatchResult
pub fn offer_purchase( origin: OriginFor<T>, nft_id: T::NFTId, payment_type: PaymentType<T>, ) -> DispatchResult
Creates a purchase offer for an NFT
Allows other accounts to purchase the NFT.
§Arguments
origin- Must be signed by the NFT ownernft_id- ID of the NFT to purchasepayment_type- Payment terms (seePaymentType)
§Events
Event::PurchaseOffered- When offer is created
§Errors
Error::NftNotFound- If NFT doesn’t existError::NotNftOwner- If caller doesn’t own the NFTError::NftInEscrow- If NFT is in escrow
sourcepub fn accept_license(
origin: OriginFor<T>,
offer_id: T::OfferId,
) -> DispatchResult
pub fn accept_license( origin: OriginFor<T>, offer_id: T::OfferId, ) -> DispatchResult
Accepts a license offer
Allows the licensee to accept the offer and create a license contract.
§Arguments
origin- Must be signed by the licenseeoffer_id- ID of the offer to accept
§Events
Event::ContractCreated- When contract is created
§Errors
Error::OfferNotFound- If offer doesn’t existError::NotALicenseOffer- If offer is not a license offer
sourcepub fn accept_purchase(
origin: OriginFor<T>,
offer_id: T::OfferId,
) -> DispatchResult
pub fn accept_purchase( origin: OriginFor<T>, offer_id: T::OfferId, ) -> DispatchResult
Accepts a purchase offer
Allows the buyer to accept the offer and create a purchase contract.
§Arguments
origin- Must be signed by the buyeroffer_id- ID of the offer to accept
§Events
Event::ContractCreated- When contract is created
§Errors
Error::OfferNotFound- If offer doesn’t existError::NotAPurchaseOffer- If offer is not a purchase offer
sourcepub fn make_periodic_payment(
origin: OriginFor<T>,
contract_id: T::ContractId,
) -> DispatchResult
pub fn make_periodic_payment( origin: OriginFor<T>, contract_id: T::ContractId, ) -> DispatchResult
Makes a periodic payment for a contract
Processes the next scheduled payment for a periodic payment contract. Handles payment calculation including any penalties from missed payments.
§Arguments
origin- Must be signed by the payer (licensee/buyer)contract_id- ID of the contract to make a payment for
§Events
Event::PeriodicPaymentMade- When payment is successfully processedEvent::PaymentsCompleted- When this was the final payment dueEvent::PaymentMade- For the actual currency transfer
§Errors
Error::ContractNotFound- If contract doesn’t existError::NotPeriodicPayment- If contract uses one-time payment instead of periodicError::PaymentNotDue- If current block is before next_payment_block or no payments are dueError::InsufficientBalance- If payer doesn’t have enough fundsError::ZeroPayment- If calculated payment amount is zero
sourcepub fn expire_license(
origin: OriginFor<T>,
contract_id: T::ContractId,
) -> DispatchResult
pub fn expire_license( origin: OriginFor<T>, contract_id: T::ContractId, ) -> DispatchResult
Expires a license contract after its duration has ended
Allows any party to expire a license contract once its duration has passed. Cleans up contract storage and updates NFT contract mappings.
§Arguments
origin- Any signed partycontract_id- ID of the license contract to expire
§Events
Event::ContractExpired- When license is successfully expired
§Errors
Error::ContractNotFound- If contract doesn’t existError::NotALicenseContract- If contract is a purchase contractError::LicenseNotExpired- If license duration hasn’t ended yet
§State Changes
- Removes contract from
Contractsstorage - Updates
NFTContractsmapping to remove expired license
sourcepub fn complete_purchase(
origin: OriginFor<T>,
contract_id: T::ContractId,
) -> DispatchResult
pub fn complete_purchase( origin: OriginFor<T>, contract_id: T::ContractId, ) -> DispatchResult
Completes a purchase contract after all payments are made
Finalizes NFT ownership transfer and cleans up contract storage. Can only be called when all payments have been completed.
§Arguments
origin- Any signed partycontract_id- ID of the purchase contract to complete
§Events
Event::ContractCompleted- When purchase is successfully completedEvent::NftRemovedFromEscrow- When NFT is released from escrow
§Errors
Error::ContractNotFound- If contract doesn’t existError::NotAPurchaseContract- If contract is a license contractError::NotPeriodicPayment- If contract is not a periodic payment contractError::PaymentNotCompleted- If any payments are still due
§State Changes
- Removes contract from
Contractsstorage - Updates
NFTContractsmapping to remove contract - Updates
Nftsstorage to reflect new owner - Removes NFT from
EscrowedNftsstorage
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn process_payment(
payer: &T::AccountId,
payee: &T::AccountId,
amount: BalanceOf<T>,
) -> DispatchResult
pub fn process_payment( payer: &T::AccountId, payee: &T::AccountId, amount: BalanceOf<T>, ) -> DispatchResult
Process a payment from payer to payee Returns Ok(()) if successful, Err if failed
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn next_nft_id() -> T::NFTId
pub fn next_nft_id() -> T::NFTId
An auto-generated getter for NextNftId.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn next_offer_id() -> T::OfferId
pub fn next_offer_id() -> T::OfferId
An auto-generated getter for NextOfferId.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn nft_contracts<KArg>(k: KArg) -> Vec<T::ContractId>where
KArg: EncodeLike<T::NFTId>,
pub fn nft_contracts<KArg>(k: KArg) -> Vec<T::ContractId>where
KArg: EncodeLike<T::NFTId>,
An auto-generated getter for NFTContracts.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn escrowed_nfts<KArg>(k: KArg) -> Option<T::AccountId>where
KArg: EncodeLike<T::NFTId>,
pub fn escrowed_nfts<KArg>(k: KArg) -> Option<T::AccountId>where
KArg: EncodeLike<T::NFTId>,
An auto-generated getter for EscrowedNfts.
Trait Implementations§
source§impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
source§type InCodeStorageVersion = NoStorageVersionSet
type InCodeStorageVersion = NoStorageVersionSet
source§fn in_code_storage_version() -> Self::InCodeStorageVersion
fn in_code_storage_version() -> Self::InCodeStorageVersion
storage_version attribute, or
[NoStorageVersionSet] if the attribute is missing.source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version and will be removed after March 2024.Self::current_storage_version] instead. Read moresource§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize]). Read more§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive pallet. Read more§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test].source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize].source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Hooks::on_initialize].source§impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade].source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey> indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> Freeze for Pallet<T>
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read more§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.