Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	contracts/Scarb.toml
#	contracts/dojo_dev.toml
  • Loading branch information
thiscaspar committed Aug 21, 2024
2 parents 3f75f52 + 4e34a49 commit 8756a62
Show file tree
Hide file tree
Showing 33 changed files with 354 additions and 413 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.4
asdf global dojo 1.0.0-alpha.4
asdf install dojo 1.0.0-alpha.5
asdf global dojo 1.0.0-alpha.5
sozo test
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,3 @@ EXPOSE 8080
EXPOSE 3000

CMD ["bash", "./scripts/startup.sh"]

4 changes: 2 additions & 2 deletions contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dojo 1.0.0-alpha.4
scarb 2.7.0-rc.4
dojo 1.0.0-alpha.5
scarb 2.7.0
3 changes: 3 additions & 0 deletions contracts/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["StarkWare.cairo1", "tamasfe.even-better-toml"]
}
4 changes: 2 additions & 2 deletions contracts/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cairo1.enableLanguageServer": true,
"cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.4/bin/dojo-language-server",
"cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.6/bin/dojo-language-server",
"cairo1.enableScarb": true,
"cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0-rc.4/bin/scarb"
"cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0/bin/scarb"
}
73 changes: 53 additions & 20 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,120 @@
# PixeLAW Contracts
Contracts written in Cairo using Dojo to showcase a Pixel World with app interoperability. Its
interoperability is made possible with core actions. Apps are any other contracts that are deployed
to the Pixel World.

Contracts written in Cairo using Dojo to showcase a Pixel World with app interoperability. Its interoperability is made possible with core actions. Apps are any other contracts that are deployed to the Pixel World.

## Development

### Prerequisites

- [asdf](https://asdf-vm.com/)
- [scarb](https://docs.swmansion.com/scarb/)
- [dojo](https://github.com/dojoengine/dojo)

### Install asdf

Follow the asdf installation instructions.

### Install dojo

```
asdf plugin add dojo https://github.com/dojoengine/asdf-dojo
asdf install dojo 1.0.0-alpha.4
```

### Install scarb

```
asdf plugin add scarb
asdf install scarb 2.7.0-rc.4
```

And after moving into contracts directory, the versions for these libs are set in the .tool-versions file.

## Default Apps

These are apps developed by PixeLAW

## Paint

### Overview

The Paint App is a collection of functions that allow players to manipulate the color of a Pixel.

### Properties

None, Paint is just behavior.

### Behavior
- public put_color (color)

- public `put_color(color)`
- context: position
- both put_fading_color (color)
- both `put_fading_color(color)`
- context: position
- public remove_color ()
- public `remove_color()`
- context: position


## Snake

### Overview

It it basically the game "snake", but with Pixels not necessarily available to move on/over. It is a player-initialized instance that coordinates pixel's color and text being overriden and reverted (if allowed).
If hitting an unowned Pixel, the snake will move, if Pixel is owned by player, Snake grows, and if Pixel is not owned but it's App allows Snake, it shrinks. In all other cases, Snake dies.

### Properties

- position
- color
- text
- direction

### Behavior

- public spawn ( color, text, direction )
- public `spawn(color, text, direction)`
- context: position
- public turn ( snake_id, direction )
- public `turn(snake_id, direction)`
- context: player
- private move ( snake_id )


- private `move(snake_id)`

## Rock Paper Scissors

### Overview

Each Pixel can contain an instance of the RPS App, where it holds a commitment (rock, paper or scissors) from player1. Any other player can now "join" and submit their move. Player1 can then reveal, the winner is decided then. Winner gains ownership of the losing RPS pixel. In case of a draw, the pixel is reset.
The App is also tracking score for each Player.

### Global Properties

- player+wins

### Game-based Properties

- player1
- player2

### Behavior

- create (position, player1, commit1)
- join (position, player2, move2)
- finish (position, move1, salt1)
- reset (position)


## CommitReveal inputs

### Param of the action

- (Hashed Commit)
- parametername of action has structure: "PREFIX_TYPE_NAME"
- PREFIX is "cr_"
- PREFIX is "cr\_"
- TYPE for now is the name of an int, felt or Enum declared in the manifest
- NAME is a chosen name to refer to the param.
- (Value+Salt reveal)
- parametername of action has structure: "PREFIX_NAME"
- PREFIX shall always be "rv_"
- PREFIX shall always be "rv\_"
- NAME is the same name user during sending the commit

### Clientside functioning
- If client finds a param starting with "cr_"

- If client finds a param starting with "cr\_"
- It will prompt user for a param with TYPE
- example:
- The game RPS needs player1 to choose one option, but only send the hashedcommit
Expand All @@ -90,7 +127,3 @@ The App is also tracking score for each Player.
- UI then calls the functions with only the hash value
- Reveal
- there will be 2 params: "rv_NAME" (the actual param) and "rs_NAME" (the used salt)




2 changes: 1 addition & 1 deletion contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79

[[package]]
name = "pixelaw"
version = "0.3.35"
version = "0.3.36"
dependencies = [
"dojo",
]
46 changes: 3 additions & 43 deletions contracts/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[package]
cairo-version = "=2.7.0"
name = "pixelaw"
version = "0.3.35"
version = "0.3.36"
homepage = "https://github.com/pixelaw/core"
# Use the prelude with the less imports as possible
# from corelib.
# edition = "2024_07"
edition = "2024_07"

[cairo]
sierra-replace-ids = true
Expand All @@ -14,47 +12,9 @@ sierra-replace-ids = true
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" }

[lib]
name = "pixelaw"
path = "src/lib.cairo"


# [[target.dojo]]
# build-external-contracts = [ ]


[tool.dojo]
initializer_class_hash = "0xbeef"

[scripts]
init_auth = "./scripts/init_auth.sh"

# The "Empty" world
# ----------------------------------------------------------------------------
[tool.dojo.world]
description = "Empty PixeLAW world"
name = "pixelaw"
seed="pixelaw"

#[tool.dojo.world.namespace]
#default = "pixelaw"
#mappings = { }
#
#
#[tool.dojo.env]
#rpc_url = "http://localhost:5050/"
#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
#world_address= "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8"


## The "Populated" world
## ----------------------------------------------------------------------------
#[profile.dev-pop.tool.dojo.world]
#description = "Populated PixeLAW world"
#name = "dev-pop"
#
#[profile.dev-pop.tool.dojo.env]
#rpc_url = "http://localhost:5050/"
#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
#world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b"
[profile.dev-pop]
44 changes: 4 additions & 40 deletions contracts/Scarb_deploy.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[package]
cairo-version = "=2.7.0"
name = "pixelaw"
version = "0.3.35"
version = "0.3.36"
homepage = "https://github.com/pixelaw/core"
# Use the prelude with the less imports as possible
# from corelib.
# edition = "2024_07"
edition = "2024_07"

[cairo]
sierra-replace-ids = true
Expand All @@ -15,44 +13,10 @@ dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" }


[[target.dojo]]
build-external-contracts = [ ]
build-external-contracts = []
path = "../contracts/src/lib.cairo"

[tool.dojo]
initializer_class_hash = "0xbeef"
[profile.dev-pop]

[scripts]
init_auth = "./scripts/init_auth.sh"

# The "Empty" world
# ----------------------------------------------------------------------------
[tool.dojo.world]
description = "Empty PixeLAW world"
name = "pixelaw"
seed="pixelaw"

[tool.dojo.world.namespace]
default = "pixelaw"
mappings = { }


[tool.dojo.env]
rpc_url = "http://localhost:5050/"
account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
world_address= "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8"


## The "Populated" world
## ----------------------------------------------------------------------------
#[profile.dev-pop.tool.dojo.world]
#description = "Populated PixeLAW world"
#name = "dev-pop"
#
#[profile.dev-pop.tool.dojo.env]
#rpc_url = "http://localhost:5050/"
#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
#world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b"
#
#
14 changes: 14 additions & 0 deletions contracts/dojo_dev-pop.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[world]
description = "Populated PixeLAW world"
name = "dev-pop"
seed = 'dev-pop'

[namespace]
default = "pixelaw"
mappings = { }

[env]
rpc_url = "http://localhost:5050/"
account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b"
26 changes: 4 additions & 22 deletions contracts/dojo_dev.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@


# The "Empty" world
# ----------------------------------------------------------------------------
[world]
description = "Empty PixeLAW world"
name = "pixelaw"
seed="pixelaw"
seed = "pixelaw"

[namespace]
default = "pixelaw"
mappings = { }

mappings = { }

[env]
rpc_url = "http://localhost:5050/"
account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
world_address= "0x2c130238b73abf493f1876d26cd52e0f45f318f99accac1d28f0ca6a3d7800f"


## The "Populated" world
## ----------------------------------------------------------------------------
#[profile.dev-pop.tool.dojo.world]
#description = "Populated PixeLAW world"
#name = "dev-pop"
#
#[profile.dev-pop.tool.dojo.env]
#rpc_url = "http://localhost:5050/"
#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486"
#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
#world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b"
world_address = "0x10bbde7919b063a353fc2c6148555434cd8a7be8d5cbfdcd06ef63787b58838"
18 changes: 7 additions & 11 deletions contracts/genesis_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@
}
},
"universalDeployer": {
"address": "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
"address": "0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
"storage": {
"0x10": "0x100"
}
},
"accounts": {
"0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486": {
"publicKey": "0x0640466ebd2ce505209d3e5c4494b4276ed8f1cde764d757eb48831961f7cdea",
"0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca": {
"publicKey": "0x640466ebd2ce505209d3e5c4494b4276ed8f1cde764d757eb48831961f7cdea",
"balance": "0xD3C21BCECCEDA1000000",
"nonce": "0x0",
"storage": {}
},
"0x01b70dbbbcc7af7ada881c80577618256bb17232e0d574a2f542b1821f610f8b": {
"publicKey": "0x04a405e8d7eab7a9d726001926817801fc77ef3c733cdcdc8481aa30368b8138",
"0xe29882a1fcba1e7e10cad46212257fea5c752a4f9b1b1ec683c503a2cf5c8a": {
"publicKey": "0x16e375df37a7653038bd9eccd767e780c2c4d4c66b4c85f455236a3fd75673a",
"balance": "0xD3C21BCECCEDA1000000",
"nonce": "0x0",
"storage": {}
}
},
"contracts": {

},
"classes": [

]
"contracts": {},
"classes": []
}
Loading

0 comments on commit 8756a62

Please sign in to comment.