Skip to content

Commit

Permalink
Feat: Update ERC721Enumerable component
Browse files Browse the repository at this point in the history
  • Loading branch information
gianalarcon committed Aug 26, 2024
1 parent aeccab4 commit ae25610
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const deployedContracts = {
devnet: {
YourCollectible: {
address:
"0x7bf2dc3695e421c31e7acf3d1498c14688a5922df268da9afc5ba9bc8e1ebda",
"0x6089cf0e1f1537f4ba7ed7f38bd45f454a78ba933cd91e8ca326aeec8187771",
abi: [
{
type: "impl",
Expand Down Expand Up @@ -817,7 +817,7 @@ const deployedContracts = {
},
],
classHash:
"0x2d7b083a934419eecfa89aabb3d052549a35fb6cba27323e4c54f2c7c558c9b",
"0x5d7a0a9e879cb1fd5c163704ecc6cda835adc46274f80b3178e428510f435e1",
},
},
sepolia: {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type ScaffoldConfig = {
};

const scaffoldConfig = {
targetNetworks: [chains.sepolia],
targetNetworks: [chains.devnet],
// Only show the Burner Wallet when running on devnet
onlyLocalBurnerWallet: false,
rpcProviderUrl: process.env.NEXT_PUBLIC_PROVIDER_URL || "",
Expand Down
2 changes: 1 addition & 1 deletion packages/snfoundry/contracts/src/YourCollectible.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod YourCollectible {
}
}

impl ERC721HooksEmptyImpl of ERC721Component::ERC721HooksTrait<ContractState> {
impl ERC721EnumerableHooksImpl of ERC721Component::ERC721HooksTrait<ContractState> {
// Implement this to add custom logic to the ERC721 hooks
// Similar to _beforeTokenTransfer in OpenZeppelin ERC721.sol
fn before_update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ pub mod ERC721EnumerableComponent {
use super::{IERC721Enumerable, ContractAddress};
use openzeppelin::token::erc721::ERC721Component;
use openzeppelin::token::erc721::interface::IERC721;
use core::num::traits::zero::Zero;

use openzeppelin::introspection::src5::SRC5Component;

#[storage]
struct Storage {
Expand All @@ -33,16 +32,15 @@ pub mod ERC721EnumerableComponent {
TContractState,
+HasComponent<TContractState>,
impl ERC721: ERC721Component::HasComponent<TContractState>,
+SRC5Component::HasComponent<TContractState>,
+ERC721Component::ERC721HooksTrait<TContractState>,
+Drop<TContractState>
> of IERC721Enumerable<ComponentState<TContractState>> {
fn token_of_owner_by_index(
self: @ComponentState<TContractState>, owner: ContractAddress, index: u256
) -> u256 {
let mut erc721_component = get_dep_component!(self, ERC721);
// ToDo: Improve to use erc721_component.balance_of()
assert(!owner.is_zero(), 'INVALID_ACCOUNT');
let balance = erc721_component.ERC721_balances.read(owner);
let erc721_component = get_dep_component!(self, ERC721);
let balance = erc721_component.balance_of(owner);
assert(index < balance, 'Owner index out of bounds');
self.owned_tokens.read((owner, index))
}
Expand Down

0 comments on commit ae25610

Please sign in to comment.