diff --git a/.github/workflows/ci-contracts.yml b/.github/workflows/ci-contracts.yml index 68f6b96..1a1647b 100644 --- a/.github/workflows/ci-contracts.yml +++ b/.github/workflows/ci-contracts.yml @@ -35,6 +35,6 @@ jobs: - uses: asdf-vm/actions/setup@v3 - run: | asdf plugin add dojo https://github.com/dojoengine/asdf-dojo - asdf install dojo 1.0.0-alpha.5 - asdf global dojo 1.0.0-alpha.5 + asdf install dojo 1.0.0-alpha.6 + asdf global dojo 1.0.0-alpha.6 sozo test diff --git a/contracts/.tool-versions b/contracts/.tool-versions index 342a21f..282ef1d 100644 --- a/contracts/.tool-versions +++ b/contracts/.tool-versions @@ -1,2 +1,2 @@ -dojo 1.0.0-alpha.5 +dojo 1.0.0-alpha.6 scarb 2.7.0 diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index 48cbe26..45ddd97 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -14,7 +14,7 @@ dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" } [lib] +[profile.dev-pop] + [scripts] init_auth = "./scripts/init_auth.sh" - -[profile.dev-pop] diff --git a/contracts/Scarb_deploy.toml b/contracts/Scarb_deploy.toml index ed3b15e..ee4a42f 100644 --- a/contracts/Scarb_deploy.toml +++ b/contracts/Scarb_deploy.toml @@ -17,6 +17,3 @@ build-external-contracts = [] path = "../contracts/src/lib.cairo" [profile.dev-pop] - -[scripts] -init_auth = "./scripts/init_auth.sh" diff --git a/contracts/dojo_dev.toml b/contracts/dojo_dev.toml index 642d40e..165e68a 100644 --- a/contracts/dojo_dev.toml +++ b/contracts/dojo_dev.toml @@ -11,4 +11,4 @@ mappings = { } rpc_url = "http://localhost:5050/" account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca" private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -world_address = "0x10bbde7919b063a353fc2c6148555434cd8a7be8d5cbfdcd06ef63787b58838" +world_address = "0x2c130238b73abf493f1876d26cd52e0f45f318f99accac1d28f0ca6a3d7800f" diff --git a/contracts/scripts/create_genesis.sh b/contracts/scripts/create_genesis.sh index 2b80e0f..927735c 100755 --- a/contracts/scripts/create_genesis.sh +++ b/contracts/scripts/create_genesis.sh @@ -78,12 +78,12 @@ sozo \ # Setup PixeLAW auth and init declare "WORLD"=$(cat $MANIFEST | jq -r '.world.address') -declare "CORE_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.name=="pixelaw::core::actions::actions") | .address') -declare "PAINT_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.name=="pixelaw::apps::paint::app::paint_actions") | .address') -declare "SNAKE_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.name=="pixelaw::apps::snake::app::snake_actions") | .address') +declare "CORE_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.tag=="pixelaw-actions") | .address') +declare "PAINT_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.tag=="pixelaw-paint_actions") | .address') +declare "SNAKE_ACTIONS"=$(cat $MANIFEST | jq -r '.contracts[] | select(.tag=="pixelaw-snake_actions") | .address') -CORE_MODELS=("App" "AppName" "CoreActionsAddress" "Pixel" "Permissions" "QueueItem") -SNAKE_MODELS=("Snake" "SnakeSegment") +CORE_MODELS=("pixelaw-App" "pixelaw-AppName" "pixelaw-CoreActionsAddress" "pixelaw-Pixel" "pixelaw-Permissions" "pixelaw-QueueItem" "pixelaw-Snake" "pixelaw-Instruction") +SNAKE_MODELS=("pixelaw-Snake" "pixelaw-SnakeSegment") echo "Write permissions for CORE_ACTIONS" diff --git a/contracts/scripts/create_snapshot.sh b/contracts/scripts/create_snapshot.sh index 025c980..0253ca4 100755 --- a/contracts/scripts/create_snapshot.sh +++ b/contracts/scripts/create_snapshot.sh @@ -89,8 +89,8 @@ sleep 1 # Setup PixeLAW auth and init declare "WORLD"=$(cat $MANIFEST | jq -r '.world.address') -CORE_MODELS=("App" "AppName" "CoreActionsAddress" "Pixel" "Permissions" "QueueItem" "Instruction") -SNAKE_MODELS=("Snake" "SnakeSegment") +CORE_MODELS=("pixelaw-App" "pixelaw-AppName" "pixelaw-CoreActionsAddress" "pixelaw-Pixel" "pixelaw-Permissions" "pixelaw-QueueItem" "pixelaw-Snake" "pixelaw-Instruction") +SNAKE_MODELS=("pixelaw-Snake" "pixelaw-SnakeSegment") echo "Start Torii" unset LS_COLORS && torii \ @@ -126,7 +126,6 @@ echo "Write permissions for SNAKE_ACTIONS: Done" echo "Initialize CORE_ACTIONS" sozo --manifest-path $DEPLOY_SCARB --profile $PROFILE execute --wait pixelaw-actions init - echo "Initialize CORE_ACTIONS: Done" echo "Initialize SNAKE_ACTIONS: Done" @@ -135,7 +134,6 @@ echo "Initialize SNAKE_ACTIONS: Done" echo "Initialize PAINT_ACTIONS: Done" sozo --manifest-path $DEPLOY_SCARB --profile $PROFILE execute --wait pixelaw-paint_actions init - echo "Initialize PAINT_ACTIONS: Done" diff --git a/contracts/scripts/init_auth.sh b/contracts/scripts/init_auth.sh index c88e1e6..98c4d06 100755 --- a/contracts/scripts/init_auth.sh +++ b/contracts/scripts/init_auth.sh @@ -2,9 +2,10 @@ set -euo pipefail pushd $(dirname "$0")/.. -export TARGET=${1:-"manifests/dev"} +export TARGET=${1:-"manifests/dev/deployment"} export STARKNET_RPC="http://localhost:5050/" + GENESIS_TEMPLATE=genesis_template.json GENESIS_OUT=genesis.json KATANA_LOG=katana.log @@ -26,24 +27,28 @@ if [ $# -gt 0 ]; then fi # make sure all components/systems are deployed -CORE_MODELS=("App" "AppName" "CoreActionsAddress" "Pixel" "Permissions" "QueueItem") - -SNAKE_MODELS=("Snake" "SnakeSegment") +CORE_MODELS=("pixelaw-App" "pixelaw-AppName" "pixelaw-CoreActionsAddress" "pixelaw-Pixel" "pixelaw-Permissions" "pixelaw-QueueItem" "pixelaw-Snake" "pixelaw-Instruction") +SNAKE_MODELS=("pixelaw-Snake" "pixelaw-SnakeSegment") echo "Write permissions for CORE_ACTIONS" for model in ${CORE_MODELS[@]}; do sleep 0.1 - sozo --profile $SCARB_PROFILE auth grant writer $model,$CORE_ACTIONS + sozo --profile $SCARB_PROFILE auth grant writer model:$model,$CORE_ACTIONS done echo "Write permissions for CORE_ACTIONS: Done" echo "Write permissions for SNAKE_ACTIONS" for model in ${SNAKE_MODELS[@]}; do sleep 0.1 - sozo --profile $SCARB_PROFILE auth grant writer $model,$SNAKE_ACTIONS + sozo --profile $SCARB_PROFILE auth grant writer model:$model,$SNAKE_ACTIONS done echo "Write permissions for SNAKE_ACTIONS: Done" +echo "Write permissions for PAINT_ACTIONS" +sleep 0.1 +sozo --profile $SCARB_PROFILE auth grant writer model:pixelaw-Pixel,$PAINT_ACTIONS +echo "Write permissions for PAINT_ACTIONS: Done" + echo "Initialize CORE_ACTIONS : $CORE_ACTIONS" sleep 0.1 diff --git a/contracts/scripts/update_contracts.sh b/contracts/scripts/update_contracts.sh index 3f61236..19c2c0c 100755 --- a/contracts/scripts/update_contracts.sh +++ b/contracts/scripts/update_contracts.sh @@ -3,6 +3,6 @@ set -euo pipefail pushd $(dirname "$0")/.. -declare "CORE_ACTIONS"=$(cat manifests/dev/manifest.json | jq -r '.contracts[] | select(.name=="pixelaw::core::actions::actions") | .address') -declare "PAINT_ACTIONS"=$(cat manifests/dev/manifest.json | jq -r '.contracts[] | select(.name=="pixelaw::apps::paint::app::paint_actions") | .address') -declare "SNAKE_ACTIONS"=$(cat manifests/dev/manifest.json | jq -r '.contracts[] | select(.name=="pixelaw::apps::snake::app::snake_actions") | .address') +declare "CORE_ACTIONS"=$(cat manifests/dev/deployment/manifest.json | jq -r '.contracts[] | select(.tag=="pixelaw-actions") | .address') +declare "PAINT_ACTIONS"=$(cat manifests/dev/deployment/manifest.json | jq -r '.contracts[] | select(.tag=="pixelaw-paint_actions") | .address') +declare "SNAKE_ACTIONS"=$(cat manifests/dev/deployment/manifest.json | jq -r '.contracts[] | select(.tag=="pixelaw-snake_actions") | .address') diff --git a/contracts/scripts/update_scarb.sh b/contracts/scripts/update_scarb.sh index 969790f..c1a7f43 100755 --- a/contracts/scripts/update_scarb.sh +++ b/contracts/scripts/update_scarb.sh @@ -3,7 +3,7 @@ set -euo pipefail pushd $(dirname "$0")/.. # Get world address from manifest -WORLD_ADDRESS=$(cat target/dev/manifest.json | jq '.world.address') +WORLD_ADDRESS=$(cat manifests/dev/deployment/manifest.json | jq '.world.address') # Check if WORLD_ADDRESS is not "null" if [ "$WORLD_ADDRESS" != "null" ]; then diff --git a/contracts/scripts/update_scarb_mac.sh b/contracts/scripts/update_scarb_mac.sh index 7fe6f21..059f827 100755 --- a/contracts/scripts/update_scarb_mac.sh +++ b/contracts/scripts/update_scarb_mac.sh @@ -3,7 +3,7 @@ set -euo pipefail pushd $(dirname "$0")/.. # Get world address from manifest -WORLD_ADDRESS=$(cat target/dev/manifest.json | jq -r '.world.address') +WORLD_ADDRESS=$(cat manifests/dev/deployment/manifest.json | jq -r '.world.address') # Check if WORLD_ADDRESS is not "null" if [ "$WORLD_ADDRESS" != "null" ]; then @@ -12,4 +12,4 @@ if [ "$WORLD_ADDRESS" != "null" ]; then sed -i '' "s/world_address = \".*\"/world_address = \"$WORLD_ADDRESS\"/" Scarb.toml fi -echo "Scarb.toml has been updated with address(es)" \ No newline at end of file +echo "Scarb.toml has been updated with address(es)" diff --git a/contracts/scripts/upload_manifest.sh b/contracts/scripts/upload_manifest.sh index a4508b8..032d1b5 100755 --- a/contracts/scripts/upload_manifest.sh +++ b/contracts/scripts/upload_manifest.sh @@ -2,7 +2,7 @@ SYSTEMS=("core" "paint" "snake") DEFAULT_BASE_URL="http://localhost:3000/manifests" -JSON_FILE="./target/dev/manifest.json" +JSON_FILE="./manifests/dev/deployment/manifest.json" # Check if a command line argument is provided if [ "$#" -ne 0 ]; then diff --git a/contracts/src/apps/paint/app.cairo b/contracts/src/apps/paint/app.cairo index 9729f26..215aca5 100644 --- a/contracts/src/apps/paint/app.cairo +++ b/contracts/src/apps/paint/app.cairo @@ -72,9 +72,6 @@ pub mod paint_utils { Option::None => 0xFF, }; - println!("rgba"); - println!("{}, {}, {}, {}", r, g, b, a); - (r, g, b, a) } } @@ -158,8 +155,6 @@ mod paint_actions { fn interact(ref world: IWorldDispatcher, default_params: DefaultParameters) { println!("interact"); - // Load important variables - // let core_actions = get_core_actions(world); let position = default_params.position; // let player = core_actions.get_player_address(default_params.for_player); diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 828f8e0..eca447e 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -5,6 +5,7 @@ mod tests { use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; use pixelaw::core::models::pixel::{pixel}; + use pixelaw::apps::paint::app::paint_utils::{encode_color, decode_color}; use pixelaw::core::models::permissions::{permissions}; use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters}; use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; @@ -61,7 +62,7 @@ mod tests { let player1 = contract_address_const::<0x1337>(); set_account_contract_address(player1); - let color = encode_color(1, 1, 1); + let color = encode_color(1, 0, 0, 1); paint_actions .interact( @@ -78,16 +79,4 @@ mod tests { println!("Passed test"); } - - fn encode_color(r: u8, g: u8, b: u8) -> u32 { - (r.into() * 0x10000) + (g.into() * 0x100) + b.into() - } - - fn decode_color(color: u32) -> (u8, u8, u8) { - let r = (color / 0x10000); - let g = (color / 0x100) & 0xff; - let b = color & 0xff; - - (r.try_into().unwrap(), g.try_into().unwrap(), b.try_into().unwrap()) - } } diff --git a/tools/local_deploy.sh b/tools/local_deploy.sh index f38d7fe..a4958ce 100755 --- a/tools/local_deploy.sh +++ b/tools/local_deploy.sh @@ -4,7 +4,7 @@ BASEDIR="./" APP_NAME=$(grep '^name =' $BASEDIR/Scarb.toml | awk -F'"' '{print $2}') PROFILE=dev -MANIFEST="$BASEDIR/manifests/$PROFILE/manifest.json" +MANIFEST="$BASEDIR/manifests/$PROFILE/deployment/manifest.json" cd $BASEDIR @@ -47,4 +47,3 @@ sozo --profile $PROFILE execute --wait -v $ACTIONS_ADDRESS init echo "Initialize ACTIONS: Done" echo "Default authorizations have been successfully set." -