From 98c1f48648f18da266bbc12f19fe775aef950298 Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Sun, 5 Nov 2023 17:25:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Upgrade=20dojo=20to=20latest=20t?= =?UTF-8?q?ag=20and=20WIP=20on=20presets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- Scarb.toml | 2 +- presets/{token => }/.gitignore | 0 presets/Scarb.lock | 27 ++++ presets/Scarb.toml | 9 ++ .../src/token => src/erc1155}/erc1155.cairo | 0 .../erc1155}/erc1155/erc1155.cairo | 0 .../erc1155}/erc1155/interface.cairo | 0 .../erc1155}/erc1155/models.cairo | 0 .../erc1155/tests.cairo} | 0 .../src/token => src/erc20}/erc20.cairo | 31 +--- .../erc20/models.cairo} | 14 +- .../erc20/tests.cairo} | 0 .../src/token => src}/erc721/erc721.cairo | 133 ++++++++---------- .../src/token => src}/erc721/models.cairo | 2 + .../erc721/tests.cairo} | 41 ++++-- presets/src/lib.cairo | 13 ++ presets/{token => }/src/tests/constants.cairo | 0 .../{token => }/src/tests/test_erc1155.cairo | 0 .../{token => }/src/tests/test_erc721.cairo | 0 presets/{token => }/src/tests/utils.cairo | 0 presets/token/Scarb.lock | 20 --- presets/token/Scarb.toml | 29 ---- presets/token/src/lib.cairo | 17 --- presets/token/src/token/erc721.cairo | 5 - .../token/src/token/erc721/interface.cairo | 60 -------- 26 files changed, 147 insertions(+), 258 deletions(-) rename presets/{token => }/.gitignore (100%) create mode 100644 presets/Scarb.lock create mode 100644 presets/Scarb.toml rename presets/{token/src/token => src/erc1155}/erc1155.cairo (100%) rename presets/{token/src/token => src/erc1155}/erc1155/erc1155.cairo (100%) rename presets/{token/src/token => src/erc1155}/erc1155/interface.cairo (100%) rename presets/{token/src/token => src/erc1155}/erc1155/models.cairo (100%) rename presets/{token/src/tests/erc1155_tests.cairo => src/erc1155/tests.cairo} (100%) rename presets/{token/src/token => src/erc20}/erc20.cairo (90%) rename presets/{token/src/token/erc20_models.cairo => src/erc20/models.cairo} (59%) rename presets/{token/src/tests/erc20_tests.cairo => src/erc20/tests.cairo} (100%) rename presets/{token/src/token => src}/erc721/erc721.cairo (79%) rename presets/{token/src/token => src}/erc721/models.cairo (97%) rename presets/{token/src/tests/erc721_tests.cairo => src/erc721/tests.cairo} (98%) create mode 100644 presets/src/lib.cairo rename presets/{token => }/src/tests/constants.cairo (100%) rename presets/{token => }/src/tests/test_erc1155.cairo (100%) rename presets/{token => }/src/tests/test_erc721.cairo (100%) rename presets/{token => }/src/tests/utils.cairo (100%) delete mode 100644 presets/token/Scarb.lock delete mode 100644 presets/token/Scarb.toml delete mode 100644 presets/token/src/lib.cairo delete mode 100644 presets/token/src/token/erc721.cairo delete mode 100644 presets/token/src/token/erc721/interface.cairo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36d683d3..61e4d579 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Check on: [push, pull_request] env: - DOJO_VERSION: v0.3.3 + DOJO_VERSION: v0.3.4 SCARB_VERSION: v2.3.1 jobs: diff --git a/Scarb.toml b/Scarb.toml index a3157149..bdb31d56 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -9,4 +9,4 @@ members = [ ] [workspace.dependencies] -dojo = { git = "https://github.com/dojoengine/dojo.git", tag = "v0.3.3" } \ No newline at end of file +dojo = { git = "https://github.com/dojoengine/dojo.git", tag = "v0.3.4" } \ No newline at end of file diff --git a/presets/token/.gitignore b/presets/.gitignore similarity index 100% rename from presets/token/.gitignore rename to presets/.gitignore diff --git a/presets/Scarb.lock b/presets/Scarb.lock new file mode 100644 index 00000000..3a767aec --- /dev/null +++ b/presets/Scarb.lock @@ -0,0 +1,27 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "0.3.4" +source = "git+https://github.com/dojoengine/dojo.git?rev=d62ec8a#d62ec8a522f92d0a0ccf226c6e929bb918b31128" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.4" + +[[package]] +name = "openzeppelin" +version = "0.8.0-beta.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?rev=4eafccf#4eafccf107f98d975b20cbb6544b2a998e5f403f" + +[[package]] +name = "presets" +version = "0.0.0" +dependencies = [ + "dojo", + "openzeppelin", +] diff --git a/presets/Scarb.toml b/presets/Scarb.toml new file mode 100644 index 00000000..67dbbe95 --- /dev/null +++ b/presets/Scarb.toml @@ -0,0 +1,9 @@ +[package] +name = "presets" +version = "0.0.0" +description = "Implementations of ERC standards for the Dojo framework." +homepage = "https://github.com/dojoengine/origami/tree/presets" + +[dependencies] +dojo = { git = "https://github.com/dojoengine/dojo.git", rev = "d62ec8a" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "4eafccf" } \ No newline at end of file diff --git a/presets/token/src/token/erc1155.cairo b/presets/src/erc1155/erc1155.cairo similarity index 100% rename from presets/token/src/token/erc1155.cairo rename to presets/src/erc1155/erc1155.cairo diff --git a/presets/token/src/token/erc1155/erc1155.cairo b/presets/src/erc1155/erc1155/erc1155.cairo similarity index 100% rename from presets/token/src/token/erc1155/erc1155.cairo rename to presets/src/erc1155/erc1155/erc1155.cairo diff --git a/presets/token/src/token/erc1155/interface.cairo b/presets/src/erc1155/erc1155/interface.cairo similarity index 100% rename from presets/token/src/token/erc1155/interface.cairo rename to presets/src/erc1155/erc1155/interface.cairo diff --git a/presets/token/src/token/erc1155/models.cairo b/presets/src/erc1155/erc1155/models.cairo similarity index 100% rename from presets/token/src/token/erc1155/models.cairo rename to presets/src/erc1155/erc1155/models.cairo diff --git a/presets/token/src/tests/erc1155_tests.cairo b/presets/src/erc1155/tests.cairo similarity index 100% rename from presets/token/src/tests/erc1155_tests.cairo rename to presets/src/erc1155/tests.cairo diff --git a/presets/token/src/token/erc20.cairo b/presets/src/erc20/erc20.cairo similarity index 90% rename from presets/token/src/token/erc20.cairo rename to presets/src/erc20/erc20.cairo index 238e05a1..d21be836 100644 --- a/presets/token/src/token/erc20.cairo +++ b/presets/src/erc20/erc20.cairo @@ -1,40 +1,21 @@ -use starknet::ContractAddress; - -#[starknet::interface] -trait IERC20 { - fn name(self: @TState) -> felt252; - fn symbol(self: @TState) -> felt252; - fn decimals(self: @TState) -> u8; - fn total_supply(self: @TState) -> u256; - fn balance_of(self: @TState, account: ContractAddress) -> u256; - fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256; - fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool; - fn transfer_from( - ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256 - ) -> bool; - fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool; -} +// External imports -trait IERC20CamelOnly { - fn totalSupply(self: @TState) -> u256; - fn balanceOf(self: @TState, account: ContractAddress) -> u256; - fn transferFrom( - ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256 - ) -> bool; -} +use openzeppelin::token::erc20::interface; #[starknet::contract] mod ERC20 { use dojo_erc::token::erc20_models::{ERC20Allowance, ERC20Balance, ERC20Meta}; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; use integer::BoundedInt; - use super::IERC20; - use super::IERC20CamelOnly; use starknet::ContractAddress; use starknet::{get_caller_address, get_contract_address}; use zeroable::Zeroable; use debug::PrintTrait; + // Local imports + + use super::interface::{IERC20, IERC20CamelOnly}; + #[storage] struct Storage { diff --git a/presets/token/src/token/erc20_models.cairo b/presets/src/erc20/models.cairo similarity index 59% rename from presets/token/src/token/erc20_models.cairo rename to presets/src/erc20/models.cairo index ab68718d..f19cda5c 100644 --- a/presets/token/src/token/erc20_models.cairo +++ b/presets/src/erc20/models.cairo @@ -1,29 +1,27 @@ -use starknet::ContractAddress; - #[derive(Model, Copy, Drop, Serde)] struct ERC20Balance { #[key] - token: ContractAddress, + token: starknet::ContractAddress, #[key] - account: ContractAddress, + account: starknet::ContractAddress, amount: u256, } #[derive(Model, Copy, Drop, Serde)] struct ERC20Allowance { #[key] - token: ContractAddress, + token: starknet::ContractAddress, #[key] - owner: ContractAddress, + owner: starknet::ContractAddress, #[key] - spender: ContractAddress, + spender: starknet::ContractAddress, amount: u256, } #[derive(Model, Copy, Drop, Serde)] struct ERC20Meta { #[key] - token: ContractAddress, + token: starknet::ContractAddress, name: felt252, symbol: felt252, total_supply: u256, diff --git a/presets/token/src/tests/erc20_tests.cairo b/presets/src/erc20/tests.cairo similarity index 100% rename from presets/token/src/tests/erc20_tests.cairo rename to presets/src/erc20/tests.cairo diff --git a/presets/token/src/token/erc721/erc721.cairo b/presets/src/erc721/erc721.cairo similarity index 79% rename from presets/token/src/token/erc721/erc721.cairo rename to presets/src/erc721/erc721.cairo index ffd7915d..57f84720 100644 --- a/presets/token/src/token/erc721/erc721.cairo +++ b/presets/src/erc721/erc721.cairo @@ -1,29 +1,71 @@ +// External imports + +use openzeppelin::token::erc721::interface; + #[starknet::contract] mod ERC721 { - use dojo_erc::token::erc721::models::{ - ERC721Meta, ERC721OperatorApproval, ERC721Owner, ERC721Balance, ERC721TokenApproval - }; - use dojo_erc::token::erc721::interface; - use dojo_erc::token::erc721::interface::{IERC721, IERC721CamelOnly}; - use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; + // Core imports + use integer::BoundedInt; + use zeroable::Zeroable; + + // Starknet imports + use starknet::ContractAddress; use starknet::{get_caller_address, get_contract_address}; - use zeroable::Zeroable; - use debug::PrintTrait; + // Dojo imports + + use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; + + // External imports + + use openzeppelin::token::erc721::erc721::ERC721; + use openzeppelin::introspection::interface::{ISRC5, ISRC5Camel}; + use openzeppelin::introspection::src5::SRC5Component; + + // Internal imports + + use presets::erc721::models::{ + ERC721Meta, + ERC721OperatorApproval, + ERC721Owner, + ERC721Balance, + ERC721TokenApproval, + }; + + // Local imports + + use super::interface; + + // Components + + component!(path: SRC5Component, storage: src5, event: SRC5Event); + #[abi(embed_v0)] + impl SRC5Impl = SRC5Component::SRC5Impl; + #[abi(embed_v0)] + impl SRC5CamelImpl = SRC5Component::SRC5CamelImpl; + impl SRC5InternalImpl = SRC5Component::InternalImpl; + impl SRC5EventCopy of Copy {} + + // Storage #[storage] struct Storage { _world: ContractAddress, + #[substorage(v0)] + src5: SRC5Component::Storage } + // Events + #[event] #[derive(Copy, Drop, starknet::Event)] enum Event { Transfer: Transfer, Approval: Approval, - ApprovalForAll: ApprovalForAll + ApprovalForAll: ApprovalForAll, + SRC5Event: SRC5Component::Event, } #[derive(Copy, Drop, starknet::Event)] @@ -56,8 +98,6 @@ mod ERC721 { const INVALID_RECEIVER: felt252 = 'ERC721: invalid receiver'; const ALREADY_MINTED: felt252 = 'ERC721: token already minted'; const WRONG_SENDER: felt252 = 'ERC721: wrong sender'; - const SAFE_MINT_FAILED: felt252 = 'ERC721: safe mint failed'; - const SAFE_TRANSFER_FAILED: felt252 = 'ERC721: safe transfer failed'; } #[constructor] @@ -79,22 +119,6 @@ mod ERC721 { // External // - // #[external(v0)] - // impl SRC5Impl of ISRC5 { - // fn supports_interface(self: @ContractState, interface_id: felt252) -> bool { - // let unsafe_state = src5::SRC5::unsafe_new_contract_state(); - // src5::SRC5::SRC5Impl::supports_interface(@unsafe_state, interface_id) - // } - // } - - // #[external(v0)] - // impl SRC5CamelImpl of ISRC5Camel { - // fn supportsInterface(self: @ContractState, interfaceId: felt252) -> bool { - // let unsafe_state = src5::SRC5::unsafe_new_contract_state(); - // src5::SRC5::SRC5CamelImpl::supportsInterface(@unsafe_state, interfaceId) - // } - // } - #[external(v0)] impl ERC721MetadataImpl of interface::IERC721Metadata { fn name(self: @ContractState) -> felt252 { @@ -115,8 +139,7 @@ mod ERC721 { #[external(v0)] impl ERC721MetadataCamelOnlyImpl of interface::IERC721MetadataCamelOnly { fn tokenURI(self: @ContractState, tokenId: u256) -> felt252 { - assert(self._exists(tokenId), Errors::INVALID_TOKEN_ID); - self.get_uri(tokenId) + self.token_uri(tokenId) } } @@ -178,7 +201,8 @@ mod ERC721 { assert( self._is_approved_or_owner(get_caller_address(), token_id), Errors::UNAUTHORIZED ); - self._safe_transfer(from, to, token_id, data); + // TODO: move to real safe transfer when support of SRC6 is enabled + self.transfer_from(from, to, token_id); } } @@ -312,11 +336,8 @@ mod ERC721 { fn initializer(ref self: ContractState, name: felt252, symbol: felt252, base_uri: felt252) { let meta = ERC721Meta { token: get_contract_address(), name, symbol, base_uri }; set!(self.world(), (meta)); - // let mut unsafe_state = src5::SRC5::unsafe_new_contract_state(); - // src5::SRC5::InternalImpl::register_interface(ref unsafe_state, interface::IERC721_ID); - // src5::SRC5::InternalImpl::register_interface( - // ref unsafe_state, interface::IERC721_METADATA_ID - // ); + self.src5.register_interface(interface::IERC721_ID); + self.src5.register_interface(interface::IERC721_METADATA_ID); } fn _owner_of(self: @ContractState, token_id: u256) -> ContractAddress { @@ -397,47 +418,5 @@ mod ERC721 { self.emit_event(Transfer { from: owner, to: Zeroable::zero(), token_id }); } - - fn _safe_mint( - ref self: ContractState, to: ContractAddress, token_id: u256, data: Span - ) { - self._mint(to, token_id); - // assert( - // _check_on_erc721_received(Zeroable::zero(), to, token_id, data), - // Errors::SAFE_MINT_FAILED - // ); - } - - fn _safe_transfer( - ref self: ContractState, - from: ContractAddress, - to: ContractAddress, - token_id: u256, - data: Span - ) { - self._transfer(from, to, token_id); - // assert( - // _check_on_erc721_received(from, to, token_id, data), Errors::SAFE_TRANSFER_FAILED - // ); - } - // fn _set_token_uri(ref self: ContractState, token_id: u256, token_uri: felt252) { - // assert(self._exists(token_id), Errors::INVALID_TOKEN_ID); - // self._token_uri.write(token_id, token_uri) - // } } - -//#[internal] -// fn _check_on_erc721_received( -// from: ContractAddress, to: ContractAddress, token_id: u256, data: Span -// ) -> bool { -// if (DualCaseSRC5 { contract_address: to } -// .supports_interface(interface::IERC721_RECEIVER_ID)) { -// DualCaseERC721Receiver { contract_address: to } -// .on_erc721_received( -// get_caller_address(), from, token_id, data -// ) == interface::IERC721_RECEIVER_ID -// } else { -// DualCaseSRC5 { contract_address: to }.supports_interface(account::interface::ISRC6_ID) -// } -// } } diff --git a/presets/token/src/token/erc721/models.cairo b/presets/src/erc721/models.cairo similarity index 97% rename from presets/token/src/token/erc721/models.cairo rename to presets/src/erc721/models.cairo index 1bc4bcad..eec7ec9c 100644 --- a/presets/token/src/token/erc721/models.cairo +++ b/presets/src/erc721/models.cairo @@ -1,3 +1,5 @@ +// Starknet imports + use starknet::ContractAddress; #[derive(Model, Copy, Drop, Serde)] diff --git a/presets/token/src/tests/erc721_tests.cairo b/presets/src/erc721/tests.cairo similarity index 98% rename from presets/token/src/tests/erc721_tests.cairo rename to presets/src/erc721/tests.cairo index 415db0ff..cdeef6be 100644 --- a/presets/token/src/tests/erc721_tests.cairo +++ b/presets/src/erc721/tests.cairo @@ -1,30 +1,41 @@ +// Core imports + use integer::u256; use integer::u256_from_felt252; -use dojo_erc::tests::utils; -use dojo_erc::tests::constants::{ - ZERO, OWNER, SPENDER, RECIPIENT, OPERATOR, OTHER, NAME, SYMBOL, URI, TOKEN_ID -}; +use zeroable::Zeroable; +use debug::PrintTrait; + +// Starknet imports -use dojo_erc::token::erc721::ERC721::ERC721Impl; -use dojo_erc::token::erc721::ERC721::ERC721CamelOnlyImpl; -use dojo_erc::token::erc721::ERC721::ERC721MetadataImpl; -use dojo_erc::token::erc721::ERC721::InternalImpl; -use dojo_erc::token::erc721::ERC721::WorldInteractionsImpl; -use dojo_erc::token::erc721::ERC721::{Approval, ApprovalForAll, Transfer}; -use dojo_erc::token::erc721::ERC721; use starknet::ContractAddress; use starknet::contract_address_const; use starknet::testing; -use zeroable::Zeroable; + +// Dojo imports + use dojo::test_utils::spawn_test_world; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -use dojo_erc::token::erc721::models::{ +// External imports + +// Internal imports + +use presets::tests::utils; +use presets::tests::constants::{ + ZERO, OWNER, SPENDER, RECIPIENT, OPERATOR, OTHER, NAME, SYMBOL, URI, TOKEN_ID +}; +use presets::erc721::ERC721::ERC721Impl; +use presets::erc721::ERC721::ERC721CamelOnlyImpl; +use presets::erc721::ERC721::ERC721MetadataImpl; +use presets::erc721::ERC721::InternalImpl; +use presets::erc721::ERC721::WorldInteractionsImpl; +use presets::erc721::ERC721::{Approval, ApprovalForAll, Transfer}; +use presets::erc721::ERC721; +use presets::erc721::models::{ ERC721Meta, erc_721_meta, ERC721OperatorApproval, erc_721_operator_approval, ERC721Owner, erc_721_owner, ERC721Balance, erc_721_balance, ERC721TokenApproval, erc_721_token_approval }; -use dojo_erc::token::erc721::ERC721::_worldContractMemberStateTrait; -use debug::PrintTrait; +use presets::erc721::ERC721::_worldContractMemberStateTrait; // // Setup diff --git a/presets/src/lib.cairo b/presets/src/lib.cairo new file mode 100644 index 00000000..95234237 --- /dev/null +++ b/presets/src/lib.cairo @@ -0,0 +1,13 @@ +mod erc721 { + mod models; + mod erc721; + use erc721::ERC721; + #[cfg(test)] + mod tests; +} + +#[cfg(test)] +mod tests { + mod constants; + mod utils; +} \ No newline at end of file diff --git a/presets/token/src/tests/constants.cairo b/presets/src/tests/constants.cairo similarity index 100% rename from presets/token/src/tests/constants.cairo rename to presets/src/tests/constants.cairo diff --git a/presets/token/src/tests/test_erc1155.cairo b/presets/src/tests/test_erc1155.cairo similarity index 100% rename from presets/token/src/tests/test_erc1155.cairo rename to presets/src/tests/test_erc1155.cairo diff --git a/presets/token/src/tests/test_erc721.cairo b/presets/src/tests/test_erc721.cairo similarity index 100% rename from presets/token/src/tests/test_erc721.cairo rename to presets/src/tests/test_erc721.cairo diff --git a/presets/token/src/tests/utils.cairo b/presets/src/tests/utils.cairo similarity index 100% rename from presets/token/src/tests/utils.cairo rename to presets/src/tests/utils.cairo diff --git a/presets/token/Scarb.lock b/presets/token/Scarb.lock deleted file mode 100644 index 8adc6f7f..00000000 --- a/presets/token/Scarb.lock +++ /dev/null @@ -1,20 +0,0 @@ -# Code generated by scarb DO NOT EDIT. -version = 1 - -[[package]] -name = "dojo" -version = "0.3.3" -dependencies = [ - "dojo_plugin", -] - -[[package]] -name = "dojo_erc" -version = "0.3.3" -dependencies = [ - "dojo", -] - -[[package]] -name = "dojo_plugin" -version = "0.3.3" diff --git a/presets/token/Scarb.toml b/presets/token/Scarb.toml deleted file mode 100644 index ef9edac6..00000000 --- a/presets/token/Scarb.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -cairo-version = "2.3.1" -description = "Implementations of ERC standards for the Dojo framework" -name = "dojo_erc" -version = "0.3.3" - -[cairo] -sierra-replace-ids = true - -[lib] - -[dependencies] -dojo = { path = "../dojo-core" } - -[scripts] -build = "sozo build" -migrate = "sozo migrate" -test = "sozo test" - -# Generate targets/manifest with sozo -[[target.dojo]] - - -[tool.dojo.env] -# Katana -rpc_url = "http://localhost:5050" -account_address = "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973" -private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x4cb5561a3a2a19d14f67f71a9da59c9194e2bbb44e1774260a111094fbd8f39" \ No newline at end of file diff --git a/presets/token/src/lib.cairo b/presets/token/src/lib.cairo deleted file mode 100644 index 537938a7..00000000 --- a/presets/token/src/lib.cairo +++ /dev/null @@ -1,17 +0,0 @@ -mod token { - mod erc20; - mod erc20_models; - mod erc721; - mod erc1155; - -} - -#[cfg(test)] -mod tests { - mod constants; - mod utils; - - mod erc20_tests; - mod erc721_tests; - mod erc1155_tests; -} diff --git a/presets/token/src/token/erc721.cairo b/presets/token/src/token/erc721.cairo deleted file mode 100644 index 15b96462..00000000 --- a/presets/token/src/token/erc721.cairo +++ /dev/null @@ -1,5 +0,0 @@ -mod erc721; -mod models; -mod interface; - -use erc721::ERC721; diff --git a/presets/token/src/token/erc721/interface.cairo b/presets/token/src/token/erc721/interface.cairo deleted file mode 100644 index 730ad2e0..00000000 --- a/presets/token/src/token/erc721/interface.cairo +++ /dev/null @@ -1,60 +0,0 @@ -use starknet::ContractAddress; - -const IERC721_ID: felt252 = 0x33eb2f84c309543403fd69f0d0f363781ef06ef6faeb0131ff16ea3175bd943; -const IERC721_METADATA_ID: felt252 = - 0x6069a70848f907fa57668ba1875164eb4dcee693952468581406d131081bbd; -const IERC721_RECEIVER_ID: felt252 = - 0x3a0dff5f70d80458ad14ae37bb182a728e3c8cdda0402a5daa86620bdf910bc; - -#[starknet::interface] -trait IERC721 { - fn balance_of(self: @TState, account: ContractAddress) -> u256; - fn owner_of(self: @TState, token_id: u256) -> ContractAddress; - fn transfer_from(ref self: TState, from: ContractAddress, to: ContractAddress, token_id: u256); - fn safe_transfer_from( - ref self: TState, - from: ContractAddress, - to: ContractAddress, - token_id: u256, - data: Span - ); - fn approve(ref self: TState, to: ContractAddress, token_id: u256); - fn set_approval_for_all(ref self: TState, operator: ContractAddress, approved: bool); - fn get_approved(self: @TState, token_id: u256) -> ContractAddress; - fn is_approved_for_all( - self: @TState, owner: ContractAddress, operator: ContractAddress - ) -> bool; -} - -#[starknet::interface] -trait IERC721CamelOnly { - fn balanceOf(self: @TState, account: ContractAddress) -> u256; - fn ownerOf(self: @TState, tokenId: u256) -> ContractAddress; - fn transferFrom(ref self: TState, from: ContractAddress, to: ContractAddress, tokenId: u256); - fn safeTransferFrom( - ref self: TState, - from: ContractAddress, - to: ContractAddress, - tokenId: u256, - data: Span - ); - fn setApprovalForAll(ref self: TState, operator: ContractAddress, approved: bool); - fn getApproved(self: @TState, tokenId: u256) -> ContractAddress; - fn isApprovedForAll(self: @TState, owner: ContractAddress, operator: ContractAddress) -> bool; -} - -// -// IERC721Metadata -// - -#[starknet::interface] -trait IERC721Metadata { - fn name(self: @TState) -> felt252; - fn symbol(self: @TState) -> felt252; - fn token_uri(self: @TState, token_id: u256) -> felt252; -} - -#[starknet::interface] -trait IERC721MetadataCamelOnly { - fn tokenURI(self: @TState, tokenId: u256) -> felt252; -}