Skip to content

Commit eacbd42

Browse files
committed
applied suggestions fixed documentation
1 parent 344194b commit eacbd42

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

CHANGELOG.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
### Added (2024-07-10)
2626

27-
- ERC721URIStorage (2024-07-10) in `/src/token/erc721/extensions`
28-
- ERC721URIStorage mock in `/src/tests/mocks/`
29-
- ERC721URIStorage tests in `/src/tests/token/erc721/`
30-
- Documentation for ERC721URIStorage extension in `/docs/modules/ROOT/api/erc721`
27+
- ERC721URIStorage (#1031)
3128

3229
## 0.14.0 (2024-06-14)
3330

docs/modules/ROOT/pages/api/erc721.adoc

+7-7
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,14 @@ use openzeppelin::token::extensions::ERC721URIStorageComponent;
701701

702702
:MetadataUpdated: xref:ERC721URIStorageComponent-MetadataUpdated[MetadataUpdated]
703703

704-
Extension of ERC721 to support dynamic NFTs.
704+
Extension of ERC721 to support storage-based URI management.
705705
It is an implementation of <<IERC721Metadata, IERC721Metadata>> but with a different `token_uri` behavior.
706706

707707
NOTE: Implementing xref:#ERC721Component[ERC721Component] is a requirement for this component to be implemented.
708708

709-
This extension keeps a track of URIs of each token id of a particular ERC721 token. The URI of any `token_id` can be set by calling the
710-
internal function, xref:#ERC721URIStorageComponent-set_token_uri[set_token_uri]. Updated `token_uri` can be queried through the external function
711-
xref:#ERC721URIStorageComponent-token_uri[token_uri].
709+
The ERC721URIStorage component provides a flexible IERC721Metadata implementation that enables storage-based token URI management.
710+
The URI of any `token_id` can be set by calling the internal function, xref:#ERC721URIStorageComponent-set_token_uri[set_token_uri].
711+
Updated `token_uri` can be queried through the external function xref:#ERC721URIStorageComponent-token_uri[token_uri].
712712

713713
[.contract-index#ERC721URIStorageComponent-Embeddable-Impls]
714714
.Embeddable Implementations
@@ -757,11 +757,11 @@ See <<IERC721Metadata-symbol,IERC721::symbol>>.
757757
Returns the Uniform Resource Identifier (URI) for the `token_id` token.
758758

759759

760-
If a base URI is set and the token URI is set , the resulting URI for each token will be the concatenation of the base URI and the token URI.
760+
If a base URI is set and the token URI is set, the resulting URI for each token will be the concatenation of the base URI and the token URI.
761761

762-
If a base URI is set and the token URI is not set , the resulting URI for each token will be the concatenation of the base URI and the `token_id`.
762+
If a base URI is set and the token URI is not set, the resulting URI for each token will be the concatenation of the base URI and the `token_id`.
763763

764-
If a base URI is not set and the token URI is set , the resulting URI for each token will be the token URI.
764+
If a base URI is not set and the token URI is set, the resulting URI for each token will be the token URI.
765765

766766
If the base URI and token URI are not set for `token_id`, the return value will be an empty `ByteArray`.
767767

src/tests/token/erc721/test_erc721_uri_storage.cairo

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn COMPONENT_STATE() -> ComponentState {
2727
ERC721URIStorageComponent::component_state_for_testing()
2828
}
2929

30-
//constructor is inside only
3130
fn setup() -> ComponentState {
3231
let mut state = COMPONENT_STATE();
3332
let mut mock_state = CONTRACT_STATE();
@@ -73,7 +72,7 @@ fn test_set_token_uri_nonexistent() {
7372
assert_only_event_metadata_update(ZERO(), TOKEN_ID_2);
7473

7574
let mut mock_contract_state = CONTRACT_STATE();
76-
//check accessible after minting
75+
// Check that the URI is accessible after minting
7776
mock_contract_state.erc721.mint(RECIPIENT(), TOKEN_ID_2);
7877

7978
let expected = SAMPLE_URI();
@@ -142,7 +141,7 @@ fn test_token_uri_persists_when_burned_and_minted() {
142141
// Helpers
143142
//
144143

145-
pub fn assert_event_metadata_update(contract: ContractAddress, token_id: u256) {
144+
fn assert_event_metadata_update(contract: ContractAddress, token_id: u256) {
146145
let event = utils::pop_log::<ERC721URIStorageComponent::Event>(contract).unwrap();
147146
let expected = ERC721URIStorageComponent::Event::MetadataUpdated(MetadataUpdated { token_id });
148147
assert!(event == expected);

src/tests/utils/constants.cairo

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub(crate) fn BASE_URI_2() -> ByteArray {
4545
"https://api.example.com/v2/"
4646
}
4747

48-
4948
pub(crate) fn SAMPLE_URI() -> ByteArray {
5049
"mock://mytoken"
5150
}

src/token/erc721/extensions/erc721_uri_storage.cairo

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
/// # ERC721URIStorage Component
55
///
6-
/// The ERC721URIStorage component enhances ERC721 tokens by keeping track of unique URIs with each token id,
7-
/// and providing a functionality of metadata updates. Each token's URI, set during minting, is immutable, ensuring
8-
/// the integrity of the metadata. It provides a reliable mechanism for linking on-chain tokens to off-chain metadata.
9-
6+
/// The ERC721URIStorage component provides a flexible IERC721Metadata implementation that enables
7+
/// storage-based token URI management.
108
#[starknet::component]
119
pub mod ERC721URIStorageComponent {
1210
use openzeppelin::introspection::src5::SRC5Component;
@@ -64,12 +62,12 @@ pub mod ERC721URIStorageComponent {
6462
let base_uri: ByteArray = ERC721Impl::_base_uri(erc721_component);
6563
let token_uri: ByteArray = self.ERC721URIStorage_token_uris.read(token_id);
6664

67-
// If there is no base_uri, return the token_uri.
65+
// If there is no base_uri, return the token_uri
6866
if base_uri.len() == 0 {
6967
return token_uri;
7068
}
7169

72-
// If both are set, concatenate the base_uri and token_uri.
70+
// If both are set, concatenate the base_uri and token_uri
7371
if token_uri.len() > 0 {
7472
return format!("{}{}", base_uri, token_uri);
7573
}
@@ -91,7 +89,7 @@ pub mod ERC721URIStorageComponent {
9189
+ERC721Component::HasComponent<TContractState>,
9290
+Drop<TContractState>
9391
> of InternalTrait<TContractState> {
94-
/// Sets or updates the `token_uri` for the respective `token_id`
92+
/// Sets or updates the `token_uri` for the respective `token_id`.
9593
///
9694
/// Emits `MetadataUpdated` event.
9795
fn set_token_uri(

0 commit comments

Comments
 (0)