Skip to content

Commit

Permalink
Update dev scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Dec 25, 2023
1 parent 279a91b commit e7f88ee
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 271 deletions.
4 changes: 3 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ dev-facade *ARGS:
dev-reg-transactor conf:
cargo run -p race-transactor -- -c {{conf}} reg

dev-transactor conf:
dev-run-transactor conf:
cargo run -p race-transactor -- -c {{conf}} run

dev-transactor conf: (dev-reg-transactor conf) (dev-run-transactor conf)

facade-transactor num:
cargo run -p race-transactor -- -c examples/conf/server{{num}}.toml reg
cargo run -p race-transactor -- -c examples/conf/server{{num}}.toml run
Expand Down
14 changes: 14 additions & 0 deletions dev/Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
holdem-simple:
zellij --layout layouts/holdem-simple.kdl

holdem-multi:
zellij --layout layouts/holdem-multi.kdl

durak-simple:
zellij --layout layouts/durak-simple.kdl

demo-app:
zellij --layout layouts/demo-app.kdl

mtt-simple:
zellij --layout layouts/mtt-simple.kdl
110 changes: 2 additions & 108 deletions dev/README.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,3 @@
# Prepare Solana development environment
# Dev Scripts for Race Development

## Load Metaplex into local test validator

```bash
solana program dump -u m metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s token_metadata_program.so

# This will reset the test-ledger
solana-test-validator --bpf-program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s token_metadata_program.so --reset
```

## Create a token for testing

```bash
spl-token create-token

spl-token create-account <TOKEN_ADDRESS>

spl-token mint <TOKEN_ADDRESS> <AMOUNT>
```
We use this token for following tests.

## Deploy RACE contract to solana localnet

``` shell
just solana
```


## Publish game bundle

Uploaded NFT metadata on Arweave:

- Chat: https://arweave.net/6SOGM007lgaeBH1SOJ-Ifm9eUUNz4kCdRqVJe-yl9_g
- Raffle: https://arweave.net/hTlRRw2tZ2q_RpklixjRIzrR3PgAChBujAKzp6wknHs

```shell
just publish Chat https://arweave.net/6SOGM007lgaeBH1SOJ-Ifm9eUUNz4kCdRqVJe-yl9_g
just publish Raffle https://arweave.net/hTlRRw2tZ2q_RpklixjRIzrR3PgAChBujAKzp6wknHs
```

NFT addresses will be returned when upload succeed. Later we will use this NFT token address as **bundle address**.

## Create game registration

```shell
just create-reg
```

## Create game accounts

To create games, a spec file in JSON is required. Replace the addresses with what you have, and save it as `spec.json`.

```json
{
"title": "<GAME TITLE>",
"reg_addr": "<REPLACE WITH THE REGISTRATION ADDRESS>",
"bundle_addr": "<REPLACE WITH THE BUNDLE ADDRESS>",
"token_addr": "<REPLACE WITH THE TOKEN ADDRESS>",
"max_players": 10,
"min_deposit": 10,
"max_deposit": 20,
"data": []
}
```

Create the game account with command line tool.

```shell
just create-game spec.json
```

Game account address will be returned.

## Generate a keypair for transactor

```shell
solana-keygen new -o transactor.json

# Transfer some SOL to this new account
solana transfer --allow-unfunded-recipient <TRANSACTOR PUBKEY> 2
```

## Create transactor configuration file

```toml
[transactor]
port = 12003
endpoint = "ws://localhost:12003"
chain = "solana"
address = "<REPLACE WITH GENERATED KEYPAIR'S PUBLIC KEY>"
reg_addresses = ["<REPLACE WITH THE REGISTRATION ADDRESS>"]

[solana]
keyfile = /path/to/transactor.json
rpc = "http://localhost:8899"
```

## Register server

``` shell
just dev-reg-transactor /path/to/transactor.toml
```

## Start transactor

```shell
just dev-transactor /path/to/transactor.toml
```
This folder contains the scripts and configurations for local development on Race Protocol.
61 changes: 61 additions & 0 deletions dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
description = "Dev scripts for Race Protocol";

inputs = {
nixpkgs = { url = "github:NixOS/nixpkgs/nixos-23.05"; };
flake-utils = { url = "github:numtide/flake-utils"; };
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
just
zellij
];
};
}
);

nixConfig = {
bash-prompt-prefix = "[flake]";
};
}
13 changes: 13 additions & 0 deletions dev/game-specs/holdem-cash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "Cash Table",
"bundle": "../race-holdem/target/race_holdem_cash.wasm",
"token": "FACADE_USDC",
"maxPlayers": 6,
"entryType": {
"cash": {
"minDeposit": 1000000,
"maxDeposit": 3000000
}
},
"data": [16,39,0,0,0,0,0,0,32,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0]
}
14 changes: 7 additions & 7 deletions dev/demo-app.kdl → dev/layouts/demo-app.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ layout {
pane {
name "Facade"
focus true
cwd "./"
cwd "../"
command "just"
args "dev-facade" "examples/draw-card/facade.json"
args "dev-facade" "-g" "examples/draw-card/facade.json"
start_suspended true
}
pane {
name "Vite"
focus true
cwd "./"
cwd "../"
command "just"
args "dev-demo-app"
}
Expand All @@ -24,15 +24,15 @@ layout {
pane {
name "Transactor"
command "just"
cwd "./"
args "facade-transactor" "1"
cwd "../"
args "dev-transactor" "dev/server-confs/server1.toml"
start_suspended true
}
pane {
name "Transactor"
command "just"
cwd "./"
args "facade-transactor" "2"
cwd "../"
args "dev-transactor" "dev/server-confs/server2.toml"
start_suspended true
}
}
Expand Down
8 changes: 4 additions & 4 deletions dev/durak-simple.kdl → dev/layouts/durak-simple.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ layout {
pane {
name "Facade"
focus true
cwd "./"
cwd "../"
command "just"
args "dev-facade" "../durak/conf/heads_up.json" "../durak/conf/3players.json"
args "dev-facade" "-g" "../durak/conf/heads_up.json" "-g" "../durak/conf/3players.json"
start_suspended true
}
pane split_direction="horizontal" {
pane {
name "Transactor"
command "just"
cwd "./"
args "facade-transactor" "1"
cwd "../"
args "dev-transactor" "dev/server-confs/server1.toml"
start_suspended true
}
pane
Expand Down
12 changes: 6 additions & 6 deletions dev/holdem-multi.kdl → dev/layouts/holdem-multi.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ layout {
pane {
name "Facade"
focus true
cwd "./"
cwd "../"
command "just"
args "dev-facade" "../race-holdem/cash/facade.json"
args "dev-facade" "-g" "../race-holdem/cash/facade.json"
start_suspended true
}
pane split_direction="vertical" {
pane {
name "Transactor 1"
command "just"
cwd "./"
args "facade-transactor" "1"
cwd "../"
args "dev-transactor" "dev/server-confs/server1.toml"
start_suspended true
}
pane {
name "Transactor 2"
command "just"
cwd "./"
args "facade-transactor" "2"
cwd "../"
args "dev-transactor" "dev/server-confs/server2.toml"
start_suspended true
}
}
Expand Down
9 changes: 4 additions & 5 deletions dev/holdem-simple.kdl → dev/layouts/holdem-simple.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ layout {
pane {
name "Facade"
focus true
cwd "./"
cwd "../"
command "just"
args "dev-facade" "../race-holdem/cash/facade.json"
start_suspended true
args "dev-facade" "-g" "dev/game-specs/holdem-cash.json"
}
pane split_direction="horizontal" {
pane {
name "Transactor"
command "just"
cwd "./"
args "facade-transactor" "1"
cwd "../"
args "dev-transactor" "dev/server-confs/server1.toml"
start_suspended true
}
pane
Expand Down
8 changes: 4 additions & 4 deletions dev/mtt-simple.kdl → dev/layouts/mtt-simple.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ layout {
pane {
name "Facade"
focus true
cwd "./"
cwd "../"
command "bash"
args "dev/create-mtt-game.sh"
args "dev/scripts/create-mtt-game.sh"
start_suspended true
}
pane split_direction="horizontal" {
pane {
name "Transactor"
command "just"
cwd "./"
args "facade-transactor" "1"
cwd "../"
args "facade-transactor" "dev/server-confs/server1.toml"
start_suspended true
}
pane
Expand Down
Loading

0 comments on commit e7f88ee

Please sign in to comment.