diff --git a/Scarb.lock b/Scarb.lock index fb7637a..899ada1 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -16,6 +16,15 @@ source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79 [[package]] name = "flippyflop" version = "0.1.0" +dependencies = [ + "dojo", + "origami_token", +] + +[[package]] +name = "origami_token" +version = "1.0.0-alpha.8" +source = "git+https://github.com/Larkooo/origami#413f24299e80c0808f67efaae968ab09068cdebe" dependencies = [ "dojo", ] diff --git a/Scarb.toml b/Scarb.toml index 6a331ac..4b0e1f3 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -13,11 +13,20 @@ move = "./scripts/move.sh" [dependencies] dojo = { path = "/Users/nasr/Documents/development.nosync/dojo/crates/dojo-core" } +origami_token = { git = "https://github.com/Larkooo/origami" } [[target.dojo]] [tool.dojo] -initializer_class_hash = "0xbeef" + +build-external-contracts = [ + "origami_token::components::security::initializable::initializable_model", + "origami_token::components::token::erc20::erc20_metadata::erc_20_metadata_model", + "origami_token::components::token::erc20::erc20_balance::erc_20_balance_model", + "origami_token::components::token::erc20::erc20_allowance::erc_20_allowance_model", + "origami_token::components::token::erc20::erc20_mintable::erc_20_mintable_model", + "origami_token::components::token::erc20::erc20_burnable::erc_20_burnable_model", +] [profile.dev] [profile.sepolia] diff --git a/dojo_dev.toml b/dojo_dev.toml index 87a4286..7ae0b91 100644 --- a/dojo_dev.toml +++ b/dojo_dev.toml @@ -17,6 +17,7 @@ seed = "flippyflop-katana" [namespace] default = "flippyflop" +mappings = { "origami_token" = "flippyflop" } [socials] x = "https://x.com/ohayo_dojo" diff --git a/dojo_sepolia.toml b/dojo_sepolia.toml index 88b880d..bedbd3c 100644 --- a/dojo_sepolia.toml +++ b/dojo_sepolia.toml @@ -17,6 +17,7 @@ seed = "flippyflop-sepolia-1000" [namespace] default = "flippyflop" +mappings = { "origami_token" = "flippyflop" } [socials] x = "https://x.com/ohayo_dojo" diff --git a/indexer.db b/indexer.db index 8e0a20b..563f329 100644 Binary files a/indexer.db and b/indexer.db differ diff --git a/manifests/dev/base/abis/contracts/flippyflop-actions-4407e5f5.json b/manifests/dev/base/abis/contracts/flippyflop-actions-4407e5f5.json index 733ef4f..3ab98a8 100644 --- a/manifests/dev/base/abis/contracts/flippyflop-actions-4407e5f5.json +++ b/manifests/dev/base/abis/contracts/flippyflop-actions-4407e5f5.json @@ -157,6 +157,13 @@ "inputs": [], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "claim", + "inputs": [], + "outputs": [], + "state_mutability": "external" } ] }, diff --git a/manifests/dev/base/abis/contracts/flippyflop-flip-5ba18c69.json b/manifests/dev/base/abis/contracts/flippyflop-flip-5ba18c69.json new file mode 100644 index 0000000..f66ce45 --- /dev/null +++ b/manifests/dev/base/abis/contracts/flippyflop-flip-5ba18c69.json @@ -0,0 +1,768 @@ +[ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::contract::IContract" + }, + { + "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": "dojo::contract::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::world_contract::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::world_contract::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::world_contract::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::world_contract::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "flippyflop::tokens::flip::flip::IDojoInit" + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::flip::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20InitializerImpl", + "interface_name": "flippyflop::tokens::flip::IERC20BridgeableInitializer" + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::IERC20BridgeableInitializer", + "items": [ + { + "type": "function", + "name": "initializer", + "inputs": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "symbol", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "Flip", + "interface_name": "flippyflop::tokens::flip::IFlip" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::IFlip", + "items": [ + { + "type": "function", + "name": "balance", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "mint_from", + "inputs": [ + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "burn_from", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::contract::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::contract::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20MetadataImpl", + "interface_name": "origami_token::components::token::erc20::erc20_metadata::IERC20Metadata" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_metadata::IERC20Metadata", + "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": "decimals", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ERC20MetadataTotalSupplyImpl", + "interface_name": "origami_token::components::token::erc20::erc20_metadata::IERC20MetadataTotalSupply" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_metadata::IERC20MetadataTotalSupply", + "items": [ + { + "type": "function", + "name": "total_supply", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ERC20MetadataTotalSupplyCamelImpl", + "interface_name": "origami_token::components::token::erc20::erc20_metadata::IERC20MetadataTotalSupplyCamel" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_metadata::IERC20MetadataTotalSupplyCamel", + "items": [ + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ERC20BalanceImpl", + "interface_name": "origami_token::components::token::erc20::erc20_balance::IERC20Balance" + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_balance::IERC20Balance", + "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": "transfer", + "inputs": [ + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "transfer_from", + "inputs": [ + { + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20BalanceCamelImpl", + "interface_name": "origami_token::components::token::erc20::erc20_balance::IERC20BalanceCamel" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_balance::IERC20BalanceCamel", + "items": [ + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20AllowanceImpl", + "interface_name": "origami_token::components::token::erc20::erc20_allowance::IERC20Allowance" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_allowance::IERC20Allowance", + "items": [ + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20BridgeableImpl", + "interface_name": "origami_token::components::token::erc20::erc20_bridgeable::IERC20Bridgeable" + }, + { + "type": "interface", + "name": "origami_token::components::token::erc20::erc20_bridgeable::IERC20Bridgeable", + "items": [ + { + "type": "function", + "name": "l2_bridge_address", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "burn", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::contract::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "origami_token::components::security::initializable::initializable_component::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_metadata::erc20_metadata_component::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_balance::erc20_balance_component::Transfer", + "kind": "struct", + "members": [ + { + "name": "from", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_balance::erc20_balance_component::Event", + "kind": "enum", + "variants": [ + { + "name": "Transfer", + "type": "origami_token::components::token::erc20::erc20_balance::erc20_balance_component::Transfer", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_allowance::erc20_allowance_component::Approval", + "kind": "struct", + "members": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_allowance::erc20_allowance_component::Event", + "kind": "enum", + "variants": [ + { + "name": "Approval", + "type": "origami_token::components::token::erc20::erc20_allowance::erc20_allowance_component::Approval", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_mintable::erc20_mintable_component::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_burnable::erc20_burnable_component::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "origami_token::components::token::erc20::erc20_bridgeable::erc20_bridgeable_component::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "flippyflop::tokens::flip::flip::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::contract::upgradeable::upgradeable::Event", + "kind": "nested" + }, + { + "name": "InitializableEvent", + "type": "origami_token::components::security::initializable::initializable_component::Event", + "kind": "flat" + }, + { + "name": "ERC20MetadataEvent", + "type": "origami_token::components::token::erc20::erc20_metadata::erc20_metadata_component::Event", + "kind": "flat" + }, + { + "name": "ERC20BalanceEvent", + "type": "origami_token::components::token::erc20::erc20_balance::erc20_balance_component::Event", + "kind": "flat" + }, + { + "name": "ERC20AllowanceEvent", + "type": "origami_token::components::token::erc20::erc20_allowance::erc20_allowance_component::Event", + "kind": "flat" + }, + { + "name": "ERC20MintableEvent", + "type": "origami_token::components::token::erc20::erc20_mintable::erc20_mintable_component::Event", + "kind": "flat" + }, + { + "name": "ERC20BurnableEvent", + "type": "origami_token::components::token::erc20::erc20_burnable::erc20_burnable_component::Event", + "kind": "flat" + }, + { + "name": "ERC20BridgeableEvent", + "type": "origami_token::components::token::erc20::erc20_bridgeable::erc20_bridgeable_component::Event", + "kind": "flat" + } + ] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/flippyflop-ERC20AllowanceModel-55d0c41e.json b/manifests/dev/base/abis/models/flippyflop-ERC20AllowanceModel-55d0c41e.json new file mode 100644 index 0000000..b6f3047 --- /dev/null +++ b/manifests/dev/base/abis/models/flippyflop-ERC20AllowanceModel-55d0c41e.json @@ -0,0 +1,429 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "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": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "erc_20_allowance_modelImpl", + "interface_name": "flippyflop::tokens::flip::Ierc_20_allowance_model" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "struct", + "name": "flippyflop::tokens::flip::ERC20AllowanceModel", + "members": [ + { + "name": "token", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::Ierc_20_allowance_model", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "flippyflop::tokens::flip::ERC20AllowanceModel" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "flippyflop::tokens::flip::erc_20_allowance_model::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/flippyflop-ERC20BalanceModel-7866fe9f.json b/manifests/dev/base/abis/models/flippyflop-ERC20BalanceModel-7866fe9f.json new file mode 100644 index 0000000..f35b898 --- /dev/null +++ b/manifests/dev/base/abis/models/flippyflop-ERC20BalanceModel-7866fe9f.json @@ -0,0 +1,425 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "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": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "erc_20_balance_modelImpl", + "interface_name": "flippyflop::tokens::flip::Ierc_20_balance_model" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "struct", + "name": "flippyflop::tokens::flip::ERC20BalanceModel", + "members": [ + { + "name": "token", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::Ierc_20_balance_model", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "flippyflop::tokens::flip::ERC20BalanceModel" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "flippyflop::tokens::flip::erc_20_balance_model::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.json b/manifests/dev/base/abis/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.json new file mode 100644 index 0000000..cbb994b --- /dev/null +++ b/manifests/dev/base/abis/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "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": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "erc_20_bridgeable_modelImpl", + "interface_name": "flippyflop::tokens::flip::Ierc_20_bridgeable_model" + }, + { + "type": "struct", + "name": "flippyflop::tokens::flip::ERC20BridgeableModel", + "members": [ + { + "name": "token", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "l2_bridge_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::Ierc_20_bridgeable_model", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "flippyflop::tokens::flip::ERC20BridgeableModel" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "flippyflop::tokens::flip::erc_20_bridgeable_model::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/flippyflop-ERC20MetadataModel-1fc3dc07.json b/manifests/dev/base/abis/models/flippyflop-ERC20MetadataModel-1fc3dc07.json new file mode 100644 index 0000000..caab4c8 --- /dev/null +++ b/manifests/dev/base/abis/models/flippyflop-ERC20MetadataModel-1fc3dc07.json @@ -0,0 +1,433 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "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": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "erc_20_metadata_modelImpl", + "interface_name": "flippyflop::tokens::flip::Ierc_20_metadata_model" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "struct", + "name": "flippyflop::tokens::flip::ERC20MetadataModel", + "members": [ + { + "name": "token", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "symbol", + "type": "core::byte_array::ByteArray" + }, + { + "name": "decimals", + "type": "core::integer::u8" + }, + { + "name": "total_supply", + "type": "core::integer::u256" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::tokens::flip::Ierc_20_metadata_model", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "flippyflop::tokens::flip::ERC20MetadataModel" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "flippyflop::tokens::flip::erc_20_metadata_model::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/abis/models/flippyflop-Game-54c54faf.json b/manifests/dev/base/abis/models/flippyflop-Game-54c54faf.json new file mode 100644 index 0000000..47e0750 --- /dev/null +++ b/manifests/dev/base/abis/models/flippyflop-Game-54c54faf.json @@ -0,0 +1,421 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::model::IModel" + }, + { + "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": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::layout::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::model::layout::Layout" + } + ] + }, + { + "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": "dojo::model::layout::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::model::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::model::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::model::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::model::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::model::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::model::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::layout::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::model::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "gameImpl", + "interface_name": "flippyflop::models::Igame" + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "flippyflop::models::Game", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "is_locked", + "type": "core::bool" + } + ] + }, + { + "type": "interface", + "name": "flippyflop::models::Igame", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "flippyflop::models::Game" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "flippyflop::models::game::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/manifests/dev/base/contracts/flippyflop-actions-4407e5f5.toml b/manifests/dev/base/contracts/flippyflop-actions-4407e5f5.toml index cc729df..98a4840 100644 --- a/manifests/dev/base/contracts/flippyflop-actions-4407e5f5.toml +++ b/manifests/dev/base/contracts/flippyflop-actions-4407e5f5.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2" -original_class_hash = "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2" +class_hash = "0x2792b58a3d449e7ac8967c2b7e09b53d01759f728c91dbff0f2c3def28ebfcf" +original_class_hash = "0x2792b58a3d449e7ac8967c2b7e09b53d01759f728c91dbff0f2c3def28ebfcf" base_class_hash = "0x0" abi = "manifests/dev/base/abis/contracts/flippyflop-actions-4407e5f5.json" reads = [] @@ -10,5 +10,6 @@ tag = "flippyflop-actions" systems = [ "flip", "flop", + "claim", ] manifest_name = "flippyflop-actions-4407e5f5" diff --git a/manifests/dev/base/contracts/flippyflop-flip-5ba18c69.toml b/manifests/dev/base/contracts/flippyflop-flip-5ba18c69.toml new file mode 100644 index 0000000..401028e --- /dev/null +++ b/manifests/dev/base/contracts/flippyflop-flip-5ba18c69.toml @@ -0,0 +1,15 @@ +kind = "DojoContract" +class_hash = "0x67f7dac6218b32160697eabc6c2bf2f2781675917924b8fdc179dcb73c3a0d3" +original_class_hash = "0x67f7dac6218b32160697eabc6c2bf2f2781675917924b8fdc179dcb73c3a0d3" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/flippyflop-flip-5ba18c69.json" +reads = [] +writes = [] +init_calldata = [] +tag = "flippyflop-flip" +systems = [ + "initializer", + "mint_from", + "burn_from", +] +manifest_name = "flippyflop-flip-5ba18c69" diff --git a/manifests/dev/base/models/flippyflop-ERC20AllowanceModel-55d0c41e.toml b/manifests/dev/base/models/flippyflop-ERC20AllowanceModel-55d0c41e.toml new file mode 100644 index 0000000..5f111fa --- /dev/null +++ b/manifests/dev/base/models/flippyflop-ERC20AllowanceModel-55d0c41e.toml @@ -0,0 +1,27 @@ +kind = "DojoModel" +class_hash = "0x223db7359762f6103fbdf6e05b5756c3a1a1daa8d80c782894ee506c6293491" +original_class_hash = "0x223db7359762f6103fbdf6e05b5756c3a1a1daa8d80c782894ee506c6293491" +abi = "manifests/dev/base/abis/models/flippyflop-ERC20AllowanceModel-55d0c41e.json" +tag = "flippyflop-ERC20AllowanceModel" +qualified_path = "flippyflop::tokens::flip::erc_20_allowance_model" +manifest_name = "flippyflop-ERC20AllowanceModel-55d0c41e" + +[[members]] +name = "token" +type = "ContractAddress" +key = true + +[[members]] +name = "owner" +type = "ContractAddress" +key = true + +[[members]] +name = "spender" +type = "ContractAddress" +key = true + +[[members]] +name = "amount" +type = "u256" +key = false diff --git a/manifests/dev/base/models/flippyflop-ERC20BalanceModel-7866fe9f.toml b/manifests/dev/base/models/flippyflop-ERC20BalanceModel-7866fe9f.toml new file mode 100644 index 0000000..01c8e5e --- /dev/null +++ b/manifests/dev/base/models/flippyflop-ERC20BalanceModel-7866fe9f.toml @@ -0,0 +1,22 @@ +kind = "DojoModel" +class_hash = "0x1c458889070338bf994106b5e95a3647a20fcf9d44887ffdaf5f7eb4c0e7173" +original_class_hash = "0x1c458889070338bf994106b5e95a3647a20fcf9d44887ffdaf5f7eb4c0e7173" +abi = "manifests/dev/base/abis/models/flippyflop-ERC20BalanceModel-7866fe9f.json" +tag = "flippyflop-ERC20BalanceModel" +qualified_path = "flippyflop::tokens::flip::erc_20_balance_model" +manifest_name = "flippyflop-ERC20BalanceModel-7866fe9f" + +[[members]] +name = "token" +type = "ContractAddress" +key = true + +[[members]] +name = "account" +type = "ContractAddress" +key = true + +[[members]] +name = "amount" +type = "u256" +key = false diff --git a/manifests/dev/base/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.toml b/manifests/dev/base/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.toml new file mode 100644 index 0000000..cb5c0cb --- /dev/null +++ b/manifests/dev/base/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.toml @@ -0,0 +1,17 @@ +kind = "DojoModel" +class_hash = "0x4f60ae83d8ae292f332022f258e627e52e113cb5377ec9b01dc3912dae63c42" +original_class_hash = "0x4f60ae83d8ae292f332022f258e627e52e113cb5377ec9b01dc3912dae63c42" +abi = "manifests/dev/base/abis/models/flippyflop-ERC20BridgeableModel-1ad0a3e6.json" +tag = "flippyflop-ERC20BridgeableModel" +qualified_path = "flippyflop::tokens::flip::erc_20_bridgeable_model" +manifest_name = "flippyflop-ERC20BridgeableModel-1ad0a3e6" + +[[members]] +name = "token" +type = "ContractAddress" +key = true + +[[members]] +name = "l2_bridge_address" +type = "ContractAddress" +key = false diff --git a/manifests/dev/base/models/flippyflop-ERC20MetadataModel-1fc3dc07.toml b/manifests/dev/base/models/flippyflop-ERC20MetadataModel-1fc3dc07.toml new file mode 100644 index 0000000..d0d0631 --- /dev/null +++ b/manifests/dev/base/models/flippyflop-ERC20MetadataModel-1fc3dc07.toml @@ -0,0 +1,32 @@ +kind = "DojoModel" +class_hash = "0x4625d48c8f7e13db2ae84c89787171f8fa53752228ae147d3c50c8b327afab3" +original_class_hash = "0x4625d48c8f7e13db2ae84c89787171f8fa53752228ae147d3c50c8b327afab3" +abi = "manifests/dev/base/abis/models/flippyflop-ERC20MetadataModel-1fc3dc07.json" +tag = "flippyflop-ERC20MetadataModel" +qualified_path = "flippyflop::tokens::flip::erc_20_metadata_model" +manifest_name = "flippyflop-ERC20MetadataModel-1fc3dc07" + +[[members]] +name = "token" +type = "ContractAddress" +key = true + +[[members]] +name = "name" +type = "ByteArray" +key = false + +[[members]] +name = "symbol" +type = "ByteArray" +key = false + +[[members]] +name = "decimals" +type = "u8" +key = false + +[[members]] +name = "total_supply" +type = "u256" +key = false diff --git a/manifests/dev/base/models/flippyflop-Game-54c54faf.toml b/manifests/dev/base/models/flippyflop-Game-54c54faf.toml new file mode 100644 index 0000000..905cb00 --- /dev/null +++ b/manifests/dev/base/models/flippyflop-Game-54c54faf.toml @@ -0,0 +1,17 @@ +kind = "DojoModel" +class_hash = "0x1bdb38d9c7364a47133d55ff8e304bdfd79e7f41db50ebbe9305daf9722f2eb" +original_class_hash = "0x1bdb38d9c7364a47133d55ff8e304bdfd79e7f41db50ebbe9305daf9722f2eb" +abi = "manifests/dev/base/abis/models/flippyflop-Game-54c54faf.json" +tag = "flippyflop-Game" +qualified_path = "flippyflop::models::game" +manifest_name = "flippyflop-Game-54c54faf" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "is_locked" +type = "bool" +key = false diff --git a/manifests/dev/deployment/manifest.json b/manifests/dev/deployment/manifest.json index c0f58bc..1e1bf7e 100644 --- a/manifests/dev/deployment/manifest.json +++ b/manifests/dev/deployment/manifest.json @@ -1311,8 +1311,8 @@ { "kind": "DojoContract", "address": "0x2728baa5c7de0dc4b2fd20d71b76edcfb201924f45e11a52906e1fd22293dbd", - "class_hash": "0x28bb42a86e4a38914ce1642c6566b6a102de8549d1c66216ebedcbcd6c8e107", - "original_class_hash": "0x28bb42a86e4a38914ce1642c6566b6a102de8549d1c66216ebedcbcd6c8e107", + "class_hash": "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2", + "original_class_hash": "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2", "base_class_hash": "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2", "abi": [ { diff --git a/manifests/dev/deployment/manifest.toml b/manifests/dev/deployment/manifest.toml index dc23f40..55867a9 100644 --- a/manifests/dev/deployment/manifest.toml +++ b/manifests/dev/deployment/manifest.toml @@ -24,8 +24,8 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" address = "0x2728baa5c7de0dc4b2fd20d71b76edcfb201924f45e11a52906e1fd22293dbd" -class_hash = "0x28bb42a86e4a38914ce1642c6566b6a102de8549d1c66216ebedcbcd6c8e107" -original_class_hash = "0x28bb42a86e4a38914ce1642c6566b6a102de8549d1c66216ebedcbcd6c8e107" +class_hash = "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2" +original_class_hash = "0x3ea068c930a55765223e357778a6265b56b93e654d27a2849d8efe895244cf2" base_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2" abi = "manifests/dev/deployment/abis/contracts/flippyflop-actions-4407e5f5.json" reads = [] diff --git a/overlays/dev/actions.toml b/overlays/dev/actions.toml index 20a193a..42b20c1 100644 --- a/overlays/dev/actions.toml +++ b/overlays/dev/actions.toml @@ -1,2 +1,10 @@ tag = "flippyflop-actions" -writes = [ "flippyflop-Tile" ] \ No newline at end of file +writes = [ + "flippyflop-Tile", + "flippyflop-Game", + "flippyflop-ERC20MetadataModel", + "flippyflop-ERC20BalanceModel", + "flippyflop-ERC20AllowanceModel", + "flippyflop-ERC20BridgeableModel", + "flippyflop-InitializableModel", +] diff --git a/overlays/dev/flip.toml b/overlays/dev/flip.toml new file mode 100644 index 0000000..5c191ec --- /dev/null +++ b/overlays/dev/flip.toml @@ -0,0 +1,8 @@ +tag = "flippyflop-Flip" +writes = [ + "flippyflop-ERC20MetadataModel", + "flippyflop-ERC20BalanceModel", + "flippyflop-ERC20AllowanceModel", + "flippyflop-ERC20BridgeableModel", + "flippyflop-InitializableModel", +] diff --git a/overlays/sepolia/actions.toml b/overlays/sepolia/actions.toml new file mode 100644 index 0000000..42b20c1 --- /dev/null +++ b/overlays/sepolia/actions.toml @@ -0,0 +1,10 @@ +tag = "flippyflop-actions" +writes = [ + "flippyflop-Tile", + "flippyflop-Game", + "flippyflop-ERC20MetadataModel", + "flippyflop-ERC20BalanceModel", + "flippyflop-ERC20AllowanceModel", + "flippyflop-ERC20BridgeableModel", + "flippyflop-InitializableModel", +] diff --git a/overlays/sepolia/flip.toml b/overlays/sepolia/flip.toml new file mode 100644 index 0000000..5c191ec --- /dev/null +++ b/overlays/sepolia/flip.toml @@ -0,0 +1,8 @@ +tag = "flippyflop-Flip" +writes = [ + "flippyflop-ERC20MetadataModel", + "flippyflop-ERC20BalanceModel", + "flippyflop-ERC20AllowanceModel", + "flippyflop-ERC20BridgeableModel", + "flippyflop-InitializableModel", +] diff --git a/src/constants.cairo b/src/constants.cairo new file mode 100644 index 0000000..12389c9 --- /dev/null +++ b/src/constants.cairo @@ -0,0 +1,7 @@ +pub const X_BOUND: u32 = 100; +pub const Y_BOUND: u32 = 100; +pub const ADDRESS_BITMAP: u256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000_u256; + + +pub const TILE_MODEL_SELECTOR: felt252 = selector_from_tag!("flippyflop-Tile"); +pub const GAME_ID: felt252 = 0x0; \ No newline at end of file diff --git a/src/lib.cairo b/src/lib.cairo index 786bb77..44530bc 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -7,3 +7,8 @@ mod models; mod tests { mod test_world; } + +mod constants; +mod tokens { + mod flip; +} \ No newline at end of file diff --git a/src/models.cairo b/src/models.cairo index a26b7e8..b6459f5 100644 --- a/src/models.cairo +++ b/src/models.cairo @@ -1,5 +1,24 @@ use starknet::ContractAddress; +#[derive(Serde, Copy, Drop)] +#[dojo::model] +pub struct Game { + #[key] + pub id: u32, + pub is_locked: bool, +} + +#[derive(Serde, Copy, Drop)] +#[dojo::model] +pub struct Tile { + #[key] + pub x: u32, + #[key] + pub y: u32, + // 2**244 address | 2**4 powerup | 2**4 powerup data + pub flipped: felt252, +} + #[derive(Serde, Copy, Drop, Introspect, PartialEq)] enum PowerUp { None: (), @@ -14,19 +33,19 @@ trait PowerUpTrait { impl PowerUpImpl of PowerUpTrait { fn probability(self: PowerUp) -> u32 { match self { - PowerUp::None => 990000, // 99.0000% - PowerUp::Empty => 5000, // 0.5000% + PowerUp::None => 996858, // 99.6858% + PowerUp::Empty => 1500, // 0.1500% PowerUp::Multiplier(val) => { if val == 2 { - 4000 // 0.4000% + 1000 // 0.1000% } else if val == 4 { - 800 // 0.0800% + 500 // 0.0500% } else if val == 8 { - 160 // 0.0160% + 125 // 0.0125% } else if val == 16 { - 32 // 0.0032% + 12 // 0.0012% } else if val == 32 { - 6 // 0.0006% + 5 // 0.0005% } else { 0 // Invalid multiplier } @@ -35,17 +54,6 @@ impl PowerUpImpl of PowerUpTrait { } } -#[derive(Serde, Copy, Drop)] -#[dojo::model] -pub struct Tile { - #[key] - pub x: u32, - #[key] - pub y: u32, - // 2**244 address | 2**4 powerup | 2**4 powerup data - pub flipped: felt252, -} - #[derive(Serde, Drop)] #[dojo::model] pub struct User { diff --git a/src/systems/actions.cairo b/src/systems/actions.cairo index 540c28c..01efa8e 100644 --- a/src/systems/actions.cairo +++ b/src/systems/actions.cairo @@ -3,24 +3,19 @@ trait IActions { fn flip(ref world: IWorldDispatcher, x: u32, y: u32); fn flop(ref world: IWorldDispatcher); + fn claim(ref world: IWorldDispatcher); } -const TILE_MODEL_SELECTOR: felt252 = - 0x61fb9291a47fbce6a74257be2400d0f807067fd73e6437aa3f7461c38153492; -const TILE_FLIPPED_SELECTOR: felt252 = - 0x1cc1e903b2099cf12a3c9efcefe94e8820db24825120dfb35aa6c519a16b10e; -const X_BOUND: u32 = 100; -const Y_BOUND: u32 = 100; -const ADDRESS_BITMAP: u256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000_u256; - // dojo decorator #[dojo::contract] mod actions { - use super::{IActions, TILE_MODEL_SELECTOR, TILE_FLIPPED_SELECTOR, X_BOUND, Y_BOUND, ADDRESS_BITMAP}; + use super::{IActions}; use starknet::{ContractAddress, get_caller_address, info::get_tx_info}; - use flippyflop::models::{Tile, PowerUp, PowerUpTrait}; + use flippyflop::models::{PowerUp, PowerUpTrait, Game}; use core::poseidon::poseidon_hash_span; use dojo::model::{FieldLayout, Layout}; + use flippyflop::tokens::flip::{IFlip, IFlipDispatcher, IFlipDispatcherTrait}; + use flippyflop::constants::{GAME_ID, ADDRESS_BITMAP, X_BOUND, Y_BOUND, TILE_MODEL_SELECTOR}; fn get_random_powerup(seed: felt252) -> PowerUp { let tx_hash = get_tx_info().transaction_hash; @@ -75,7 +70,23 @@ mod actions { (address.try_into().unwrap(), powerup) } - + + fn flip_token(world: IWorldDispatcher) -> IFlipDispatcher { + let (class_hash, contract_address) = + match world.resource(selector_from_tag!("flippyflop-FLIP")) { + dojo::world::Resource::Contract(( + class_hash, contract_address + )) => (class_hash, contract_address), + _ => (0.try_into().unwrap(), 0.try_into().unwrap()) + }; + + if class_hash.is_zero() || contract_address.is_zero() { + panic!("Invalid FLIP token resource!"); + } + + IFlipDispatcher { contract_address } + } + #[abi(embed_v0)] impl ActionsImpl of IActions { // Humans can only flip unflipped tiles, but they can chose their tile to unflip. @@ -121,5 +132,56 @@ mod actions { ); } } + + fn claim(ref world: IWorldDispatcher) { + let game = get!(world, GAME_ID, Game); + assert!(game.is_locked == false, "Game is locked"); + + + let player = get_caller_address(); + let flip_token = flip_token(world); + let mut total_tokens: u256 = 0; + + // Iterate through all tiles + let mut x: u32 = 0; + loop { + if x >= X_BOUND { + break; + } + + let mut y: u32 = 0; + loop { + if y >= Y_BOUND { + break; + } + + let entity_hash = poseidon_hash_span(array![x.into(), y.into()].span()); + let tile = world.entity_lobotomized(TILE_MODEL_SELECTOR, entity_hash); + + // Check if the tile is flipped and belongs to the player + let (tile_owner, powerup) = unpack_flipped_data(tile); + if tile_owner == player { + // Calculate base token amount (1 ETH in wei) + let mut tokens: u256 = 1000000000000000000; + + // Apply powerup multiplier if any + if let PowerUp::Multiplier(multiplier) = powerup { + tokens *= multiplier.into(); + } + + total_tokens += tokens; + } + + y += 1; + }; + + x += 1; + }; + + // Mint FLIP tokens to the player + if total_tokens > 0 { + flip_token.mint_from(player, total_tokens); + } + } } } diff --git a/src/systems/game.cairo b/src/systems/game.cairo new file mode 100644 index 0000000..3dc16bd --- /dev/null +++ b/src/systems/game.cairo @@ -0,0 +1,31 @@ +use starknet::ContractAddress; +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; + +#[dojo::interface] +trait IGameManager { + fn lock_game(ref self: IWorldDispatcher); + fn unlock_game(ref self: IWorldDispatcher); +} + +#[dojo::contract] +mod game_manager { + use flippyflop::constants::{GAME_MODEL_SELECTOR, GAME_ID}; + use flippyflop::models::Game; + use super::{IGameManager}; + use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; + + #[abi(embed_v0)] + impl GameManagerImpl of IGameManager { + fn lock_game(ref self: IWorldDispatcher) { + assert(world.is_caller_world_owner(), 'Caller is not world owner'); + + set!(world, Game { id: GAME_ID, is_locked: true }); + } + + fn unlock_game(ref self: IWorldDispatcher) { + assert(world.is_caller_world_owner(), 'Caller is not world owner'); + + set!(world, Game { id: GAME_ID, is_locked: false }); + } + } +} \ No newline at end of file diff --git a/src/tokens/FLIP.cairo b/src/tokens/FLIP.cairo new file mode 100644 index 0000000..c285bdf --- /dev/null +++ b/src/tokens/FLIP.cairo @@ -0,0 +1,268 @@ +use starknet::{ContractAddress, ClassHash}; +use dojo::world::IWorldDispatcher; + +#[dojo::model] +#[derive(Copy, Drop, Serde)] +struct ERC20AllowanceModel { + #[key] + token: ContractAddress, + #[key] + owner: ContractAddress, + #[key] + spender: ContractAddress, + amount: u256, +} + +#[dojo::model] +#[derive(Copy, Drop, Serde)] +struct ERC20BalanceModel { + #[key] + token: ContractAddress, + #[key] + account: ContractAddress, + amount: u256, +} + +#[dojo::model] +#[derive(Copy, Drop, Serde)] +struct ERC20BridgeableModel { + #[key] + token: ContractAddress, + l2_bridge_address: ContractAddress +} + +#[dojo::model] +#[derive(Drop, Serde)] +struct ERC20MetadataModel { + #[key] + token: ContractAddress, + name: ByteArray, + symbol: ByteArray, + decimals: u8, + total_supply: u256, +} + + +#[starknet::interface] +trait IERC20BridgeablePreset { + // IWorldProvider + fn world(self: @TState,) -> IWorldDispatcher; + + // IUpgradeable + fn upgrade(ref self: TState, new_class_hash: ClassHash); + + // IERC20Metadata + fn decimals(self: @TState,) -> u8; + fn name(self: @TState,) -> ByteArray; + fn symbol(self: @TState,) -> ByteArray; + + // IERC20MetadataTotalSupply + fn total_supply(self: @TState,) -> u256; + + // IERC20MetadataTotalSupplyCamel + fn totalSupply(self: @TState,) -> u256; + + // IERC20Balance + fn balance_of(self: @TState, account: ContractAddress) -> u256; + fn transfer(ref self: TState, recipient: ContractAddress, amount: u256) -> bool; + fn transfer_from( + ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256 + ) -> bool; + + // IERC20BalanceCamel + fn balanceOf(self: @TState, account: ContractAddress) -> u256; + fn transferFrom( + ref self: TState, sender: ContractAddress, recipient: ContractAddress, amount: u256 + ) -> bool; + + // IERC20Allowance + fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256; + fn approve(ref self: TState, spender: ContractAddress, amount: u256) -> bool; + + // IERC20Bridgeable + fn burn(ref self: TState, account: ContractAddress, amount: u256); + fn l2_bridge_address(self: @TState,) -> ContractAddress; + fn mint(ref self: TState, recipient: ContractAddress, amount: u256); + + // WITHOUT INTERFACE !!! + fn initializer( + ref self: TState, + name: ByteArray, + symbol: ByteArray, + initial_supply: u256, + recipient: ContractAddress, + l2_bridge_address: ContractAddress + ); + fn dojo_resource(self: @TState,) -> felt252; +} + + +/// +/// Interface required to remove compiler warnings and future +/// deprecation. +/// +#[starknet::interface] +trait IERC20BridgeableInitializer { + fn initializer(ref self: TState, name: ByteArray, symbol: ByteArray); +} + +#[starknet::interface] +trait IFlip { + fn balance(self: @TState, account: ContractAddress) -> u256; + fn mint_from(ref self: TState, recipient: ContractAddress, amount: u256); + fn burn_from(ref self: TState, account: ContractAddress, amount: u256); +} + +#[dojo::contract] +mod flip { + use core::num::traits::Bounded; + use starknet::ContractAddress; + use starknet::{get_caller_address, get_contract_address}; + use zeroable::Zeroable; + + use origami_token::components::security::initializable::initializable_component; + + use origami_token::components::token::erc20::erc20_metadata::erc20_metadata_component; + use origami_token::components::token::erc20::erc20_balance::erc20_balance_component; + use origami_token::components::token::erc20::erc20_allowance::erc20_allowance_component; + use origami_token::components::token::erc20::erc20_mintable::erc20_mintable_component; + use origami_token::components::token::erc20::erc20_burnable::erc20_burnable_component; + use origami_token::components::token::erc20::erc20_bridgeable::erc20_bridgeable_component; + + component!(path: initializable_component, storage: initializable, event: InitializableEvent); + + component!(path: erc20_metadata_component, storage: erc20_metadata, event: ERC20MetadataEvent); + component!(path: erc20_balance_component, storage: erc20_balance, event: ERC20BalanceEvent); + component!( + path: erc20_allowance_component, storage: erc20_allowance, event: ERC20AllowanceEvent + ); + component!(path: erc20_mintable_component, storage: erc20_mintable, event: ERC20MintableEvent); + component!(path: erc20_burnable_component, storage: erc20_burnable, event: ERC20BurnableEvent); + component!( + path: erc20_bridgeable_component, storage: erc20_bridgeable, event: ERC20BridgeableEvent + ); + + #[storage] + struct Storage { + #[substorage(v0)] + initializable: initializable_component::Storage, + #[substorage(v0)] + erc20_metadata: erc20_metadata_component::Storage, + #[substorage(v0)] + erc20_balance: erc20_balance_component::Storage, + #[substorage(v0)] + erc20_allowance: erc20_allowance_component::Storage, + #[substorage(v0)] + erc20_mintable: erc20_mintable_component::Storage, + #[substorage(v0)] + erc20_burnable: erc20_burnable_component::Storage, + #[substorage(v0)] + erc20_bridgeable: erc20_bridgeable_component::Storage, + } + + #[event] + #[derive(Copy, Drop, starknet::Event)] + enum Event { + #[flat] + InitializableEvent: initializable_component::Event, + #[flat] + ERC20MetadataEvent: erc20_metadata_component::Event, + #[flat] + ERC20BalanceEvent: erc20_balance_component::Event, + #[flat] + ERC20AllowanceEvent: erc20_allowance_component::Event, + #[flat] + ERC20MintableEvent: erc20_mintable_component::Event, + #[flat] + ERC20BurnableEvent: erc20_burnable_component::Event, + #[flat] + ERC20BridgeableEvent: erc20_bridgeable_component::Event, + } + + mod Errors { + const CALLER_IS_NOT_OWNER: felt252 = 'ERC20: caller is not owner'; + } + + + impl InitializableImpl = initializable_component::InitializableImpl; + + #[abi(embed_v0)] + impl ERC20MetadataImpl = + erc20_metadata_component::ERC20MetadataImpl; + + #[abi(embed_v0)] + impl ERC20MetadataTotalSupplyImpl = + erc20_metadata_component::ERC20MetadataTotalSupplyImpl; + + #[abi(embed_v0)] + impl ERC20MetadataTotalSupplyCamelImpl = + erc20_metadata_component::ERC20MetadataTotalSupplyCamelImpl; + + #[abi(embed_v0)] + impl ERC20BalanceImpl = + erc20_balance_component::ERC20BalanceImpl; + + #[abi(embed_v0)] + impl ERC20BalanceCamelImpl = + erc20_balance_component::ERC20BalanceCamelImpl; + + #[abi(embed_v0)] + impl ERC20AllowanceImpl = + erc20_allowance_component::ERC20AllowanceImpl; + + #[abi(embed_v0)] + impl ERC20BridgeableImpl = + erc20_bridgeable_component::ERC20BridgeableImpl; + + + // + // Internal Impls + // + + impl InitializableInternalImpl = initializable_component::InternalImpl; + impl ERC20MetadataInternalImpl = erc20_metadata_component::InternalImpl; + impl ERC20BalanceInternalImpl = erc20_balance_component::InternalImpl; + impl ERC20AllowanceInternalImpl = erc20_allowance_component::InternalImpl; + impl ERC20MintableInternalImpl = erc20_mintable_component::InternalImpl; + impl ERC20BurnableInternalImpl = erc20_burnable_component::InternalImpl; + impl ERC20BridgeableInternalImpl = erc20_bridgeable_component::InternalImpl; + + // + // Initializer + // + + fn dojo_init(ref self: ContractState) { + self.erc20_metadata.initialize("FLIP", "FLIP", 18); + + self.initializable.initialize(); + } + + #[abi(embed_v0)] + impl ERC20InitializerImpl of super::IERC20BridgeableInitializer { + fn initializer(ref self: ContractState, name: ByteArray, symbol: ByteArray) { + // assert( + // self.world().is_owner(self.selector(), get_caller_address()), + // Errors::CALLER_IS_NOT_OWNER + // ); + + self.erc20_metadata.initialize(name, symbol, 18); + + self.initializable.initialize(); + } + } + + #[abi(embed_v0)] + impl Flip of super::IFlip { + fn balance(self: @ContractState, account: ContractAddress) -> u256 { + self.erc20_balance.balance_of(account) + } + + fn mint_from(ref self: ContractState, recipient: ContractAddress, amount: u256) { + self.erc20_mintable.mint(recipient, amount); + } + + fn burn_from(ref self: ContractState, account: ContractAddress, amount: u256) { + self.erc20_burnable.burn(account, amount); + } + } +} \ No newline at end of file