Skip to content

Commit

Permalink
nep-393: add class metadata interface
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Jan 25, 2024
1 parent f2f981a commit 70d7e37
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions neps/nep-0393.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ pub struct ContractMetadata {
pub reference_hash: Option<Base64VecU8>,
}

pub struct ClassMetadata {
/// Issuer class name. Required.
pub name: String,
/// If defined, should be used instead of `contract_metadata.symbol`.
pub symbol: Option<String>,
/// An URL to an Icon. To protect fellow developers from unintentionally triggering any
/// SSRF vulnerabilities with URL parsers, we don't allow to set an image bytes here.
/// If it doesn't start with a scheme (eg: https://)
/// then `contract_metadata.base_uri` should be prepended.
pub icon: Option<String>,
/// JSON or an URL to a JSON file with more info. If it doesn't start with a scheme
/// (eg: https://) then base_uri should be prepended.
pub reference: Option<String>,
/// Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included.
pub reference_hash: Option<Base64VecU8>,
}

/// TokenMetadata defines attributes for each SBT token.
pub struct TokenMetadata {
pub class: ClassId, // token class. Required. Must be non zero.
Expand Down Expand Up @@ -448,12 +465,18 @@ Example **Soul Transfer** interface:

### SBT Issuer interface

SBTContract is the minimum required interface to be implemented by issuer. Other methods, such as a mint function, which requests the registry to proceed with token minting, is specific to an Issuer implementation (similarly, mint is not part of the FT standard).
SBTIssuer is the minimum required interface to be implemented by issuer. Other methods, such as a mint function, which requests the registry to proceed with token minting, is specific to an Issuer implementation (similarly, mint is not part of the FT standard).

The issuer must provide metadata object of the Issuer. Optionally, Issuer can also provide metadata object for each token class.
Issuer level (contract) metadata, must provide information common to all tokens and all classes defined by the issuer. Class level metadata, must provide information common to all tokens of a given class. Information should be deduplicated and denormalized whenever possible.
Example: if all tokens of a give class share the same symbol and icon, then both icon and symbol must be defined in the `ClassMetadata` and left empty (`None`) in the token metadata level. If a particular SBT (token) has to have unique icon, but we would like to keep a default icon for all tokens of a given issuer, then we can have default icon defined in the `ContractMetadata.icon` and each SBT, that has to have different icon, can have it specified in `TokenMetadata.icon`.

```rust
pub trait SBTContract {
pub trait SBTIssuer {
/// returns contract metadata
fn sbt_metadata(&self) -> ContractMetadata;
/// returns sbt class metadata, or None if class is not found.
fn sbt_class_metadata(&self, class: ClassId) -> Option<ClassMetadata>;
}
```

Expand Down

0 comments on commit 70d7e37

Please sign in to comment.