Skip to content

Commit

Permalink
Updates to address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzoic committed Sep 7, 2023
1 parent f1eb130 commit 8f7ab8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions standards/src_7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ We also take a look at existing common metadata practices such as [OpenSea's Met

The following describes an enum that wraps various metadata types into a single return type. There SHALL be the following variants in the `MetadataType` enum:

### - `String: String`
### - `StringData: String`

The **String** variant SHALL be used when the stored metadata for the corresponding asset and key is of the `String` type. The **String** variant MUST be used when a URI is required but MAY contain any arbitrary `String`.
The `StringData` variant SHALL be used when the stored metadata for the corresponding asset and key is of the `String` type. The `StringData` variant MUST be used when a URI is required but MAY contain any arbitrary `String`.

### - `Int: u64`
### - `IntData: u64`

The **Int** variant SHALL be used when the stored metadata for the corresponding asset and key is of the `u64` type.
The `IntData` variant SHALL be used when the stored metadata for the corresponding asset and key is of the `u64` type.

### - `Bytes: Bytes`
### - `BytesData: Bytes`

The **Bytes** variant SHALL be used when the stored metadata for the corresponding asset and key is of the `Bytes` type. The **Bytes** variant should be used when storing custom data such as but not limited to structs and enums.
The `BytesData` variant SHALL be used when the stored metadata for the corresponding asset and key is of the `Bytes` type. The `BytesData` variant should be used when storing custom data such as but not limited to structs and enums.

## Require Functions

### `fn metadata(asset: AssetId, key: String) -> Option<MetadataType>`

This function MUST return valid metadata for the corresponding `asset` and `key`, where the data is either a `String`, `Int`, or `Bytes` variant. If no metadata exists, the function MUST return `None`.
This function MUST return valid metadata for the corresponding `asset` and `key`, where the data is either a `StringData`, `IntData`, or `BytesData` variant. If no metadata exists, the function MUST return `None`.

# Rationale

Expand Down
10 changes: 5 additions & 5 deletions standards/src_7/src/src_7.sw
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ abi SRC7 {
/// use src_7::{SRC7, MetadataType};
/// use std::string::String;
///
/// fn foo(contract: ContractId, asset: AssetId) {
/// let contract_abi = abi(SRC7, contract);
/// fn foo(contract_id: ContractId, asset: AssetId) {
/// let contract_abi = abi(SRC7, contract_id);
/// let key = String::from_ascii_str("image");
/// let data = contract_abi.metadata(asset, key);
/// assert(data.is_some());
Expand All @@ -34,9 +34,9 @@ abi SRC7 {
/// Universal return type for metadata.
pub enum MetadataType {
/// Used when the stored metadata is a `String`.
String: String,
StringData: String,
/// Used when the stored metadata is a `u64`.
Int: u64,
IntData: u64,
/// Used when the stored metadata is a `u64`.
Bytes: Bytes,
BytesData: Bytes,
}

0 comments on commit 8f7ab8a

Please sign in to comment.