From 51baf04b5b770fbac20c897458aae56f6ea030ce Mon Sep 17 00:00:00 2001 From: aymericdelab Date: Fri, 13 Dec 2024 18:44:22 +0100 Subject: [PATCH 01/13] [controller] add erc20 resources to controller Fixes #2468 --- .../local/resource_addresses.json | 33 +++++++++++++++++++ .../mainnet/resource_addresses.json | 32 ++++++++++++++++++ .../sepolia/resource_addresses.json | 33 +++++++++++++++++++ .../src/hooks/context/starknet-provider.tsx | 15 ++++++--- client/src/ui/utils/utils.tsx | 24 ++++++++++++++ .../providers/starknet-provider.tsx | 10 +++++- landing/src/components/ui/utils/utils.ts | 6 +++- 7 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 client/public/resource_addresses/local/resource_addresses.json create mode 100644 client/public/resource_addresses/mainnet/resource_addresses.json create mode 100644 client/public/resource_addresses/sepolia/resource_addresses.json diff --git a/client/public/resource_addresses/local/resource_addresses.json b/client/public/resource_addresses/local/resource_addresses.json new file mode 100644 index 000000000..6ab080f43 --- /dev/null +++ b/client/public/resource_addresses/local/resource_addresses.json @@ -0,0 +1,33 @@ +{ + "STONE": [1, "0x10b3d48c8f0cb6a3d009d3548ab3db455d7fa86407c8869c8525d7f977cfedd"], + "COAL": [2, "0x5dfd0869838aa5a19c54a28717322df1c29c8e0d41a5c6ef126c003f9c29c5d"], + "WOOD": [3, "0x76b8390d8ba5d26423ea5af6ad31b62639ca4a5238e74db1e41dc67b8f57bcd"], + "COPPER": [4, "0x11f4b77a1e0aa2642730a38b4cea40ad4bea984379234bdb60cc41d9ebcd17f"], + "IRONWOOD": [5, "0x453e4a8802c423877beaa3f1ca0fcc3fcfcb543ff92e8b1355381bda4775d48"], + "OBSIDIAN": [6, "0x2c155f2164b68657d0ea8206fcb8c852e91dd5168126437708138d679e31877"], + "GOLD": [7, "0x54a6240d12444353c78a7f64d91e4f8eabc947b760b9369a05b3b154b68b503"], + "SILVER": [8, "0x35e191ed0abcf8270e1b4ae5c7121669ebdc675424dc669f74f8f32a62a61b1"], + "MITHRAL": [9, "0x2925a949eee52af5820a6ba2bdd9aae082ef46082f9a4e1edeb376ce61278a8"], + "ALCHEMICALSILVER": [10, "0x22ae713a2c06f3687f8a50823a16a8e86f49ed1505c43902849fd251e0f5adf"], + "COLDIRON": [11, "0x14e6946dbe9b530bd04d1c347ed695e6f49a163985d8a3410a8a1e1628178a4"], + "DEEPCRYSTAL": [12, "0x30617a0b90f2b04fb1c3e4d5f9e8baca60bde357cdceaa1ea136b1ee7312807"], + "RUBY": [13, "0x47286cdb7554cef18df9eba041164b450fbd1b860825cfa3db2621e4dc7d303"], + "DIAMONDS": [14, "0x18159aba74ae56043f653e5971be4339b0ddc1acdded44d4d1d5373cf7f5534"], + "HARTWOOD": [15, "0x4c7d2035de503300081c41c10dbec1cb2059e6291c7c9fda86610b4b8ecd579"], + "IGNIUM": [16, "0x62d79c2f5f0a7e1485f1948145197dee7f1e35443999daf55016ae39cad7810"], + "TWILIGHTQUARTZ": [17, "0x6cb29e0530292656a0e8ecf73fc04e00c8b68c58ff44a69cca2919cd804c528"], + "TRUEICE": [18, "0x10bc643e2a16bc214c6d3e27972263828e8a137fc634099255b7302eaf38a23"], + "ADAMANTINE": [19, "0x6c4c97ecee863c57c978952ca271065704c3b5ac7010962bdc9c97944c0bd37"], + "SAPPHIRE": [20, "0x70b0dbcbfafd50a1bd7602fd02fc6fcdfc48ece068603a016ffdafb968e2587"], + "ETHEREALSILICA": [21, "0x72fb88593bd78eb19f1514f6a2537b943d23db15ad067e85678f6e9a52345c5"], + "DRAGONHIDE": [22, "0xbeaedcc84e52b9f6197ad5cb5b441fac304afdd036438c208ae3928dd30de0"], + "DEMONHIDE": [28, "0x3f7d97969da364fd2ac0da5b6a877e6c4d4bfade4b3db50561abe02aac3ea48"], + "ANCIENTFRAGMENT": [29, "0x10cb48622578710d600c1d8bf4942035f573d8f1ee95c8a4d3d242139441dbe"], + "DONKEY": [249, "0x1d1542407040c2dce32b3ea35b06c627d4c7c0c6b133972fb903a71fc96156d"], + "KNIGHT": [250, "0x25cebc9ae778dc52ba67b722406586cbabcfd752dda5c3aa541313189617806"], + "CROSSBOWMAN": [251, "0x32ffb922c07155cad08b60a98ce2f660d25b818945d111dc184c7da31cd118f"], + "PALADIN": [252, "0x6910caf9920622e1e0c1ae7b210204268b48146a717e83353a1cf307e42c635"], + "WHEAT": [254, "0x360a3d398a2164b8404a69b2c6f0527c3d6cef480d776b0cf38bb6f531473ab"], + "FISH": [255, "0x613688e2001af02f4181d76587f3e8bb90b516985087b64ec0eaa866ec3ae29"], + "LORDS": [253, "0x4b2162f4b591fbf2052f0600652655675471a850656468dc3ddf57ad4fdbf56"] +} diff --git a/client/public/resource_addresses/mainnet/resource_addresses.json b/client/public/resource_addresses/mainnet/resource_addresses.json new file mode 100644 index 000000000..0ffbd2453 --- /dev/null +++ b/client/public/resource_addresses/mainnet/resource_addresses.json @@ -0,0 +1,32 @@ +{ + "STONE": [1, "0x439a1c010e3e1bb2d43d43411000893c0042bd88f6c701611a0ea914d426da4"], + "COAL": [2, "0xce635e3f241b0ae78c46a929d84a9101910188f9c4024eaa7559556503c31a"], + "WOOD": [3, "0x40d8907cec0f7ae9c364dfb12485a1314d84c129bf1898d2f3d4b7fcc7d44f4"], + "COPPER": [4, "0x66ed5c928ee027a9419ace1cbea8389885161db5572a7c5c4fef2310e9bf494"], + "IRONWOOD": [5, "0x1720cf6318bff45e62acc588680ae3cd4d5f8465b1d52cb710533c9299b031a"], + "OBSIDIAN": [6, "0x3b6448d09dcd023507376402686261f5d6739455fa02f804907b066e488da66"], + "GOLD": [7, "0xdff9dca192609c4e86ab3be22c7ec1e968876c992d21986f3c542be97fa2f"], + "SILVER": [8, "0x6fe21d2d4a8a05bdb70f09c9250af9870020d5dcc35f410b4a39d6605c3e353"], + "MITHRAL": [9, "0x67ba235c569c23877064b2ac6ebd4d79f32d3c00f5fab8e28a3b5700b957f6"], + "ALCHEMICALSILVER": [10, "0x3956a5301e99522038a2e7dcb9c2a89bf087ffa79310ee0a508b5538efd8ddd"], + "COLDIRON": [11, "0x555d713e59d4ff96b7960447e9bc9e79bfdeab5b0eea74e3df81bce61cfbc77"], + "DEEPCRYSTAL": [12, "0x1d655ac834d38df7921074fc1588411e202b1af83307cbd996983aff52db3a8"], + "RUBY": [13, "0x3d9b66720959d0e7687b898292c10e62e78626f2dba5e1909961a2ce3f86612"], + "DIAMONDS": [14, "0xe03ea8ae385f64754820af5c01c36abf1b8130dd6797d3fd9d430e4114e876"], + "HARTWOOD": [15, "0x5620aa7170cd66dbcbc37d03087bfe4633ffef91d3e4d97b501de906004f79b"], + "IGNIUM": [16, "0x625c1f789b03ebebc7a9322366f38ebad1f693b84b2abd8cb8f5b2748b0cdd5"], + "TWILIGHTQUARTZ": [17, "0x35e24c02409c3cfe8d5646399a62c4d102bb782938d5f5180e92c9c62d3faf7"], + "TRUEICE": [18, "0x4485f5a6e16562e1c761cd348e63256d00389e3ddf4f5d98afe7ab44c57c481"], + "ADAMANTINE": [19, "0x367f838f85a2f5e1580d6f011e4476f581083314cff8721ba3dda9706076eed"], + "SAPPHIRE": [20, "0x2f8dd022568af8f9f718aa37707a9b858529db56910633a160456838b6cbcbc"], + "ETHEREALSILICA": [21, "0x68b6e23cbbd58a644700f55e96c83580921e9f521b6e5175396b53ba7910e7d"], + "DRAGONHIDE": [22, "0x3bf856515bece3c93f5061b7941b8645f817a0acab93c758b8c7b4bc0afa3c6"], + "ANCIENTFRAGMENT": [29, "0x0695b08ecdfdd828c2e6267da62f59e6d7543e690ef56a484df25c8566b332a5"], + "DONKEY": [249, "0x264be95a4a2ace20add68cb321acdccd2f9f8440ee1c7abd85da44ddab01085"], + "KNIGHT": [250, "0xac965f9e67164723c16735a9da8dbc9eb8e43b1bd0323591e87c056badf606"], + "CROSSBOWMAN": [251, "0x67e4ac00a241be06ba6afc11fa2715ec7da0c42c05a67ef6ecfcfeda725aaa8"], + "PALADIN": [252, "0x3bc86299bee061c7c8d7546ccb62b9daf9bffc653b1508facb722c6593874bc"], + "WHEAT": [254, "0x57a3f1ee475e072ce3be41785c0e889b7295d7a0dcc22b992c5b9408dbeb280"], + "FISH": [255, "0x27719173cfe10f1aa38d2aaed0a075b6077290f1e817aa3485d2b828394f4d9"], + "LORDS": [253, "0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"] +} diff --git a/client/public/resource_addresses/sepolia/resource_addresses.json b/client/public/resource_addresses/sepolia/resource_addresses.json new file mode 100644 index 000000000..141db8956 --- /dev/null +++ b/client/public/resource_addresses/sepolia/resource_addresses.json @@ -0,0 +1,33 @@ +{ + "STONE": [1, "0x6158648e6c53488e316a9f681623b9e0359240329a00e5d5f5e82da21453b4c"], + "COAL": [2, "0xeff1980a4f28877118e06aff65d8c972ccc69c7d699975194ae8e83978b116"], + "WOOD": [3, "0x1605f515516e0ea60df3ae92a8204037866c3b27199865133f9f9f35208d298"], + "COPPER": [4, "0x76c0ee15cd5e588f0fa6ffb7c9ce301f96d33cd9f6bf0760ed2e55407130e4"], + "IRONWOOD": [5, "0x9f9cb4a6cb392f2c8526ae6c1f48ddb1eb67598030afdcabe06a48c752b3c6"], + "OBSIDIAN": [6, "0x53d73cddd205f590bf93290fcce62cb1079bd440e7253bef50ce2d890583c09"], + "GOLD": [7, "0x45ee17873d009cb7f8ad88bdd01218b07ceb055a8b22d6a0795028b2aafd8d8"], + "SILVER": [8, "0x56defcf99c674db261f508b584537c760b9001df9a8cb13275afa564f600dbe"], + "MITHRAL": [9, "0x7613ec3c16e4cefc9c33bea2b7e16614a0c4b5237e26cf75f335e0f028da988"], + "ALCHEMICALSILVER": [10, "0x705f42f2a89bf32c504c19c618ca6738747871016bba0b3fc32f3cd73782160"], + "COLDIRON": [11, "0x22bc712f59ceefc7c7521c607eb5f48759ffd906ee6342ee80dad2973f58d8"], + "DEEPCRYSTAL": [12, "0x242f3bcca7f72b5ca034dfe9903bb73024353cec795dca1fd8e2f500d17a733"], + "RUBY": [13, "0x9c473b26f7df7897b517f3c9e1ce8f1f7236b67666983f5ddaf039ca4c46a9"], + "DIAMONDS": [14, "0x78d34a4af3742f6f3377e97dd69f95680bb0f08521ad935428e3b2c3c5ed01e"], + "HARTWOOD": [15, "0x3d3f23f4829b8fe343b00c44c63828f5a81e468fb30eb9504c7c44455cead7b"], + "IGNIUM": [16, "0x204f9596fa6f05c2de88f3a7fe42c0d11fb04cc96128f18fbe112e44f360696"], + "TWILIGHTQUARTZ": [17, "0x1a0f1b62ef495956532db0306d13c92c02604995178d3fc98b84c8b8fb8a18e"], + "TRUEICE": [18, "0x3e089cd9be6c251dae20c64649a770507750f4b4c9e65ebf30bdb63b541605d"], + "ADAMANTINE": [19, "0x55399ca187391f4cc03abb00a04e3b6974bc0d7757ad959ac2804e6c1c468d5"], + "SAPPHIRE": [20, "0x62feb496f301b27bbda2389463d1ca06ef9f22d4208aecef2e85da1e4c90c4f"], + "ETHEREALSILICA": [21, "0x25eb12bb5298a2b14ceb9109086d330810d55c5e9a8c17e60fc956453b30d14"], + "DRAGONHIDE": [22, "0x463ebcc1b9ac911930a471fb9b608e9e7ca07ed81aab66f8889dd45b41c28b2"], + "DEMONHIDE": [28, "0x9613c7e4c04929c616a81f150006bc1a96bb77426851d300ef3dfaf2d0c318"], + "ANCIENTFRAGMENT": [29, "0x403c764fd76f926eec43218f46f79cfb5fe86dfeb1ae76010027697f65733f1"], + "DONKEY": [249, "0x6b6c4437543e46a8a80835fa50643fbd32275d3836396d8cd9c1d7c987f4ea9"], + "KNIGHT": [250, "0x298cba6b152d04fd54195dbae0e74512ff740d14946d2d65f26d0c039feffe2"], + "CROSSBOWMAN": [251, "0x116ce3b8c4a70f61e0131cc8681bc50a5eb35276e7985c07e3a508c2eb25f8f"], + "PALADIN": [252, "0x63f2da6f023bb0f281daa4011beb62ef501207569654e01d9315673471b8839"], + "WHEAT": [254, "0x2cbcad77a7b2bdf87c128f035beef05e3a007c15b2e332b1f1fb04d19ffd1b4"], + "FISH": [255, "0x3da1d29652bf12f64366ca4e9b36ec046cc92f6dc3b4675d956db1c3d742f0f"], + "LORDS": [253, "0x342ad5cc14002c005a5cedcfce2bd3af98d5e7fb79e9bf949b3a91cf145d72e"] +} diff --git a/client/src/hooks/context/starknet-provider.tsx b/client/src/hooks/context/starknet-provider.tsx index 7bcb01a0d..19a1a0717 100644 --- a/client/src/hooks/context/starknet-provider.tsx +++ b/client/src/hooks/context/starknet-provider.tsx @@ -1,13 +1,20 @@ -import React, { useCallback } from "react"; - +import { getSeasonAddresses } from "@/ui/utils/utils"; import ControllerConnector from "@cartridge/connector/controller"; import { ColorMode } from "@cartridge/controller"; import { mainnet, sepolia } from "@starknet-react/chains"; import { Connector, StarknetConfig, jsonRpcProvider, voyager } from "@starknet-react/core"; +import React, { useCallback } from "react"; import { env } from "../../../env"; import { policies } from "./policies"; import { signingPolicy } from "./signing-policy"; +const resourceAddresses = await getSeasonAddresses(); + +const LORDS = resourceAddresses["LORDS"][1]; +const otherResources = Object.entries(resourceAddresses) + .filter(([key]) => key !== "LORDS") + .map(([_, [__, address]]) => address); + const preset: string = "eternum"; const theme: string = "eternum"; const slot: string = env.VITE_PUBLIC_SLOT; @@ -28,7 +35,7 @@ const controller = slot, preset, tokens: { - erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"], + erc20: [LORDS, ...otherResources], }, colorMode, }) @@ -40,7 +47,7 @@ const controller = policies: [...signingPolicy, ...policies, vrfPolicy], theme, tokens: { - erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"], + erc20: [LORDS, ...otherResources], }, colorMode, }); diff --git a/client/src/ui/utils/utils.tsx b/client/src/ui/utils/utils.tsx index 648e27e38..40b501334 100644 --- a/client/src/ui/utils/utils.tsx +++ b/client/src/ui/utils/utils.tsx @@ -16,6 +16,7 @@ import { import { type ComponentValue } from "@dojoengine/recs"; import { getEntityIdFromKeys } from "@dojoengine/utils"; import * as THREE from "three"; +import { env } from "../../../env"; import { SortInterface } from "../elements/SortButton"; export { getEntityIdFromKeys }; @@ -499,3 +500,26 @@ export const getRandomBackgroundImage = () => { export const adjustWonderLordsCost = (cost: ResourceCost[]): ResourceCost[] => { return cost.map((item) => (item.resource === ResourcesIds.Lords ? { ...item, amount: item.amount * 0.1 } : item)); }; + +export const getSeasonAddressesPath = () => { + return `/resource_addresses/${env.VITE_PUBLIC_CHAIN}/resource_addresses.json`; +}; +export const getJSONFile = async (filePath: string) => { + const response = await fetch(filePath); + const data = await response.json(); + return data; +}; +interface ResourceAddresses { + [key: string]: [number, string]; +} + +export const getSeasonAddresses = async (): Promise => { + try { + const path = getSeasonAddressesPath(); + const data = await getJSONFile(path); + return data; + } catch (error) { + console.error("Error loading season addresses:", error); + return {}; + } +}; diff --git a/landing/src/components/providers/starknet-provider.tsx b/landing/src/components/providers/starknet-provider.tsx index 970095d81..d37158447 100644 --- a/landing/src/components/providers/starknet-provider.tsx +++ b/landing/src/components/providers/starknet-provider.tsx @@ -4,8 +4,16 @@ import { mainnet, sepolia } from "@starknet-react/chains"; import { StarknetConfig, argent, braavos, jsonRpcProvider, useInjectedConnectors, voyager } from "@starknet-react/core"; import React, { useCallback } from "react"; import { env } from "../../../env"; +import { getSeasonAddresses } from "../ui/utils/utils"; //import { cartridgeController } from "./cartridge-controller"; +const resourceAddresses = await getSeasonAddresses(); + +const LORDS = resourceAddresses["LORDS"][1]; +const otherResources = Object.entries(resourceAddresses) + .filter(([key]) => key !== "LORDS") + .map(([_, [__, address]]) => address); + const theme: string = "eternum"; const slot: string = "realms-world-04"; const namespace: string = "eternum"; @@ -17,7 +25,7 @@ const cartridgeController = new ControllerConnector({ theme, colorMode, tokens: { - erc20: ["0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49"], + erc20: [LORDS, ...otherResources], }, // namespace, slot, diff --git a/landing/src/components/ui/utils/utils.ts b/landing/src/components/ui/utils/utils.ts index 99d7d330b..431f0836c 100644 --- a/landing/src/components/ui/utils/utils.ts +++ b/landing/src/components/ui/utils/utils.ts @@ -438,7 +438,11 @@ export const getJSONFile = async (filePath: string) => { return data; }; -export const getSeasonAddresses = async () => { +interface ResourceAddresses { + [key: string]: [number, string]; +} + +export const getSeasonAddresses = async (): Promise => { try { const path = getSeasonAddressesPath(); const data = await getJSONFile(path); From 06b41313d6bec063e40f5e900ad630ce3cbe87ef Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 14:52:37 +0100 Subject: [PATCH 02/13] Fix division by 0 in AMM --- client/src/dojo/modelManager/MarketManager.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/dojo/modelManager/MarketManager.ts b/client/src/dojo/modelManager/MarketManager.ts index a0ea53826..fc4ce199c 100644 --- a/client/src/dojo/modelManager/MarketManager.ts +++ b/client/src/dojo/modelManager/MarketManager.ts @@ -87,7 +87,7 @@ export class MarketManager { public getOutputAmount(inputAmount: number, inputReserve: bigint, outputReserve: bigint, feeRateNum: number) { // Ensure reserves are not zero and input amount is valid - if (inputReserve < 0n || outputReserve < 0n) { + if (inputReserve <= 0n || outputReserve < 0n) { throw new Error("Reserves must be >= zero"); } if (inputAmount < 0) { @@ -137,7 +137,12 @@ export class MarketManager { const market = this.getMarket(); if (!market) return 0; - let outputAmount = this.getOutputAmount(lordsAmount, market.lords_amount, market.resource_amount, feeRateNum); + let outputAmount = 0n; + try { + outputAmount = this.getOutputAmount(lordsAmount, market.lords_amount, market.resource_amount, feeRateNum); + } catch (e) { + console.log(e); + } return Number(outputAmount); }; @@ -157,6 +162,8 @@ export class MarketManager { const numerator = BigInt(inputReserve) * BigInt(outputReserve); const denominator = BigInt(outputReserve) - BigInt(resourceAmount); + if (denominator <= 0n) return 0; + const inputAmount = numerator / denominator - BigInt(inputReserve); // Adjust for fees From fdeec05e743c0c6ca35a7d8a1f433332d0befaf4 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 14:58:07 +0100 Subject: [PATCH 03/13] Make resources ordering the same everywhere + resource selection cleanup --- .../src/ui/components/bank/LiquidityTable.tsx | 4 ++-- client/src/ui/components/bank/ResourceBar.tsx | 18 +++++++++-------- client/src/ui/components/bank/Swap.tsx | 20 +++++++++++++++++-- .../construction/SelectPreviewBuilding.tsx | 8 ++------ .../ui/components/trading/RealmProduction.tsx | 12 +++++++++-- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/client/src/ui/components/bank/LiquidityTable.tsx b/client/src/ui/components/bank/LiquidityTable.tsx index 16d1294d4..31328bcce 100644 --- a/client/src/ui/components/bank/LiquidityTable.tsx +++ b/client/src/ui/components/bank/LiquidityTable.tsx @@ -1,5 +1,5 @@ import { useEntities } from "@/hooks/helpers/useEntities"; -import { ID, RESOURCE_TIERS, resources } from "@bibliothecadao/eternum"; +import { ID, RESOURCE_TIERS, ResourcesIds, resources } from "@bibliothecadao/eternum"; import { useState } from "react"; import { LiquidityResourceRow } from "./LiquidityResourceRow"; @@ -27,9 +27,9 @@ export const LiquidityTable = ({ bankEntityId, entity_id }: LiquidityTableProps) } const filteredResources = Object.entries(RESOURCE_TIERS).flatMap(([tier, resourceIds]) => { - if (tier === "lords") return []; return resourceIds.filter( (resourceId) => + resourceId !== ResourcesIds.Lords && resources .find((r) => r.id === resourceId) ?.trait.toLowerCase() diff --git a/client/src/ui/components/bank/ResourceBar.tsx b/client/src/ui/components/bank/ResourceBar.tsx index 09d3e323a..769380e2e 100644 --- a/client/src/ui/components/bank/ResourceBar.tsx +++ b/client/src/ui/components/bank/ResourceBar.tsx @@ -129,21 +129,23 @@ export const ResourceBar = ({ - + {resources.length > 1 && ( - +
+ +
)} {filteredResources.map((resource) => ( ))} diff --git a/client/src/ui/components/bank/Swap.tsx b/client/src/ui/components/bank/Swap.tsx index 6d5a3d2d4..52668b282 100644 --- a/client/src/ui/components/bank/Swap.tsx +++ b/client/src/ui/components/bank/Swap.tsx @@ -10,7 +10,15 @@ import { ResourceBar } from "@/ui/components/bank/ResourceBar"; import Button from "@/ui/elements/Button"; import { ResourceIcon } from "@/ui/elements/ResourceIcon"; import { divideByPrecision, formatNumber, multiplyByPrecision } from "@/ui/utils/utils"; -import { ContractAddress, DONKEY_ENTITY_TYPE, ID, ResourcesIds, resources } from "@bibliothecadao/eternum"; +import { + ContractAddress, + DONKEY_ENTITY_TYPE, + ID, + RESOURCE_TIERS, + Resources, + ResourcesIds, + resources, +} from "@bibliothecadao/eternum"; import { useCallback, useEffect, useMemo, useState } from "react"; import { TravelInfo } from "../resources/TravelInfo"; import { ConfirmationPopup } from "./ConfirmationPopup"; @@ -173,10 +181,18 @@ export const ResourceSwap = ({ } }; + const orderedResources = useMemo(() => { + return Object.values(RESOURCE_TIERS) + .flat() + .map((id) => resources.find((r) => r.id === id)) + .filter((r): r is Resources => !!r) + .filter((r) => !Number.isNaN(r.id)); + }, []); + const renderResourceBar = useCallback( (disableInput: boolean, isLords: boolean) => { const amount = isLords ? lordsAmount : resourceAmount; - const selectableResources = resources.filter((r) => + const selectableResources = orderedResources.filter((r) => isLords ? r.id === ResourcesIds.Lords : r.id !== ResourcesIds.Lords, ); diff --git a/client/src/ui/components/construction/SelectPreviewBuilding.tsx b/client/src/ui/components/construction/SelectPreviewBuilding.tsx index 5b8890758..4ae6c1296 100644 --- a/client/src/ui/components/construction/SelectPreviewBuilding.tsx +++ b/client/src/ui/components/construction/SelectPreviewBuilding.tsx @@ -2,10 +2,8 @@ import { ReactComponent as InfoIcon } from "@/assets/icons/common/info.svg"; import { ClientComponents } from "@/dojo/createClientComponents"; import { configManager } from "@/dojo/setup"; import { DojoResult, useDojo } from "@/hooks/context/DojoContext"; -import { useQuestClaimStatus } from "@/hooks/helpers/useQuests"; import { useGetRealm } from "@/hooks/helpers/useRealm"; import { useResourceBalance } from "@/hooks/helpers/useResources"; -import { useQuestStore } from "@/hooks/store/useQuestStore"; import useUIStore from "@/hooks/store/useUIStore"; import { usePlayResourceSound } from "@/hooks/useUISound"; import { ResourceMiningTypes } from "@/types"; @@ -18,22 +16,22 @@ import { Tabs } from "@/ui/elements/tab"; import { unpackResources } from "@/ui/utils/packedData"; import { hasEnoughPopulationForBuilding } from "@/ui/utils/realms"; import { + ResourceIdToMiningType, adjustWonderLordsCost, divideByPrecision, getEntityIdFromKeys, gramToKg, isResourceProductionBuilding, - ResourceIdToMiningType, } from "@/ui/utils/utils"; import { BuildingEnumToString, BuildingType, CapacityConfigCategory, - findResourceById, ID, ResourceCost as ResourceCostType, ResourcesIds, WORLD_CONFIG_ID, + findResourceById, } from "@bibliothecadao/eternum"; import { Component, getComponentValue } from "@dojoengine/recs"; import clsx from "clsx"; @@ -45,13 +43,11 @@ export const SelectPreviewBuildingMenu = ({ className, entityId }: { className?: const setPreviewBuilding = useUIStore((state) => state.setPreviewBuilding); const previewBuilding = useUIStore((state) => state.previewBuilding); - const selectedQuest = useQuestStore((state) => state.selectedQuest); const { realm } = useGetRealm(entityId); const { getBalance } = useResourceBalance(); const { playResourceSound } = usePlayResourceSound(); - const { questClaimStatus } = useQuestClaimStatus(); const buildingTypes = Object.keys(BuildingType).filter( (key) => diff --git a/client/src/ui/components/trading/RealmProduction.tsx b/client/src/ui/components/trading/RealmProduction.tsx index b14cc11fd..8ac624917 100644 --- a/client/src/ui/components/trading/RealmProduction.tsx +++ b/client/src/ui/components/trading/RealmProduction.tsx @@ -20,11 +20,19 @@ export const RealmProduction = () => {

Search produced resource

- setFilterProduced(resourceId)} className="w-full" /> + setFilterProduced(resourceId)} + className="w-full" + realmProduction={true} + />

Search consumed resource

- setFilterConsumed(resourceId)} className="w-full" /> + setFilterConsumed(resourceId)} + className="w-full" + realmProduction={true} + />
From 8c1e0ded026d68f1c53610868433c464a0e75881 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 15:00:07 +0100 Subject: [PATCH 04/13] Fix donkeys burned for sell order creation --- client/src/ui/components/trading/MarketOrderPanel.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/ui/components/trading/MarketOrderPanel.tsx b/client/src/ui/components/trading/MarketOrderPanel.tsx index 7120b3fbe..9539027ba 100644 --- a/client/src/ui/components/trading/MarketOrderPanel.tsx +++ b/client/src/ui/components/trading/MarketOrderPanel.tsx @@ -19,7 +19,6 @@ import { multiplyByPrecision, } from "@/ui/utils/utils"; import { - CapacityConfigCategory, DONKEY_ENTITY_TYPE, ONE_MONTH, ResourcesIds, @@ -557,7 +556,7 @@ const OrderCreation = ({ }, [resource, lords]); const donkeysNeeded = useMemo(() => { - return calculateDonkeysNeeded(orderWeight); + return calculateDonkeysNeeded(multiplyByPrecision(orderWeight)); }, [orderWeight]); const { currentDefaultTick } = useNextBlockTimestamp(); From ec808580da11bb25b6aec361017a69d31fa3a896 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 15:00:55 +0100 Subject: [PATCH 05/13] filter resources from realm production --- client/src/ui/elements/SelectResource.tsx | 46 ++++++++++++++++------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/client/src/ui/elements/SelectResource.tsx b/client/src/ui/elements/SelectResource.tsx index d2a8c7f0f..e551bf468 100644 --- a/client/src/ui/elements/SelectResource.tsx +++ b/client/src/ui/elements/SelectResource.tsx @@ -1,7 +1,7 @@ import { ReactComponent as Cross } from "@/assets/icons/common/cross.svg"; -import { ResourcesIds } from "@bibliothecadao/eternum"; +import { RESOURCE_TIERS, ResourcesIds } from "@bibliothecadao/eternum"; import clsx from "clsx"; -import React, { useRef, useState } from "react"; +import React, { useMemo, useRef, useState } from "react"; import { ResourceIcon } from "./ResourceIcon"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./Select"; import TextInput from "./TextInput"; @@ -9,20 +9,37 @@ import TextInput from "./TextInput"; interface SelectResourceProps { onSelect: (resourceId: number | null) => void; className?: string; + realmProduction?: boolean; } -export const SelectResource: React.FC = ({ onSelect, className }) => { +export const SelectResource: React.FC = ({ onSelect, className, realmProduction = false }) => { const [searchInput, setSearchInput] = useState(""); const [selectedResource, setSelectedResource] = useState(""); const [open, setOpen] = useState(false); const inputRef = useRef(null); - const resourceIds = Object.values(ResourcesIds) - .filter((resource) => resource !== ResourcesIds.AncientFragment && resource !== ResourcesIds.Lords) - .filter((resource) => typeof resource === "number"); + const REALM_PRODUCTION_EXCLUDED = [ + ResourcesIds.AncientFragment, + ResourcesIds.Crossbowman, + ResourcesIds.Knight, + ResourcesIds.Paladin, + ResourcesIds.Fish, + ResourcesIds.Wheat, + ResourcesIds.Donkey, + ]; - const filteredResourceIds = resourceIds.filter((resourceId) => + const orderedResources = useMemo(() => { + return Object.values(RESOURCE_TIERS) + .flat() + .filter((resourceId) => { + if (resourceId === ResourcesIds.Lords) return false; + if (realmProduction && REALM_PRODUCTION_EXCLUDED.includes(resourceId)) return false; + return true; + }); + }, [realmProduction]); + + const filteredResourceIds = orderedResources.filter((resourceId) => ResourcesIds[resourceId].toLowerCase().startsWith(searchInput.toLowerCase()), ); @@ -76,13 +93,14 @@ export const SelectResource: React.FC = ({ onSelect, classN - +
+ +
{filteredResourceIds.map((resourceId) => (
From 0775913ce687a5175965bef2fb2cb167c169b8d4 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 15:15:10 +0100 Subject: [PATCH 06/13] Change points -> Victory Points --- docs/pages/mechanics/achievements.mdx | 2 +- docs/pages/mechanics/hyperstructures.mdx | 14 +++++++------- docs/pages/mechanics/key-concepts.mdx | 2 +- docs/pages/seasons/rewards.mdx | 6 +++--- vocs.config.ts | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/pages/mechanics/achievements.mdx b/docs/pages/mechanics/achievements.mdx index 22e8039f2..c4af8ec29 100644 --- a/docs/pages/mechanics/achievements.mdx +++ b/docs/pages/mechanics/achievements.mdx @@ -4,7 +4,7 @@ Achievements are a lasting testament to your accomplishments across all seasons, awarded for completing specific in-game objectives. Players earn achievements through the Cartridge Controller, with requirements accessible by clicking on -their controller name. Completing achievements earns points, allowing players to compete for positions on the +their controller name. Completing achievements earns Victory Points, allowing players to compete for positions on the achievement leaderboard. ### Achievement Categories diff --git a/docs/pages/mechanics/hyperstructures.mdx b/docs/pages/mechanics/hyperstructures.mdx index 511e63978..24067ab64 100644 --- a/docs/pages/mechanics/hyperstructures.mdx +++ b/docs/pages/mechanics/hyperstructures.mdx @@ -5,7 +5,7 @@ import { HYPERSTRUCTURE_POINTS_FOR_WIN } from "@bibliothecadao/eternum"; # 🏛️ Hyperstructures Hyperstructures are massive social engineering projects that can be constructucted in the Eternum world. Victory in -Eternum is achieved by accumulating **{formatNumberWithCommas(HYPERSTRUCTURE_POINTS_FOR_WIN)}** points. View and manage +Eternum is achieved by accumulating **{formatNumberWithCommas(HYPERSTRUCTURE_POINTS_FOR_WIN)}** Victory Points. View and manage Hyperstructures in the World Map under World Structures. Date: Sat, 14 Dec 2024 15:16:07 +0100 Subject: [PATCH 07/13] lint --- docs/pages/mechanics/hyperstructures.mdx | 8 ++++---- docs/pages/mechanics/key-concepts.mdx | 4 ++-- docs/pages/mechanics/military/units.mdx | 3 ++- docs/pages/seasons/rewards.mdx | 14 +++++++------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/pages/mechanics/hyperstructures.mdx b/docs/pages/mechanics/hyperstructures.mdx index 24067ab64..3b431f679 100644 --- a/docs/pages/mechanics/hyperstructures.mdx +++ b/docs/pages/mechanics/hyperstructures.mdx @@ -5,8 +5,8 @@ import { HYPERSTRUCTURE_POINTS_FOR_WIN } from "@bibliothecadao/eternum"; # 🏛️ Hyperstructures Hyperstructures are massive social engineering projects that can be constructucted in the Eternum world. Victory in -Eternum is achieved by accumulating **{formatNumberWithCommas(HYPERSTRUCTURE_POINTS_FOR_WIN)}** Victory Points. View and manage -Hyperstructures in the World Map under World Structures. +Eternum is achieved by accumulating **{formatNumberWithCommas(HYPERSTRUCTURE_POINTS_FOR_WIN)}** Victory Points. View and +manage Hyperstructures in the World Map under World Structures. Season 0 Prize pool: > From 75fd95133f1c737a6d89badba33550777fbe6293 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 15:20:16 +0100 Subject: [PATCH 08/13] Replace hardcoded value --- client/src/ui/utils/utils.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/ui/utils/utils.tsx b/client/src/ui/utils/utils.tsx index cd49125a3..bd97b0038 100644 --- a/client/src/ui/utils/utils.tsx +++ b/client/src/ui/utils/utils.tsx @@ -505,5 +505,5 @@ export const calculateDonkeysNeeded = (orderWeight: number): number => { const configManager = ClientConfigManager.instance(); const donkeyCapacityGrams = configManager.getCapacityConfig(CapacityConfigCategory.Donkey); - return Math.ceil((orderWeight / 1000) / donkeyCapacityGrams); -}; \ No newline at end of file + return Math.ceil(divideByPrecision(orderWeight) / donkeyCapacityGrams); +}; From 948bcfea33abd3ff4a4c96e51d5592bba784a2a4 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 18:06:46 +0100 Subject: [PATCH 09/13] fix hs & mines names --- client/src/hooks/helpers/useEntities.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/hooks/helpers/useEntities.tsx b/client/src/hooks/helpers/useEntities.tsx index f567d6a38..d32d1ca0c 100644 --- a/client/src/hooks/helpers/useEntities.tsx +++ b/client/src/hooks/helpers/useEntities.tsx @@ -252,7 +252,6 @@ export const useEntitiesUtils = () => { const entityName = getComponentValue(EntityName, getEntityIdFromKeys([BigInt(entityId)])); const realm = getComponentValue(Realm, getEntityIdFromKeys([BigInt(entityId)])); const structure = getComponentValue(Structure, getEntityIdFromKeys([BigInt(entityId)])); - if (structure?.category === StructureType[StructureType.Realm] && realm) { return getRealmName(realm); } @@ -272,9 +271,8 @@ export const useEntitiesUtils = () => { if (abbr) { return `${abbr} ${structure.entity_id}`; } - - return `${structure?.category} ${structure?.entity_id}`; } + return `${structure?.category} ${structure?.entity_id}`; }; const getAddressName = (address: ContractAddress) => { From e4a280a759e337749b1c9bb65650fb973173cdd4 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 14 Dec 2024 18:08:39 +0100 Subject: [PATCH 10/13] Add dest name in transit --- client/src/ui/components/entities/Entity.tsx | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/client/src/ui/components/entities/Entity.tsx b/client/src/ui/components/entities/Entity.tsx index 479047c50..b8a137fdc 100644 --- a/client/src/ui/components/entities/Entity.tsx +++ b/client/src/ui/components/entities/Entity.tsx @@ -63,22 +63,22 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { setIsSyncing(true); const fetch = async () => { - try { - await addToSubscription( - dojo.network.toriiClient, - dojo.network.contractComponents as any, - arrival.entityId.toString(), - ); - localStorage.setItem(cacheKey, now.toString()); - } catch (error) { - console.error("Fetch failed", error); - } finally { - setIsSyncing(false); - } - }; - fetch(); + try { + await addToSubscription( + dojo.network.toriiClient, + dojo.network.contractComponents as any, + arrival.entityId.toString(), + ); + localStorage.setItem(cacheKey, now.toString()); + } catch (error) { + console.error("Fetch failed", error); + } finally { + setIsSyncing(false); } - }, [arrival.entityId, dojo.network.toriiClient, dojo.network.contractComponents, entityResources.length]); + }; + fetch(); + } + }, [arrival.entityId, dojo.network.toriiClient, dojo.network.contractComponents, entityResources.length]); const army = useMemo(() => getArmy(arrival.entityId), [arrival.entityId, entity.resources]); @@ -90,7 +90,8 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => {
) : (
- {formatTime(Number(entity.arrivalTime) - nextBlockTimestamp)} + Arriving in {formatTime(Number(entity.arrivalTime) - nextBlockTimestamp)} to{" "} + {getEntityName(arrival.recipientEntityId)}
) ) : null; @@ -109,6 +110,7 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { className="!text-gold" type="vertical" size="xs" + withTooltip={true} resourceId={resource.resourceId} amount={divideByPrecision(resource.amount)} /> From f531288a80a21c2e9743ce89807008e734541ef8 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Sun, 15 Dec 2024 11:06:27 +1100 Subject: [PATCH 11/13] travel --- client/src/ui/components/resources/TravelInfo.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/ui/components/resources/TravelInfo.tsx b/client/src/ui/components/resources/TravelInfo.tsx index e27d6deaa..482b78dab 100644 --- a/client/src/ui/components/resources/TravelInfo.tsx +++ b/client/src/ui/components/resources/TravelInfo.tsx @@ -45,8 +45,13 @@ export const TravelInfo = ({ setDonkeyBalance(calculatedDonkeyBalance); + const onlyDonkeysAndLords = resources.every( + (r) => r.resourceId === ResourcesIds.Donkey || r.resourceId === ResourcesIds.Lords + ); + if (setCanCarry) { - setCanCarry(calculatedDonkeyBalance >= neededDonkeys); + // TODO: hacky way to set can carry to true if only donkeys and lords + onlyDonkeysAndLords ? setCanCarry(true) : setCanCarry(calculatedDonkeyBalance >= neededDonkeys); } }, [resources, entityId, resourceWeight, donkeyBalance, setCanCarry]); @@ -54,14 +59,14 @@ export const TravelInfo = ({ <> - {travelTime && ( + {travelTime ? ( - )} + ):''} - ):''} + ) : ( + "" + )}
Travel Time {`${Math.floor(travelTime / 60)} hrs ${travelTime % 60} mins`}
Total Transfer Weight {`${currencyFormat( From c3008e070e8fa5bcca3446bd4294c0edd3c23baa Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Sun, 15 Dec 2024 11:31:23 +1100 Subject: [PATCH 12/13] fix army reinforce bug --- client/src/hooks/helpers/useArmies.tsx | 32 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/client/src/hooks/helpers/useArmies.tsx b/client/src/hooks/helpers/useArmies.tsx index 00c145741..a20fb1886 100644 --- a/client/src/hooks/helpers/useArmies.tsx +++ b/client/src/hooks/helpers/useArmies.tsx @@ -9,15 +9,15 @@ import { } from "@bibliothecadao/eternum"; import { useEntityQuery } from "@dojoengine/react"; import { - type Component, - type ComponentValue, - type Entity, Has, HasValue, Not, NotValue, getComponentValue, runQuery, + type Component, + type ComponentValue, + type Entity, } from "@dojoengine/recs"; import { getEntityIdFromKeys } from "@dojoengine/utils"; import { useMemo } from "react"; @@ -63,6 +63,7 @@ const formatArmies = ( Owner: Component, Realm: Component, Stamina: Component, + Structure: Component, ): ArmyInfo[] => { return armies .map((armyEntityId) => { @@ -117,10 +118,14 @@ const formatArmies = ( const realm = entityOwner && getComponentValue(Realm, getEntityIdFromKeys([BigInt(entityOwner.entity_owner_id)])); const homePosition = realm && getComponentValue(Position, getEntityIdFromKeys([BigInt(realm.entity_id)])); + const structure = getComponentValue(Structure, getEntityIdFromKeys([BigInt(entityOwner.entity_owner_id)])); + + const structurePosition = structure && getComponentValue(Position, getEntityIdFromKeys([BigInt(structure.entity_id)])); + const isMine = (owner?.address || 0n) === ContractAddress(playerAddress); const isMercenary = owner === undefined; - const isHome = homePosition && position.x === homePosition.x && position.y === homePosition.y; + const isHome = structurePosition && position.x === structurePosition.x && position.y === structurePosition.y; return { ...army, @@ -166,6 +171,7 @@ export const useArmiesByEntityOwner = ({ entity_owner_entity_id }: { entity_owne Protectee, EntityName, Stamina, + Structure }, }, account: { account }, @@ -191,6 +197,7 @@ export const useArmiesByEntityOwner = ({ entity_owner_entity_id }: { entity_owne Owner, Realm, Stamina, + Structure ); }, [armies]); @@ -221,6 +228,7 @@ export const useArmiesByEntityOwnerWithPositionAndQuantity = ({ Protectee, EntityName, Stamina, + Structure }, }, account: { account }, @@ -251,6 +259,7 @@ export const useArmiesByEntityOwnerWithPositionAndQuantity = ({ Owner, Realm, Stamina, + Structure ); }, [armies]); @@ -277,6 +286,7 @@ export const getArmiesByBattleId = () => { Protectee, EntityName, Stamina, + Structure }, }, account: { account }, @@ -301,6 +311,7 @@ export const getArmiesByBattleId = () => { Owner, Realm, Stamina, + Structure ); }; return armiesByBattleId; @@ -324,6 +335,7 @@ export const useArmyByArmyEntityId = (entityId: ID): ArmyInfo | undefined => { Protectee, EntityName, Stamina, + Structure }, }, account: { account }, @@ -347,6 +359,7 @@ export const useArmyByArmyEntityId = (entityId: ID): ArmyInfo | undefined => { Owner, Realm, Stamina, + Structure )[0]; }; @@ -369,6 +382,7 @@ export const getUserArmyInBattle = (battle_id: ID) => { Protectee, EntityName, Stamina, + Structure }, }, } = useDojo(); @@ -398,6 +412,7 @@ export const getUserArmyInBattle = (battle_id: ID) => { Owner, Realm, Stamina, + Structure )[0]; }, [battle_id]); @@ -432,6 +447,7 @@ export const useOwnArmiesByPosition = ({ Protectee, EntityName, Stamina, + Structure }, }, } = useDojo(); @@ -461,6 +477,7 @@ export const useOwnArmiesByPosition = ({ Owner, Realm, Stamina, + Structure ).filter((army) => playerStructures.some((structure) => structure.entity_id === army.entityOwner.entity_owner_id), ); @@ -496,6 +513,7 @@ export const useEnemyArmiesByPosition = ({ Protectee, EntityName, Stamina, + Structure }, }, } = useDojo(); @@ -524,6 +542,7 @@ export const useEnemyArmiesByPosition = ({ Owner, Realm, Stamina, + Structure ).filter((army) => playerStructures.every((structure) => structure.entity_id !== army.entityOwner.entity_owner_id), ); @@ -551,6 +570,7 @@ export const getArmyByEntityId = () => { Protectee, EntityName, Stamina, + Structure }, }, account: { account }, @@ -575,6 +595,7 @@ export const getArmyByEntityId = () => { Owner, Realm, Stamina, + Structure )[0]; }; @@ -598,6 +619,7 @@ export const getArmyByEntityId = () => { Owner, Realm, Stamina, + Structure )[0]; }; @@ -623,6 +645,7 @@ export const getArmiesByPosition = () => { Protectee, EntityName, Stamina, + Structure }, }, } = useDojo(); @@ -646,6 +669,7 @@ export const getArmiesByPosition = () => { Owner, Realm, Stamina, + Structure ); }; From 2776a3849433c5b0e7f3c08dba8f415b2f212fd8 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Sun, 15 Dec 2024 11:39:11 +1100 Subject: [PATCH 13/13] lint --- client/src/dojo/queries.ts | 2 +- client/src/hooks/helpers/useArmies.tsx | 41 ++++---- client/src/three/scenes/Worldmap.ts | 98 +++++++++---------- .../resources/InventoryResources.tsx | 6 +- .../ui/components/resources/TravelInfo.tsx | 6 +- client/src/ui/layouts/World.tsx | 14 +-- client/src/ui/utils/utils.tsx | 2 +- landing/src/components/modules/bridge-in.tsx | 9 +- .../src/components/modules/realms-grid.tsx | 28 +++--- .../components/modules/season-passes-grid.tsx | 24 +++-- 10 files changed, 115 insertions(+), 115 deletions(-) diff --git a/client/src/dojo/queries.ts b/client/src/dojo/queries.ts index fe44ebfd2..0514e4f57 100644 --- a/client/src/dojo/queries.ts +++ b/client/src/dojo/queries.ts @@ -106,7 +106,7 @@ export const addMarketSubscription = async ( }, }, components, - 30_000, + 30_000, false, ); }; diff --git a/client/src/hooks/helpers/useArmies.tsx b/client/src/hooks/helpers/useArmies.tsx index a20fb1886..617eea3ff 100644 --- a/client/src/hooks/helpers/useArmies.tsx +++ b/client/src/hooks/helpers/useArmies.tsx @@ -120,7 +120,8 @@ const formatArmies = ( const structure = getComponentValue(Structure, getEntityIdFromKeys([BigInt(entityOwner.entity_owner_id)])); - const structurePosition = structure && getComponentValue(Position, getEntityIdFromKeys([BigInt(structure.entity_id)])); + const structurePosition = + structure && getComponentValue(Position, getEntityIdFromKeys([BigInt(structure.entity_id)])); const isMine = (owner?.address || 0n) === ContractAddress(playerAddress); const isMercenary = owner === undefined; @@ -171,7 +172,7 @@ export const useArmiesByEntityOwner = ({ entity_owner_entity_id }: { entity_owne Protectee, EntityName, Stamina, - Structure + Structure, }, }, account: { account }, @@ -197,7 +198,7 @@ export const useArmiesByEntityOwner = ({ entity_owner_entity_id }: { entity_owne Owner, Realm, Stamina, - Structure + Structure, ); }, [armies]); @@ -228,7 +229,7 @@ export const useArmiesByEntityOwnerWithPositionAndQuantity = ({ Protectee, EntityName, Stamina, - Structure + Structure, }, }, account: { account }, @@ -259,7 +260,7 @@ export const useArmiesByEntityOwnerWithPositionAndQuantity = ({ Owner, Realm, Stamina, - Structure + Structure, ); }, [armies]); @@ -286,7 +287,7 @@ export const getArmiesByBattleId = () => { Protectee, EntityName, Stamina, - Structure + Structure, }, }, account: { account }, @@ -311,7 +312,7 @@ export const getArmiesByBattleId = () => { Owner, Realm, Stamina, - Structure + Structure, ); }; return armiesByBattleId; @@ -335,7 +336,7 @@ export const useArmyByArmyEntityId = (entityId: ID): ArmyInfo | undefined => { Protectee, EntityName, Stamina, - Structure + Structure, }, }, account: { account }, @@ -359,7 +360,7 @@ export const useArmyByArmyEntityId = (entityId: ID): ArmyInfo | undefined => { Owner, Realm, Stamina, - Structure + Structure, )[0]; }; @@ -382,7 +383,7 @@ export const getUserArmyInBattle = (battle_id: ID) => { Protectee, EntityName, Stamina, - Structure + Structure, }, }, } = useDojo(); @@ -412,7 +413,7 @@ export const getUserArmyInBattle = (battle_id: ID) => { Owner, Realm, Stamina, - Structure + Structure, )[0]; }, [battle_id]); @@ -447,7 +448,7 @@ export const useOwnArmiesByPosition = ({ Protectee, EntityName, Stamina, - Structure + Structure, }, }, } = useDojo(); @@ -477,7 +478,7 @@ export const useOwnArmiesByPosition = ({ Owner, Realm, Stamina, - Structure + Structure, ).filter((army) => playerStructures.some((structure) => structure.entity_id === army.entityOwner.entity_owner_id), ); @@ -513,7 +514,7 @@ export const useEnemyArmiesByPosition = ({ Protectee, EntityName, Stamina, - Structure + Structure, }, }, } = useDojo(); @@ -542,7 +543,7 @@ export const useEnemyArmiesByPosition = ({ Owner, Realm, Stamina, - Structure + Structure, ).filter((army) => playerStructures.every((structure) => structure.entity_id !== army.entityOwner.entity_owner_id), ); @@ -570,7 +571,7 @@ export const getArmyByEntityId = () => { Protectee, EntityName, Stamina, - Structure + Structure, }, }, account: { account }, @@ -595,7 +596,7 @@ export const getArmyByEntityId = () => { Owner, Realm, Stamina, - Structure + Structure, )[0]; }; @@ -619,7 +620,7 @@ export const getArmyByEntityId = () => { Owner, Realm, Stamina, - Structure + Structure, )[0]; }; @@ -645,7 +646,7 @@ export const getArmiesByPosition = () => { Protectee, EntityName, Stamina, - Structure + Structure, }, }, } = useDojo(); @@ -669,7 +670,7 @@ export const getArmiesByPosition = () => { Owner, Realm, Stamina, - Structure + Structure, ); }; diff --git a/client/src/three/scenes/Worldmap.ts b/client/src/three/scenes/Worldmap.ts index e5e06babb..e747f43c9 100644 --- a/client/src/three/scenes/Worldmap.ts +++ b/client/src/three/scenes/Worldmap.ts @@ -680,63 +680,63 @@ export default class WorldmapScene extends HexagonScene { // Skip if we've already fetched this chunk if (this.fetchedChunks.has(chunkKey)) { - console.log("Already fetched"); - return; + console.log("Already fetched"); + return; } // Add to fetched chunks before the query to prevent concurrent duplicate requests this.fetchedChunks.add(chunkKey); try { - await getEntities( - this.dojo.network.toriiClient, - { - Composite: { - operator: "And", - clauses: [ - { - Member: { - model: "s0_eternum-Tile", - member: "col", - operator: "Gte", - value: { Primitive: { U32: startCol - range } }, - }, - }, - { - Member: { - model: "s0_eternum-Tile", - member: "col", - operator: "Lte", - value: { Primitive: { U32: startCol + range } }, - }, - }, - { - Member: { - model: "s0_eternum-Tile", - member: "row", - operator: "Gte", - value: { Primitive: { U32: startRow - range } }, - }, - }, - { - Member: { - model: "s0_eternum-Tile", - member: "row", - operator: "Lte", - value: { Primitive: { U32: startRow + range } }, - }, - }, - ], + await getEntities( + this.dojo.network.toriiClient, + { + Composite: { + operator: "And", + clauses: [ + { + Member: { + model: "s0_eternum-Tile", + member: "col", + operator: "Gte", + value: { Primitive: { U32: startCol - range } }, + }, + }, + { + Member: { + model: "s0_eternum-Tile", + member: "col", + operator: "Lte", + value: { Primitive: { U32: startCol + range } }, + }, + }, + { + Member: { + model: "s0_eternum-Tile", + member: "row", + operator: "Gte", + value: { Primitive: { U32: startRow - range } }, }, - }, - this.dojo.network.contractComponents as any, - 1000, - false, - ); + }, + { + Member: { + model: "s0_eternum-Tile", + member: "row", + operator: "Lte", + value: { Primitive: { U32: startRow + range } }, + }, + }, + ], + }, + }, + this.dojo.network.contractComponents as any, + 1000, + false, + ); } catch (error) { - // If there's an error, remove the chunk from cached set so it can be retried - this.fetchedChunks.delete(chunkKey); - console.error('Error fetching tile entities:', error); + // If there's an error, remove the chunk from cached set so it can be retried + this.fetchedChunks.delete(chunkKey); + console.error("Error fetching tile entities:", error); } } diff --git a/client/src/ui/components/resources/InventoryResources.tsx b/client/src/ui/components/resources/InventoryResources.tsx index 8136bef67..8f555fda6 100644 --- a/client/src/ui/components/resources/InventoryResources.tsx +++ b/client/src/ui/components/resources/InventoryResources.tsx @@ -51,11 +51,7 @@ export const InventoryResources = ({ setIsSyncing(true); try { - await addToSubscription( - dojo.network.toriiClient, - dojo.network.contractComponents as any, - entityId.toString(), - ); + await addToSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any, entityId.toString()); localStorage.setItem(cacheKey, now.toString()); } catch (error) { console.error("Fetch failed", error); diff --git a/client/src/ui/components/resources/TravelInfo.tsx b/client/src/ui/components/resources/TravelInfo.tsx index 482b78dab..26cf06500 100644 --- a/client/src/ui/components/resources/TravelInfo.tsx +++ b/client/src/ui/components/resources/TravelInfo.tsx @@ -46,7 +46,7 @@ export const TravelInfo = ({ setDonkeyBalance(calculatedDonkeyBalance); const onlyDonkeysAndLords = resources.every( - (r) => r.resourceId === ResourcesIds.Donkey || r.resourceId === ResourcesIds.Lords + (r) => r.resourceId === ResourcesIds.Donkey || r.resourceId === ResourcesIds.Lords, ); if (setCanCarry) { @@ -66,7 +66,9 @@ export const TravelInfo = ({ {`${Math.floor(travelTime / 60)} hrs ${travelTime % 60} mins`}
Total Transfer Weight {`${currencyFormat( diff --git a/client/src/ui/layouts/World.tsx b/client/src/ui/layouts/World.tsx index 87c966e09..e0909a8f1 100644 --- a/client/src/ui/layouts/World.tsx +++ b/client/src/ui/layouts/World.tsx @@ -159,13 +159,13 @@ export const World = ({ backgroundImage }: { backgroundImage: string }) => { console.log("world loading", worldLoading); - try { - await addMarketSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any); - } catch (error) { - console.error("Fetch failed", error); - } finally { - setMarketLoading(false); - } + try { + await addMarketSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any); + } catch (error) { + console.error("Fetch failed", error); + } finally { + setMarketLoading(false); + } }; fetch(); diff --git a/client/src/ui/utils/utils.tsx b/client/src/ui/utils/utils.tsx index eba5075da..e565ab35e 100644 --- a/client/src/ui/utils/utils.tsx +++ b/client/src/ui/utils/utils.tsx @@ -523,7 +523,7 @@ export const getSeasonAddresses = async (): Promise => { console.error("Error loading season addresses:", error); return {}; } -} +}; export const calculateDonkeysNeeded = (orderWeight: number): number => { const configManager = ClientConfigManager.instance(); const donkeyCapacityGrams = configManager.getCapacityConfig(CapacityConfigCategory.Donkey); diff --git a/landing/src/components/modules/bridge-in.tsx b/landing/src/components/modules/bridge-in.tsx index fe9b56cdc..2de6a3aef 100644 --- a/landing/src/components/modules/bridge-in.tsx +++ b/landing/src/components/modules/bridge-in.tsx @@ -226,7 +226,14 @@ export const BridgeIn = () => {
To Realm