Skip to content

Commit

Permalink
update for contract changes
Browse files Browse the repository at this point in the history
  • Loading branch information
starknetdev committed Sep 22, 2023
1 parent 636be20 commit 62b4f01
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 449 deletions.
4 changes: 2 additions & 2 deletions indexer/env-goerli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GAME="0x05407e809f20fefdf5a66bae7e359f43f04f6263773b4c4e7a82d7c8711a84c1"
GAME="0x0432b7f75ee336a6c297df710d567e02242e4dfe7efa51f213af63e28f362582"
START=857000
MONGO_CONNECTION_STRING="mongodb://mongo:mongo@localhost:27017"
MONGO_CONNECTION_STRING="mongodb://mongo:mongo@34.255.200.178:27017"
200 changes: 103 additions & 97 deletions indexer/goerli-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,110 +12,116 @@ services:
MONGO_INITDB_ROOT_USERNAME: mongo
MONGO_INITDB_ROOT_PASSWORD: mongo

# etcd:
# image: docker.io/bitnami/etcd:3.5
# environment:
# ALLOW_NONE_AUTHENTICATION: "yes"
# volumes:
# - etcd_data:/bitnami/etcd
etcd:
image: docker.io/bitnami/etcd:3.5
environment:
ALLOW_NONE_AUTHENTICATION: "yes"
volumes:
- etcd_data:/bitnami/etcd


# adventurers_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/adventurers.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: adventurers
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
adventurers_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/adventurers.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: adventurers
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

# battles_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/battles.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: battles
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
battles_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/battles.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: battles
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

# beasts_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/beasts.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: beasts
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
beasts_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/beasts.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: beasts
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

# discoveries_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/discoveries.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: discoveries
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
discoveries_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/discoveries.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: discoveries
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

# items_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/items.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: items
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
items_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/items.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: items
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

# scores_indexer:
# image: quay.io/apibara/sink-mongo:0.3
# depends_on:
# - etcd
# restart: always
# command:
# - run
# - --allow-env=/data/env-goerli
# - /data/src/scores.ts
# volumes:
# - ./:/data/
# environment:
# PERSIST_TO_ETCD: http://etcd:2379
# SINK_ID: scores
# AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq
scores_indexer:
image: quay.io/apibara/sink-mongo:0.3
depends_on:
- etcd
- mongo
restart: always
command:
- run
- --allow-env=/data/env-goerli
- /data/src/scores.ts
volumes:
- ./:/data/
environment:
PERSIST_TO_ETCD: http://etcd:2379
SINK_ID: scores
AUTH_TOKEN: dna_jX3t04zs9zywBnHWVmUq

volumes:
# etcd_data:
etcd_data:
mongo_data:
16 changes: 10 additions & 6 deletions indexer/graphql/src/indexer/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ class AdventurersFilter:
intelligence: Optional[FeltValueFilter] = None
wisdom: Optional[FeltValueFilter] = None
charisma: Optional[FeltValueFilter] = None
luck: Optional[FeltValueFilter] = None
xp: Optional[FeltValueFilter] = None
weapon: Optional[FeltValueFilter] = None
chest: Optional[FeltValueFilter] = None
Expand Down Expand Up @@ -760,6 +761,7 @@ class AdventurersOrderByInput:
intelligence: Optional[OrderByInput] = None
wisdom: Optional[OrderByInput] = None
charisma: Optional[OrderByInput] = None
luck: Optional[OrderByInput] = None
xp: Optional[OrderByInput] = None
weapon: Optional[OrderByInput] = None
chest: Optional[OrderByInput] = None
Expand Down Expand Up @@ -889,6 +891,7 @@ class Adventurer:
intelligence: Optional[FeltValue]
wisdom: Optional[FeltValue]
charisma: Optional[FeltValue]
luck: Optional[FeltValue]
xp: Optional[FeltValue]
weapon: Optional[ItemValue]
chest: Optional[ItemValue]
Expand Down Expand Up @@ -921,6 +924,7 @@ def from_mongo(cls, data):
intelligence=data["intelligence"],
wisdom=data["wisdom"],
charisma=data["charisma"],
luck=data["luck"],
xp=data["xp"],
weapon=data["weapon"],
chest=data["chest"],
Expand Down Expand Up @@ -1608,15 +1612,15 @@ async def run_graphql_api(mongo_goerli=None, mongo_mainnet=None, port="8080"):
},
)

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

runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", int(port), ssl_context=ssl_context)
site = web.TCPSite(runner, "0.0.0.0", int(port))
await site.start()

print(f"GraphQL server started on port {port}")
Expand Down
2 changes: 1 addition & 1 deletion indexer/graphql/src/indexer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def graphql(mongo_goerli, mongo_mainnet, port):
if port is None:
port = "8080"
if mongo_goerli is None:
mongo_goerli = "mongodb://apibara:apibara@localhost:27017"
mongo_goerli = "mongodb://mongo:mongo@localhost:27017"
if mongo_mainnet is None:
mongo_mainnet = "mongodb://apibara:apibara@localhost:27018"

Expand Down
27 changes: 7 additions & 20 deletions indexer/src/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
START_GAME,
} from "./utils/events.ts";
import { insertItem, updateItemsXP } from "./utils/helpers.ts";
import { checkExistsInt } from "./utils/encode.ts";
import { checkExistsInt, encodeIntAsBytes } from "./utils/encode.ts";
import { MONGO_CONNECTION_STRING, ITEMS_NUMBER } from "./utils/constants.ts";

const GAME = Deno.env.get("GAME");
Expand Down Expand Up @@ -73,25 +73,6 @@ export default function transform({ header, events }: Block) {
const as = value.adventurerState;
const itemInserts: any[] = [];
console.log("START_GAME", "->", "ITEMS UPDATES");
// for (let i = 1; i < ITEMS_NUMBER; i++) {
// itemInserts.push(
// insertItem({
// item: i,
// adventurerId: as.adventurerId,
// owner: false,
// equipped: false,
// ownerAddress: 0,
// xp: 0,
// special1: 0,
// special2: 0,
// special3: 0,
// isAvailable: false,
// purchasedTime: 0,
// timestamp: new Date().toISOString(),
// })
// );
// }

const starterWeapon = {
entity: {
item: checkExistsInt(BigInt(as.adventurer.weapon.id)),
Expand All @@ -104,6 +85,12 @@ export default function transform({ header, events }: Block) {
owner: true,
equipped: true,
ownerAddress: checkExistsInt(BigInt(as.owner)),
xp: encodeIntAsBytes(BigInt(0)),
special1: null,
special2: null,
special3: null,
isAvailable: false,
purchasedTime: null,
timestamp: new Date().toISOString(),
},
},
Expand Down
Loading

0 comments on commit 62b4f01

Please sign in to comment.