diff --git a/client/src/dojo/setup.ts b/client/src/dojo/setup.ts index f0807df8d..2fe3aeeb4 100644 --- a/client/src/dojo/setup.ts +++ b/client/src/dojo/setup.ts @@ -1,9 +1,10 @@ import { BUILDING_CATEGORY_POPULATION_CONFIG_ID, + HYPERSTRUCTURE_CONFIG_ID, WORLD_CONFIG_ID } from "@bibliothecadao/eternum"; import { DojoConfig } from "@dojoengine/core"; -import { getSyncEntities, getSyncEvents, syncEntities } from "@dojoengine/state"; +import { getEntities, getSyncEntities, getSyncEvents, syncEntities } from "@dojoengine/state"; import { Clause } from "@dojoengine/torii-client"; import { createClientComponents } from "./createClientComponents"; import { createSystemCalls } from "./createSystemCalls"; @@ -19,14 +20,7 @@ export async function setup({ ...config }: DojoConfig) { const components = createClientComponents(network); const systemCalls = createSystemCalls(network); - const clauses: Clause[] = [ - { - Keys: { - keys: [undefined], - pattern_matching: "FixedLen", - models: [], - }, - }, + const configClauses: Clause[] = [ { Keys: { keys: [WORLD_CONFIG_ID.toString(), undefined, undefined], @@ -34,22 +28,39 @@ export async function setup({ ...config }: DojoConfig) { models: [], }, }, + { + Keys: { + keys: [WORLD_CONFIG_ID.toString(), undefined], + pattern_matching: "FixedLen", + models: [], + }, + }, + { + Keys: { + keys: [BUILDING_CATEGORY_POPULATION_CONFIG_ID.toString(), undefined], + pattern_matching: "FixedLen", + models: [], + }, + }, + { + Keys: { + keys: [HYPERSTRUCTURE_CONFIG_ID.toString(), undefined], + pattern_matching: "VariableLen", + models: [], + }, + }, + ]; + + await getEntities(network.toriiClient, {Composite: {operator: "Or", clauses: configClauses}}, network.contractComponents as any); + + const clauses: Clause[] = [ { Keys: { - keys: [WORLD_CONFIG_ID.toString(), undefined], - pattern_matching: "FixedLen", - models: [], - }, - }, - { - Keys: { - keys: [BUILDING_CATEGORY_POPULATION_CONFIG_ID.toString(), undefined], + keys: [undefined], pattern_matching: "FixedLen", models: [], }, }, - - ]; // fetch all existing entities from torii diff --git a/client/src/ui/components/entities/Entity.tsx b/client/src/ui/components/entities/Entity.tsx index 9d15c2e44..c853b37f5 100644 --- a/client/src/ui/components/entities/Entity.tsx +++ b/client/src/ui/components/entities/Entity.tsx @@ -1,3 +1,4 @@ +import { addToSubscription } from "@/dojo/queries"; import { useDojo } from "@/hooks/context/DojoContext"; import { ArrivalInfo } from "@/hooks/helpers/use-resource-arrivals"; import { getArmyByEntityId } from "@/hooks/helpers/useArmies"; @@ -10,7 +11,7 @@ import { divideByPrecision, formatTime, getEntityIdFromKeys } from "@/ui/utils/u import { EntityType } from "@bibliothecadao/eternum"; import { useComponentValue } from "@dojoengine/react"; import clsx from "clsx"; -import React, { useMemo } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { DepositResources } from "../resources/DepositResources"; const entityIcon: Record = { @@ -32,6 +33,8 @@ type EntityProps = { export const EntityArrival = ({ arrival, ...props }: EntityProps) => { const dojo = useDojo(); + const [isSyncing, setIsSyncing] = useState(false); + const { getEntityInfo, getEntityName } = useEntitiesUtils(); const { getResourcesFromBalance } = useResourcesUtils(); const nextBlockTimestamp = useUIStore.getState().nextBlockTimestamp; @@ -45,6 +48,26 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { return getResourcesFromBalance(arrival.entityId); }, [weight]); + useEffect(() => { + if (entityResources.length === 0) { + setIsSyncing(true); + const fetch = async () => { + try { + await addToSubscription( + dojo.network.toriiClient, + dojo.network.contractComponents as any, + arrival.entityId.toString(), + ); + } catch (error) { + console.error("Fetch failed", error); + } finally { + setIsSyncing(false); + } + }; + fetch(); + } + }, [arrival.entityId, dojo.network.toriiClient, dojo.network.contractComponents, entityResources.length]); + const army = useMemo(() => getArmy(arrival.entityId), [arrival.entityId, entity.resources]); const renderEntityStatus = useMemo(() => { @@ -62,6 +85,10 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { }, [nextBlockTimestamp, arrival.recipientEntityId, arrival.hasResources, entity.arrivalTime]); const renderedResources = useMemo(() => { + if (isSyncing) { + return
Syncing resources...
; + } + return entityResources .filter(Boolean) .map((resource) => ( @@ -74,7 +101,7 @@ export const EntityArrival = ({ arrival, ...props }: EntityProps) => { amount={divideByPrecision(resource.amount)} /> )); - }, [entityResources]); + }, [entityResources, isSyncing]); const name = entity.entityType === EntityType.TROOP ? army?.name : entityName[entity.entityType]; diff --git a/landing/dojoConfig.ts b/landing/dojoConfig.ts index 41617863d..b80bfa33d 100644 --- a/landing/dojoConfig.ts +++ b/landing/dojoConfig.ts @@ -19,9 +19,13 @@ const { // const isLocal = VITE_PUBLIC_CHAIN === "local" || VITE_PUBLIC_CHAIN === "testnet"; // const manifest = VITE_PUBLIC_DEV === true && isLocal ? devManifest : productionManifest; -let manifest = VITE_PUBLIC_DEV === true ? devManifest : sepoliaManifest; +const manifestMap = { + 'local': devManifest, + 'mainnet': productionManifest, + 'sepolia': sepoliaManifest +} as const; -manifest = VITE_PUBLIC_CHAIN === "mainnet" ? productionManifest : manifest; +const manifest = manifestMap[VITE_PUBLIC_CHAIN as keyof typeof manifestMap] ?? sepoliaManifest; export const getManifest = () => { return manifest; diff --git a/landing/package.json b/landing/package.json index b43917c44..b28262fa3 100644 --- a/landing/package.json +++ b/landing/package.json @@ -19,13 +19,13 @@ "@bibliothecadao/eternum": "workspace:^", "@cartridge/connector": "^0.5.3", "@cartridge/controller": "^0.5.3", - "@dojoengine/core": "1.0.1", - "@dojoengine/create-burner": "1.0.1", - "@dojoengine/react": "1.0.1", + "@dojoengine/core": "1.0.3-alpha.1", + "@dojoengine/create-burner": "1.0.3-alpha.1", + "@dojoengine/react": "1.0.3-alpha.1", "@dojoengine/recs": "^2.0.13", - "@dojoengine/state": "1.0.1", - "@dojoengine/torii-client": "1.0.1", - "@dojoengine/utils": "1.0.1", + "@dojoengine/state": "1.0.3-alpha.1", + "@dojoengine/torii-client": "1.0.3-alpha.1", + "@dojoengine/utils": "1.0.3-alpha.1", "@graphql-codegen/schema-ast": "^4.1.0", "@graphql-typed-document-node/core": "^3.2.0", "@headlessui/react": "^1.7.18", diff --git a/landing/src/components/modules/app-sidebar.tsx b/landing/src/components/modules/app-sidebar.tsx index 2510d8b15..cb5092f86 100644 --- a/landing/src/components/modules/app-sidebar.tsx +++ b/landing/src/components/modules/app-sidebar.tsx @@ -57,10 +57,12 @@ export function AppSidebar() { return ( -
- - Eternum -
+ +
+ + Eternum +
+
diff --git a/landing/src/components/modules/bridge-fees.tsx b/landing/src/components/modules/bridge-fees.tsx index f64d61d8e..2a4ecbb9c 100644 --- a/landing/src/components/modules/bridge-fees.tsx +++ b/landing/src/components/modules/bridge-fees.tsx @@ -86,11 +86,11 @@ export const BridgeFees = ({
{formatFee(feesForAllResources.reduce((sum, fees) => sum + Number(fees.totalFee), 0))} units
- + {feesForAllResources.map((fees) => { const resourceName = ResourcesIds[fees.id as keyof typeof ResourcesIds]; return ( -
+
{resourceName} @@ -114,11 +114,10 @@ export const BridgeFees = ({
{fees.seasonPoolFee}
-
+
Client Fees ({calculateBridgeFeeDisplayPercent(bridgeConfig.client_fee_on_dpt_percent)}%)
{fees.clientFee}
-
); })} diff --git a/landing/src/components/modules/bridge-in.tsx b/landing/src/components/modules/bridge-in.tsx index 8cfd63b3c..2c0a36ab0 100644 --- a/landing/src/components/modules/bridge-in.tsx +++ b/landing/src/components/modules/bridge-in.tsx @@ -149,9 +149,11 @@ export const BridgeIn = () => { throw new Error("No valid resources selected"); } - await bridgeIntoRealm(validResources, ADMIN_BANK_ENTITY_ID, BigInt(realmEntityId!)); - setSelectedResourceIds([]); - setSelectedResourceAmounts({}); + const resp = await bridgeIntoRealm(validResources, ADMIN_BANK_ENTITY_ID, BigInt(realmEntityId!)); + if (resp) { + setSelectedResourceIds([]); + setSelectedResourceAmounts({}); + } } catch (error) { console.error("Bridge into realm error:", error); toast.error("Failed to transfer resources"); @@ -180,10 +182,10 @@ export const BridgeIn = () => {
{displayAddress(address || "")}
-
To Realm
+
To Realm
{res?.id && ( diff --git a/landing/src/components/modules/bridge-out-step-1.tsx b/landing/src/components/modules/bridge-out-step-1.tsx index c14a1bc95..64a59a56a 100644 --- a/landing/src/components/modules/bridge-out-step-1.tsx +++ b/landing/src/components/modules/bridge-out-step-1.tsx @@ -136,11 +136,11 @@ export const BridgeOutStep1 = () => { }; }), ); - console.log(validResources); - await bridgeStartWithdrawFromRealm(validResources, ADMIN_BANK_ENTITY_ID, BigInt(realmEntityId!)); - - setSelectedResourceIds([]); - setSelectedResourceAmounts({}); + const tx = await bridgeStartWithdrawFromRealm(validResources, ADMIN_BANK_ENTITY_ID, BigInt(realmEntityId!)); + if (tx) { + setSelectedResourceIds([]); + setSelectedResourceAmounts({}); + } } finally { setIsLoading(false); } @@ -161,7 +161,7 @@ export const BridgeOutStep1 = () => {
From Realm
{ - if (value === null) { - setDonkeyEntityId(0n); - setSelectedResourceIds([]); - setSelectedResourceAmounts({}); - return; - } - const currentDonkeyInfo = donkeyInfos?.find((donkey) => donkey.donkeyEntityId?.toString() === value); - setDonkeyEntityId(BigInt(value)); - setSelectedResourceIds( - currentDonkeyInfo!.donkeyResources.map((resource) => resource.resourceId as never) ?? 0, - ); - setSelectedResourceAmounts({ - [currentDonkeyInfo!.donkeyResources[0].resourceId ?? 0]: - currentDonkeyInfo!.donkeyResources[0].amount / RESOURCE_PRECISION, - }); - }} - > - - - - - - Choose a donkey - - {donkeyInfos?.map((donkey) => ( - - Donkey Drove {donkey.donkeyEntityId}{" "} - {Number(donkey.donkeyArrivalTime) * 1000 <= Date.now() - ? "(Arrived!)" - : `(Arrives in ${Math.floor( - (Number(donkey.donkeyArrivalTime) * 1000 - Date.now()) / (1000 * 60 * 60), - )}h ${Math.floor( - ((Number(donkey.donkeyArrivalTime) * 1000 - Date.now()) / (1000 * 60)) % 60, - )}m)`} - - ))} - {!donkeyInfos?.length &&
No donkeys found at the bank
} -
- -
-
-
To
-
{displayAddress(address || "")}
-
+
+
Withdraw To
+
{displayAddress(address || "")}
- {selectedResourceIds.length > 0 && ( - setSelectedResourceIds(value as unknown as never[])} - selectedResourceAmounts={selectedResourceAmounts} - setSelectedResourceAmounts={setSelectedResourceAmounts} - /> - )} + + +
Select Donkeys (optional)
+ {isTableOpen ? ( + + ) : ( + + )} +
+ + +
+ + + + + 0 && selectedDonkeys.size === donkeyInfos.length} + onChange={() => { + const newSelected = new Set(); + + if (selectedDonkeys.size !== donkeyInfos.length) { + donkeyInfos.forEach((donkey) => { + if (Number(donkey.donkeyArrivalTime) * 1000 <= Date.now()) { + newSelected.add(BigInt(donkey.donkeyEntityId || 0)); + } + }); + } + setSe + setSelectedDonkeys(newSelected); + updateResourcesFromSelectedDonkeys(newSelected); + }} + /> + + Donkey ID + Resources + Status + + + + {donkeyInfos?.map((donkey) => { + const isArrived = Number(donkey.donkeyArrivalTime) * 1000 <= Date.now(); + return ( + { + if (!isArrived) return; + + const newSelected = new Set(selectedDonkeys); + const donkeyId = BigInt(donkey.donkeyEntityId || 0); + if (newSelected.has(donkeyId)) { + newSelected.delete(donkeyId); + } else { + newSelected.add(donkeyId); + } + setSelectedDonkeys(newSelected); + updateResourcesFromSelectedDonkeys(newSelected); + }} + > + + + + #{donkey.donkeyEntityId} + + {donkey.donkeyResources.map((resource) => ( +
+ + {(resource.amount / RESOURCE_PRECISION).toFixed(2)} +
+ ))} +
+ + {Number(donkey.donkeyArrivalTime) * 1000 <= Date.now() ? ( + Arrived + ) : ( + `Arrives in ${Math.floor( + (Number(donkey.donkeyArrivalTime) * 1000 - Date.now()) / (1000 * 60 * 60), + )}h ${Math.floor(((Number(donkey.donkeyArrivalTime) * 1000 - Date.now()) / (1000 * 60)) % 60)}m` + )} + +
+ ); + })} + {!donkeyInfos?.length && ( + + + No donkeys found at the bank + + + )} +
+
+
+
+
{
); }; diff --git a/landing/src/components/ui/SelectResources.tsx b/landing/src/components/ui/SelectResources.tsx index 7a998f17e..c9f224a16 100644 --- a/landing/src/components/ui/SelectResources.tsx +++ b/landing/src/components/ui/SelectResources.tsx @@ -70,8 +70,11 @@ export const SelectResources = ({ const updatedResourceIds = [...selectedResourceIds]; updatedResourceIds[index] = value; setSelectedResourceIds(updatedResourceIds); + + // Remove the old resource amount and set the new one + const { [selectedResourceIds[index]]: _, ...remainingAmounts } = selectedResourceAmounts; setSelectedResourceAmounts({ - ...selectedResourceAmounts, + ...remainingAmounts, [value]: 1, }); // playResourceSound(value); @@ -155,10 +158,15 @@ export const SelectSingleResource = ({ value={selectedResourceIds[index]} onChange={(value) => { const updatedResourceIds = [...selectedResourceIds]; + console.log(updatedResourceIds); + console.log(index) updatedResourceIds[index] = value; setSelectedResourceIds(updatedResourceIds); + + // Remove the old resource amount and set the new one + const { [selectedResourceIds[index]]: _, ...remainingAmounts } = selectedResourceAmounts; setSelectedResourceAmounts({ - ...selectedResourceAmounts, + ...remainingAmounts, [value]: 1, }); // playResourceSound(value); diff --git a/landing/src/components/ui/utils/utils.ts b/landing/src/components/ui/utils/utils.ts index 9ab1903d8..99d7d330b 100644 --- a/landing/src/components/ui/utils/utils.ts +++ b/landing/src/components/ui/utils/utils.ts @@ -8,11 +8,11 @@ import { BuildingType, ContractAddress, EternumGlobalConfig, + ResourcesIds, + TickIds, type ID, type Position, type Resource, - ResourcesIds, - TickIds, } from "@bibliothecadao/eternum"; import { type ComponentValue } from "@dojoengine/recs"; import { getEntityIdFromKeys } from "@dojoengine/utils"; @@ -442,7 +442,6 @@ export const getSeasonAddresses = async () => { try { const path = getSeasonAddressesPath(); const data = await getJSONFile(path); - console.log({ data }); return data; } catch (error) { console.error("Error loading season addresses:", error); diff --git a/landing/src/dojo/createSystemCalls.ts b/landing/src/dojo/createSystemCalls.ts index c536942bf..ac226a68a 100644 --- a/landing/src/dojo/createSystemCalls.ts +++ b/landing/src/dojo/createSystemCalls.ts @@ -65,7 +65,8 @@ export function createSystemCalls({ provider }: SetupNetworkResult) { const withErrorHandling = Promise>(fn: T) => { return async (...args: Parameters): Promise> => { try { - return await fn(...args); + const resp = await fn(...args); + return resp; } catch (error: any) { let errorMessage = error.message; @@ -131,15 +132,15 @@ export function createSystemCalls({ provider }: SetupNetworkResult) { }; const bridge_resources_into_realm = async (props: SystemProps.BridgeResourcesIntoRealmProps) => { - await provider.bridge_resources_into_realm(props); + return await provider.bridge_resources_into_realm(props); }; const bridge_start_withdraw_from_realm = async (props: SystemProps.BridgeStartWithdrawFromRealmProps) => { - await provider.bridge_start_withdraw_from_realm(props); + return await provider.bridge_start_withdraw_from_realm(props); }; const bridge_finish_withdraw_from_realm = async (props: SystemProps.BridgeFinishWithdrawFromRealmProps) => { - await provider.bridge_finish_withdraw_from_realm(props); + return await provider.bridge_finish_withdraw_from_realm(props); }; const isLive = async () => { diff --git a/landing/src/dojo/setup.ts b/landing/src/dojo/setup.ts index d1298d938..0efd65ea0 100644 --- a/landing/src/dojo/setup.ts +++ b/landing/src/dojo/setup.ts @@ -1,5 +1,7 @@ +import { WORLD_CONFIG_ID } from "@bibliothecadao/eternum"; import { DojoConfig } from "@dojoengine/core"; -import { getSyncEntities, getSyncEvents } from "@dojoengine/state"; +import { getSyncEntities, getSyncEvents, syncEntities } from "@dojoengine/state"; +import { Clause } from "@dojoengine/torii-client"; import { createClientComponents } from "./createClientComponents"; import { createSystemCalls } from "./createSystemCalls"; import { ClientConfigManager } from "./modelManager/ConfigManager"; @@ -59,14 +61,44 @@ export async function setup({ ...config }: DojoConfig) { // count "FragmentMineDiscovered", ]) as any; - + const clauses: Clause[] = [ + { + Keys: { + keys: [undefined], + pattern_matching: "FixedLen", + models: [], + }, + }, + { + Keys: { + keys: [WORLD_CONFIG_ID.toString(), undefined], + pattern_matching: "VariableLen", + models: [], + }, + }, + { + Keys: { + keys: [WORLD_CONFIG_ID.toString()], + pattern_matching: "VariableLen", + models: [], + }, + }, + ]; // fetch all existing entities from torii with optional component filtering - const sync = await getSyncEntities(network.toriiClient, filteredComponents, undefined, [], 10_000, false); + await getSyncEntities( + network.toriiClient, + filteredComponents, + { Composite: { operator: "Or", clauses } }, + [], + 10_000, + ); - const eventSync = getSyncEvents(network.toriiClient, filteredEvents, undefined, [], 20_000, false, false); + const sync = await syncEntities(network.toriiClient, filteredComponents, [], false); configManager.setDojo(components); + const eventSync = getSyncEvents(network.toriiClient, filteredEvents, undefined, [], 20_000, false, false); + return { network, components, diff --git a/landing/src/hooks/helpers/useResources.tsx b/landing/src/hooks/helpers/useResources.tsx index c9e1c71f8..bbef77688 100644 --- a/landing/src/hooks/helpers/useResources.tsx +++ b/landing/src/hooks/helpers/useResources.tsx @@ -19,12 +19,13 @@ export function getResourceBalance() { return { getBalance }; } -export function donkeyArrivals() { +export function useDonkeyArrivals() { const { setup: { components: { Position, EntityOwner, ArrivalTime, OwnedResourcesTracker, Weight }, }, } = useDojo(); + const dojo = useDojo(); const getOwnerArrivalsAtBank = (realmEntityIds: ID[]) => { const bankPosition = getComponentValue(Position, getEntityIdFromKeys([BigInt(ADMIN_BANK_ENTITY_ID)])); @@ -46,7 +47,6 @@ export function donkeyArrivals() { }; const getDonkeyInfo = (donkeyEntity: Entity) => { - const dojo = useDojo(); const tickConfigDefault = configManager.getTick(TickIds.Default); const timestamp = Math.floor(Date.now() / 1000); const currentDefaultTick = Math.floor(timestamp / Number(tickConfigDefault)); diff --git a/landing/src/hooks/useBridge.tsx b/landing/src/hooks/useBridge.tsx index c8ec4f577..9b19eb0fe 100644 --- a/landing/src/hooks/useBridge.tsx +++ b/landing/src/hooks/useBridge.tsx @@ -44,14 +44,15 @@ export const useBridgeAsset = () => { const _bridgeStartWithdrawFromRealm = useCallback( async (resources: { tokenAddress: string; amount: bigint }[], throughBankId: bigint, fromRealmEntityId: bigint) => { if (account) { - await bridge_start_withdraw_from_realm({ + return await bridge_start_withdraw_from_realm({ signer: account, resources: resources, through_bank_id: throughBankId, from_realm_entity_id: fromRealmEntityId, }) - .then(() => { + .then((resp) => { toast(`Withdrawal initiated successfully. Resources are on their way to the bank.`); + return resp; }) .catch((e) => { console.error(`Bridge withdraw from realm error:`, e); @@ -62,18 +63,18 @@ export const useBridgeAsset = () => { ); const _bridgeFinishWithdrawFromRealm = useCallback( - async (tokenAddress: string, throughBankId: bigint, fromDonkeyEntityId: bigint) => { + async ( donkeyResources: { tokenAddress: string; from_entity_id: bigint }[], throughBankId: bigint) => { if (account) { - await bridge_finish_withdraw_from_realm({ + return await bridge_finish_withdraw_from_realm({ signer: account, - tokenAddress: tokenAddress, + donkey_resources: donkeyResources, through_bank_id: throughBankId, - from_entity_id: fromDonkeyEntityId, recipient_address: account.address, client_fee_recipient: env.VITE_PUBLIC_CLIENT_FEE_RECIPIENT, }) - .then(() => { + .then((resp) => { toast(`Withdrawal Completed! Resources sent to your wallet!`); + return resp; }) .catch((e) => { console.error(`Bridge withdraw from realm error:`, e); diff --git a/landing/src/index.css b/landing/src/index.css index 05ff390c0..88c37949b 100644 --- a/landing/src/index.css +++ b/landing/src/index.css @@ -107,3 +107,9 @@ /* border: 2px solid var(--gray-gold, #776756); */ @apply bg-gold; } + +@property --border-angle { + inherits: false; + initial-value: 0deg; + syntax: ''; +} \ No newline at end of file diff --git a/landing/src/routes/season-passes.lazy.tsx b/landing/src/routes/season-passes.lazy.tsx index 16dbef7a4..948b0578f 100644 --- a/landing/src/routes/season-passes.lazy.tsx +++ b/landing/src/routes/season-passes.lazy.tsx @@ -20,7 +20,7 @@ export const Route = createLazyFileRoute("/season-passes")({ function SeasonPasses() { const { connectors } = useConnect(); - const { address, account } = useAccount(); + const { address } = useAccount(); const [isTransferOpen, setIsTransferOpen] = useState(false); diff --git a/landing/tailwind.config.js b/landing/tailwind.config.js index 8b87a38be..27e40196b 100644 --- a/landing/tailwind.config.js +++ b/landing/tailwind.config.js @@ -76,6 +76,14 @@ export default { md: "calc(var(--radius) - 2px)", sm: "calc(var(--radius) - 4px)", }, + animation: { + border: "border 4s linear infinite", + }, + keyframes: { + border: { + to: { "--border-angle": "360deg" }, + }, + }, colors: { background: "hsl(var(--background))", foreground: "hsl(var(--foreground))", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b4cecf69..a62ad0db2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -132,7 +132,7 @@ importers: version: link:../sdk/packages/eternum '@cartridge/connector': specifier: 0.5.5 - version: 0.5.5(encoding@0.1.13)(get-starknet-core@3.3.4(starknet@6.11.0(encoding@0.1.13)))(react@18.3.1)(typescript@5.7.2) + version: 0.5.5(encoding@0.1.13)(get-starknet-core@4.0.0)(react@18.3.1)(typescript@5.7.2) '@cartridge/controller': specifier: 0.5.5 version: 0.5.5(encoding@0.1.13) @@ -189,7 +189,7 @@ importers: version: 3.1.0 '@starknet-react/core': specifier: ^3.0.3 - version: 3.6.2(get-starknet-core@3.3.4(starknet@6.11.0(encoding@0.1.13)))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) + version: 3.6.2(get-starknet-core@4.0.0)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) '@tanstack/react-query': specifier: ^5.59.15 version: 5.62.7(react@18.3.1) @@ -427,26 +427,26 @@ importers: specifier: ^0.5.3 version: 0.5.5(encoding@0.1.13) '@dojoengine/core': - specifier: 1.0.1 - version: 1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) '@dojoengine/create-burner': - specifier: 1.0.1 - version: 1.0.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) '@dojoengine/react': - specifier: 1.0.1 - version: 1.0.1(@types/node@20.17.10)(@types/react@18.3.16)(jsdom@24.1.3)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(type-fest@2.19.0)(typescript@5.7.2)(zod@3.24.1) + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1(@types/node@20.17.10)(@types/react@18.3.16)(@vitest/ui@2.1.8(vitest@2.1.8))(jsdom@24.1.3)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(type-fest@2.19.0)(typescript@5.7.2)(zod@3.24.1) '@dojoengine/recs': specifier: ^2.0.13 version: 2.0.13(typescript@5.7.2)(zod@3.24.1) '@dojoengine/state': - specifier: 1.0.1 - version: 1.0.1(@types/node@20.17.10)(jsdom@24.1.3)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(typescript@5.7.2)(zod@3.24.1) + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1(@types/node@20.17.10)(@vitest/ui@2.1.8(vitest@2.1.8))(jsdom@24.1.3)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(typescript@5.7.2)(zod@3.24.1) '@dojoengine/torii-client': - specifier: 1.0.1 - version: 1.0.1 + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1 '@dojoengine/utils': - specifier: 1.0.1 - version: 1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)(zod@3.24.1) + specifier: 1.0.3-alpha.1 + version: 1.0.3-alpha.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)(zod@3.24.1) '@graphql-codegen/schema-ast': specifier: ^4.1.0 version: 4.1.0(graphql@16.9.0) @@ -1493,25 +1493,12 @@ packages: peerDependencies: starknet: 6.11.0 - '@dojoengine/core@1.0.1': - resolution: {integrity: sha512-b1/uIWC2XBP7qVj5Log+vkCdxB5gsm4PhSCM+4xpgLBkf7xDDG9kZ/XltNgkNdO+GzeeT/R3BnvfmwpMmwDywQ==} - hasBin: true - peerDependencies: - starknet: 6.11.0 - '@dojoengine/core@1.0.3-alpha.1': resolution: {integrity: sha512-UAKjqrgjThj3GpoDGnHp76yGSBO7jsC17iQEPIUevZcrRGFKYBlrE8TnW71y6ATo4xIu1d+OVh9mbhrZx/fG/Q==} hasBin: true peerDependencies: starknet: 6.11.0 - '@dojoengine/create-burner@1.0.1': - resolution: {integrity: sha512-E6k5baRzIo91pET90NGWOsUHyXYSuVapIb7lb8z8dvZ+Zdru+RzQqC9K8nIpFjjDtGTbfCaQb8fZ/meUuvf0Ww==} - peerDependencies: - react: ^18.2.0 - react-dom: ^18.2.0 - starknet: 6.11.0 - '@dojoengine/create-burner@1.0.3-alpha.1': resolution: {integrity: sha512-jV+9dXskKrgFVRjKFTanBE4AUwdiv8L99HSI7EFw7M0lkWDn07kvc1jIH1nmApE9NrKA/RzUsUfuuctKvCQHXw==} peerDependencies: @@ -1519,13 +1506,6 @@ packages: react-dom: ^18.2.0 starknet: 6.11.0 - '@dojoengine/react@1.0.1': - resolution: {integrity: sha512-DsAvGlrOuOjp2LeL6H3VHjcT32tz7dhvUIrjKRMgFX2NWcbqYVKaOv4Jm1YX4oSZi+SqDvKhlzrOma1sfrITdg==} - peerDependencies: - react: ^18.2.0 - starknet: 6.11.0 - type-fest: ^2.14.0 - '@dojoengine/react@1.0.3-alpha.1': resolution: {integrity: sha512-F5Rft2/p9365bJvAoy5JhgVS4Q7roxZ5oZR5xwJvX8Ni6kBzuO3gUJRLw3z52bYhBkyexqxM4IQwOxK6vRP46g==} peerDependencies: @@ -1536,33 +1516,17 @@ packages: '@dojoengine/recs@2.0.13': resolution: {integrity: sha512-Cgz4Unlnk2FSDoFTYKrJexX/KiSYPMFMxftxQkC+9LUKS5yNGkgFQM7xu4/L1HvpDAenL7NjUmH6ynRAS7Iifw==} - '@dojoengine/state@1.0.1': - resolution: {integrity: sha512-akvjXw7nls0wnmcd0xb9klDfNEfSicjGZOK9HO2LOIOxisv4H7XVElVXmm68qjWYgVCfMKtvXtWuVA45M/ztvw==} - peerDependencies: - starknet: 6.11.0 - '@dojoengine/state@1.0.3-alpha.1': resolution: {integrity: sha512-wjInSqugEKhHu5L7RxOJI55mZ+J68k5QNfN/ESQxvecztTBMIF7PRBCizojVS56q0ke5dOhXsy7yxiIncs/OAg==} peerDependencies: starknet: 6.11.0 - '@dojoengine/torii-client@1.0.1': - resolution: {integrity: sha512-10dFxX/wSFv7nSIAMo+Vly84CHyPEhyPB7T4od5aTDI+TuYOVIYqj4sDuytccZrj0cZmiDcw6vm9wL/C3rieKQ==} - '@dojoengine/torii-client@1.0.3-alpha.1': resolution: {integrity: sha512-n3+Z6SyG2hovMrDvU3OMsSta3Ai37hW5Jy/DC+uYwJP55HNh0oHQ8ovGtBvwgytnMsKKnagpXzP68Ai8dHwmYg==} - '@dojoengine/torii-wasm@1.0.1': - resolution: {integrity: sha512-/kr0BP+Kb6aNqtTPniFOLErHRhBoXWZnCoY1zuHjWQI0IJi820MjtgrCObG8TDjxHvtjgGLGt92IlwiTDlbdEQ==} - '@dojoengine/torii-wasm@1.0.3-alpha.1': resolution: {integrity: sha512-piNAMay3E1ZFSgzJ4DE2zySf7FqtRJYHPkLmaoWnrJfUnfcsfFCYY+hRm/KoYCcohZWwab3MfFcQxDIKj1Zuyw==} - '@dojoengine/utils@1.0.1': - resolution: {integrity: sha512-2E5bCYSeifsLxN5bmez8ziJSKbexWxRr3Ss3+txDWLICzfIqNA6eF43rBgUp6/w4NDI57ClimSq7TwXcU/lepA==} - peerDependencies: - starknet: 6.11.0 - '@dojoengine/utils@1.0.3-alpha.1': resolution: {integrity: sha512-nKuUsDw510MjJ36ZwoCe3SjC3An7LCbCom7+xvuzt7tbGqxO0lDe6htSfumCkSxIzsjQc7wTfGJGpLHJIvbDGw==} peerDependencies: @@ -10563,6 +10527,19 @@ snapshots: - typescript - utf-8-validate + '@cartridge/connector@0.5.5(encoding@0.1.13)(get-starknet-core@4.0.0)(react@18.3.1)(typescript@5.7.2)': + dependencies: + '@cartridge/controller': 0.5.5(encoding@0.1.13) + '@starknet-react/core': 3.6.2(get-starknet-core@4.0.0)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) + starknet: 6.11.0(encoding@0.1.13) + transitivePeerDependencies: + - bufferutil + - encoding + - get-starknet-core + - react + - typescript + - utf-8-validate + '@cartridge/controller@0.5.5(encoding@0.1.13)': dependencies: '@cartridge/account-wasm': 0.5.5 @@ -10650,16 +10627,6 @@ snapshots: - typescript - utf-8-validate - '@dojoengine/core@1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)': - dependencies: - '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) - starknet: 6.11.0(encoding@0.1.13) - zod: 3.24.1 - transitivePeerDependencies: - - bufferutil - - typescript - - utf-8-validate - '@dojoengine/core@1.0.3-alpha.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)': dependencies: '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) @@ -10670,22 +10637,6 @@ snapshots: - typescript - utf-8-validate - '@dojoengine/create-burner@1.0.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)': - dependencies: - '@dojoengine/core': 1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) - '@scure/bip32': 1.6.0 - '@starknet-react/core': 2.3.0(get-starknet-core@3.3.4(starknet@6.11.0(encoding@0.1.13)))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13)) - encoding: 0.1.13 - get-starknet-core: 3.3.4(starknet@6.11.0(encoding@0.1.13)) - js-cookie: 3.0.5 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - starknet: 6.11.0(encoding@0.1.13) - transitivePeerDependencies: - - bufferutil - - typescript - - utf-8-validate - '@dojoengine/create-burner@1.0.3-alpha.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)': dependencies: '@dojoengine/core': 1.0.3-alpha.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2) @@ -10702,44 +10653,6 @@ snapshots: - typescript - utf-8-validate - '@dojoengine/react@1.0.1(@types/node@20.17.10)(@types/react@18.3.16)(jsdom@24.1.3)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(type-fest@2.19.0)(typescript@5.7.2)(zod@3.24.1)': - dependencies: - '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) - '@dojoengine/state': 1.0.1(@types/node@20.17.10)(jsdom@24.1.3)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(typescript@5.7.2)(zod@3.24.1) - '@dojoengine/torii-client': 1.0.1 - '@dojoengine/utils': 1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)(zod@3.24.1) - '@latticexyz/utils': 2.2.14 - encoding: 0.1.13 - fast-deep-equal: 3.1.3 - get-starknet-core: 3.3.4(starknet@6.11.0(encoding@0.1.13)) - js-cookie: 3.0.5 - react: 18.3.1 - rxjs: 7.5.5 - starknet: 6.11.0(encoding@0.1.13) - type-fest: 2.19.0 - zustand: 4.5.5(@types/react@18.3.16)(react@18.3.1) - transitivePeerDependencies: - - '@edge-runtime/vm' - - '@types/node' - - '@types/react' - - '@vitest/browser' - - '@vitest/ui' - - bufferutil - - happy-dom - - immer - - jsdom - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - typescript - - utf-8-validate - - zod - '@dojoengine/react@1.0.3-alpha.1(@types/node@20.17.10)(@types/react@18.3.16)(@vitest/ui@2.1.8(vitest@2.1.8))(jsdom@24.1.3)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(type-fest@2.19.0)(typescript@5.7.2)(zod@3.24.1)': dependencies: '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) @@ -10802,32 +10715,6 @@ snapshots: - utf-8-validate - zod - '@dojoengine/state@1.0.1(@types/node@20.17.10)(jsdom@24.1.3)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(typescript@5.7.2)(zod@3.24.1)': - dependencies: - '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) - '@dojoengine/torii-client': 1.0.1 - starknet: 6.11.0(encoding@0.1.13) - vitest: 1.6.0(@types/node@20.17.10)(@vitest/ui@2.1.8(vitest@2.1.8))(jsdom@24.1.3)(terser@5.37.0) - transitivePeerDependencies: - - '@edge-runtime/vm' - - '@types/node' - - '@vitest/browser' - - '@vitest/ui' - - bufferutil - - happy-dom - - jsdom - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - typescript - - utf-8-validate - - zod - '@dojoengine/state@1.0.3-alpha.1(@types/node@20.17.10)(@vitest/ui@2.1.8(vitest@2.1.8))(jsdom@24.1.3)(starknet@6.11.0(encoding@0.1.13))(terser@5.37.0)(typescript@5.7.2)(zod@3.24.1)': dependencies: '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) @@ -10854,31 +10741,12 @@ snapshots: - utf-8-validate - zod - '@dojoengine/torii-client@1.0.1': - dependencies: - '@dojoengine/torii-wasm': 1.0.1 - '@dojoengine/torii-client@1.0.3-alpha.1': dependencies: '@dojoengine/torii-wasm': 1.0.3-alpha.1 - '@dojoengine/torii-wasm@1.0.1': {} - '@dojoengine/torii-wasm@1.0.3-alpha.1': {} - '@dojoengine/utils@1.0.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)(zod@3.24.1)': - dependencies: - '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) - '@latticexyz/utils': 2.2.14 - mathjs: 12.4.3 - micro-starknet: 0.2.3 - starknet: 6.11.0(encoding@0.1.13) - transitivePeerDependencies: - - bufferutil - - typescript - - utf-8-validate - - zod - '@dojoengine/utils@1.0.3-alpha.1(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)(zod@3.24.1)': dependencies: '@dojoengine/recs': 2.0.13(typescript@5.7.2)(zod@3.24.1) @@ -13168,6 +13036,22 @@ snapshots: - typescript - utf-8-validate + '@starknet-react/core@3.6.2(get-starknet-core@4.0.0)(react@18.3.1)(starknet@6.11.0(encoding@0.1.13))(typescript@5.7.2)': + dependencies: + '@starknet-io/types-js': 0.7.10 + '@starknet-react/chains': 3.1.0 + '@tanstack/react-query': 5.62.7(react@18.3.1) + eventemitter3: 5.0.1 + get-starknet-core: 4.0.0 + react: 18.3.1 + starknet: 6.11.0(encoding@0.1.13) + viem: 2.21.54(typescript@5.7.2)(zod@3.24.1) + zod: 3.24.1 + transitivePeerDependencies: + - bufferutil + - typescript + - utf-8-validate + '@stitches/react@1.2.8(react@18.3.1)': dependencies: react: 18.3.1 diff --git a/sdk/packages/eternum/src/provider/index.ts b/sdk/packages/eternum/src/provider/index.ts index 3f81544a6..48a49f106 100644 --- a/sdk/packages/eternum/src/provider/index.ts +++ b/sdk/packages/eternum/src/provider/index.ts @@ -303,8 +303,6 @@ export class EternumProvider extends EnhancedDojoProvider { public async bridge_start_withdraw_from_realm(props: SystemProps.BridgeStartWithdrawFromRealmProps) { const { resources, through_bank_id, from_realm_entity_id, signer } = props; - console.log({ resources }); - const calls = resources.map((resource) => ({ contractAddress: getContractByName(this.manifest, `${NAMESPACE}-resource_bridge_systems`), entrypoint: "start_withdraw", @@ -314,15 +312,17 @@ export class EternumProvider extends EnhancedDojoProvider { } public async bridge_finish_withdraw_from_realm(props: SystemProps.BridgeFinishWithdrawFromRealmProps) { - const { tokenAddress, through_bank_id, from_entity_id, recipient_address, client_fee_recipient, signer } = props; + const { donkey_resources, through_bank_id, recipient_address, client_fee_recipient, signer } = props; + + + const calls = donkey_resources.map((donkey_resource) => ({ + contractAddress: getContractByName(this.manifest, `${NAMESPACE}-resource_bridge_systems`), + entrypoint: "finish_withdraw", + calldata: [through_bank_id, donkey_resource.from_entity_id, donkey_resource.tokenAddress, recipient_address, client_fee_recipient], + })); + + return await this.executeAndCheckTransaction(signer, calls); - return await this.executeAndCheckTransaction(signer, [ - { - contractAddress: getContractByName(this.manifest, `${NAMESPACE}-resource_bridge_systems`), - entrypoint: "finish_withdraw", - calldata: [through_bank_id, from_entity_id, tokenAddress, recipient_address, client_fee_recipient], - }, - ]); } public async bridge_resources_into_realm(props: SystemProps.BridgeResourcesIntoRealmProps) { diff --git a/sdk/packages/eternum/src/types/provider.ts b/sdk/packages/eternum/src/types/provider.ts index fb45381ab..dd12a9fc8 100644 --- a/sdk/packages/eternum/src/types/provider.ts +++ b/sdk/packages/eternum/src/types/provider.ts @@ -27,8 +27,10 @@ export interface BridgeStartWithdrawFromRealmProps extends SystemSigner { export interface BridgeFinishWithdrawFromRealmProps extends SystemSigner { through_bank_id: num.BigNumberish; - from_entity_id: num.BigNumberish; - tokenAddress: num.BigNumberish; + donkey_resources: { + tokenAddress: num.BigNumberish; + from_entity_id: num.BigNumberish; + }[]; recipient_address: num.BigNumberish; client_fee_recipient: num.BigNumberish; }