Skip to content

Commit 70d7e37

Browse files
nep-393: add class metadata interface
1 parent f2f981a commit 70d7e37

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

neps/nep-0393.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,23 @@ pub struct ContractMetadata {
290290
pub reference_hash: Option<Base64VecU8>,
291291
}
292292

293+
pub struct ClassMetadata {
294+
/// Issuer class name. Required.
295+
pub name: String,
296+
/// If defined, should be used instead of `contract_metadata.symbol`.
297+
pub symbol: Option<String>,
298+
/// An URL to an Icon. To protect fellow developers from unintentionally triggering any
299+
/// SSRF vulnerabilities with URL parsers, we don't allow to set an image bytes here.
300+
/// If it doesn't start with a scheme (eg: https://)
301+
/// then `contract_metadata.base_uri` should be prepended.
302+
pub icon: Option<String>,
303+
/// JSON or an URL to a JSON file with more info. If it doesn't start with a scheme
304+
/// (eg: https://) then base_uri should be prepended.
305+
pub reference: Option<String>,
306+
/// Base64-encoded sha256 hash of JSON from reference field. Required if `reference` is included.
307+
pub reference_hash: Option<Base64VecU8>,
308+
}
309+
293310
/// TokenMetadata defines attributes for each SBT token.
294311
pub struct TokenMetadata {
295312
pub class: ClassId, // token class. Required. Must be non zero.
@@ -448,12 +465,18 @@ Example **Soul Transfer** interface:
448465

449466
### SBT Issuer interface
450467

451-
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).
468+
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).
469+
470+
The issuer must provide metadata object of the Issuer. Optionally, Issuer can also provide metadata object for each token class.
471+
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.
472+
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`.
452473

453474
```rust
454-
pub trait SBTContract {
475+
pub trait SBTIssuer {
455476
/// returns contract metadata
456477
fn sbt_metadata(&self) -> ContractMetadata;
478+
/// returns sbt class metadata, or None if class is not found.
479+
fn sbt_class_metadata(&self, class: ClassId) -> Option<ClassMetadata>;
457480
}
458481
```
459482

0 commit comments

Comments
 (0)