From d575627ce296acb586554ed471df53d13168d47a Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 17 Jan 2025 20:24:30 -0600 Subject: [PATCH] tabs and contract call fix --- frontend/src/App.js | 26 +- frontend/src/contracts/art_peace.abi.json | 281 ++++++++++++------ frontend/src/contracts/canvas_nft.abi.json | 4 + frontend/src/contracts/multi_canvas.abi.json | 256 ++++++++++++++++ .../src/tabs/worlds/WorldsCreationPanel.js | 9 +- 5 files changed, 471 insertions(+), 105 deletions(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index ec19f0ea..84c3fc7f 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -123,22 +123,35 @@ function App() { // Window management usePreventZoom(); + const defaultWorldsTabs = ['Canvas', 'Worlds', 'Stencils', 'Account']; + const defaultTabs = []; + // TODO: Add features back /* - const tabs = [ + [ 'Canvas', 'Factions', 'NFTs', 'Quests', 'Vote', - 'Worlds', 'Account' ]; - // : ['Canvas', 'Factions', 'NFTs', 'Quests', 'Vote', 'Account']; */ - // TODO: Add features back - const tabs = devnetMode ? ['Canvas', 'Worlds', 'Stencils', 'Account'] : []; - const [activeTab, setActiveTab] = useState(tabs[0]); + const [tabs, setTabs] = useState( + worldsMode ? defaultWorldsTabs : defaultTabs + ); + const [activeTab, setActiveTab] = useState( + worldsMode ? defaultWorldsTabs[0] : defaultTabs[0] + ); useLockScroll(activeTab === 'Canvas'); + useEffect(() => { + if (worldsMode) { + setTabs(defaultWorldsTabs); + setActiveTab(defaultWorldsTabs[0]); + } else { + setTabs(defaultTabs); + setActiveTab(defaultTabs[0]); + } + }, [worldsMode]); const isDesktopOrLaptop = useMediaQuery({ query: '(min-width: 1224px)' @@ -226,6 +239,7 @@ function App() { ); const multiCanvasContract = new Contract( multi_canvas_abi, + // '0x03ce937f91fa0c88a4023f582c729935a5366385091166a763e53281e45ac410', process.env.REACT_APP_CANVAS_FACTORY_CONTRACT_ADDRESS, account ); diff --git a/frontend/src/contracts/art_peace.abi.json b/frontend/src/contracts/art_peace.abi.json index c837aeab..36cdf14e 100644 --- a/frontend/src/contracts/art_peace.abi.json +++ b/frontend/src/contracts/art_peace.abi.json @@ -80,6 +80,20 @@ } ] }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, { "type": "struct", "name": "art_peace::templates::interfaces::FactionTemplateMetadata", @@ -813,6 +827,26 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "already_liked_nft", + "inputs": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "nft_id", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "add_faction_template", @@ -1131,23 +1165,44 @@ }, { "type": "impl", - "name": "TemplateStoreComponentImpl", - "interface_name": "art_peace::templates::interfaces::ITemplateStore" + "name": "ArtPeaceCanvasNFTLikeAndUnlike", + "interface_name": "art_peace::nfts::interfaces::ICanvasNFTLikeAndUnlike" }, { - "type": "struct", - "name": "core::integer::u256", - "members": [ + "type": "interface", + "name": "art_peace::nfts::interfaces::ICanvasNFTLikeAndUnlike", + "items": [ { - "name": "low", - "type": "core::integer::u128" + "type": "function", + "name": "like_nft", + "inputs": [ + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" }, { - "name": "high", - "type": "core::integer::u128" + "type": "function", + "name": "unlike_nft", + "inputs": [ + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" } ] }, + { + "type": "impl", + "name": "TemplateStoreComponentImpl", + "interface_name": "art_peace::templates::interfaces::ITemplateStore" + }, { "type": "struct", "name": "art_peace::templates::interfaces::TemplateMetadata", @@ -1489,65 +1544,6 @@ } ] }, - { - "type": "event", - "name": "art_peace::art_peace::ArtPeace::DailyQuestClaimed", - "kind": "struct", - "members": [ - { - "name": "day_index", - "type": "core::integer::u32", - "kind": "key" - }, - { - "name": "quest_id", - "type": "core::integer::u32", - "kind": "key" - }, - { - "name": "user", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "key" - }, - { - "name": "reward", - "type": "core::integer::u32", - "kind": "data" - }, - { - "name": "calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "art_peace::art_peace::ArtPeace::MainQuestClaimed", - "kind": "struct", - "members": [ - { - "name": "quest_id", - "type": "core::integer::u32", - "kind": "key" - }, - { - "name": "user", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "key" - }, - { - "name": "reward", - "type": "core::integer::u32", - "kind": "data" - }, - { - "name": "calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, { "type": "event", "name": "art_peace::art_peace::ArtPeace::VoteColor", @@ -1769,63 +1765,166 @@ }, { "type": "event", - "name": "art_peace::art_peace::ArtPeace::HostAwardedUser", + "name": "art_peace::templates::component::TemplateStoreComponent::TemplateAdded", "kind": "struct", "members": [ + { + "name": "id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "metadata", + "type": "art_peace::templates::interfaces::TemplateMetadata", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "art_peace::templates::component::TemplateStoreComponent::TemplateCompleted", + "kind": "struct", + "members": [ + { + "name": "id", + "type": "core::integer::u32", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "art_peace::templates::component::TemplateStoreComponent::Event", + "kind": "enum", + "variants": [ + { + "name": "TemplateAdded", + "type": "art_peace::templates::component::TemplateStoreComponent::TemplateAdded", + "kind": "nested" + }, + { + "name": "TemplateCompleted", + "type": "art_peace::templates::component::TemplateStoreComponent::TemplateCompleted", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "art_peace::art_peace::ArtPeace::DailyQuestClaimed", + "kind": "struct", + "members": [ + { + "name": "day_index", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "quest_id", + "type": "core::integer::u32", + "kind": "key" + }, { "name": "user", "type": "core::starknet::contract_address::ContractAddress", "kind": "key" }, { - "name": "amount", + "name": "reward", "type": "core::integer::u32", "kind": "data" + }, + { + "name": "calldata", + "type": "core::array::Span::", + "kind": "data" } ] }, { "type": "event", - "name": "art_peace::templates::component::TemplateStoreComponent::TemplateAdded", + "name": "art_peace::art_peace::ArtPeace::MainQuestClaimed", "kind": "struct", "members": [ { - "name": "id", + "name": "quest_id", "type": "core::integer::u32", "kind": "key" }, { - "name": "metadata", - "type": "art_peace::templates::interfaces::TemplateMetadata", + "name": "user", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "reward", + "type": "core::integer::u32", + "kind": "data" + }, + { + "name": "calldata", + "type": "core::array::Span::", "kind": "data" } ] }, { "type": "event", - "name": "art_peace::templates::component::TemplateStoreComponent::TemplateCompleted", + "name": "art_peace::art_peace::ArtPeace::HostAwardedUser", "kind": "struct", "members": [ { - "name": "id", + "name": "user", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "amount", "type": "core::integer::u32", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "art_peace::art_peace::ArtPeace::LikeNftAwarded", + "kind": "struct", + "members": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress", "kind": "key" + }, + { + "name": "amount", + "type": "core::integer::u32", + "kind": "data" } ] }, { "type": "event", - "name": "art_peace::templates::component::TemplateStoreComponent::Event", + "name": "art_peace::art_peace::ArtPeace::ExtraPixelsAwarded", "kind": "enum", "variants": [ { - "name": "TemplateAdded", - "type": "art_peace::templates::component::TemplateStoreComponent::TemplateAdded", + "name": "DailyQuest", + "type": "art_peace::art_peace::ArtPeace::DailyQuestClaimed", "kind": "nested" }, { - "name": "TemplateCompleted", - "type": "art_peace::templates::component::TemplateStoreComponent::TemplateCompleted", + "name": "MainQuest", + "type": "art_peace::art_peace::ArtPeace::MainQuestClaimed", + "kind": "nested" + }, + { + "name": "HostAwardedUser", + "type": "art_peace::art_peace::ArtPeace::HostAwardedUser", + "kind": "nested" + }, + { + "name": "LikeNft", + "type": "art_peace::art_peace::ArtPeace::LikeNftAwarded", "kind": "nested" } ] @@ -1875,16 +1974,6 @@ "type": "art_peace::art_peace::ArtPeace::ExtraPixelsPlaced", "kind": "nested" }, - { - "name": "DailyQuestClaimed", - "type": "art_peace::art_peace::ArtPeace::DailyQuestClaimed", - "kind": "nested" - }, - { - "name": "MainQuestClaimed", - "type": "art_peace::art_peace::ArtPeace::MainQuestClaimed", - "kind": "nested" - }, { "name": "VoteColor", "type": "art_peace::art_peace::ArtPeace::VoteColor", @@ -1945,15 +2034,15 @@ "type": "art_peace::art_peace::ArtPeace::ChainFactionTemplateRemoved", "kind": "nested" }, - { - "name": "HostAwardedUser", - "type": "art_peace::art_peace::ArtPeace::HostAwardedUser", - "kind": "nested" - }, { "name": "TemplateEvent", "type": "art_peace::templates::component::TemplateStoreComponent::Event", "kind": "flat" + }, + { + "name": "ExtraPixelsAwardedEvent", + "type": "art_peace::art_peace::ArtPeace::ExtraPixelsAwarded", + "kind": "flat" } ] } diff --git a/frontend/src/contracts/canvas_nft.abi.json b/frontend/src/contracts/canvas_nft.abi.json index 19442e29..506c3a14 100644 --- a/frontend/src/contracts/canvas_nft.abi.json +++ b/frontend/src/contracts/canvas_nft.abi.json @@ -673,6 +673,10 @@ { "name": "symbol", "type": "core::byte_array::ByteArray" + }, + { + "name": "round_number", + "type": "core::felt252" } ] }, diff --git a/frontend/src/contracts/multi_canvas.abi.json b/frontend/src/contracts/multi_canvas.abi.json index 5c97f85a..467f65ff 100644 --- a/frontend/src/contracts/multi_canvas.abi.json +++ b/frontend/src/contracts/multi_canvas.abi.json @@ -12,6 +12,10 @@ "name": "name", "type": "core::felt252" }, + { + "name": "unique_name", + "type": "core::felt252" + }, { "name": "width", "type": "core::integer::u128" @@ -52,6 +56,10 @@ "name": "name", "type": "core::felt252" }, + { + "name": "unique_name", + "type": "core::felt252" + }, { "name": "width", "type": "core::integer::u128" @@ -78,6 +86,28 @@ } ] }, + { + "type": "struct", + "name": "art_peace::multi_canvas::MultiCanvas::StencilMetadata", + "members": [ + { + "name": "hash", + "type": "core::felt252" + }, + { + "name": "width", + "type": "core::integer::u128" + }, + { + "name": "height", + "type": "core::integer::u128" + }, + { + "name": "position", + "type": "core::integer::u128" + } + ] + }, { "type": "interface", "name": "art_peace::multi_canvas::IMultiCanvas", @@ -280,6 +310,20 @@ "outputs": [], "state_mutability": "external" }, + { + "type": "function", + "name": "enable_awards", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "disable_awards", + "inputs": [], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "award_user", @@ -483,6 +527,110 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "get_stencil_count", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + } + ], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_stencil", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + }, + { + "name": "stencil_id", + "type": "core::integer::u32" + } + ], + "outputs": [ + { + "type": "art_peace::multi_canvas::MultiCanvas::StencilMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "add_stencil", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + }, + { + "name": "stencil", + "type": "art_peace::multi_canvas::MultiCanvas::StencilMetadata" + } + ], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "remove_stencil", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + }, + { + "name": "stencil_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "favorite_stencil", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + }, + { + "name": "stencil_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "unfavorite_stencil", + "inputs": [ + { + "name": "canvas_id", + "type": "core::integer::u32" + }, + { + "name": "stencil_id", + "type": "core::integer::u32" + } + ], + "outputs": [], + "state_mutability": "external" } ] }, @@ -706,6 +854,94 @@ } ] }, + { + "type": "event", + "name": "art_peace::multi_canvas::MultiCanvas::StencilAdded", + "kind": "struct", + "members": [ + { + "name": "canvas_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil", + "type": "art_peace::multi_canvas::MultiCanvas::StencilMetadata", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "art_peace::multi_canvas::MultiCanvas::StencilRemoved", + "kind": "struct", + "members": [ + { + "name": "canvas_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil", + "type": "art_peace::multi_canvas::MultiCanvas::StencilMetadata", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "art_peace::multi_canvas::MultiCanvas::StencilFavorited", + "kind": "struct", + "members": [ + { + "name": "canvas_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "art_peace::multi_canvas::MultiCanvas::StencilUnfavorited", + "kind": "struct", + "members": [ + { + "name": "canvas_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "stencil_id", + "type": "core::integer::u32", + "kind": "key" + }, + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + } + ] + }, { "type": "event", "name": "art_peace::multi_canvas::MultiCanvas::Event", @@ -760,6 +996,26 @@ "name": "CanvasUnfavorited", "type": "art_peace::multi_canvas::MultiCanvas::CanvasUnfavorited", "kind": "nested" + }, + { + "name": "StencilAdded", + "type": "art_peace::multi_canvas::MultiCanvas::StencilAdded", + "kind": "nested" + }, + { + "name": "StencilRemoved", + "type": "art_peace::multi_canvas::MultiCanvas::StencilRemoved", + "kind": "nested" + }, + { + "name": "StencilFavorited", + "type": "art_peace::multi_canvas::MultiCanvas::StencilFavorited", + "kind": "nested" + }, + { + "name": "StencilUnfavorited", + "type": "art_peace::multi_canvas::MultiCanvas::StencilUnfavorited", + "kind": "nested" } ] } diff --git a/frontend/src/tabs/worlds/WorldsCreationPanel.js b/frontend/src/tabs/worlds/WorldsCreationPanel.js index 3b1d16cc..4d0d76d8 100644 --- a/frontend/src/tabs/worlds/WorldsCreationPanel.js +++ b/frontend/src/tabs/worlds/WorldsCreationPanel.js @@ -30,6 +30,7 @@ const WorldsCreationPanel = (props) => { const createWorldCall = async ( name, + slug, width, height, timer, @@ -42,13 +43,15 @@ const WorldsCreationPanel = (props) => { return; // TODO: Validate ... const host = props.account.address; + let formattedPalette = palette.map((color) => '0x' + color); let createWorldParams = { host: host, name: toHex(name), + unique_name: toHex(slug), width: width, height: height, time_between_pixels: timer, - color_palette: palette, + color_palette: formattedPalette, start_time: start, end_time: end }; @@ -61,12 +64,12 @@ const WorldsCreationPanel = (props) => { const { suggestedMaxFee } = await props.estimateInvokeFee({ contractAddress: props.canvasFactoryContract.address, entrypoint: 'create_canvas', - calldata: createWorldsCalldata + calldata: createWorldsCalldata.calldata }); /* global BigInt */ const maxFee = (suggestedMaxFee * BigInt(15)) / BigInt(10); const result = await props.canvasFactoryContract.create_canvas( - createWorldParams.calldata, + createWorldsCalldata.calldata, { maxFee }