diff --git a/standards/src_7/README.md b/standards/src_7/README.md index e862227..0e74141 100644 --- a/standards/src_7/README.md +++ b/standards/src_7/README.md @@ -29,23 +29,27 @@ 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 `Metadata` enum: -### - `StringData: String` +### - `B256` -The `StringData` variant SHALL be used when the stored metadata for the corresponding asset and `String` key pair is of the `String` type. The `StringData` variant MUST be used when a URI is required but MAY contain any arbitrary `String`. +The `B256` variant SHALL be used when the stored metadata for the corresponding `AssetId` and `Sting` key pair is of the `b256` type. -### - `IntData: u64` +### - `Bytes` -The `IntData` variant SHALL be used when the stored metadata for the corresponding asset and `Sting` key pair is of the `u64` type. +The `Bytes` variant SHALL be used when the stored metadata for the corresponding `AssetId` and `String` key pair is of the `Bytes` type. The `Bytes` variant should be used when storing custom data such as but not limited to structs and enums. -### - `BytesData: Bytes` +### - `Int` -The `BytesData` variant SHALL be used when the stored metadata for the corresponding asset and `String` key pair is of the `Bytes` type. The `BytesData` variant should be used when storing custom data such as but not limited to structs and enums. +The `Int` variant SHALL be used when the stored metadata for the corresponding `AssetId` and `Sting` key pair is of the `u64` type. + +### - `String` + +The `String` variant SHALL be used when the stored metadata for the corresponding `AssetId` and `String` key pair is of the `String` type. The `String` variant MUST be used when a URI is required but MAY contain any arbitrary `String` data. ## Require Functions ### `fn metadata(asset: AssetId, key: String) -> Option` -This function MUST return valid metadata for the corresponding `asset` and `key`, where the data is either a `StringData`, `IntData`, or `BytesData` variant. If the asset does not exist or 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 `B256`, `Bytes`, `Int`, or `String` variant. If the asset does not exist or no metadata exists, the function MUST return `None`. # Rationale diff --git a/standards/src_7/src/src_7.sw b/standards/src_7/src/src_7.sw index f5b7218..bb4a473 100644 --- a/standards/src_7/src/src_7.sw +++ b/standards/src_7/src/src_7.sw @@ -33,25 +33,30 @@ abi SRC7 { /// Universal return type for metadata. pub enum Metadata { - /// Used when the stored metadata is a `String`. - StringData: String, - /// Used when the stored metadata is a `u64`. - IntData: u64, + // Used when the stored metadata is a `b256`. + B256: b256, /// Used when the stored metadata is `Bytes`. - BytesData: Bytes, + Bytes: Bytes, + /// Used when the stored metadata is a `u64`. + Int: u64, + /// Used when the stored metadata is a `String`. + String: String, } impl core::ops::Eq for Metadata { fn eq(self, other: Self) -> bool { match (self, other) { - (Metadata::StringData(string1), Metadata::StringData(string2)) => { - string1 == string2 + (Metadata::B256(bytes1), Metadata::B256(bytes2)) => { + bytes1 == bytes2 + }, + (Metadata::Bytes(bytes1), Metadata::Bytes(bytes2)) => { + bytes1 == bytes2 }, - (Metadata::IntData(int1), Metadata::IntData(int2)) => { + (Metadata::Int(int1), Metadata::Int(int2)) => { int1 == int2 }, - (Metadata::BytesData(bytes1), Metadata::BytesData(bytes2)) => { - bytes1 == bytes2 + (Metadata::String(string1), Metadata::String(string2)) => { + string1 == string2 }, _ => false, }