diff --git a/ui/package.json b/ui/package.json index 72a93e13e..45cb9739b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,7 +12,7 @@ "@apollo/client": "^3.7.11", "@cartridge/controller": "^0.3.18", "@fontsource/vt323": "^4.5.10", - "@starknet-react/core": "^2.1.5", + "@starknet-react/core": "^2.5.0", "@svgr/webpack": "^7.0.0", "@types/js-cookie": "^3.0.3", "@types/node": "18.15.11", diff --git a/ui/src/app/components/interlude/Lobby.tsx b/ui/src/app/components/interlude/Lobby.tsx index d30a860ef..912b2274c 100644 --- a/ui/src/app/components/interlude/Lobby.tsx +++ b/ui/src/app/components/interlude/Lobby.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import { Block } from "starknet"; import { useQueriesStore } from "@/app/hooks/useQueryStore"; import { Adventurer, NullAdventurer } from "@/app/types"; import { useBlock } from "@starknet-react/core"; @@ -19,7 +20,8 @@ export default function Lobby() { }); const handleFilterLobby = (adventurers: Adventurer[]) => { return adventurers.filter( - (adventurer) => adventurer?.revealBlock! > blockData?.block_number! + (adventurer) => + adventurer?.revealBlock! > (blockData as Block)?.block_number! ); }; @@ -78,7 +80,7 @@ export default function Lobby() { key={index} adventurer={adventurer} handleRowSelected={handleRowSelected} - currentBlock={blockData?.block_number!} + currentBlock={(blockData as Block)?.block_number!} /> ) )} diff --git a/ui/src/app/components/marketplace/MarketplaceRow.tsx b/ui/src/app/components/marketplace/MarketplaceRow.tsx index 8c94a9013..d7e47cdf5 100644 --- a/ui/src/app/components/marketplace/MarketplaceRow.tsx +++ b/ui/src/app/components/marketplace/MarketplaceRow.tsx @@ -69,7 +69,7 @@ const MarketplaceRow = ({ const enoughGold = calculatedNewGold >= itemPrice; const checkTransacting = (item: string) => { - if (txData?.status == "RECEIVED") { + if (txData?.finality_status !== undefined) { return transactingMarketIds?.includes(item); } else { return false; diff --git a/ui/src/app/components/navigation/TxActivity.tsx b/ui/src/app/components/navigation/TxActivity.tsx index f77186de2..095b6b7c1 100644 --- a/ui/src/app/components/navigation/TxActivity.tsx +++ b/ui/src/app/components/navigation/TxActivity.tsx @@ -19,11 +19,11 @@ export const TxActivity = () => { hash: hash ? hash : "0x0", }) as { data: InvokeTransactionReceiptResponse }; - if (data?.status === "ACCEPTED_ON_L2") { + if (data?.finality_status === "ACCEPTED_ON_L2") { setTxAccepted(true); } - if (data?.status === "REJECTED") { + if (data?.execution_status === "REVERTED") { stopLoading("Rejected"); } diff --git a/ui/src/app/components/start/Spawn.tsx b/ui/src/app/components/start/Spawn.tsx index e3c8be915..1e29102d8 100644 --- a/ui/src/app/components/start/Spawn.tsx +++ b/ui/src/app/components/start/Spawn.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { CallData, Contract } from "starknet"; +import { Block, CallData, Contract } from "starknet"; import { useAccount, useConnect, useBlock } from "@starknet-react/core"; import Image from "next/image"; import { TypeAnimation } from "react-type-animation"; @@ -120,7 +120,7 @@ export const Spawn = ({ refetchInterval: false, }); - const currentBlockNumber = blockData?.block_number ?? 0; + const currentBlockNumber = (blockData as Block)?.block_number ?? 0; const [fetchedAverageBlockTime, setFetchedAverageBlockTime] = useState(false); diff --git a/ui/src/app/containers/BeastScreen.tsx b/ui/src/app/containers/BeastScreen.tsx index fd80ae402..f51d073d9 100644 --- a/ui/src/app/containers/BeastScreen.tsx +++ b/ui/src/app/containers/BeastScreen.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react"; import { useBlock } from "@starknet-react/core"; -import { Contract } from "starknet"; +import { Contract, Block } from "starknet"; import { BattleDisplay } from "@/app/components/beast/BattleDisplay"; import { BeastDisplay } from "@/app/components/beast/BeastDisplay"; import useLoadingStore from "@/app/hooks/useLoadingStore"; @@ -171,7 +171,7 @@ export default function BeastScreen({ ); - const currentBlockNumber = blockData?.block_number ?? 0; + const currentBlockNumber = (blockData as Block)?.block_number ?? 0; const revealBlockReached = currentBlockNumber >= (adventurer?.revealBlock ?? 0); diff --git a/ui/src/app/containers/InventoryScreen.tsx b/ui/src/app/containers/InventoryScreen.tsx index ff7268ef9..b1a489735 100644 --- a/ui/src/app/containers/InventoryScreen.tsx +++ b/ui/src/app/containers/InventoryScreen.tsx @@ -101,7 +101,7 @@ export default function InventoryScreen({ const gameData = new GameData(); const checkTransacting = (item: string) => { - if (txData?.status == "RECEIVED") { + if (txData?.finality_status !== undefined) { return transactingItemIds?.includes(item); } else { return false; diff --git a/ui/src/app/containers/LeaderboardScreen.tsx b/ui/src/app/containers/LeaderboardScreen.tsx index 4962416bc..6df875e17 100644 --- a/ui/src/app/containers/LeaderboardScreen.tsx +++ b/ui/src/app/containers/LeaderboardScreen.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { Contract } from "starknet"; +import { Block, Contract } from "starknet"; import { useBlock } from "@starknet-react/core"; import { getAdventurerByXP, @@ -45,7 +45,7 @@ export default function LeaderboardScreen({ refetchInterval: false, }); - const currentBlock = blockData?.block_number; + const currentBlock = (blockData as Block)?.block_number; const { data, refetch, setData, setIsLoading, setNotLoading } = useQueriesStore(); diff --git a/ui/src/app/containers/TopUp.tsx b/ui/src/app/containers/TopUp.tsx index b09d9b034..c2e6b7bf8 100644 --- a/ui/src/app/containers/TopUp.tsx +++ b/ui/src/app/containers/TopUp.tsx @@ -20,8 +20,7 @@ import { AccountInterface, Contract, DeclareTransactionReceiptResponse, - RevertedTransactionReceiptResponse, - RejectedTransactionReceiptResponse, + GetTransactionReceiptResponse, } from "starknet"; import { ETH_PREFUND_AMOUNT } from "@/app/lib/burner"; import Eth from "public/icons/eth-2.svg"; @@ -77,8 +76,7 @@ interface SectionContentProps { ethAmount?: number | undefined ) => Promise< | DeclareTransactionReceiptResponse - | RevertedTransactionReceiptResponse - | RejectedTransactionReceiptResponse + | GetTransactionReceiptResponse | undefined >; isToppingUpEth: boolean; diff --git a/ui/src/app/lib/burner.ts b/ui/src/app/lib/burner.ts index 36498273e..4affc6bab 100644 --- a/ui/src/app/lib/burner.ts +++ b/ui/src/app/lib/burner.ts @@ -25,8 +25,7 @@ export const ETH_PREFUND_AMOUNT = isMainnet const rpc_addr = process.env.NEXT_PUBLIC_RPC_URL; const provider = new Provider({ - rpc: { nodeUrl: rpc_addr! }, - sequencer: { baseUrl: rpc_addr! }, + nodeUrl: rpc_addr!, }); interface UseBurnerProps { diff --git a/ui/src/app/lib/utils/syscalls.ts b/ui/src/app/lib/utils/syscalls.ts index 392338c21..f48aac3dd 100644 --- a/ui/src/app/lib/utils/syscalls.ts +++ b/ui/src/app/lib/utils/syscalls.ts @@ -3,7 +3,7 @@ import { InvokeTransactionReceiptResponse, Contract, AccountInterface, - RevertedTransactionReceiptResponse, + GetTransactionReceiptResponse, Provider, } from "starknet"; import { GameData } from "@/app/lib/data/GameData"; @@ -38,8 +38,7 @@ import { TRANSACTION_WAIT_RETRY_INTERVAL } from "@/app/lib/constants"; const rpc_addr = process.env.NEXT_PUBLIC_RPC_URL; const provider = new Provider({ - rpc: { nodeUrl: rpc_addr! }, - sequencer: { baseUrl: rpc_addr! }, + nodeUrl: rpc_addr!, }); export interface SyscallsProps { @@ -348,11 +347,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } // Here we need to process the StartGame event first and use the output for AmbushedByBeast event @@ -463,11 +462,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } const events = await parseEvents( @@ -733,11 +732,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } // reset battles by tx hash @@ -1001,11 +1000,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } // Add optimistic data @@ -1207,11 +1206,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } // Add optimistic data @@ -1359,11 +1358,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } const events = await parseEvents( @@ -1444,11 +1443,11 @@ export function syscalls({ }); // Handle if the tx was reverted if ( - (receipt as RevertedTransactionReceiptResponse).execution_status === + (receipt as GetTransactionReceiptResponse).execution_status === "REVERTED" ) { throw new Error( - (receipt as RevertedTransactionReceiptResponse).revert_reason + (receipt as GetTransactionReceiptResponse).revert_reason ); } const events = await parseEvents( diff --git a/ui/yarn.lock b/ui/yarn.lock index 5baa4d339..239d63de0 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1601,17 +1601,17 @@ "@stablelib/random" "^1.0.2" "@stablelib/wipe" "^1.0.1" -"@starknet-react/chains@^0.1.3": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@starknet-react/chains/-/chains-0.1.3.tgz#8e5d248f860b850b0b03e1059d6a4010d4801818" - integrity sha512-dSpLgDS02PmPzFVoW07EBVRbsX+h7MH7DYx2FF7vJv/J6eMGY7KtSupJW9R6ys0iADAxSg0UDcZr7syuy+b/Pg== +"@starknet-react/chains@^0.1.7": + version "0.1.7" + resolved "https://registry.yarnpkg.com/@starknet-react/chains/-/chains-0.1.7.tgz#58503379e2ffabe33b4f6e0f2aef775e84745a4d" + integrity sha512-UNh97I1SvuJKaAhKOmpEk8JcWuZWMlPG/ba2HcvFYL9x/47BKndJ+Da9V+iJFtkHUjreVnajT1snsaz1XMG+UQ== -"@starknet-react/core@^2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@starknet-react/core/-/core-2.1.5.tgz#a6a68f5223bd42190f3235e9737a66f47f4b3c07" - integrity sha512-lHBZMVFkz7XzyCy24Ca7/b55AkJU+alTD5520lBEbqYYOUAALdKCVp8+rlwPYv5Z8pkJzqRLoB//X6mTsky6Lw== +"@starknet-react/core@^2.5.0": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@starknet-react/core/-/core-2.5.0.tgz#77da3204f2207e3b4b25bfef40ee80df12651534" + integrity sha512-nH5Vf0oAeqn0+rerUpaAzgbd9z+sBKYZNk6pgFX2s1BNCuRGXyJDoVkQoouVeGKdJO2M8jyMDUVWQn9rE1dDqw== dependencies: - "@starknet-react/chains" "^0.1.3" + "@starknet-react/chains" "^0.1.7" "@tanstack/react-query" "^5.0.1" eventemitter3 "^5.0.1" immutable "^4.3.4" @@ -1729,17 +1729,17 @@ dependencies: tslib "^2.4.0" -"@tanstack/query-core@5.14.0": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.14.0.tgz#96a88030b7f104a37d42e549dd7453373ba7879f" - integrity sha512-OEri9fVDYT8XEqgh/dc6fFp1niyqu+MDY+Vp/LwU+scdk9xQLZ7KdUMEUh/sqTEjRM5BlFzAhAv+EIYcvSxt0Q== +"@tanstack/query-core@5.28.4": + version "5.28.4" + resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.28.4.tgz#fa416532f8b33ca8608d40bb9728b60e2e1a38dc" + integrity sha512-uQZqOFqLWUvXNIQZ63XdKzg22NtHzgCBUfDmjDHi3BoF+nUYeBNvMi/xFPtFrMhqRzG2Ir4mYaGsWZzmiEjXpA== "@tanstack/react-query@^5.0.1": - version "5.14.0" - resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.14.0.tgz#d2c79ee88f473cd859b9a7885d2f5c33ca3bd749" - integrity sha512-+qCooNZr7aGr6a0UEblfEgDSO1y+H7h7JnT4nUlbyfgCGE695lmBiqTciuW1C1Jr6J6Z2bwyd6YmBDKFKszWhA== + version "5.28.4" + resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.28.4.tgz#32e56ca4fd08513a906fe6323908f0e38ffccbba" + integrity sha512-BErcoB/QQG6YwLSUKnaGxF+lSc270RH2w3kMBpG0i4YzDCsFs2pdxPX1WVknQvFk9bNgukMb158hc2Zb4SdwSA== dependencies: - "@tanstack/query-core" "5.14.0" + "@tanstack/query-core" "5.28.4" "@trpc/client@^10.38.1": version "10.44.1" @@ -3705,9 +3705,9 @@ ignore@^5.2.0: integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== immutable@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.4.tgz#2e07b33837b4bb7662f288c244d1ced1ef65a78f" - integrity sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA== + version "4.3.5" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.5.tgz#f8b436e66d59f99760dc577f5c99a4fd2a5cc5a0" + integrity sha512-8eabxkth9gZatlwl5TBuJnCsoTADlL6ftEr7A4qgdaTsPyreilDSnUk57SO+jfKcNtxPa22U5KK6DSeAYhpBJw== import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.3.0"