Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions deploy_docs/COMPLETE_DEPLOY_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,35 @@ The core Dojo world deployment was handled by the `sozo` toolchain.
SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target \
sozo migrate --profile release --wait --use-blake2s-casm-class-hash
```
* **Outcome**: Successful. `manifest_release.json` updated (скопировать в фронт при деплое).
* **Outcome**: Successful. `manifest_release.json` updated (copy to frontend on deploy).
* **World Address**: `0x07c7e6cbe015e7a1ee77c4e29b859894c8eae03ac1ff69361df6bd8c262c9d47`.

## 3. Post-Deployment Setup (Gold Token & Wiring)
## 3. Post-Deployment Setup (GameConfig + Gold Token & Wiring)

### GameConfig (STRK + rebirth fee)

* **STRK address (immutable):** `config_system`'s `dojo_init` takes the STRK token address as calldata. Set it in `dojo_release.toml` before migrating; if a wrong address is used you must redeploy.
* **Rebirth fee (owner adjustable):** After deploy, verify `rebirth_fee` is non-zero; if it is `0`, no fee is collected:
* Quick check via Torii GQL:
```graphql
query { warpacksGameConfigModels { edges { node { id rebirth_fee strk_address } } } }
```
* To set/update the fee (wei):
```bash
SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target \
sozo execute --profile release --wait --use-blake2s-casm-class-hash \
--account-address <DEPLOYER> --private-key <PK> --rpc-url <RPC> \
Warpacks-config_system set_rebirth_fee <FEE_WEI>
```
The fee accrues on the `actions` system; use `withdraw_strk` there to move funds. Setting `0` disables charging.
* After setting a non-zero fee, players must approve STRK to the `actions` address once; otherwise `spawn/rebirth` will revert on `transfer_from`:
```bash
sncast --accounts-file <ACCOUNTS_JSON> --account <PLAYER_ACCOUNT> invoke \
--url <RPC> \
--contract-address <STRK_ERC20_ADDRESS> \
--function approve \
--calldata "<ACTIONS_ADDRESS> <ALLOWANCE_LOW> <ALLOWANCE_HIGH>"
```

After world deployment, Gold ERC20 was declared, deployed, and wired with sozo 1.8.2 (no starkli needed):

Expand Down
62 changes: 62 additions & 0 deletions deploy_docs/CONTRACT_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Contract Migration Guide (Sepolia, Dojo 1.8.x)

Это сжатый чек-лист, как мы мигрируем изменения контрактов Warpack Masters на Starknet Sepolia. Команды основаны на последней миграции (world `0x07c7e6cbe015e7a1ee77c4e29b859894c8eae03ac1ff69361df6bd8c262c9d47`).

## 0. Предусловия
- Установлено: `sozo 1.8.2`, `scarb 2.13.1`, `cairo 2.13.1`.
- Env:
- `STARKNET_RPC_URL=https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_9/iOVGW3WTTEPV8_IPJI5X68y5_lMStBKN`
- `STARKNET_ACCOUNT` / `STARKNET_PRIVATE_KEY` указывают на деплойер (см. `account.json`).
- Используем локальные кэши, чтобы не писать в `$HOME`:
- `SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target XDG_CACHE_HOME=.scarb_cache`
- Если DNS до scarbs.xyz нестабилен: добавить `SCARB_OFFLINE=true`.

## 1. Сборка
```bash
SCARB_OFFLINE=true \
SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target XDG_CACHE_HOME=.scarb_cache \
sozo build --profile release
```

## 2. Миграция на Sepolia
```bash
SCARB_OFFLINE=true \
SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target XDG_CACHE_HOME=.scarb_cache \
sozo migrate --profile release --wait --use-blake2s-casm-class-hash
```
- Проверяем вывод: мир должен остаться `0x07c7...c9d47`, manifest обновится.
- После миграции **скопировать `manifest_release.json` во фронт** (иначе Torii/фронт смотрят на старые адреса).

## 3. (Опционально) Перерегистрировать Gold и MINTER_ROLE
Если менялись адреса систем (actions/fight/token_factory) или нужно “освежить” роли:
```bash
SCARB_OFFLINE=true \
SCARB_CACHE=.scarb_cache SCARB_CONFIG=.scarb_config SCARB_TARGET_DIR=target XDG_CACHE_HOME=.scarb_cache \
STARKNET_RPC_URL=$STARKNET_RPC_URL \
scripts/init_register_gold.sh release 0x0689731c6c6df7798e601d730f18a0eae7f9a138f9ac9c54d27d94b423b29eca
```
Скрипт:
- Регистрирует Gold в `token_factory`.
- Выдаёт MINTER_ROLE (`0x032d…956a6`) для `actions` и `fight`.

## 4. (Опционально) Засеять данные
Если окружение свежее или нужно обновить каталоги:
```bash
# Каталог предметов
SCARB_OFFLINE=true STARKNET_RPC_URL=$STARKNET_RPC_URL scripts/init_batch_add_items.sh release

# Преднастроенные dummy (упадёт с "name already exists", если уже есть)
SCARB_OFFLINE=true STARKNET_RPC_URL=$STARKNET_RPC_URL scripts/init_pre_dummies.sh release

# Рецепты (Augmented Dagger)
SCARB_OFFLINE=true STARKNET_RPC_URL=$STARKNET_RPC_URL scripts/init_add_recipes.sh release
```
Каждый скрипт читает адреса из свежего `manifest_release.json`.

## 5. Что проверить после миграции
- `manifest_release.json` содержит актуальные адреса контрактов (actions/fight/token_factory).
- В бою не возникает `Caller is missing role` (значит MINTER_ROLE на Gold выдан).
- Фронт смотрит на новый manifest + Torii endpoint `https://api.cartridge.gg/x/warpack-masters/torii/graphql`.

## Быстрый tl;dr
1) build с кэшами, 2) migrate с `--use-blake2s-casm-class-hash`, 3) скопировать manifest во фронт, 4) при необходимости `init_register_gold.sh` + seeding скрипты.***
2 changes: 1 addition & 1 deletion docs/_mechanics/combat.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ Damage is calculated in this order:
- Loss counter increases
- Win streak resets to 0

After 5 losses, a character must use the rebirth system to continue.
After 3 losses, a character must use the rebirth system to continue.
16 changes: 8 additions & 8 deletions docs/_mechanics/rebirth.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ related_mechanics: [combat, items]

# Rebirth System

The rebirth system in Warpack Masters is a core progression mechanic that allows players to reset and start fresh after accumulating 5 losses, while maintaining certain progress aspects.
The rebirth system in Warpack Masters is a core progression mechanic that allows players to reset and start fresh after accumulating 3 losses, while maintaining certain progress aspects.

## When to Rebirth

Rebirth becomes mandatory when you reach 5 losses. At this point, you cannot participate in further battles until you go through the rebirth process.
Rebirth becomes mandatory when you reach 3 losses. At this point, you cannot participate in further battles until you go through the rebirth process.

## Rebirth Cost

Rebirth has an associated cost in STRK tokens (the game's currency):

- The cost is defined as `REBIRTH_FEE` in the game constants
- You must have enough STRK tokens in your wallet to complete the rebirth
- The fee is stored in `GameConfig.rebirth_fee` (defaulted at deploy, adjustable by the world owner; `0` disables charging)
- STRK address must be configured in `GameConfig` and the caller must have enough STRK approved to the actions contract
- The same fee is charged on the first-ever spawn, since spawn/rebirth share the initializer

## What Resets

Expand Down Expand Up @@ -55,7 +56,7 @@ After rebirth, your character begins with:

The rebirth system creates interesting strategic decisions:

- When to voluntarily rebirth before hitting 5 losses
- When to voluntarily rebirth before hitting 3 losses
- How to balance short-term success vs. long-term progression
- Whether to spend resources before rebirthing
- How to adapt your strategy based on accumulated knowledge
Expand All @@ -64,8 +65,8 @@ The rebirth system creates interesting strategic decisions:

The rebirth process follows these steps in the code:

1. Verify the player has reached 5 losses
2. Collect the STRK token fee
1. Verify the player has reached 3 losses
2. Collect the STRK token fee from `GameConfig.rebirth_fee` if STRK is configured and the fee is non-zero
3. Save the character's persistent data (name, class, rating, etc.)
4. Clear all items from inventory and storage
5. Reset all grid spaces to disabled
Expand All @@ -83,4 +84,3 @@ While rebirth resets many aspects of your character, it's an essential part of t
- Higher birth counts might unlock special features
- The persisting rating allows for matchmaking appropriate to your skill level
- Knowledge gained from previous runs helps optimize future strategies

4 changes: 2 additions & 2 deletions docs/_tutorials/combat-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ After a battle:

- **Winning** rewards you with 5 gold, increased rating, and potentially health bonuses
- **Losing** gives you 2 gold and decreases your rating
- After 5 losses, you'll need to use the rebirth system
- After 3 losses, you'll need to use the rebirth system

In the [next tutorial]({{ site.baseurl }}/tutorials/item-synergies), we'll cover how to create powerful item synergies.
In the [next tutorial]({{ site.baseurl }}/tutorials/item-synergies), we'll cover how to create powerful item synergies.
6 changes: 3 additions & 3 deletions docs/_tutorials/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ The battle will play out automatically based on the items you've placed and thei
Now that you understand the basics, it's time to learn about the [combat system]({{ site.baseurl }}/tutorials/combat-basics) and how different items interact during battle.

Remember:
- You can only fight if you have fewer than 5 losses
- After 5 losses, you'll need to use the rebirth system
- You can only fight if you have fewer than 3 losses
- After 3 losses, you'll need to use the rebirth system
- Each victory grants gold and increases your rating

Good luck, and may your strategies lead you to victory!
Good luck, and may your strategies lead you to victory!
10 changes: 10 additions & 0 deletions init_debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
~/Documents/warpacks/WM/Warpack-Masters ~/Documents/warpacks/WM/Warpack-Masters
---------------------------------------------------------------------------
Environment: release
Using manifest: ./manifest_release.json
World: 0x7ecfce5883757e973fcf2c1cfe2e7e58193d8c47ad530d033e0e3932de2be0b
Item system: 0x7b68a36e57fb4bd7dd60addc293f7f3998dca6416933cd10bba14dffa2cd7bf
---------------------------------------------------------------------------

ContractNotFound

42 changes: 37 additions & 5 deletions manifest_release.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"contracts": [
{
"address": "0x6cf6450c132752fbf3ace05d82f5d61fac097a6f62d0abd0b2b04a204ac16e6",
"class_hash": "0x6635300160f6482c5284aa765c3db928e800b08fe8ad51a8c5e9d4adfff6b4a",
"class_hash": "0xd9d73917d390dc29ca10d8e64b5df68a40b1059725b47212cb5b0b4ff8db48",
"init_calldata": [],
"tag": "Warpacks-actions",
"selector": "0x72c10aa5b1ff0c1599517beb7189673c59fa924c4753b33bab057a8c6200cb1",
Expand All @@ -55,14 +55,15 @@
},
{
"address": "0x31693c679ca789499a357600e50437f0f12a750ec82c74c410bba494078e58b",
"class_hash": "0x59781c5e627b2810ac4c169a1438e8c7c598f8009af97e51214c08af4400ed2",
"class_hash": "0x3ebfc3c7b64f0c439036216004eff64aea805125a3c02986452dabd0c20cbeb",
"init_calldata": [
"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
],
"tag": "Warpacks-config_system",
"selector": "0x6a040c0928ffc6a945e7efcd3576d8b6cbdb914afac47c911f85d89616c2dcb",
"systems": [
"dojo_init",
"set_rebirth_fee",
"upgrade"
]
},
Expand All @@ -80,7 +81,7 @@
},
{
"address": "0x1e9c91163b28a0cf2ebeb8311df4f57f7788b8f9bc10707d8f5243df57d97ea",
"class_hash": "0x5517034aa9d6c2396ffef89b39f91ead3b632f72adc2acbeaa6caa58e5830b0",
"class_hash": "0x23c88cba302d0c834cfdc345f09b94992d1b0749cabf93a029e139d37b1d1d",
"init_calldata": [],
"tag": "Warpacks-fight_system",
"selector": "0x7627186b5551a815f66c9d473067aa0639a516500356edd8a655b0bada60e3c",
Expand Down Expand Up @@ -116,7 +117,7 @@
},
{
"address": "0x5de82f88168fd0816686086dd11eb120f60d385b35c66031d5d624b7a37547",
"class_hash": "0x4da04060fa03499e1d4070709ea6d8facc754b14e9e8a6cebb4008a33c56f08",
"class_hash": "0x57fb3722abc1db2e4c4ab1ebbe5ddbcaee85569b9ec7eaefb7f8863250d7497",
"init_calldata": [],
"tag": "Warpacks-shop_system",
"selector": "0x4fc6e53062bad497f56645e733043df064f1a4d8bb0ce745f62942d893b8dd",
Expand Down Expand Up @@ -533,9 +534,14 @@
"name": "strk_address",
"type": "core::starknet::contract_address::ContractAddress",
"key": false
},
{
"name": "rebirth_fee",
"type": "core::integer::u256",
"key": false
}
],
"class_hash": "0x4aa6ed3e1aea200eaf7c54c641f4981369833e6582a37e34162da1f032b7e86",
"class_hash": "0x5e04d73bf6f921d878404ed382c18063ecf9f20daf821adad5301a384970773",
"tag": "Warpacks-GameConfig",
"selector": "0x28b5af007fcc24010d8f1ae72d7baf968817c5c7b5e8c5b54cd13da9175eb9e"
},
Expand Down Expand Up @@ -3745,6 +3751,10 @@
{
"name": "strk_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "rebirth_fee",
"type": "core::integer::u256"
}
]
},
Expand All @@ -3755,6 +3765,10 @@
{
"name": "strk_address",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "rebirth_fee",
"type": "core::integer::u256"
}
]
},
Expand Down Expand Up @@ -4537,6 +4551,24 @@
"kind": "enum",
"variants": []
},
{
"type": "interface",
"name": "warpack_masters::systems::config::IConfig",
"items": [
{
"type": "function",
"name": "set_rebirth_fee",
"inputs": [
{
"name": "rebirth_fee",
"type": "core::integer::u256"
}
],
"outputs": [],
"state_mutability": "external"
}
]
},
{
"type": "event",
"name": "warpack_masters::systems::config::config_system::Event",
Expand Down
92 changes: 92 additions & 0 deletions scripts/create_gold_token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

set -euo pipefail

pushd $(dirname "$0")/..



# Add parameter handling for environment

ENV=${1:-release} # Default to 'release'

MANIFEST_FILE="./manifest_${ENV}.json"



if [[ ! -f "$MANIFEST_FILE" ]]; then

echo "Error: Manifest file $MANIFEST_FILE does not exist"

exit 1

fi



: "${STARKNET_RPC_URL:?Environment variable STARKNET_RPC_URL must be set}"



export WORLD_ADDRESS=$(cat $MANIFEST_FILE | jq -r '.world.address')

export ACTIONS_ADDRESS=$(cat $MANIFEST_FILE | jq -r '.contracts[] | select(.tag == "Warpacks-actions").address')



# ERC20 Mintable class hash (declared earlier)

export ERC20_CLASS_HASH=0x05149c08b262aa481b02e5ca23138e8324fcd963d017aa834224c69547adc081



# Get account address from dojo_${ENV}.toml

export ACCOUNT_ADDRESS=0x123232bf1c29849c80483d4b1ce48a67fd6e46b6d5f784c75d733cb53e3fbf8



echo "---------------------------------------------------------------------------"

echo "Environment: $ENV"

echo "World: $WORLD_ADDRESS"

echo "Actions: $ACTIONS_ADDRESS"

echo "Account (admin): $ACCOUNT_ADDRESS"

echo "ERC20 Class Hash: $ERC20_CLASS_HASH"

echo "---------------------------------------------------------------------------"



# Create gold token with:

# - admin: account address (can grant roles)

# - minter: actions contract (can mint tokens)

# - upgrader: account address (can upgrade contract)

sozo execute -P ${ENV} Warpacks-token_factory create_gold_token \

$ACCOUNT_ADDRESS \

$ACTIONS_ADDRESS \

$ACCOUNT_ADDRESS \

$ERC20_CLASS_HASH \

--wait --rpc-url $STARKNET_RPC_URL



echo "---------------------------------------------------------------------------"

echo "Gold token created and registered successfully!"

echo "---------------------------------------------------------------------------"

Loading