Skip to content

Commit

Permalink
- update abi
Browse files Browse the repository at this point in the history
- increase max stats on all to 31
- increase max health
- update indexer events with new contract changes
  • Loading branch information
starknetdev committed May 27, 2024
1 parent 6c3ce92 commit c1cb52b
Show file tree
Hide file tree
Showing 11 changed files with 746 additions and 491 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ contracts/beasts/target/CACHEDIR.TAG
keys
account
ls1.5.pem
ls1.5-2.pem
contracts/game_entropy/target/CACHEDIR.TAG
contracts/game_entropy/target/dev/game_entropy.sierra

Expand Down
8 changes: 2 additions & 6 deletions indexer/graphql/src/indexer/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,6 @@ class ItemsOrderByInput:
class Adventurer:
id: Optional[FeltValue]
entropy: Optional[HexValue]
lastAction: Optional[FeltValue]
owner: Optional[HexValue]
name: Optional[StringValue]
health: Optional[FeltValue]
Expand All @@ -930,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 @@ -943,7 +941,6 @@ def from_mongo(cls, data):
return cls(
id=data["id"],
entropy=data["entropy"],
lastAction=data["lastAction"],
owner=data["owner"],
name=data["name"],
health=data["health"],
Expand All @@ -965,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
22 changes: 10 additions & 12 deletions indexer/src/adventurers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export default function transform({ header, events }: Block) {
id: as.adventurerId,
owner: as.owner,
entropy: as.adventurerEntropy,
lastAction: as.adventurer.lastActionBlock,
health: as.adventurer.health,
xp: as.adventurer.xp,
strength: as.adventurer.stats.strength,
Expand All @@ -119,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
37 changes: 19 additions & 18 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,24 +75,26 @@ 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 },
health: { index: 0, parser: parseU16 },
xp: { index: 1, parser: parseU16 },
beastHealth: { index: 2, parser: parseU16 },
statsUpgradesAvailable: { index: 3, parser: parseU8 },
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 },
stats: { index: 5, parser: parseStats },
equipment: { index: 6, parser: parseEquipment },
mutated: { index: 7, parser: parseBoolean },
});

export const parseAdventurerState = combineParsers({
Expand Down Expand Up @@ -173,7 +174,7 @@ 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 },
Expand Down
62 changes: 29 additions & 33 deletions indexer/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export function insertAdventurer({
id,
owner,
entropy,
lastAction,
health,
xp,
strength,
Expand All @@ -25,9 +24,8 @@ export function insertAdventurer({
ring,
beastHealth,
statUpgrades,
actionsPerBlock,
name,
startBlock,
startEntropy,
revealBlock,
createdTime,
lastUpdatedTime,
Expand All @@ -44,7 +42,6 @@ export function insertAdventurer({
$set: {
...entity,
entropy: encodeIntAsBytes(BigInt(entropy)),
lastAction: encodeIntAsBytes(BigInt(lastAction)),
health: encodeIntAsBytes(BigInt(health)),
xp: encodeIntAsBytes(BigInt(xp)),
strength: encodeIntAsBytes(BigInt(strength)),
Expand All @@ -64,9 +61,8 @@ export function insertAdventurer({
ring: checkExistsInt(BigInt(ring)),
beastHealth: encodeIntAsBytes(BigInt(beastHealth)),
statUpgrades: checkExistsInt(BigInt(statUpgrades)),
actionsPerBlock: encodeIntAsBytes(BigInt(actionsPerBlock)),
name: checkExistsInt(BigInt(name)),
startBlock: encodeIntAsBytes(BigInt(startBlock)),
startEntropy: encodeIntAsBytes(BigInt(startEntropy)),
revealBlock: encodeIntAsBytes(BigInt(revealBlock)),
createdTime: createdTime,
lastUpdatedTime: lastUpdatedTime,
Expand Down Expand Up @@ -174,7 +170,6 @@ export function updateAdventurer({
$set: {
...entity,
entropy: encodeIntAsBytes(BigInt(adventurerState.adventurerEntropy)),
lastAction: encodeIntAsBytes(BigInt(adventurer.lastActionBlock)),
health: encodeIntAsBytes(BigInt(adventurer.health)),
xp: encodeIntAsBytes(BigInt(adventurer.xp)),
strength: encodeIntAsBytes(BigInt(adventurer.stats.strength)),
Expand All @@ -185,17 +180,18 @@ export function updateAdventurer({
charisma: encodeIntAsBytes(BigInt(adventurer.stats.charisma)),
luck: encodeIntAsBytes(BigInt(adventurer.stats.luck)),
gold: encodeIntAsBytes(BigInt(adventurer.gold)),
weapon: checkExistsInt(BigInt(adventurer.weapon.id)),
chest: checkExistsInt(BigInt(adventurer.chest.id)),
head: checkExistsInt(BigInt(adventurer.head.id)),
waist: checkExistsInt(BigInt(adventurer.waist.id)),
foot: checkExistsInt(BigInt(adventurer.foot.id)),
hand: checkExistsInt(BigInt(adventurer.hand.id)),
neck: checkExistsInt(BigInt(adventurer.neck.id)),
ring: checkExistsInt(BigInt(adventurer.ring.id)),
weapon: checkExistsInt(BigInt(adventurer.equipment.weapon.id)),
chest: checkExistsInt(BigInt(adventurer.equipment.chest.id)),
head: checkExistsInt(BigInt(adventurer.equipment.head.id)),
waist: checkExistsInt(BigInt(adventurer.equipment.waist.id)),
foot: checkExistsInt(BigInt(adventurer.equipment.foot.id)),
hand: checkExistsInt(BigInt(adventurer.equipment.hand.id)),
neck: checkExistsInt(BigInt(adventurer.equipment.neck.id)),
ring: checkExistsInt(BigInt(adventurer.equipment.ring.id)),
beastHealth: encodeIntAsBytes(BigInt(adventurer.beastHealth)),
statUpgrades: encodeIntAsBytes(BigInt(adventurer.statsPointsAvailable)),
actionsPerBlock: encodeIntAsBytes(BigInt(adventurer.actionsPerBlock)),
statUpgrades: encodeIntAsBytes(
BigInt(adventurer.statsUpgradesAvailable)
),
lastUpdatedTime: timestamp,
timestamp,
},
Expand Down Expand Up @@ -434,58 +430,58 @@ export function updateItemsXP({
const itemUpdates: any[] = [];
itemUpdates.push(
updateItemXP({
item: adventurer.weapon.id,
item: adventurer.equipment.weapon.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.weapon.xp,
xp: adventurer.equipment.weapon.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.chest.id,
item: adventurer.equipment.chest.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.chest.xp,
xp: adventurer.equipment.chest.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.head.id,
item: adventurer.equipment.head.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.head.xp,
xp: adventurer.equipment.head.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.waist.id,
item: adventurer.equipment.waist.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.waist.xp,
xp: adventurer.equipment.waist.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.foot.id,
item: adventurer.equipment.foot.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.foot.xp,
xp: adventurer.equipment.foot.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.hand.id,
item: adventurer.equipment.hand.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.hand.xp,
xp: adventurer.equipment.hand.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.neck.id,
item: adventurer.equipment.neck.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.neck.xp,
xp: adventurer.equipment.neck.xp,
})
);
itemUpdates.push(
updateItemXP({
item: adventurer.ring.id,
item: adventurer.equipment.ring.id,
adventurerId: adventurerState.adventurerId,
xp: adventurer.ring.xp,
xp: adventurer.equipment.ring.xp,
})
);
const filteredUpdates = itemUpdates.filter((value) => value !== undefined);
Expand Down
Loading

0 comments on commit c1cb52b

Please sign in to comment.