From c8bcb20d6047ad15cafda775875cbf2b99184a95 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Fri, 12 Apr 2024 12:18:23 +0700 Subject: [PATCH 01/11] FeatL Add snake_case --- .../snfoundry/contracts/src/challenge0.cairo | 6 ++-- packages/snfoundry/scripts_js/deploy.js | 29 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 80e0abe6..ef67185c 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -15,10 +15,10 @@ mod Challenge0 { component!(path: ERC721Component, storage: erc721, event: ERC721Event); component!(path: SRC5Component, storage: src5, event: SRC5Event); - // ERC721Mixin #[abi(embed_v0)] - impl ERC721MixinImpl = ERC721Component::ERC721MixinImpl; - //pub impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl; + impl ERC721Impl = ERC721Component::ERC721Impl; + #[abi(embed_v0)] + impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl; impl ERC721InternalImpl = ERC721Component::InternalImpl; #[storage] diff --git a/packages/snfoundry/scripts_js/deploy.js b/packages/snfoundry/scripts_js/deploy.js index 2cee6253..7f1c6b25 100644 --- a/packages/snfoundry/scripts_js/deploy.js +++ b/packages/snfoundry/scripts_js/deploy.js @@ -125,28 +125,23 @@ const deployContract = async ( }; const deployScript = async () => { - const { - classHash: helloStarknetClassHash, - abi: helloStarknetAbi, - address: ContractAddress, - } = await deployContract(null, "HelloStarknet"); // can pass another argument for the exported contract name - await deployContract( - { - name: 1, - }, - "SimpleStorage" - ); - + // const { + // classHash: helloStarknetClassHash, + // abi: helloStarknetAbi, + // address: ContractAddress, + // } = await deployContract(null, "HelloStarknet"); // can pass another argument for the exported contract name // await deployContract( // { - // name: "MARQUIS", - // symbol: "MARQ", - // recipient: deployer.address, - // fixed_supply: 100, + // name: 1, // }, - // "Challenge1" + // "SimpleStorage" // ); + await deployContract( + null, + "Challenge0" + ); + // await deployContract( // { // name: 1, From 49ba1d5a4480b2aa1d0710491c7ba5f756fd0431 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Fri, 12 Apr 2024 15:44:29 +0700 Subject: [PATCH 02/11] Add owner component --- .../nextjs/contracts/deployedContracts.ts | 1703 ++++++++++++----- .../snfoundry/contracts/src/challenge0.cairo | 21 +- packages/snfoundry/scripts_js/deploy.js | 2 +- 3 files changed, 1274 insertions(+), 452 deletions(-) diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index c7bca93d..ddb99dea 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -5,14 +5,12 @@ const deployedContracts = { devnet: { - Challenge0: { - address: - "0x064a129d88d4a54e467afd5fb138fec224259bc3fdfb1239b8b4605bad6d8546", + Challenge2: { abi: [ { type: "impl", - name: "Challenge0Impl", - interface_name: "contracts::challenge0::IChallenge0", + name: "ERC1155Impl", + interface_name: "openzeppelin::token::erc1155::interface::IERC1155", }, { type: "struct", @@ -29,47 +27,24 @@ const deployedContracts = { ], }, { - type: "interface", - name: "contracts::challenge0::IChallenge0", - items: [ - { - type: "function", - name: "mint_item", - inputs: [ - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "external", - }, + type: "struct", + name: "core::array::Span::", + members: [ { - type: "function", - name: "mint_id", - inputs: [ - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "id", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", + name: "snapshot", + type: "@core::array::Array::", }, ], }, { - type: "impl", - name: "ERC721MixinImpl", - interface_name: "openzeppelin::token::erc721::interface::ERC721ABI", + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], }, { type: "struct", @@ -95,27 +70,9 @@ const deployedContracts = { }, ], }, - { - type: "struct", - name: "core::byte_array::ByteArray", - members: [ - { - name: "data", - type: "core::array::Array::", - }, - { - name: "pending_word", - type: "core::felt252", - }, - { - name: "pending_word_len", - type: "core::integer::u32", - }, - ], - }, { type: "interface", - name: "openzeppelin::token::erc721::interface::ERC721ABI", + name: "openzeppelin::token::erc1155::interface::IERC1155", items: [ { type: "function", @@ -125,6 +82,10 @@ const deployedContracts = { name: "account", type: "core::starknet::contract_address::ContractAddress", }, + { + name: "token_id", + type: "core::integer::u256", + }, ], outputs: [ { @@ -135,16 +96,20 @@ const deployedContracts = { }, { type: "function", - name: "owner_of", + name: "balance_of_batch", inputs: [ { - name: "token_id", - type: "core::integer::u256", + name: "accounts", + type: "core::array::Span::", + }, + { + name: "token_ids", + type: "core::array::Span::", }, ], outputs: [ { - type: "core::starknet::contract_address::ContractAddress", + type: "core::array::Span::", }, ], state_mutability: "view", @@ -165,6 +130,10 @@ const deployedContracts = { name: "token_id", type: "core::integer::u256", }, + { + name: "value", + type: "core::integer::u256", + }, { name: "data", type: "core::array::Span::", @@ -175,7 +144,7 @@ const deployedContracts = { }, { type: "function", - name: "transfer_from", + name: "safe_batch_transfer_from", inputs: [ { name: "from", @@ -186,61 +155,21 @@ const deployedContracts = { type: "core::starknet::contract_address::ContractAddress", }, { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "approve", - inputs: [ - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", + name: "token_ids", + type: "core::array::Span::", }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "set_approval_for_all", - inputs: [ { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", + name: "values", + type: "core::array::Span::", }, { - name: "approved", - type: "core::bool", + name: "data", + type: "core::array::Span::", }, ], outputs: [], state_mutability: "external", }, - { - type: "function", - name: "get_approved", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::starknet::contract_address::ContractAddress", - }, - ], - state_mutability: "view", - }, { type: "function", name: "is_approved_for_all", @@ -263,45 +192,53 @@ const deployedContracts = { }, { type: "function", - name: "supports_interface", + name: "set_approval_for_all", inputs: [ { - name: "interface_id", - type: "core::felt252", + name: "operator", + type: "core::starknet::contract_address::ContractAddress", }, - ], - outputs: [ { + name: "approved", type: "core::bool", }, ], - state_mutability: "view", + outputs: [], + state_mutability: "external", }, + ], + }, + { + type: "impl", + name: "ERC1155MetadataURIImpl", + interface_name: + "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", + }, + { + type: "struct", + name: "core::byte_array::ByteArray", + members: [ { - type: "function", - name: "name", - inputs: [], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", + name: "data", + type: "core::array::Array::", }, { - type: "function", - name: "symbol", - inputs: [], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", + name: "pending_word", + type: "core::felt252", + }, + { + name: "pending_word_len", + type: "core::integer::u32", }, + ], + }, + { + type: "interface", + name: "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", + items: [ { type: "function", - name: "token_uri", + name: "uri", inputs: [ { name: "token_id", @@ -315,6 +252,18 @@ const deployedContracts = { ], state_mutability: "view", }, + ], + }, + { + type: "impl", + name: "ERC1155Camel", + interface_name: + "openzeppelin::token::erc1155::interface::IERC1155Camel", + }, + { + type: "interface", + name: "openzeppelin::token::erc1155::interface::IERC1155Camel", + items: [ { type: "function", name: "balanceOf", @@ -323,6 +272,10 @@ const deployedContracts = { name: "account", type: "core::starknet::contract_address::ContractAddress", }, + { + name: "tokenId", + type: "core::integer::u256", + }, ], outputs: [ { @@ -333,16 +286,20 @@ const deployedContracts = { }, { type: "function", - name: "ownerOf", + name: "balanceOfBatch", inputs: [ { - name: "tokenId", - type: "core::integer::u256", + name: "accounts", + type: "core::array::Span::", + }, + { + name: "tokenIds", + type: "core::array::Span::", }, ], outputs: [ { - type: "core::starknet::contract_address::ContractAddress", + type: "core::array::Span::", }, ], state_mutability: "view", @@ -363,6 +320,10 @@ const deployedContracts = { name: "tokenId", type: "core::integer::u256", }, + { + name: "value", + type: "core::integer::u256", + }, { name: "data", type: "core::array::Span::", @@ -373,7 +334,7 @@ const deployedContracts = { }, { type: "function", - name: "transferFrom", + name: "safeBatchTransferFrom", inputs: [ { name: "from", @@ -384,24 +345,16 @@ const deployedContracts = { type: "core::starknet::contract_address::ContractAddress", }, { - name: "tokenId", - type: "core::integer::u256", + name: "tokenIds", + type: "core::array::Span::", }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "setApprovalForAll", - inputs: [ { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", + name: "values", + type: "core::array::Span::", }, { - name: "approved", - type: "core::bool", + name: "data", + type: "core::array::Span::", }, ], outputs: [], @@ -409,52 +362,63 @@ const deployedContracts = { }, { type: "function", - name: "getApproved", + name: "isApprovedForAll", inputs: [ { - name: "tokenId", - type: "core::integer::u256", + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", }, ], outputs: [ { - type: "core::starknet::contract_address::ContractAddress", + type: "core::bool", }, ], state_mutability: "view", }, { type: "function", - name: "isApprovedForAll", + name: "setApprovalForAll", inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, { name: "operator", type: "core::starknet::contract_address::ContractAddress", }, - ], - outputs: [ { + name: "approved", type: "core::bool", }, ], - state_mutability: "view", + outputs: [], + state_mutability: "external", }, + ], + }, + { + type: "impl", + name: "SRC5Impl", + interface_name: "openzeppelin::introspection::interface::ISRC5", + }, + { + type: "interface", + name: "openzeppelin::introspection::interface::ISRC5", + items: [ { type: "function", - name: "tokenURI", + name: "supports_interface", inputs: [ { - name: "tokenId", - type: "core::integer::u256", + name: "interface_id", + type: "core::felt252", }, ], outputs: [ { - type: "core::byte_array::ByteArray", + type: "core::bool", }, ], state_mutability: "view", @@ -464,13 +428,35 @@ const deployedContracts = { { type: "constructor", name: "constructor", - inputs: [], - }, - { + inputs: [ + { + name: "base_uri", + type: "core::byte_array::ByteArray", + }, + { + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_ids", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + ], + }, + { type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", kind: "struct", members: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, { name: "from", type: "core::starknet::contract_address::ContractAddress", @@ -482,37 +468,52 @@ const deployedContracts = { kind: "key", }, { - name: "token_id", + name: "id", type: "core::integer::u256", - kind: "key", + kind: "data", + }, + { + name: "value", + type: "core::integer::u256", + kind: "data", }, ], }, { type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", kind: "struct", members: [ { - name: "owner", + name: "operator", type: "core::starknet::contract_address::ContractAddress", kind: "key", }, { - name: "approved", + name: "from", type: "core::starknet::contract_address::ContractAddress", kind: "key", }, { - name: "token_id", - type: "core::integer::u256", + name: "to", + type: "core::starknet::contract_address::ContractAddress", kind: "key", }, + { + name: "ids", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, ], }, { type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", kind: "struct", members: [ { @@ -534,22 +535,44 @@ const deployedContracts = { }, { type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", + kind: "struct", + members: [ + { + name: "value", + type: "core::byte_array::ByteArray", + kind: "data", + }, + { + name: "id", + type: "core::integer::u256", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", kind: "enum", variants: [ { - name: "Transfer", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", + name: "TransferSingle", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", kind: "nested", }, { - name: "Approval", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", + name: "TransferBatch", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", kind: "nested", }, { name: "ApprovalForAll", - type: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", + kind: "nested", + }, + { + name: "URI", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", kind: "nested", }, ], @@ -562,12 +585,12 @@ const deployedContracts = { }, { type: "event", - name: "contracts::challenge0::Challenge0::Event", + name: "contracts::challenge2::Challenge2::Event", kind: "enum", variants: [ { - name: "ERC721Event", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Event", + name: "ERC1155Event", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", kind: "flat", }, { @@ -579,199 +602,82 @@ const deployedContracts = { }, ], }, - }, - mainnet: { - HelloStarknet: { + Challenge0: { address: - "0x0750aa622d77436d69d58c91dbc73a6d0d25db0b7076c1377cdda15e13fd632b", + "0x04c0c6e25c5390f336eb281aea82b675e9150702f1bcba64b144e7b61c02d356", abi: [ { type: "impl", - name: "HelloStarknetImpl", - interface_name: "contracts::helloStarknet::IHelloStarknet", + name: "Challenge0Impl", + interface_name: "contracts::challenge0::IChallenge0", }, { - type: "interface", - name: "contracts::helloStarknet::IHelloStarknet", - items: [ - { - type: "function", - name: "increase_balance", - inputs: [ - { - name: "amount", - type: "core::integer::u32", - }, - ], - outputs: [], - state_mutability: "external", - }, + type: "struct", + name: "core::integer::u256", + members: [ { - type: "function", - name: "get_balance", - inputs: [], - outputs: [ - { - type: "core::integer::u32", - }, - ], - state_mutability: "view", + name: "low", + type: "core::integer::u128", }, { - type: "function", - name: "get_balance_increment", - inputs: [ - { - name: "amount", - type: "core::integer::u32", - }, - ], - outputs: [ - { - type: "core::integer::u32", - }, - ], - state_mutability: "view", + name: "high", + type: "core::integer::u128", }, ], }, - { - type: "event", - name: "contracts::helloStarknet::HelloStarknet::Event", - kind: "enum", - variants: [], - }, - ], - }, - }, - sepolia: { - HelloStarknet: { - address: - "0x07e6136fbfaae09a09f491c97c127c661b9e2edb553be28e1966d1ac1724d98c", - abi: [ - { - type: "impl", - name: "HelloStarknetImpl", - interface_name: "contracts::helloStarknet::IHelloStarknet", - }, { type: "interface", - name: "contracts::helloStarknet::IHelloStarknet", + name: "contracts::challenge0::IChallenge0", items: [ { type: "function", - name: "increase_balance", + name: "mint_item", inputs: [ { - name: "amount", - type: "core::integer::u32", + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", }, ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "get_balance", - inputs: [], outputs: [ { - type: "core::integer::u32", + type: "core::integer::u256", }, ], - state_mutability: "view", + state_mutability: "external", }, { type: "function", - name: "get_balance_increment", + name: "mint_id", inputs: [ { - name: "amount", - type: "core::integer::u32", + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", }, - ], - outputs: [ { - type: "core::integer::u32", + name: "id", + type: "core::integer::u256", }, ], - state_mutability: "view", + outputs: [], + state_mutability: "external", }, ], }, - { - type: "event", - name: "contracts::helloStarknet::HelloStarknet::Event", - kind: "enum", - variants: [], - }, - ], - }, - SimpleStorage: { - address: - "0x072c40ba7d070bfd6aaa7532743f635cc432748ab1f7e8e4254c4238975858f3", - abi: [ { type: "impl", - name: "SimpleStorageImpl", - interface_name: "contracts::simpleStorage::ISimpleStorage", - }, - { - type: "interface", - name: "contracts::simpleStorage::ISimpleStorage", - items: [ - { - type: "function", - name: "get_name", - inputs: [], - outputs: [ - { - type: "core::felt252", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "set_name", - inputs: [ - { - name: "name", - type: "core::felt252", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], + name: "ERC721Impl", + interface_name: "openzeppelin::token::erc721::interface::IERC721", }, { - type: "constructor", - name: "constructor", - inputs: [ + type: "struct", + name: "core::array::Span::", + members: [ { - name: "name", - type: "core::felt252", + name: "snapshot", + type: "@core::array::Array::", }, ], }, - { - type: "event", - name: "contracts::simpleStorage::SimpleStorage::Event", - kind: "enum", - variants: [], - }, - ], - }, - Vote: { - address: - "0x04c394c4fc87a9a62f04205ac456f6811b6bcb0465e339f95308332cbff7364f", - abi: [ - { - type: "impl", - name: "VoteImpl", - interface_name: "contracts::vote::VoteTrait", - }, { type: "enum", name: "core::bool", @@ -788,178 +694,242 @@ const deployedContracts = { }, { type: "interface", - name: "contracts::vote::VoteTrait", + name: "openzeppelin::token::erc721::interface::IERC721", items: [ { type: "function", - name: "get_vote_status", - inputs: [], - outputs: [ - { - type: "(core::integer::u8, core::integer::u8, core::integer::u8, core::integer::u8)", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "voter_can_vote", + name: "balance_of", inputs: [ { - name: "user_address", + name: "account", type: "core::starknet::contract_address::ContractAddress", }, ], outputs: [ { - type: "core::bool", + type: "core::integer::u256", }, ], state_mutability: "view", }, { type: "function", - name: "is_voter_registered", + name: "owner_of", inputs: [ { - name: "address", - type: "core::starknet::contract_address::ContractAddress", + name: "token_id", + type: "core::integer::u256", }, ], outputs: [ { - type: "core::bool", + type: "core::starknet::contract_address::ContractAddress", }, ], state_mutability: "view", }, { type: "function", - name: "vote", + name: "safe_transfer_from", inputs: [ { - name: "vote", - type: "core::integer::u8", - }, + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_id", + type: "core::integer::u256", + }, + { + name: "data", + type: "core::array::Span::", + }, ], outputs: [], state_mutability: "external", }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ { - name: "voter_1", - type: "core::starknet::contract_address::ContractAddress", + type: "function", + name: "transfer_from", + inputs: [ + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_id", + type: "core::integer::u256", + }, + ], + outputs: [], + state_mutability: "external", }, { - name: "voter_2", - type: "core::starknet::contract_address::ContractAddress", + type: "function", + name: "approve", + inputs: [ + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_id", + type: "core::integer::u256", + }, + ], + outputs: [], + state_mutability: "external", }, { - name: "voter_3", - type: "core::starknet::contract_address::ContractAddress", + type: "function", + name: "set_approval_for_all", + inputs: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "approved", + type: "core::bool", + }, + ], + outputs: [], + state_mutability: "external", }, - ], - }, - { - type: "event", - name: "contracts::vote::Vote::VoteCast", - kind: "struct", - members: [ { - name: "voter", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", + type: "function", + name: "get_approved", + inputs: [ + { + name: "token_id", + type: "core::integer::u256", + }, + ], + outputs: [ + { + type: "core::starknet::contract_address::ContractAddress", + }, + ], + state_mutability: "view", }, { - name: "vote", - type: "core::integer::u8", - kind: "data", + type: "function", + name: "is_approved_for_all", + inputs: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", }, ], }, { - type: "event", - name: "contracts::vote::Vote::UnauthorizedAttempt", - kind: "struct", + type: "impl", + name: "ERC721MetadataImpl", + interface_name: + "openzeppelin::token::erc721::interface::IERC721Metadata", + }, + { + type: "struct", + name: "core::byte_array::ByteArray", members: [ { - name: "unauthorized_address", - type: "core::starknet::contract_address::ContractAddress", - kind: "data", + name: "data", + type: "core::array::Array::", }, - ], - }, - { - type: "event", - name: "contracts::vote::Vote::Event", - kind: "enum", - variants: [ { - name: "VoteCast", - type: "contracts::vote::Vote::VoteCast", - kind: "nested", + name: "pending_word", + type: "core::felt252", }, { - name: "UnauthorizedAttempt", - type: "contracts::vote::Vote::UnauthorizedAttempt", - kind: "nested", + name: "pending_word_len", + type: "core::integer::u32", }, ], }, - ], - }, - Ownable: { - address: - "0x07b0a115eb4111e34607418ff37015e8f60149541d3af39b094d19eea2ec5ad4", - abi: [ - { - type: "impl", - name: "OwnableDataImpl", - interface_name: "contracts::IData", - }, { type: "interface", - name: "contracts::IData", + name: "openzeppelin::token::erc721::interface::IERC721Metadata", items: [ { type: "function", - name: "get_data", + name: "name", + inputs: [], + outputs: [ + { + type: "core::byte_array::ByteArray", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "symbol", inputs: [], outputs: [ { - type: "core::integer::u64", + type: "core::byte_array::ByteArray", }, ], state_mutability: "view", }, { type: "function", - name: "set_data", + name: "token_uri", inputs: [ { - name: "new_value", - type: "core::integer::u64", + name: "token_id", + type: "core::integer::u256", }, ], - outputs: [], - state_mutability: "external", + outputs: [ + { + type: "core::byte_array::ByteArray", + }, + ], + state_mutability: "view", }, ], }, { type: "impl", name: "OwnableImpl", - interface_name: "contracts::IOwnable", + interface_name: "openzeppelin::access::ownable::interface::IOwnable", }, { type: "interface", - name: "contracts::IOwnable", + name: "openzeppelin::access::ownable::interface::IOwnable", items: [ + { + type: "function", + name: "owner", + inputs: [], + outputs: [ + { + type: "core::starknet::contract_address::ContractAddress", + }, + ], + state_mutability: "view", + }, { type: "function", name: "transfer_ownership", @@ -974,14 +944,10 @@ const deployedContracts = { }, { type: "function", - name: "owner", + name: "renounce_ownership", inputs: [], - outputs: [ - { - type: "core::starknet::contract_address::ContractAddress", - }, - ], - state_mutability: "view", + outputs: [], + state_mutability: "external", }, ], }, @@ -990,52 +956,897 @@ const deployedContracts = { name: "constructor", inputs: [ { - name: "initial_owner", + name: "owner", type: "core::starknet::contract_address::ContractAddress", }, ], }, { type: "event", - name: "contracts::ownable_component::OwnershipTransferred", + name: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", kind: "struct", members: [ { - name: "previous_owner", + name: "from", type: "core::starknet::contract_address::ContractAddress", kind: "key", }, { - name: "new_owner", + name: "to", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "token_id", + type: "core::integer::u256", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", + kind: "struct", + members: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "approved", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "token_id", + type: "core::integer::u256", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", + kind: "struct", + members: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "operator", type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "approved", + type: "core::bool", kind: "data", }, ], }, { type: "event", - name: "contracts::ownable_component::Event", + name: "openzeppelin::token::erc721::erc721::ERC721Component::Event", kind: "enum", variants: [ { - name: "OwnershipTransferred", - type: "contracts::ownable_component::OwnershipTransferred", + name: "Transfer", + type: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", + kind: "nested", + }, + { + name: "Approval", + type: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", + kind: "nested", + }, + { + name: "ApprovalForAll", + type: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", kind: "nested", }, ], }, { type: "event", - name: "contracts::Ownable::Event", + name: "openzeppelin::introspection::src5::SRC5Component::Event", kind: "enum", - variants: [ + variants: [], + }, + { + type: "event", + name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred", + kind: "struct", + members: [ + { + name: "previous_owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "new_owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted", + kind: "struct", + members: [ + { + name: "previous_owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "new_owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::access::ownable::ownable::OwnableComponent::Event", + kind: "enum", + variants: [ + { + name: "OwnershipTransferred", + type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred", + kind: "nested", + }, + { + name: "OwnershipTransferStarted", + type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted", + kind: "nested", + }, + ], + }, + { + type: "event", + name: "contracts::challenge0::Challenge0::Event", + kind: "enum", + variants: [ + { + name: "ERC721Event", + type: "openzeppelin::token::erc721::erc721::ERC721Component::Event", + kind: "flat", + }, + { + name: "SRC5Event", + type: "openzeppelin::introspection::src5::SRC5Component::Event", + kind: "flat", + }, + { + name: "OwnableEvent", + type: "openzeppelin::access::ownable::ownable::OwnableComponent::Event", + kind: "flat", + }, + ], + }, + ], + }, + }, + sepolia: { + HelloStarknet: { + address: + "0x049fd22553ca315836e8f18c94c60d9383900884c2a4bc1d215bae043e3b1038", + abi: [ + { + type: "impl", + name: "HelloStarknetImpl", + interface_name: "contracts::helloStarknet::IHelloStarknet", + }, + { + type: "interface", + name: "contracts::helloStarknet::IHelloStarknet", + items: [ + { + type: "function", + name: "increase_balance", + inputs: [ + { + name: "amount", + type: "core::integer::u32", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "get_balance", + inputs: [], + outputs: [ + { + type: "core::integer::u32", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "get_balance_increment", + inputs: [ + { + name: "amount", + type: "core::integer::u32", + }, + ], + outputs: [ + { + type: "core::integer::u32", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "event", + name: "contracts::helloStarknet::HelloStarknet::Event", + kind: "enum", + variants: [], + }, + ], + }, + SimpleStorage: { + address: + "0x07b11042855e9f3d0006d517c220d99849bdfddd8c7e6ee406356c65313ed040", + abi: [ + { + type: "impl", + name: "SimpleStorageImpl", + interface_name: "contracts::simpleStorage::ISimpleStorage", + }, + { + type: "interface", + name: "contracts::simpleStorage::ISimpleStorage", + items: [ + { + type: "function", + name: "get_name", + inputs: [], + outputs: [ + { + type: "core::felt252", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_name", + inputs: [ + { + name: "name", + type: "core::felt252", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "constructor", + name: "constructor", + inputs: [ + { + name: "name", + type: "core::felt252", + }, + ], + }, + { + type: "event", + name: "contracts::simpleStorage::SimpleStorage::Event", + kind: "enum", + variants: [], + }, + ], + }, + Challenge2: { + address: + "0x0612828fc31c858279315c1ad0747241d2d777c31ab30b97619e7c0fc238606d", + abi: [ + { + type: "impl", + name: "ERC1155Impl", + interface_name: "openzeppelin::token::erc1155::interface::IERC1155", + }, + { + type: "struct", + name: "core::integer::u256", + members: [ + { + name: "low", + type: "core::integer::u128", + }, + { + name: "high", + type: "core::integer::u128", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "struct", + name: "core::array::Span::", + members: [ + { + name: "snapshot", + type: "@core::array::Array::", + }, + ], + }, + { + type: "enum", + name: "core::bool", + variants: [ + { + name: "False", + type: "()", + }, + { + name: "True", + type: "()", + }, + ], + }, + { + type: "interface", + name: "openzeppelin::token::erc1155::interface::IERC1155", + items: [ + { + type: "function", + name: "balance_of", + inputs: [ + { + name: "account", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_id", + type: "core::integer::u256", + }, + ], + outputs: [ + { + type: "core::integer::u256", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "balance_of_batch", + inputs: [ + { + name: "accounts", + type: "core::array::Span::", + }, + { + name: "token_ids", + type: "core::array::Span::", + }, + ], + outputs: [ + { + type: "core::array::Span::", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "safe_transfer_from", + inputs: [ + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_id", + type: "core::integer::u256", + }, + { + name: "value", + type: "core::integer::u256", + }, + { + name: "data", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "safe_batch_transfer_from", + inputs: [ + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_ids", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + { + name: "data", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "is_approved_for_all", + inputs: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "set_approval_for_all", + inputs: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "approved", + type: "core::bool", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "impl", + name: "ERC1155MetadataURIImpl", + interface_name: + "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", + }, + { + type: "struct", + name: "core::byte_array::ByteArray", + members: [ + { + name: "data", + type: "core::array::Array::", + }, + { + name: "pending_word", + type: "core::felt252", + }, + { + name: "pending_word_len", + type: "core::integer::u32", + }, + ], + }, + { + type: "interface", + name: "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", + items: [ + { + type: "function", + name: "uri", + inputs: [ + { + name: "token_id", + type: "core::integer::u256", + }, + ], + outputs: [ + { + type: "core::byte_array::ByteArray", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "impl", + name: "ERC1155Camel", + interface_name: + "openzeppelin::token::erc1155::interface::IERC1155Camel", + }, + { + type: "interface", + name: "openzeppelin::token::erc1155::interface::IERC1155Camel", + items: [ + { + type: "function", + name: "balanceOf", + inputs: [ + { + name: "account", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "tokenId", + type: "core::integer::u256", + }, + ], + outputs: [ + { + type: "core::integer::u256", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "balanceOfBatch", + inputs: [ + { + name: "accounts", + type: "core::array::Span::", + }, + { + name: "tokenIds", + type: "core::array::Span::", + }, + ], + outputs: [ + { + type: "core::array::Span::", + }, + ], + state_mutability: "view", + }, { - name: "OwnableEvent", - type: "contracts::ownable_component::Event", + type: "function", + name: "safeTransferFrom", + inputs: [ + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "tokenId", + type: "core::integer::u256", + }, + { + name: "value", + type: "core::integer::u256", + }, + { + name: "data", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "safeBatchTransferFrom", + inputs: [ + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "tokenIds", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + { + name: "data", + type: "core::array::Span::", + }, + ], + outputs: [], + state_mutability: "external", + }, + { + type: "function", + name: "isApprovedForAll", + inputs: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + { + type: "function", + name: "setApprovalForAll", + inputs: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "approved", + type: "core::bool", + }, + ], + outputs: [], + state_mutability: "external", + }, + ], + }, + { + type: "impl", + name: "SRC5Impl", + interface_name: "openzeppelin::introspection::interface::ISRC5", + }, + { + type: "interface", + name: "openzeppelin::introspection::interface::ISRC5", + items: [ + { + type: "function", + name: "supports_interface", + inputs: [ + { + name: "interface_id", + type: "core::felt252", + }, + ], + outputs: [ + { + type: "core::bool", + }, + ], + state_mutability: "view", + }, + ], + }, + { + type: "constructor", + name: "constructor", + inputs: [ + { + name: "base_uri", + type: "core::byte_array::ByteArray", + }, + { + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "token_ids", + type: "core::array::Span::", + }, + { + name: "values", + type: "core::array::Span::", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", + kind: "struct", + members: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "id", + type: "core::integer::u256", + kind: "data", + }, + { + name: "value", + type: "core::integer::u256", + kind: "data", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", + kind: "struct", + members: [ + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "from", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "to", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "ids", + type: "core::array::Span::", + kind: "data", + }, + { + name: "values", + type: "core::array::Span::", + kind: "data", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", + kind: "struct", + members: [ + { + name: "owner", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "operator", + type: "core::starknet::contract_address::ContractAddress", + kind: "key", + }, + { + name: "approved", + type: "core::bool", + kind: "data", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", + kind: "struct", + members: [ + { + name: "value", + type: "core::byte_array::ByteArray", + kind: "data", + }, + { + name: "id", + type: "core::integer::u256", + kind: "key", + }, + ], + }, + { + type: "event", + name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", + kind: "enum", + variants: [ + { + name: "TransferSingle", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", + kind: "nested", + }, + { + name: "TransferBatch", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", + kind: "nested", + }, + { + name: "ApprovalForAll", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", + kind: "nested", + }, + { + name: "URI", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", kind: "nested", }, ], }, + { + type: "event", + name: "openzeppelin::introspection::src5::SRC5Component::Event", + kind: "enum", + variants: [], + }, + { + type: "event", + name: "contracts::challenge2::Challenge2::Event", + kind: "enum", + variants: [ + { + name: "ERC1155Event", + type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", + kind: "flat", + }, + { + name: "SRC5Event", + type: "openzeppelin::introspection::src5::SRC5Component::Event", + kind: "flat", + }, + ], + }, ], }, }, diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index ef67185c..f42cb8c4 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -7,26 +7,34 @@ pub trait IChallenge0 { } #[starknet::contract] mod Challenge0 { - use super::IChallenge0; + use super::{IChallenge0, ContractAddress}; use openzeppelin::introspection::src5::SRC5Component; use openzeppelin::token::erc721::ERC721Component; - use starknet::ContractAddress; + use openzeppelin::access::ownable::OwnableComponent; component!(path: ERC721Component, storage: erc721, event: ERC721Event); component!(path: SRC5Component, storage: src5, event: SRC5Event); + component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); + #[abi(embed_v0)] impl ERC721Impl = ERC721Component::ERC721Impl; #[abi(embed_v0)] impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl; + #[abi(embed_v0)] + impl OwnableImpl = OwnableComponent::OwnableImpl; + impl ERC721InternalImpl = ERC721Component::InternalImpl; + impl InternalImpl = OwnableComponent::InternalImpl; #[storage] struct Storage { #[substorage(v0)] erc721: ERC721Component::Storage, #[substorage(v0)] - src5: SRC5Component::Storage + src5: SRC5Component::Storage, + #[substorage(v0)] + ownable: OwnableComponent::Storage } #[event] @@ -35,17 +43,20 @@ mod Challenge0 { #[flat] ERC721Event: ERC721Component::Event, #[flat] - SRC5Event: SRC5Component::Event + SRC5Event: SRC5Component::Event, + #[flat] + OwnableEvent: OwnableComponent::Event } #[constructor] - fn constructor(ref self: ContractState) { + fn constructor(ref self: ContractState, owner: ContractAddress) { let name: ByteArray = "YourCollectible"; let symbol: ByteArray = "YCB"; let base_uri: ByteArray = "https://ipfs.io/ipfs/QmfVMAmNM1kDEBYrC2TPzQDoCRFH6F5tE1e9Mr4FkkR5Xr"; // bison nft self.erc721.initializer(name, symbol, base_uri); + self.ownable.initializer(owner); } #[abi(embed_v0)] diff --git a/packages/snfoundry/scripts_js/deploy.js b/packages/snfoundry/scripts_js/deploy.js index 7f1c6b25..5af91ac5 100644 --- a/packages/snfoundry/scripts_js/deploy.js +++ b/packages/snfoundry/scripts_js/deploy.js @@ -138,7 +138,7 @@ const deployScript = async () => { // ); await deployContract( - null, + {owner: deployer.address}, "Challenge0" ); From a4c0fcfdacc3baf2f56d393136430647dcc6c9d7 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Fri, 12 Apr 2024 16:04:07 +0700 Subject: [PATCH 03/11] Feat: Add counter --- .../nextjs/contracts/deployedContracts.ts | 2 +- .../snfoundry/contracts/src/challenge0.cairo | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index ddb99dea..0071d5f6 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -604,7 +604,7 @@ const deployedContracts = { }, Challenge0: { address: - "0x04c0c6e25c5390f336eb281aea82b675e9150702f1bcba64b144e7b61c02d356", + "0x047615b2387eed7eaeed17d87c357e00240f9e80d858b4d4ade2fd3c707a424c", abi: [ { type: "impl", diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index f42cb8c4..2c7c3311 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -25,7 +25,7 @@ mod Challenge0 { impl OwnableImpl = OwnableComponent::OwnableImpl; impl ERC721InternalImpl = ERC721Component::InternalImpl; - impl InternalImpl = OwnableComponent::InternalImpl; + impl OwnableInternalImpl = OwnableComponent::InternalImpl; #[storage] struct Storage { @@ -34,7 +34,8 @@ mod Challenge0 { #[substorage(v0)] src5: SRC5Component::Storage, #[substorage(v0)] - ownable: OwnableComponent::Storage + ownable: OwnableComponent::Storage, + counter: u256 } #[event] @@ -62,12 +63,24 @@ mod Challenge0 { #[abi(embed_v0)] pub impl Challenge0Impl of IChallenge0 { fn mint_item(ref self: ContractState, recipient: ContractAddress) -> u256 { - let id: u256 = 1; - self.erc721._mint(recipient, id); // _mint include _setTokenURI() - id + self._increment(); + let token_id = self._current(); + self.erc721._mint(recipient, token_id); // _mint include _setTokenURI() + token_id } fn mint_id(ref self: ContractState, recipient: ContractAddress, id: u256) { self.erc721._mint(recipient, id); } } + + #[generate_trait] + impl InternalImpl of InternalTrait { + fn _increment(ref self: ContractState) { + self.counter.write(self.counter.read() + 1); + } + + fn _current(ref self: ContractState) -> u256 { + self.counter.read() + } + } } From a176c3452980852467509b6391fbf7186a384cd5 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Fri, 12 Apr 2024 16:23:16 +0700 Subject: [PATCH 04/11] Feat add safe_mint --- .../nextjs/contracts/deployedContracts.ts | 1849 +---------------- .../snfoundry/contracts/src/challenge0.cairo | 3 +- 2 files changed, 3 insertions(+), 1849 deletions(-) diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index 0071d5f6..1951aa9b 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -3,1853 +3,6 @@ * You should not edit it manually or your changes might be overwritten. */ -const deployedContracts = { - devnet: { - Challenge2: { - abi: [ - { - type: "impl", - name: "ERC1155Impl", - interface_name: "openzeppelin::token::erc1155::interface::IERC1155", - }, - { - type: "struct", - name: "core::integer::u256", - members: [ - { - name: "low", - type: "core::integer::u128", - }, - { - name: "high", - type: "core::integer::u128", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "enum", - name: "core::bool", - variants: [ - { - name: "False", - type: "()", - }, - { - name: "True", - type: "()", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155", - items: [ - { - type: "function", - name: "balance_of", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "balance_of_batch", - inputs: [ - { - name: "accounts", - type: "core::array::Span::", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - ], - outputs: [ - { - type: "core::array::Span::", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "safe_transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - { - name: "value", - type: "core::integer::u256", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "safe_batch_transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "is_approved_for_all", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "set_approval_for_all", - inputs: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "approved", - type: "core::bool", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "ERC1155MetadataURIImpl", - interface_name: - "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", - }, - { - type: "struct", - name: "core::byte_array::ByteArray", - members: [ - { - name: "data", - type: "core::array::Array::", - }, - { - name: "pending_word", - type: "core::felt252", - }, - { - name: "pending_word_len", - type: "core::integer::u32", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", - items: [ - { - type: "function", - name: "uri", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "impl", - name: "ERC1155Camel", - interface_name: - "openzeppelin::token::erc1155::interface::IERC1155Camel", - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155Camel", - items: [ - { - type: "function", - name: "balanceOf", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenId", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "balanceOfBatch", - inputs: [ - { - name: "accounts", - type: "core::array::Span::", - }, - { - name: "tokenIds", - type: "core::array::Span::", - }, - ], - outputs: [ - { - type: "core::array::Span::", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "safeTransferFrom", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenId", - type: "core::integer::u256", - }, - { - name: "value", - type: "core::integer::u256", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "safeBatchTransferFrom", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenIds", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "isApprovedForAll", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "setApprovalForAll", - inputs: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "approved", - type: "core::bool", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "SRC5Impl", - interface_name: "openzeppelin::introspection::interface::ISRC5", - }, - { - type: "interface", - name: "openzeppelin::introspection::interface::ISRC5", - items: [ - { - type: "function", - name: "supports_interface", - inputs: [ - { - name: "interface_id", - type: "core::felt252", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ - { - name: "base_uri", - type: "core::byte_array::ByteArray", - }, - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", - kind: "struct", - members: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "id", - type: "core::integer::u256", - kind: "data", - }, - { - name: "value", - type: "core::integer::u256", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", - kind: "struct", - members: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "ids", - type: "core::array::Span::", - kind: "data", - }, - { - name: "values", - type: "core::array::Span::", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", - kind: "struct", - members: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "approved", - type: "core::bool", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", - kind: "struct", - members: [ - { - name: "value", - type: "core::byte_array::ByteArray", - kind: "data", - }, - { - name: "id", - type: "core::integer::u256", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", - kind: "enum", - variants: [ - { - name: "TransferSingle", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", - kind: "nested", - }, - { - name: "TransferBatch", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", - kind: "nested", - }, - { - name: "ApprovalForAll", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", - kind: "nested", - }, - { - name: "URI", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", - kind: "nested", - }, - ], - }, - { - type: "event", - name: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "enum", - variants: [], - }, - { - type: "event", - name: "contracts::challenge2::Challenge2::Event", - kind: "enum", - variants: [ - { - name: "ERC1155Event", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", - kind: "flat", - }, - { - name: "SRC5Event", - type: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "flat", - }, - ], - }, - ], - }, - Challenge0: { - address: - "0x047615b2387eed7eaeed17d87c357e00240f9e80d858b4d4ade2fd3c707a424c", - abi: [ - { - type: "impl", - name: "Challenge0Impl", - interface_name: "contracts::challenge0::IChallenge0", - }, - { - type: "struct", - name: "core::integer::u256", - members: [ - { - name: "low", - type: "core::integer::u128", - }, - { - name: "high", - type: "core::integer::u128", - }, - ], - }, - { - type: "interface", - name: "contracts::challenge0::IChallenge0", - items: [ - { - type: "function", - name: "mint_item", - inputs: [ - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "external", - }, - { - type: "function", - name: "mint_id", - inputs: [ - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "id", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "ERC721Impl", - interface_name: "openzeppelin::token::erc721::interface::IERC721", - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "enum", - name: "core::bool", - variants: [ - { - name: "False", - type: "()", - }, - { - name: "True", - type: "()", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc721::interface::IERC721", - items: [ - { - type: "function", - name: "balance_of", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "owner_of", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::starknet::contract_address::ContractAddress", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "safe_transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "approve", - inputs: [ - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "set_approval_for_all", - inputs: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "approved", - type: "core::bool", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "get_approved", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::starknet::contract_address::ContractAddress", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "is_approved_for_all", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "impl", - name: "ERC721MetadataImpl", - interface_name: - "openzeppelin::token::erc721::interface::IERC721Metadata", - }, - { - type: "struct", - name: "core::byte_array::ByteArray", - members: [ - { - name: "data", - type: "core::array::Array::", - }, - { - name: "pending_word", - type: "core::felt252", - }, - { - name: "pending_word_len", - type: "core::integer::u32", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc721::interface::IERC721Metadata", - items: [ - { - type: "function", - name: "name", - inputs: [], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "symbol", - inputs: [], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "token_uri", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "impl", - name: "OwnableImpl", - interface_name: "openzeppelin::access::ownable::interface::IOwnable", - }, - { - type: "interface", - name: "openzeppelin::access::ownable::interface::IOwnable", - items: [ - { - type: "function", - name: "owner", - inputs: [], - outputs: [ - { - type: "core::starknet::contract_address::ContractAddress", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "transfer_ownership", - inputs: [ - { - name: "new_owner", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "renounce_ownership", - inputs: [], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", - kind: "struct", - members: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "token_id", - type: "core::integer::u256", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", - kind: "struct", - members: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "approved", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "token_id", - type: "core::integer::u256", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", - kind: "struct", - members: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "approved", - type: "core::bool", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc721::erc721::ERC721Component::Event", - kind: "enum", - variants: [ - { - name: "Transfer", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Transfer", - kind: "nested", - }, - { - name: "Approval", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Approval", - kind: "nested", - }, - { - name: "ApprovalForAll", - type: "openzeppelin::token::erc721::erc721::ERC721Component::ApprovalForAll", - kind: "nested", - }, - ], - }, - { - type: "event", - name: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "enum", - variants: [], - }, - { - type: "event", - name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred", - kind: "struct", - members: [ - { - name: "previous_owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "new_owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted", - kind: "struct", - members: [ - { - name: "previous_owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "new_owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::access::ownable::ownable::OwnableComponent::Event", - kind: "enum", - variants: [ - { - name: "OwnershipTransferred", - type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred", - kind: "nested", - }, - { - name: "OwnershipTransferStarted", - type: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted", - kind: "nested", - }, - ], - }, - { - type: "event", - name: "contracts::challenge0::Challenge0::Event", - kind: "enum", - variants: [ - { - name: "ERC721Event", - type: "openzeppelin::token::erc721::erc721::ERC721Component::Event", - kind: "flat", - }, - { - name: "SRC5Event", - type: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "flat", - }, - { - name: "OwnableEvent", - type: "openzeppelin::access::ownable::ownable::OwnableComponent::Event", - kind: "flat", - }, - ], - }, - ], - }, - }, - sepolia: { - HelloStarknet: { - address: - "0x049fd22553ca315836e8f18c94c60d9383900884c2a4bc1d215bae043e3b1038", - abi: [ - { - type: "impl", - name: "HelloStarknetImpl", - interface_name: "contracts::helloStarknet::IHelloStarknet", - }, - { - type: "interface", - name: "contracts::helloStarknet::IHelloStarknet", - items: [ - { - type: "function", - name: "increase_balance", - inputs: [ - { - name: "amount", - type: "core::integer::u32", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "get_balance", - inputs: [], - outputs: [ - { - type: "core::integer::u32", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "get_balance_increment", - inputs: [ - { - name: "amount", - type: "core::integer::u32", - }, - ], - outputs: [ - { - type: "core::integer::u32", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "event", - name: "contracts::helloStarknet::HelloStarknet::Event", - kind: "enum", - variants: [], - }, - ], - }, - SimpleStorage: { - address: - "0x07b11042855e9f3d0006d517c220d99849bdfddd8c7e6ee406356c65313ed040", - abi: [ - { - type: "impl", - name: "SimpleStorageImpl", - interface_name: "contracts::simpleStorage::ISimpleStorage", - }, - { - type: "interface", - name: "contracts::simpleStorage::ISimpleStorage", - items: [ - { - type: "function", - name: "get_name", - inputs: [], - outputs: [ - { - type: "core::felt252", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "set_name", - inputs: [ - { - name: "name", - type: "core::felt252", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ - { - name: "name", - type: "core::felt252", - }, - ], - }, - { - type: "event", - name: "contracts::simpleStorage::SimpleStorage::Event", - kind: "enum", - variants: [], - }, - ], - }, - Challenge2: { - address: - "0x0612828fc31c858279315c1ad0747241d2d777c31ab30b97619e7c0fc238606d", - abi: [ - { - type: "impl", - name: "ERC1155Impl", - interface_name: "openzeppelin::token::erc1155::interface::IERC1155", - }, - { - type: "struct", - name: "core::integer::u256", - members: [ - { - name: "low", - type: "core::integer::u128", - }, - { - name: "high", - type: "core::integer::u128", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "struct", - name: "core::array::Span::", - members: [ - { - name: "snapshot", - type: "@core::array::Array::", - }, - ], - }, - { - type: "enum", - name: "core::bool", - variants: [ - { - name: "False", - type: "()", - }, - { - name: "True", - type: "()", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155", - items: [ - { - type: "function", - name: "balance_of", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "balance_of_batch", - inputs: [ - { - name: "accounts", - type: "core::array::Span::", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - ], - outputs: [ - { - type: "core::array::Span::", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "safe_transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_id", - type: "core::integer::u256", - }, - { - name: "value", - type: "core::integer::u256", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "safe_batch_transfer_from", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "is_approved_for_all", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "set_approval_for_all", - inputs: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "approved", - type: "core::bool", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "ERC1155MetadataURIImpl", - interface_name: - "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", - }, - { - type: "struct", - name: "core::byte_array::ByteArray", - members: [ - { - name: "data", - type: "core::array::Array::", - }, - { - name: "pending_word", - type: "core::felt252", - }, - { - name: "pending_word_len", - type: "core::integer::u32", - }, - ], - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155MetadataURI", - items: [ - { - type: "function", - name: "uri", - inputs: [ - { - name: "token_id", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::byte_array::ByteArray", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "impl", - name: "ERC1155Camel", - interface_name: - "openzeppelin::token::erc1155::interface::IERC1155Camel", - }, - { - type: "interface", - name: "openzeppelin::token::erc1155::interface::IERC1155Camel", - items: [ - { - type: "function", - name: "balanceOf", - inputs: [ - { - name: "account", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenId", - type: "core::integer::u256", - }, - ], - outputs: [ - { - type: "core::integer::u256", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "balanceOfBatch", - inputs: [ - { - name: "accounts", - type: "core::array::Span::", - }, - { - name: "tokenIds", - type: "core::array::Span::", - }, - ], - outputs: [ - { - type: "core::array::Span::", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "safeTransferFrom", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenId", - type: "core::integer::u256", - }, - { - name: "value", - type: "core::integer::u256", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "safeBatchTransferFrom", - inputs: [ - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "tokenIds", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - { - name: "data", - type: "core::array::Span::", - }, - ], - outputs: [], - state_mutability: "external", - }, - { - type: "function", - name: "isApprovedForAll", - inputs: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - { - type: "function", - name: "setApprovalForAll", - inputs: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "approved", - type: "core::bool", - }, - ], - outputs: [], - state_mutability: "external", - }, - ], - }, - { - type: "impl", - name: "SRC5Impl", - interface_name: "openzeppelin::introspection::interface::ISRC5", - }, - { - type: "interface", - name: "openzeppelin::introspection::interface::ISRC5", - items: [ - { - type: "function", - name: "supports_interface", - inputs: [ - { - name: "interface_id", - type: "core::felt252", - }, - ], - outputs: [ - { - type: "core::bool", - }, - ], - state_mutability: "view", - }, - ], - }, - { - type: "constructor", - name: "constructor", - inputs: [ - { - name: "base_uri", - type: "core::byte_array::ByteArray", - }, - { - name: "recipient", - type: "core::starknet::contract_address::ContractAddress", - }, - { - name: "token_ids", - type: "core::array::Span::", - }, - { - name: "values", - type: "core::array::Span::", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", - kind: "struct", - members: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "id", - type: "core::integer::u256", - kind: "data", - }, - { - name: "value", - type: "core::integer::u256", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", - kind: "struct", - members: [ - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "from", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "to", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "ids", - type: "core::array::Span::", - kind: "data", - }, - { - name: "values", - type: "core::array::Span::", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", - kind: "struct", - members: [ - { - name: "owner", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "operator", - type: "core::starknet::contract_address::ContractAddress", - kind: "key", - }, - { - name: "approved", - type: "core::bool", - kind: "data", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", - kind: "struct", - members: [ - { - name: "value", - type: "core::byte_array::ByteArray", - kind: "data", - }, - { - name: "id", - type: "core::integer::u256", - kind: "key", - }, - ], - }, - { - type: "event", - name: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", - kind: "enum", - variants: [ - { - name: "TransferSingle", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferSingle", - kind: "nested", - }, - { - name: "TransferBatch", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::TransferBatch", - kind: "nested", - }, - { - name: "ApprovalForAll", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::ApprovalForAll", - kind: "nested", - }, - { - name: "URI", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::URI", - kind: "nested", - }, - ], - }, - { - type: "event", - name: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "enum", - variants: [], - }, - { - type: "event", - name: "contracts::challenge2::Challenge2::Event", - kind: "enum", - variants: [ - { - name: "ERC1155Event", - type: "openzeppelin::token::erc1155::erc1155::ERC1155Component::Event", - kind: "flat", - }, - { - name: "SRC5Event", - type: "openzeppelin::introspection::src5::SRC5Component::Event", - kind: "flat", - }, - ], - }, - ], - }, - }, -} as const; +const deployedContracts = { } as const; export default deployedContracts; diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 2c7c3311..7e241f04 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -65,7 +65,8 @@ mod Challenge0 { fn mint_item(ref self: ContractState, recipient: ContractAddress) -> u256 { self._increment(); let token_id = self._current(); - self.erc721._mint(recipient, token_id); // _mint include _setTokenURI() + let data = array![].span(); + self.erc721._safe_mint(recipient, token_id, data); token_id } fn mint_id(ref self: ContractState, recipient: ContractAddress, id: u256) { From c9c0630776b2542468d0135c9450eec2a32e6e77 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Sat, 13 Apr 2024 18:07:50 +0700 Subject: [PATCH 05/11] Feat: Improve fn token_uri() --- packages/nextjs/scaffold.config.ts | 2 +- .../snfoundry/contracts/src/challenge0.cairo | 40 +++++++++++++------ packages/snfoundry/scripts_js/deploy.js | 2 +- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts index b57feb3a..9d010910 100644 --- a/packages/nextjs/scaffold.config.ts +++ b/packages/nextjs/scaffold.config.ts @@ -8,7 +8,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 || "", diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 7e241f04..4405451e 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -1,9 +1,11 @@ use starknet::ContractAddress; #[starknet::interface] -pub trait IChallenge0 { - fn mint_item(ref self: T, recipient: ContractAddress) -> u256; - fn mint_id(ref self: T, recipient: ContractAddress, id: u256); +trait IChallenge0 { + fn mint_item(ref self: T, recipient: ContractAddress //, uri: ByteArray + ) -> u256; + fn tokenIdCounter(self: @T) -> u256; + fn full_token_uri(self: @T, token_id: u256) -> ByteArray; } #[starknet::contract] mod Challenge0 { @@ -35,7 +37,8 @@ mod Challenge0 { src5: SRC5Component::Storage, #[substorage(v0)] ownable: OwnableComponent::Storage, - counter: u256 + counter: u256, + token_uris: LegacyMap, } #[event] @@ -53,24 +56,31 @@ mod Challenge0 { fn constructor(ref self: ContractState, owner: ContractAddress) { let name: ByteArray = "YourCollectible"; let symbol: ByteArray = "YCB"; - let base_uri: ByteArray = - "https://ipfs.io/ipfs/QmfVMAmNM1kDEBYrC2TPzQDoCRFH6F5tE1e9Mr4FkkR5Xr"; // bison nft + let base_uri: ByteArray = "https://ipfs.io/"; self.erc721.initializer(name, symbol, base_uri); self.ownable.initializer(owner); } #[abi(embed_v0)] - pub impl Challenge0Impl of IChallenge0 { - fn mint_item(ref self: ContractState, recipient: ContractAddress) -> u256 { + impl Challenge0Impl of IChallenge0 { + fn mint_item( + ref self: ContractState, recipient: ContractAddress //, uri: ByteArray + ) -> u256 { self._increment(); let token_id = self._current(); - let data = array![].span(); - self.erc721._safe_mint(recipient, token_id, data); + self.erc721._mint(recipient, token_id); + let uri: ByteArray = + "QmfVMAmNM1kDEBYrC2TPzQDoCRFH6F5tE1e9Mr4FkkR5Xr"; // Pass this as an argument + self._setTokenURI(token_id, uri); token_id } - fn mint_id(ref self: ContractState, recipient: ContractAddress, id: u256) { - self.erc721._mint(recipient, id); + fn tokenIdCounter(self: @ContractState) -> u256 { + self._current() + } + + fn full_token_uri(self: @ContractState, token_id: u256) -> ByteArray { + format!("{}{}", self.erc721._base_uri(), self.token_uris.read(token_id)) } } @@ -80,8 +90,12 @@ mod Challenge0 { self.counter.write(self.counter.read() + 1); } - fn _current(ref self: ContractState) -> u256 { + fn _current(self: @ContractState) -> u256 { self.counter.read() } + + fn _setTokenURI(ref self: ContractState, token_id: u256, uri: ByteArray) { + self.token_uris.write(token_id, uri); + } } } diff --git a/packages/snfoundry/scripts_js/deploy.js b/packages/snfoundry/scripts_js/deploy.js index 5af91ac5..823477a9 100644 --- a/packages/snfoundry/scripts_js/deploy.js +++ b/packages/snfoundry/scripts_js/deploy.js @@ -138,7 +138,7 @@ const deployScript = async () => { // ); await deployContract( - {owner: deployer.address}, + {owner: "0x4b3f4ba8c00a02b66142a4b1dd41a4dfab4f92650922a3280977b0f03c75ee1"}, // last account in devnet accounts "Challenge0" ); From ce5661a2b68ed47e1f2e0083edf48b1127c1629d Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Sat, 13 Apr 2024 18:14:38 +0700 Subject: [PATCH 06/11] fmt --- .github/workflows/lint.yml | 6 ++-- .../nextjs/contracts/deployedContracts.ts | 2 +- .../hooks/scaffold-stark/useSwitchNetwork.ts | 4 ++- .../nextjs/utils/scaffold-stark/contract.ts | 33 +++++++++---------- packages/snfoundry/scripts_js/deploy.js | 31 +++++++++-------- .../scripts_js/helpers/deploy-wrapper.js | 2 +- .../snfoundry/scripts_js/helpers/networks.js | 6 ++-- .../scripts_js/helpers/parseDeployments.js | 10 +++--- 8 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8046d021..59cc8a55 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,12 +3,12 @@ name: Next.js CI on: push: paths: - - 'packages/nextjs/**' + - "packages/nextjs/**" pull_request: branches: - main paths: - - 'packages/nextjs/**' + - "packages/nextjs/**" jobs: ci: @@ -27,7 +27,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} - cache: 'yarn' + cache: "yarn" #cache-dependency-path: packages/nextjs/yarn.lock - name: Install dependencies (Next.js) diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index 1951aa9b..25751cee 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -3,6 +3,6 @@ * You should not edit it manually or your changes might be overwritten. */ -const deployedContracts = { } as const; +const deployedContracts = {} as const; export default deployedContracts; diff --git a/packages/nextjs/hooks/scaffold-stark/useSwitchNetwork.ts b/packages/nextjs/hooks/scaffold-stark/useSwitchNetwork.ts index 791253fc..702e4483 100644 --- a/packages/nextjs/hooks/scaffold-stark/useSwitchNetwork.ts +++ b/packages/nextjs/hooks/scaffold-stark/useSwitchNetwork.ts @@ -5,7 +5,9 @@ export const useSwitchNetwork = () => { await window.starknet.request({ type: "wallet_switchStarknetChain", params: { - chainId: `SN_${network == "mainnet" ? "MAIN" : network.toUpperCase()}`, + chainId: `SN_${ + network == "mainnet" ? "MAIN" : network.toUpperCase() + }`, }, }); } diff --git a/packages/nextjs/utils/scaffold-stark/contract.ts b/packages/nextjs/utils/scaffold-stark/contract.ts index 93953f7f..d93234f1 100644 --- a/packages/nextjs/utils/scaffold-stark/contract.ts +++ b/packages/nextjs/utils/scaffold-stark/contract.ts @@ -248,26 +248,25 @@ type UseScaffoldArgsParam< TFunctionName extends ExtractAbiFunctionNamesScaffold< ContractAbi >, -> = - TFunctionName extends ExtractAbiFunctionNamesWithInputsScaffold< - ContractAbi - > - ? { - args: OptionalTupple< - UnionToIntersection< - ExtractArgs< +> = TFunctionName extends ExtractAbiFunctionNamesWithInputsScaffold< + ContractAbi +> + ? { + args: OptionalTupple< + UnionToIntersection< + ExtractArgs< + ContractAbi, + ExtractAbiFunctionScaffold< ContractAbi, - ExtractAbiFunctionScaffold< - ContractAbi, - TFunctionName - > + TFunctionName > > - >; - } - : { - args?: never; - }; + > + >; + } + : { + args?: never; + }; export type UseScaffoldReadConfig< TContractName extends ContractName, diff --git a/packages/snfoundry/scripts_js/deploy.js b/packages/snfoundry/scripts_js/deploy.js index 823477a9..7b5612a4 100644 --- a/packages/snfoundry/scripts_js/deploy.js +++ b/packages/snfoundry/scripts_js/deploy.js @@ -14,17 +14,17 @@ const { provider, deployer } = networks[networkName]; const deployContract = async ( constructorArgs, contractName, - exportContractName + exportContractName, ) => { const compiledContractCasm = JSON.parse( fs .readFileSync( path.resolve( __dirname, - `../contracts/target/dev/contracts_${contractName}.compiled_contract_class.json` - ) + `../contracts/target/dev/contracts_${contractName}.compiled_contract_class.json`, + ), ) - .toString("ascii") + .toString("ascii"), ); const compiledContractSierra = JSON.parse( @@ -32,10 +32,10 @@ const deployContract = async ( .readFileSync( path.resolve( __dirname, - `../contracts/target/dev/contracts_${contractName}.contract_class.json` - ) + `../contracts/target/dev/contracts_${contractName}.contract_class.json`, + ), ) - .toString("ascii") + .toString("ascii"), ); let classHash; @@ -43,7 +43,7 @@ const deployContract = async ( let contractAddress; const precomputedClassHash = hash.computeSierraContractClassHash( - compiledContractSierra + compiledContractSierra, ); const contractCalldata = new CallData(compiledContractSierra.abi); const constructorCalldata = constructorArgs @@ -60,7 +60,7 @@ const deployContract = async ( contract: compiledContractSierra, casm: compiledContractCasm, }, - {} + {}, ); totalFee = estimatedFeeDeclare * 2n; } catch (e) { @@ -81,14 +81,14 @@ const deployContract = async ( }, { maxFee: totalFee * 20n, // this optional max fee serves when error AccountValidation Failed or small fee on public networks , try 5n , 10n, 20n, 50n, 100n - } + }, ); const debug = await provider.waitForTransaction( tryDeclareAndDeploy.deploy.transaction_hash, { successStates: [TransactionStatus.ACCEPTED_ON_L2], // retryInterval: 10000, // we can retry in 10 seconds - } + }, ); classHash = tryDeclareAndDeploy.declare.class_hash; existingClass = await provider.getClassByHash(classHash); @@ -100,7 +100,7 @@ const deployContract = async ( console.log("Deployed contract ", contractName, " at: ", contractAddress); const chainIdPath = path.resolve( __dirname, - `../deployments/${networkName}.json` + `../deployments/${networkName}.json`, ); let deployments = {}; if (fs.existsSync(chainIdPath)) { @@ -138,8 +138,11 @@ const deployScript = async () => { // ); await deployContract( - {owner: "0x4b3f4ba8c00a02b66142a4b1dd41a4dfab4f92650922a3280977b0f03c75ee1"}, // last account in devnet accounts - "Challenge0" + { + owner: + "0x4b3f4ba8c00a02b66142a4b1dd41a4dfab4f92650922a3280977b0f03c75ee1", + }, // last account in devnet accounts + "Challenge0", ); // await deployContract( diff --git a/packages/snfoundry/scripts_js/helpers/deploy-wrapper.js b/packages/snfoundry/scripts_js/helpers/deploy-wrapper.js index 4a301fcc..29ca328d 100644 --- a/packages/snfoundry/scripts_js/helpers/deploy-wrapper.js +++ b/packages/snfoundry/scripts_js/helpers/deploy-wrapper.js @@ -9,5 +9,5 @@ require("child_process").execSync( "cd contracts && scarb build && node ../scripts_js/deploy.js --network " + process.env.NETWORK + " && node ../scripts_js/helpers/parseDeployments.js", - { stdio: "inherit" } + { stdio: "inherit" }, ); diff --git a/packages/snfoundry/scripts_js/helpers/networks.js b/packages/snfoundry/scripts_js/helpers/networks.js index 4330075b..61bb61d2 100644 --- a/packages/snfoundry/scripts_js/helpers/networks.js +++ b/packages/snfoundry/scripts_js/helpers/networks.js @@ -33,7 +33,7 @@ const deployerGoerli = providerGoerli, process.env.ACCOUNT_ADDRESS_GOERLI, process.env.PRIVATE_KEY_GOERLI, - 1 + 1, ); // sepolia @@ -49,7 +49,7 @@ const deployerSepolia = providerSepolia, process.env.ACCOUNT_ADDRESS_SEPOLIA, process.env.PRIVATE_KEY_SEPOLIA, - 1 + 1, ); // mainnet @@ -65,7 +65,7 @@ const deployerMainnet = providerMainnet, process.env.ACCOUNT_ADDRESS_MAINNET, process.env.PRIVATE_KEY_MAINNET, - 1 + 1, ); module.exports = { diff --git a/packages/snfoundry/scripts_js/helpers/parseDeployments.js b/packages/snfoundry/scripts_js/helpers/parseDeployments.js index 90d827c3..9eb86d0f 100644 --- a/packages/snfoundry/scripts_js/helpers/parseDeployments.js +++ b/packages/snfoundry/scripts_js/helpers/parseDeployments.js @@ -24,7 +24,7 @@ const getContractDataFromDeployments = () => { try { const abiFilePath = path.join( __dirname, - `../../contracts/target/dev/contracts_${contractData.contract}.contract_class.json` + `../../contracts/target/dev/contracts_${contractData.contract}.contract_class.json`, ); const abiContent = JSON.parse(fs.readFileSync(abiFilePath, "utf8")); @@ -51,7 +51,7 @@ const generateTsAbis = () => { // Use chainId directly as it is already a hex string return `${content}${chainId}:${JSON.stringify(chainConfig, null, 2)},`; }, - "" + "", ); if (!fs.existsSync(TARGET_DIR)) { @@ -64,12 +64,12 @@ const generateTsAbis = () => { `${generatedContractComment}\n\nconst deployedContracts = {${fileContent}} as const;\n\nexport default deployedContracts;`, { parser: "typescript", - } - ) + }, + ), ); console.log( - `📝 Updated TypeScript contract definition file on ${TARGET_DIR}/deployedContracts.ts` + `📝 Updated TypeScript contract definition file on ${TARGET_DIR}/deployedContracts.ts`, ); }; From 625b69169edd948f40beb18d701b819bd377c5d5 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Sat, 13 Apr 2024 18:17:39 +0700 Subject: [PATCH 07/11] fmt --- .../nextjs/utils/scaffold-stark/contract.ts | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/nextjs/utils/scaffold-stark/contract.ts b/packages/nextjs/utils/scaffold-stark/contract.ts index d93234f1..93953f7f 100644 --- a/packages/nextjs/utils/scaffold-stark/contract.ts +++ b/packages/nextjs/utils/scaffold-stark/contract.ts @@ -248,25 +248,26 @@ type UseScaffoldArgsParam< TFunctionName extends ExtractAbiFunctionNamesScaffold< ContractAbi >, -> = TFunctionName extends ExtractAbiFunctionNamesWithInputsScaffold< - ContractAbi -> - ? { - args: OptionalTupple< - UnionToIntersection< - ExtractArgs< - ContractAbi, - ExtractAbiFunctionScaffold< +> = + TFunctionName extends ExtractAbiFunctionNamesWithInputsScaffold< + ContractAbi + > + ? { + args: OptionalTupple< + UnionToIntersection< + ExtractArgs< ContractAbi, - TFunctionName + ExtractAbiFunctionScaffold< + ContractAbi, + TFunctionName + > > > - > - >; - } - : { - args?: never; - }; + >; + } + : { + args?: never; + }; export type UseScaffoldReadConfig< TContractName extends ContractName, From b33257ded3a2901e29f5462060d2646ab21aa1fa Mon Sep 17 00:00:00 2001 From: jrcarlos2000 Date: Sat, 13 Apr 2024 19:49:19 +0800 Subject: [PATCH 08/11] support bytearray on contract write --- .../nextjs/app/debug/_components/contract/utilsContract.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/nextjs/app/debug/_components/contract/utilsContract.tsx b/packages/nextjs/app/debug/_components/contract/utilsContract.tsx index 4f0a2959..34e9a1e2 100644 --- a/packages/nextjs/app/debug/_components/contract/utilsContract.tsx +++ b/packages/nextjs/app/debug/_components/contract/utilsContract.tsx @@ -1,5 +1,6 @@ import { AbiFunction, AbiParameter } from "~~/utils/scaffold-stark/contract"; import { uint256 } from "starknet"; +import { byteArray } from "starknet-dev"; /** * Generates a key based on function metadata */ @@ -37,6 +38,9 @@ const deepParseValues = (value: any, keyAndType?: any): any => { if (keyAndType.includes("core::integer::u256")) { return uint256.bnToUint256(value); } + if (keyAndType.includes("core::byte_array::ByteArray")) { + return byteArray.byteArrayFromString(value); + } } if (typeof value === "string") { if (isJsonString(value)) { From 1301e05f3ad3cc0d45b67b68d64b4a65a6262cb8 Mon Sep 17 00:00:00 2001 From: jrcarlos2000 Date: Sat, 13 Apr 2024 19:51:28 +0800 Subject: [PATCH 09/11] add completed contract --- packages/snfoundry/contracts/src/challenge0.cairo | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 4405451e..7edb67ac 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -2,7 +2,7 @@ use starknet::ContractAddress; #[starknet::interface] trait IChallenge0 { - fn mint_item(ref self: T, recipient: ContractAddress //, uri: ByteArray + fn mint_item(ref self: T, recipient: ContractAddress, uri: ByteArray ) -> u256; fn tokenIdCounter(self: @T) -> u256; fn full_token_uri(self: @T, token_id: u256) -> ByteArray; @@ -65,13 +65,11 @@ mod Challenge0 { #[abi(embed_v0)] impl Challenge0Impl of IChallenge0 { fn mint_item( - ref self: ContractState, recipient: ContractAddress //, uri: ByteArray + ref self: ContractState, recipient: ContractAddress, uri: ByteArray ) -> u256 { self._increment(); let token_id = self._current(); self.erc721._mint(recipient, token_id); - let uri: ByteArray = - "QmfVMAmNM1kDEBYrC2TPzQDoCRFH6F5tE1e9Mr4FkkR5Xr"; // Pass this as an argument self._setTokenURI(token_id, uri); token_id } From ec5ed1466e30aa1e8b543eba7c3b5a8f3634e15f Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Sat, 13 Apr 2024 21:37:27 +0700 Subject: [PATCH 10/11] Feat: Improve fn token_uri() --- .../snfoundry/contracts/src/challenge0.cairo | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 7edb67ac..565dba72 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -2,10 +2,8 @@ use starknet::ContractAddress; #[starknet::interface] trait IChallenge0 { - fn mint_item(ref self: T, recipient: ContractAddress, uri: ByteArray - ) -> u256; + fn mint_item(ref self: T, recipient: ContractAddress, uri: ByteArray) -> u256; fn tokenIdCounter(self: @T) -> u256; - fn full_token_uri(self: @T, token_id: u256) -> ByteArray; } #[starknet::contract] mod Challenge0 { @@ -13,6 +11,7 @@ mod Challenge0 { use openzeppelin::introspection::src5::SRC5Component; use openzeppelin::token::erc721::ERC721Component; use openzeppelin::access::ownable::OwnableComponent; + use openzeppelin::token::erc721::interface::IERC721Metadata; component!(path: ERC721Component, storage: erc721, event: ERC721Event); component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -22,8 +21,6 @@ mod Challenge0 { #[abi(embed_v0)] impl ERC721Impl = ERC721Component::ERC721Impl; #[abi(embed_v0)] - impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl; - #[abi(embed_v0)] impl OwnableImpl = OwnableComponent::OwnableImpl; impl ERC721InternalImpl = ERC721Component::InternalImpl; @@ -62,11 +59,22 @@ mod Challenge0 { self.ownable.initializer(owner); } + #[abi(embed_v0)] + impl WrappedIERC721MetadataImpl of IERC721Metadata { + fn token_uri(self: @ContractState, token_id: u256) -> ByteArray { + self._full_token_uri(token_id) + } + fn name(self: @ContractState) -> ByteArray { + self.erc721.name() + } + fn symbol(self: @ContractState) -> ByteArray { + self.erc721.symbol() + } + } + #[abi(embed_v0)] impl Challenge0Impl of IChallenge0 { - fn mint_item( - ref self: ContractState, recipient: ContractAddress, uri: ByteArray - ) -> u256 { + fn mint_item(ref self: ContractState, recipient: ContractAddress, uri: ByteArray) -> u256 { self._increment(); let token_id = self._current(); self.erc721._mint(recipient, token_id); @@ -76,10 +84,6 @@ mod Challenge0 { fn tokenIdCounter(self: @ContractState) -> u256 { self._current() } - - fn full_token_uri(self: @ContractState, token_id: u256) -> ByteArray { - format!("{}{}", self.erc721._base_uri(), self.token_uris.read(token_id)) - } } #[generate_trait] @@ -92,6 +96,13 @@ mod Challenge0 { self.counter.read() } + fn _full_token_uri(self: @ContractState, token_id: u256) -> ByteArray { + assert(self.erc721._exists(token_id), ERC721Component::Errors::INVALID_TOKEN_ID); + let base_uri = self.erc721._base_uri(); + let token_uri = self.token_uris.read(token_id); + format!("{}{}", base_uri, token_uri) + } + fn _setTokenURI(ref self: ContractState, token_id: u256, uri: ByteArray) { self.token_uris.write(token_id, uri); } From 314dac463ccabe577a84d33af5a249a01d891d33 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Sat, 13 Apr 2024 22:51:14 +0700 Subject: [PATCH 11/11] Fix: Format to snake_case --- .../snfoundry/contracts/src/challenge0.cairo | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/snfoundry/contracts/src/challenge0.cairo b/packages/snfoundry/contracts/src/challenge0.cairo index 565dba72..22ac713b 100644 --- a/packages/snfoundry/contracts/src/challenge0.cairo +++ b/packages/snfoundry/contracts/src/challenge0.cairo @@ -3,7 +3,7 @@ use starknet::ContractAddress; #[starknet::interface] trait IChallenge0 { fn mint_item(ref self: T, recipient: ContractAddress, uri: ByteArray) -> u256; - fn tokenIdCounter(self: @T) -> u256; + fn token_id_counter(self: @T) -> u256; } #[starknet::contract] mod Challenge0 { @@ -62,7 +62,7 @@ mod Challenge0 { #[abi(embed_v0)] impl WrappedIERC721MetadataImpl of IERC721Metadata { fn token_uri(self: @ContractState, token_id: u256) -> ByteArray { - self._full_token_uri(token_id) + self._token_uri(token_id) } fn name(self: @ContractState) -> ByteArray { self.erc721.name() @@ -78,10 +78,10 @@ mod Challenge0 { self._increment(); let token_id = self._current(); self.erc721._mint(recipient, token_id); - self._setTokenURI(token_id, uri); + self._set_token_uri(token_id, uri); token_id } - fn tokenIdCounter(self: @ContractState) -> u256 { + fn token_id_counter(self: @ContractState) -> u256 { self._current() } } @@ -96,14 +96,14 @@ mod Challenge0 { self.counter.read() } - fn _full_token_uri(self: @ContractState, token_id: u256) -> ByteArray { + fn _token_uri(self: @ContractState, token_id: u256) -> ByteArray { assert(self.erc721._exists(token_id), ERC721Component::Errors::INVALID_TOKEN_ID); let base_uri = self.erc721._base_uri(); - let token_uri = self.token_uris.read(token_id); - format!("{}{}", base_uri, token_uri) + let uri = self.token_uris.read(token_id); + format!("{}{}", base_uri, uri) } - fn _setTokenURI(ref self: ContractState, token_id: u256, uri: ByteArray) { + fn _set_token_uri(ref self: ContractState, token_id: u256, uri: ByteArray) { self.token_uris.write(token_id, uri); } }