diff --git a/indexer/env-sepolia b/indexer/env-sepolia index 9a2f23753..954f39509 100644 --- a/indexer/env-sepolia +++ b/indexer/env-sepolia @@ -1,4 +1,4 @@ -GAME="0x02b66531874c952844913b8cbc573878c794112b546cbf39409013e33d4777fe" +GAME="0x00e55a2cde54c0051a72e44e81ddeed12103cc1cd1a20dc14fe52520e69b14ea" START=60000 MONGO_CONNECTION_STRING="mongodb://mongo:mongo@mongo:27017" MONGO_DB="mongo" diff --git a/indexer/graphql/Dockerfile.sepolia b/indexer/graphql/Dockerfile.sepolia index 344e9fb3a..3afc262af 100644 --- a/indexer/graphql/Dockerfile.sepolia +++ b/indexer/graphql/Dockerfile.sepolia @@ -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}@34.245.17.93:27017", "--port", "8080" ] diff --git a/indexer/restart-compose-sepolia.sh b/indexer/restart-compose-sepolia.sh new file mode 100644 index 000000000..30a3a12f7 --- /dev/null +++ b/indexer/restart-compose-sepolia.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Path to your docker-compose.yml file +COMPOSE_PATH="sepolia-compose.yaml" + +# Container names (as specified in docker-compose.yml) +CONTAINER_NAMES=("indexer-adventurers_indexer-1" "indexer-battles_indexer-1" "indexer-beasts_indexer-1" "indexer-discoveries_indexer-1" "indexer-items_indexer-1" "indexer-scores_indexer-1") + +# Time to wait between checks (5mins / 300 seconds) +INTERVAL=300 + +# Check if a block has been processed in the last minute +check_container_activity() { + local CONTAINER_NAME="$1" + LAST_LOG=$(docker logs "$CONTAINER_NAME" 2>&1 | tail -1) # Assuming you want the last log entry + echo "Extracted log: $LAST_LOG" # Print timestamp for verification + LAST_TIMESTAMP=$(echo "$LAST_LOG" | sed -E 's/\x1B\[[0-9;]*[JKmsu]//g' | cut -d' ' -f1) + + echo "Extracted timestamp: $LAST_TIMESTAMP" # Print timestamp for verification + + # Convert timestamp to epoch (seconds since 1970) + LAST_EPOCH=$(date -d "$LAST_TIMESTAMP" +%s) + CURRENT_EPOCH=$(date +%s) + echo "Current time difference: $((CURRENT_EPOCH - LAST_EPOCH)) seconds" + + # If the difference is more than the interval, return 1 (unhealthy) + if (( CURRENT_EPOCH - LAST_EPOCH > INTERVAL )); then + return 1 + else + return 0 + fi +} + +while true; do + for CONTAINER_NAME in "${CONTAINER_NAMES[@]}"; do + if ! check_container_activity "$CONTAINER_NAME"; then + echo "Container $CONTAINER_NAME seems to be stuck. Restarting..." + docker-compose -f $COMPOSE_PATH stop "$CONTAINER_NAME" + docker-compose -f $COMPOSE_PATH up -d "$CONTAINER_NAME" + # # Add a notification mechanism here if needed + fi + done + sleep $INTERVAL +done diff --git a/ui/.env.preview b/ui/.env.preview index 9f24bc390..42db98370 100644 --- a/ui/.env.preview +++ b/ui/.env.preview @@ -4,7 +4,7 @@ NEXT_PUBLIC_RPC_API_KEY=efb20d63-c5e0-4f5d-ab72-ef7add92779f NEXT_PUBLIC_LS_GQL_URL=https://survivor-sepolia-indexer.realms.world/graphql NEXT_PUBLIC_TOKENS_GQL_URL=https://testnet.realms.world/api/graphql NEXT_PUBLIC_ETH_ADDRESS=0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 -NEXT_PUBLIC_GAME_ADDRESS=0x02b66531874c952844913b8cbc573878c794112b546cbf39409013e33d4777fe +NEXT_PUBLIC_GAME_ADDRESS=0x027069eaf29f2db58ff8321b58f162b9e8365304688fd96b01f1a0dd17d07fd3 NEXT_PUBLIC_OLD_GAME_ADDRESS=0x0 NEXT_PUBLIC_LORDS_ADDRESS=0x019c92fa87f4d5e3be25c3dd6a284f30282a07e87cd782f5fd387b82c8142017 NEXT_PUBLIC_BEASTS_ADDRESS=0x020c7c02c973ffa3a48fb78e9472b679c72c11b59512f524154ade0a39f54136 diff --git a/ui/package.json b/ui/package.json index c7ba1d0fc..09eaf2c30 100644 --- a/ui/package.json +++ b/ui/package.json @@ -18,6 +18,7 @@ "@types/node": "18.15.11", "@types/react": "18.0.31", "@types/react-dom": "18.0.11", + "@vercel/analytics": "^1.2.2", "autoprefixer": "^10.4.14", "class-variance-authority": "^0.4.0", "clsx": "^1.2.1", diff --git a/ui/src/app/components/start/Spawn.tsx b/ui/src/app/components/start/Spawn.tsx index 1e29102d8..446097c75 100644 --- a/ui/src/app/components/start/Spawn.tsx +++ b/ui/src/app/components/start/Spawn.tsx @@ -112,9 +112,11 @@ export const Spawn = ({ } }; - const onMainnet = process.env.NEXT_PUBLIC_NETWORK === "mainnet"; + const onMainnet = + process.env.NEXT_PUBLIC_NETWORK === "mainnet" || + process.env.NEXT_PUBLIC_NETWORK === "sepolia"; - const waitEstimate = 12 * averageBlockTime; // add one for closer estimate + const waitEstimate = 2 * averageBlockTime; const { data: blockData } = useBlock({ refetchInterval: false, @@ -130,6 +132,8 @@ export const Spawn = ({ setFetchedAverageBlockTime(true); }; + console.log(averageBlockTime); + useEffect(() => { if (onMainnet && !fetchedAverageBlockTime && currentBlockNumber > 0) { fetchData(); diff --git a/ui/src/app/containers/BeastScreen.tsx b/ui/src/app/containers/BeastScreen.tsx index 7912210ff..f1810e33c 100644 --- a/ui/src/app/containers/BeastScreen.tsx +++ b/ui/src/app/containers/BeastScreen.tsx @@ -52,7 +52,9 @@ export default function BeastScreen({ (state) => state.data.battlesByBeastQuery?.battles || [] ); - const mainnetBotProtection = process.env.NEXT_PUBLIC_NETWORK === "mainnet"; + const mainnetBotProtection = + process.env.NEXT_PUBLIC_NETWORK === "mainnet" || + process.env.NEXT_PUBLIC_NETWORK === "sepolia"; const { data: blockData } = useBlock({ refetchInterval: @@ -96,7 +98,12 @@ export default function BeastScreen({ label: "TILL DEATH", action: async () => { resetNotification(); - await attack(true, beastData); + if (adventurer?.level === 1) { + const entropyBlockData = await getBlock(adventurer?.startBlock! + 1); + await attack(true, beastData, entropyBlockData?.block_hash ?? 0); + } else { + await attack(true, beastData); + } }, disabled: adventurer?.beastHealth == undefined || @@ -184,7 +191,7 @@ export default function BeastScreen({ const currentBlockNumber = (blockData as Block)?.block_number ?? 0; const revealBlockReached = - currentBlockNumber >= (adventurer?.revealBlock ?? 0); + currentBlockNumber >= (adventurer?.revealBlock! + 1 ?? 0); useEffect(() => { if (revealBlockReached) { @@ -197,6 +204,8 @@ export default function BeastScreen({ return ; } + console.log(revealBlockReached, mainnetBotProtection, averageBlockTime); + return (
{!revealBlockReached && mainnetBotProtection && ( @@ -267,7 +276,7 @@ export default function BeastScreen({
Reveal:
- {adventurer?.revealBlock} + {adventurer?.revealBlock! + 1}
diff --git a/ui/src/app/containers/InterludeScreen.tsx b/ui/src/app/containers/InterludeScreen.tsx index 7e562e797..7eb82321b 100644 --- a/ui/src/app/containers/InterludeScreen.tsx +++ b/ui/src/app/containers/InterludeScreen.tsx @@ -26,6 +26,7 @@ export default function InterludeScreen({ const nextEntropyTime = adventurerCreatedTime + secondsUntilNextEntropy * 1000; setNextEntropyTime(nextEntropyTime); + console.log(secondsUntilNextEntropy, averageBlockTime, "hello"); }; const onMainnet = process.env.NEXT_PUBLIC_NETWORK === "mainnet"; @@ -34,6 +35,13 @@ export default function InterludeScreen({ getNextEntropyTime(); }, []); + console.log( + countDownExpired, + nextEntropyTime, + new Date().getTime(), + new Date(adventurer?.createdTime!).getTime() + ); + return ( <> {!countDownExpired && ( diff --git a/ui/src/app/layout.tsx b/ui/src/app/layout.tsx index ad4d4ddf8..46db87434 100644 --- a/ui/src/app/layout.tsx +++ b/ui/src/app/layout.tsx @@ -2,6 +2,7 @@ import { ApolloProvider } from "@apollo/client"; import { gameClient, goldenTokenClient } from "@/app/lib/clients"; +import { Analytics } from "@vercel/analytics/react"; import "@/app/globals.css"; export default function RootLayout({ @@ -23,6 +24,7 @@ export default function RootLayout({ {children} + ); diff --git a/ui/src/app/lib/utils/syscalls.ts b/ui/src/app/lib/utils/syscalls.ts index 997b68a4f..599ab3fb3 100644 --- a/ui/src/app/lib/utils/syscalls.ts +++ b/ui/src/app/lib/utils/syscalls.ts @@ -710,7 +710,10 @@ export function syscalls({ const setBlockHashTx: Call = { contractAddress: gameContract?.address ?? "", entrypoint: "set_starting_entropy", - calldata: [adventurer?.id?.toString() ?? "", blockHash!], + calldata: [ + adventurer?.id?.toString() ?? "", + BigInt(blockHash! ?? 0).toString(), + ], }; const attackTx: Call = { contractAddress: gameContract?.address ?? "", @@ -718,7 +721,9 @@ export function syscalls({ calldata: [adventurer?.id?.toString() ?? "", tillDeath ? "1" : "0"], }; const attackCalls = - process.env.NEXT_PUBLIC_NETWORK === "mainnet" + (process.env.NEXT_PUBLIC_NETWORK === "mainnet" || + process.env.NEXT_PUBLIC_NETWORK === "sepolia") && + blockHash ? [setBlockHashTx, attackTx] : [attackTx]; addToCalls(attackTx); @@ -734,6 +739,7 @@ export function syscalls({ showTopUpDialog, setTopUpAccount ); + // } setTxHash(tx?.transaction_hash); addTransaction({ hash: tx?.transaction_hash, diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx index fd39254cf..09ea59c32 100644 --- a/ui/src/app/page.tsx +++ b/ui/src/app/page.tsx @@ -541,7 +541,10 @@ function Home({ updateConnectors }: HomeProps) {
- {introComplete ? ( +
+ Loot Survivor is being reborn. More death coming soon. +
+ {/* {introComplete ? ( <> {screen === "onboarding" ? ( @@ -688,7 +691,7 @@ function Home({ updateConnectors }: HomeProps) { ) : ( - )} + )} */}
); } diff --git a/ui/tsconfig.json b/ui/tsconfig.json index 33d3e8978..e66498f0f 100644 --- a/ui/tsconfig.json +++ b/ui/tsconfig.json @@ -17,7 +17,7 @@ "moduleResolution": "Node", "resolveJsonModule": true, "isolatedModules": true, - "noUnusedLocals": true, + // "noUnusedLocals": true, // "noUnusedParameters": true, "noEmit": true, "jsx": "preserve", diff --git a/ui/yarn.lock b/ui/yarn.lock index 48837367c..87b2ad0e0 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1886,6 +1886,13 @@ "@typescript-eslint/types" "5.59.2" eslint-visitor-keys "^3.3.0" +"@vercel/analytics@^1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-1.2.2.tgz#715d8f203a170c06ba36b363e03b048c03060d5d" + integrity sha512-X0rctVWkQV1e5Y300ehVNqpOfSOufo7ieA5PIdna8yX/U7Vjz0GFsGf4qvAhxV02uQ2CVt7GYcrFfddXXK2Y4A== + dependencies: + server-only "^0.0.1" + "@walletconnect/core@2.12.2": version "2.12.2" resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.12.2.tgz#12bd568b90daed876e58ebcc098c12843a3321e6" @@ -5125,6 +5132,11 @@ semver@^7.3.7: dependencies: lru-cache "^6.0.0" +server-only@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/server-only/-/server-only-0.0.1.tgz#0f366bb6afb618c37c9255a314535dc412cd1c9e" + integrity sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA== + set-cookie-parser@^2.4.8: version "2.6.0" resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz#131921e50f62ff1a66a461d7d62d7b21d5d15a51"