Skip to content

Commit

Permalink
Merge pull request #67 from pixelaw/fix/minor-changes
Browse files Browse the repository at this point in the history
[ FIX ] Minor changes
  • Loading branch information
thiscaspar authored Aug 21, 2024
2 parents 8756a62 + 980e613 commit 2551f64
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dojo 1.0.0-alpha.5
dojo 1.0.0-alpha.6
scarb 2.7.0
4 changes: 2 additions & 2 deletions contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
3 changes: 0 additions & 3 deletions contracts/Scarb_deploy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ build-external-contracts = []
path = "../contracts/src/lib.cairo"

[profile.dev-pop]

[scripts]
init_auth = "./scripts/init_auth.sh"
2 changes: 1 addition & 1 deletion contracts/dojo_dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ mappings = { }
rpc_url = "http://localhost:5050/"
account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
world_address = "0x10bbde7919b063a353fc2c6148555434cd8a7be8d5cbfdcd06ef63787b58838"
world_address = "0x2c130238b73abf493f1876d26cd52e0f45f318f99accac1d28f0ca6a3d7800f"
10 changes: 5 additions & 5 deletions contracts/scripts/create_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions contracts/scripts/create_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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"
Expand All @@ -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"


Expand Down
17 changes: 11 additions & 6 deletions contracts/scripts/init_auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions contracts/scripts/update_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')
2 changes: 1 addition & 1 deletion contracts/scripts/update_scarb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/update_scarb_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"
echo "Scarb.toml has been updated with address(es)"
2 changes: 1 addition & 1 deletion contracts/scripts/upload_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions contracts/src/apps/paint/app.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ pub mod paint_utils {
Option::None => 0xFF,
};

println!("rgba");
println!("{}, {}, {}, {}", r, g, b, a);

(r, g, b, a)
}
}
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 2 additions & 13 deletions contracts/src/apps/paint/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(
Expand All @@ -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())
}
}
3 changes: 1 addition & 2 deletions tools/local_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -47,4 +47,3 @@ sozo --profile $PROFILE execute --wait -v $ACTIONS_ADDRESS init
echo "Initialize ACTIONS: Done"

echo "Default authorizations have been successfully set."

0 comments on commit 2551f64

Please sign in to comment.