0x0::plugins

Module of the PluginDomain for extending collection contracts

A plugin is a smart contract which extends the functionality of the collection base contract by obtaining an instance of the collection Witness type. Plugins are thus able to implement custom logic for collections post-deployment. This solves the issue that after a package is deployed, it can no longer leverage witness protected API.

Structs

plugins::PluginDomain<C> has store

Fields:

Name Type Description
generator witness::WitnessGenerator<C>

Generator responsible for issuing delegated witnesses

packages vec_set::VecSet<type_name::TypeName>

Witnesses that have the ability to mutate standard domains

plugins::Witness has drop

Witness used to authenticate witness protected endpoints

Methods

public fun add_plugin<C, PluginWitness>(
    _witness: witness::Witness<C>,
    collection: &mut collection::Collection<C>,
)

Attributes witness as a plugin on the Collection

Panics

Panics if witness was already attributed or PluginDomain is not registered on the Collection.

public fun remove_plugin<C, PluginWitness>(
    _witness: witness::Witness<C>,
    collection: &mut collection::Collection<C>,
)

Removes witness as a plugin on the Collection

Panics

Panics if witness was not attributed or PluginDomain is not registered on the Collection.

public fun delegate<C, PluginWitness>(
    _witness: &PluginWitness,
    collection: &mut collection::Collection<C>,
): witness::Witness<C>

Create a delegated witness

Delegated witness can be used to authorize mutating operations across most OriginByte domains.

Panics

Panics if plugin witness was not a plugin or CreatorsDomain was not registered on the Collection.

public fun contains_plugin<C, PluginWitness>(
    domain: &plugins::PluginDomain<C>,
): bool

Returns whether witness is a defined plugin

public fun borrow_plugins<C>(
    domain: &plugins::PluginDomain<C>,
): &vec_set::VecSet<type_name::TypeName>

Returns list of all defined plugins

public fun borrow_plugin_domain<C>(
    collection: &collection::Collection<C>,
): &plugins::PluginDomain<C>

Borrows PluginDomain from Collection

Panics

Panics if PluginDomain is not registered on Collection.

public fun add_plugin_domain<C, W>(
    witness: &W,
    collection: &mut collection::Collection<C>,
)

Adds PluginDomain to Collection

Panics

Panics if CreatorsDomain already exists.

public fun assert_plugin<C, PluginWitness>(
    domain: &plugins::PluginDomain<C>,
)

Asserts that witness is attributed in PluginDomain

Panics

Panics if PluginDomain is not defined or witness is not a plugin.

public fun assert_domain<C>(
    collection: &collection::Collection<C>,
)

Asserts that PluginDomain is defined on the Collection

Panics

Panics if PluginDomain is not defined on the Collection.