Skip to content

Commit

Permalink
Document ERC721ReceiverComponent (#945)
Browse files Browse the repository at this point in the history
* docs: ERC1155ReceiverComponent added

* feat: update CHANGELOG

* feat: apply update reviews

* fix: CHANGELOG

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

Co-authored-by: Andrew Fleming <[email protected]>

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

Co-authored-by: Andrew Fleming <[email protected]>

---------

Co-authored-by: Andrew Fleming <[email protected]>
  • Loading branch information
ericnordelo and andrew-fleming authored Mar 22, 2024
1 parent 07afeae commit 9f14829
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- ERC721ReceiverComponent documentation (#945)

### Changed

- Bump scarb to v2.6.3 (#946)

### Fixed

- ERC721ReceiverComponent mixin embeddable implementation name (#945)

## 0.10.0 (2024-03-07)

### Added
Expand Down
13 changes: 0 additions & 13 deletions docs/modules/ROOT/pages/api/erc1155.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ NOTE: {src5-component-required-note}
[.sub-index#ERC1155Component-Embeddable-Impls-ERC1155MetadataURIImpl]
.ERC1155MetadataURIImpl
* xref:#ERC1155Component-uri[`++uri(self, token_id)++`]
--

[.contract-index#ERC1155Component-Embeddable-Impls-camelCase]
.Embeddable implementations (camelCase)
--
[.sub-index#ERC1155Component-Embeddable-Impls-ER1155CamelImpl]
.ER1155CamelImpl
* xref:#ERC1155Component-balanceOf[`++balanceOf(self, account, tokenId)++`]
Expand Down Expand Up @@ -316,8 +312,6 @@ on the token type ID substitution mechanism
Clients calling this function must replace the `\{id\}` substring with the
actual token type ID.

==== camelCase Support

[.contract-item]
[[ERC1155Component-balanceOf]]
==== `[.contract-item-name]#++balanceOf++#++(self: @ContractState, account: ContractAddress, tokenId: u256) → u256++` [.item-kind]#external#
Expand Down Expand Up @@ -559,11 +553,7 @@ NOTE: {src5-component-required-note}
.ERC1155ReceiverImpl
* xref:#ERC1155ReceiverComponent-on_erc1155_received[`++on_erc1155_received(self, operator, from, token_id, value, data)++`]
* xref:#ERC1155ReceiverComponent-on_erc1155_batch_received[`++on_erc1155_batch_received(self, operator, from, token_ids, values, data)++`]
--

[.contract-index#ERC1155ReceiverComponent-Embeddable-Impls-camelCase]
.Embeddable implementations (camelCase)
--
.ERC1155ReceiverCamelImpl
* xref:#ERC1155ReceiverComponent-onERC1155Received[`++onERC1155Received(self, operator, from, tokenId, value, data)++`]
* xref:#ERC1155ReceiverComponent-onERC1155BatchReceived[`++onERC1155BatchReceived(self, operator, from, tokenIds, values, data)++`]
Expand All @@ -590,9 +580,6 @@ Returns the `IERC1155Receiver` interface ID.

Returns the `IERC1155Receiver` interface ID.

==== camelCase Support


[.contract-item]
[[ERC1155ReceiverComponent-onERC1155Received]]
==== `[.contract-item-name]#++onERC1155Received++#++(operator: ContractAddress, from: ContractAddress, token_id: u256, value: u256, data Span<felt252>) -> felt252++` [.item-kind]#external#
Expand Down
66 changes: 66 additions & 0 deletions docs/modules/ROOT/pages/api/erc721.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ See <<IERC721-ApprovalForAll,IERC721::ApprovalForAll>>.

See <<IERC721-Transfer,IERC721::Transfer>>.

== Receiver

[.contract]
[[IERC721Receiver]]
=== `++IERC721Receiver++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.10.0/src/token/erc721/interface.cairo#L70-L79[{github-icon},role=heading-link]
Expand Down Expand Up @@ -620,6 +622,70 @@ Interface for contracts that support receiving `safe_transfer_from` transfers.

Whenever an IERC721 `token_id` token is transferred to this non-account contract via <<IERC721-safe_transfer_from,IERC721::safe_transfer_from>> by `operator` from `from`, this function is called.

[.contract]
[[ERC721ReceiverComponent]]
=== `++ERC721ReceiverComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.10.0/src/token/erc721/erc721_receiver.cairo[{github-icon},role=heading-link]

[.hljs-theme-dark]
```javascript
use openzeppelin::token::erc721::ERC721ReceiverComponent;
```

ERC721Receiver component implementing <<IERC721Receiver,IERC721Receiver>>.

NOTE: {src5-component-required-note}

[.contract-index#ERC721ReceiverComponent-Embeddable-Mixin-Impl]
.{mixin-impls}

--
.ERCReceiverMixinImpl
* xref:#ERC721ReceiverComponent-Embeddable-Impls-ERC721ReceiverImpl[`++ERC721ReceiverImpl++`]
* xref:#ERC721ReceiverComponent-Embeddable-Impls-ERC721ReceiverCamelImpl[`++ERC721ReceiverCamelImpl++`]
* xref:api/introspection.adoc#SRC5Component-Embeddable-Impls[`++SRC5Impl++`]
--

[.contract-index#ERC721ReceiverComponent-Embeddable-Impls]
.Embeddable Implementations
--
[.sub-index#ERC721ReceiverComponent-Embeddable-Impls-ERC721ReceiverImpl]
.ERC721ReceiverImpl
* xref:#ERC721ReceiverComponent-on_erc721_received[`++on_erc721_received(self, operator, from, token_id, data)++`]

[.sub-index#ERC721ReceiverComponent-Embeddable-Impls-ERC721ReceiverCamelImpl]
.ERC721ReceiverCamelImpl
* xref:#ERC721ReceiverComponent-onERC721Received[`++onERC721Received(self, operator, from, tokenId, data)++`]
--

[.contract-index]
.Internal Functions
--
.InternalImpl
* xref:#ERC721ReceiverComponent-initializer[`++initializer(self)++`]
--

==== Embeddable functions

[.contract-item]
[[ERC721ReceiverComponent-on_erc721_received]]
==== `[.contract-item-name]#++on_erc721_received++#++(self: @ContractState, operator: ContractAddress, from: ContractAddress, token_id: u256, data Span<felt252>) -> felt252++` [.item-kind]#external#

Returns the `IERC721Receiver` interface ID.

[.contract-item]
[[ERC721ReceiverComponent-onERC721Received]]
==== `[.contract-item-name]#++onERC721Received++#++(self: @ContractState, operator: ContractAddress, from: ContractAddress, token_id: u256, data Span<felt252>) -> felt252++` [.item-kind]#external#

See <<ERC721ReceiverComponent-on_erc721_received,ERC721ReceiverComponent::on_erc721_received>>.

==== Internal functions

[.contract-item]
[[ERC721ReceiverComponent-initializer]]
==== `[.contract-item-name]#++initializer++#++(ref self: ContractState)++` [.item-kind]#internal#

Registers the `IERC721Receiver` interface ID as supported through introspection.

== Presets

[.contract]
Expand Down
2 changes: 1 addition & 1 deletion src/token/erc721/erc721_receiver.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mod ERC721ReceiverComponent {
}
}

#[embeddable_as(ERC721ReceiverAMixinmpl)]
#[embeddable_as(ERC721ReceiverMixinImpl)]
impl ERC721ReceiverMixin<
TContractState,
+HasComponent<TContractState>,
Expand Down

0 comments on commit 9f14829

Please sign in to comment.