Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LS 1.5 #9

Closed
wants to merge 18 commits into from
Closed
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
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ contracts/beasts/target/CACHEDIR.TAG

keys
account
loot-survivor.pem
ls1.5.pem
ls1.5-2.pem
contracts/game_entropy/target/CACHEDIR.TAG
contracts/game_entropy/target/dev/game_entropy.sierra

Expand Down
12 changes: 12 additions & 0 deletions indexer/dna/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.6'

services:
dna:
image: quay.io/apibara/starknet:1.5.0
restart: always
ports:
- "7171:7171"
command:
- start
- --rpc
- http://host.docker.internal:5050
4 changes: 2 additions & 2 deletions indexer/env-sepolia
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GAME="0x02b66531874c952844913b8cbc573878c794112b546cbf39409013e33d4777fe"
START=60000
GAME="0x0305f26ad19e0a10715d9f3137573d3a543de7b707967cd85d11234d6ec0fb7e"
START=68300
MONGO_CONNECTION_STRING="mongodb://mongo:mongo@mongo:27017"
MONGO_DB="mongo"
STREAM_URL='https://sepolia.starknet.a5a.ch'
2 changes: 1 addition & 1 deletion indexer/graphql/Dockerfile.sepolia
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN python3 -m pip install pycryptodome
RUN poetry config virtualenvs.create false
RUN poetry install

ENTRYPOINT [ "indexer", "graphql", "--mongo", "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@54.74.126.103:27017", "--port", "8080" ]
ENTRYPOINT [ "indexer", "graphql", "--mongo", "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@54.157.59.41:27017", "--port", "8080" ]
16 changes: 8 additions & 8 deletions indexer/graphql/src/indexer/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ class OrderByInput:
@strawberry.input
class AdventurersFilter:
id: Optional[FeltValueFilter] = None
entropy: Optional[HexValueFilter] = None
lastAction: Optional[FeltValueFilter] = None
owner: Optional[HexValueFilter] = None
name: Optional[StringFilter] = None
Expand Down Expand Up @@ -778,6 +779,7 @@ class ItemsFilter:
@strawberry.input
class AdventurersOrderByInput:
id: Optional[OrderByInput] = None
entropy: Optional[OrderByInput] = None
lastAction: Optional[OrderByInput] = None
owner: Optional[OrderByInput] = None
name: Optional[OrderByInput] = None
Expand Down Expand Up @@ -905,7 +907,7 @@ class ItemsOrderByInput:
@strawberry.type
class Adventurer:
id: Optional[FeltValue]
lastAction: Optional[FeltValue]
entropy: Optional[HexValue]
owner: Optional[HexValue]
name: Optional[StringValue]
health: Optional[FeltValue]
Expand All @@ -927,9 +929,8 @@ class Adventurer:
ring: Optional[ItemValue]
beastHealth: Optional[FeltValue]
statUpgrades: Optional[FeltValue]
startBlock: Optional[FeltValue]
startEntropy: Optional[FeltValue]
revealBlock: Optional[FeltValue]
actionsPerBlock: Optional[FeltValue]
gold: Optional[FeltValue]
createdTime: Optional[str]
lastUpdatedTime: Optional[str]
Expand All @@ -939,7 +940,7 @@ class Adventurer:
def from_mongo(cls, data):
return cls(
id=data["id"],
lastAction=data["lastAction"],
entropy=data["entropy"],
owner=data["owner"],
name=data["name"],
health=data["health"],
Expand All @@ -961,9 +962,8 @@ def from_mongo(cls, data):
ring=data["ring"],
beastHealth=data["beastHealth"],
statUpgrades=data["statUpgrades"],
startBlock=data["startBlock"],
startEntropy=data["startEntropy"],
revealBlock=data["revealBlock"],
actionsPerBlock=data["actionsPerBlock"],
gold=data["gold"],
createdTime=data["createdTime"],
lastUpdatedTime=data["lastUpdatedTime"],
Expand Down Expand Up @@ -1601,8 +1601,8 @@ async def run_graphql_api(mongo=None, port="8080"):

ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain(
"/etc/letsencrypt/live/survivor-sepolia-indexer.realms.world/fullchain.pem",
"/etc/letsencrypt/live/survivor-sepolia-indexer.realms.world/privkey.pem",
"/etc/letsencrypt/live/ls-indexer-sepolia.provable.games/fullchain.pem",
"/etc/letsencrypt/live/ls-indexer-sepolia.provable.games/privkey.pem",
)

runner = web.AppRunner(app)
Expand Down
12 changes: 6 additions & 6 deletions indexer/sepolia-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:


adventurers_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand All @@ -45,7 +45,7 @@ services:
- indexer

battles_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand All @@ -64,7 +64,7 @@ services:
- indexer

beasts_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand All @@ -83,7 +83,7 @@ services:
- indexer

discoveries_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand All @@ -102,7 +102,7 @@ services:
- indexer

items_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand All @@ -121,7 +121,7 @@ services:
- indexer

scores_indexer:
image: quay.io/apibara/sink-mongo:0.4.2
image: quay.io/apibara/sink-mongo:0.8.0
depends_on:
- etcd
- mongo
Expand Down
23 changes: 11 additions & 12 deletions indexer/src/adventurers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function transform({ header, events }: Block) {
insertAdventurer({
id: as.adventurerId,
owner: as.owner,
lastAction: as.adventurer.lastActionBlock,
entropy: as.adventurerEntropy,
health: as.adventurer.health,
xp: as.adventurer.xp,
strength: as.adventurer.stats.strength,
Expand All @@ -118,19 +118,18 @@ export default function transform({ header, events }: Block) {
charisma: as.adventurer.stats.charisma,
luck: as.adventurer.stats.luck,
gold: as.adventurer.gold,
weapon: as.adventurer.weapon.id,
chest: as.adventurer.chest.id,
head: as.adventurer.head.id,
waist: as.adventurer.waist.id,
foot: as.adventurer.foot.id,
hand: as.adventurer.hand.id,
neck: as.adventurer.neck.id,
ring: as.adventurer.ring.id,
weapon: as.adventurer.equipment.weapon.id,
chest: as.adventurer.equipment.chest.id,
head: as.adventurer.equipment.head.id,
waist: as.adventurer.equipment.waist.id,
foot: as.adventurer.equipment.foot.id,
hand: as.adventurer.equipment.hand.id,
neck: as.adventurer.equipment.neck.id,
ring: as.adventurer.equipment.ring.id,
beastHealth: as.adventurer.beastHealth,
statUpgrades: as.adventurer.statsPointsAvailable,
actionsPerBlock: as.adventurer.actionsPerBlock,
statUpgrades: as.adventurer.statsUpgradesAvailable,
name: am.name,
startBlock: am.startBlock,
startEntropy: am.startEntropy,
revealBlock: value.revealBlock,
createdTime: new Date().toISOString(),
lastUpdatedTime: new Date().toISOString(),
Expand Down
5 changes: 2 additions & 3 deletions indexer/src/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@ export default function transform({ header, events }: Block) {
case START_GAME: {
const { value } = parseStartGame(event.data, 0);
const as = value.adventurerState;
const itemInserts: any[] = [];
console.log("START_GAME", "->", "ITEMS UPDATES");
const starterWeapon = {
entity: {
item: checkExistsInt(BigInt(as.adventurer.weapon.id)),
item: checkExistsInt(BigInt(as.adventurer.equipment.weapon.id)),
adventurerId: checkExistsInt(BigInt(as.adventurerId)),
},
update: {
$set: {
item: checkExistsInt(BigInt(as.adventurer.weapon.id)),
item: checkExistsInt(BigInt(as.adventurer.equipment.weapon.id)),
adventurerId: checkExistsInt(BigInt(as.adventurerId)),
owner: true,
equipped: true,
Expand Down
52 changes: 29 additions & 23 deletions indexer/src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const parseStats = combineParsers({
export const parseLootStatistics = combineParsers({
id: { index: 0, parser: parseU8 },
xp: { index: 1, parser: parseU16 },
metadata: { index: 2, parser: parseU8 },
});

export const parseLoot = combineParsers({
Expand All @@ -76,30 +75,33 @@ export const parseLootWithPrice = combineParsers({
price: { index: 1, parser: parseU16 },
});

export const parseEquipment = combineParsers({
weapon: { index: 0, parser: parseLootStatistics },
chest: { index: 1, parser: parseLootStatistics },
head: { index: 2, parser: parseLootStatistics },
waist: { index: 3, parser: parseLootStatistics },
foot: { index: 4, parser: parseLootStatistics },
hand: { index: 5, parser: parseLootStatistics },
neck: { index: 6, parser: parseLootStatistics },
ring: { index: 7, parser: parseLootStatistics },
});

export const parseAdventurer = combineParsers({
lastActionBlock: { index: 0, parser: parseU16 },
health: { index: 1, parser: parseU16 },
xp: { index: 2, parser: parseU16 },
stats: { index: 3, parser: parseStats },
gold: { index: 4, parser: parseU16 },
weapon: { index: 5, parser: parseLootStatistics },
chest: { index: 6, parser: parseLootStatistics },
head: { index: 7, parser: parseLootStatistics },
waist: { index: 8, parser: parseLootStatistics },
foot: { index: 9, parser: parseLootStatistics },
hand: { index: 10, parser: parseLootStatistics },
neck: { index: 11, parser: parseLootStatistics },
ring: { index: 12, parser: parseLootStatistics },
beastHealth: { index: 13, parser: parseU16 },
statsPointsAvailable: { index: 14, parser: parseU8 },
actionsPerBlock: { index: 15, parser: parseU8 },
mutated: { index: 16, parser: parseBoolean },
health: { index: 0, parser: parseU16 },
xp: { index: 1, parser: parseU16 },
gold: { index: 2, parser: parseU16 },
beastHealth: { index: 3, parser: parseU16 },
statsUpgradesAvailable: { index: 4, parser: parseU8 },
stats: { index: 5, parser: parseStats },
equipment: { index: 6, parser: parseEquipment },
mutated: { index: 7, parser: parseBoolean },
});

export const parseAdventurerState = combineParsers({
owner: { index: 0, parser: parseFelt252 },
adventurerId: { index: 1, parser: parseFelt252 },
adventurer: { index: 2, parser: parseAdventurer },
adventurerEntropy: { index: 2, parser: parseFelt252 },
adventurer: { index: 3, parser: parseAdventurer },
});

export const parseSpecialPowers = combineParsers({
Expand Down Expand Up @@ -172,10 +174,10 @@ export const parseAdventurerDied = combineParsers({
});

export const parseAdventurerMetadata = combineParsers({
startBlock: { index: 0, parser: parseU128 },
startEntropy: { index: 0, parser: parseU128 },
startingStats: { index: 1, parser: parseStats },
name: { index: 2, parser: parseU128 },
interfaceCamel: { index: 3, parser: parseBoolean },
interfaceCamel: { index: 2, parser: parseBoolean },
name: { index: 3, parser: parseU128 },
});

export const parseStartGame = combineParsers({
Expand All @@ -196,7 +198,11 @@ export const parseBag = combineParsers({
item9: { index: 8, parser: parseLootStatistics },
item10: { index: 9, parser: parseLootStatistics },
item11: { index: 10, parser: parseLootStatistics },
mutated: { index: 11, parser: parseBoolean },
item12: { index: 11, parser: parseLootStatistics },
item13: { index: 12, parser: parseLootStatistics },
item14: { index: 13, parser: parseLootStatistics },
item15: { index: 14, parser: parseLootStatistics },
mutated: { index: 15, parser: parseBoolean },
});

export const parseAdventurerStateWithBag = combineParsers({
Expand Down
Loading
Loading