From 076d4976434443d5103bc6f952edb4f5214a33da Mon Sep 17 00:00:00 2001 From: Tudor Morar Date: Mon, 15 Dec 2025 16:18:44 +0200 Subject: [PATCH 1/2] Upgrade devnet contract --- .../PingPongComponent/PingPongComponent.tsx | 9 ++++- src/config/config.devnet.ts | 2 +- src/contracts/ping-pong.abi.json | 39 +++++++++++++------ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/components/PingPongComponent/PingPongComponent.tsx b/src/components/PingPongComponent/PingPongComponent.tsx index 55e93b22..cfc70e11 100644 --- a/src/components/PingPongComponent/PingPongComponent.tsx +++ b/src/components/PingPongComponent/PingPongComponent.tsx @@ -76,7 +76,14 @@ export const PingPongComponent = ({ return; } - const secondsRemaining = await getTimeToPong(); + const msRemaining = await getTimeToPong(); + + // If backend now returns milliseconds, convert to whole seconds + const secondsRemaining = + msRemaining == null + ? msRemaining + : Math.max(0, Math.floor(msRemaining / 1000)); + const { canPing, timeRemaining } = setTimeRemaining(secondsRemaining); setHasPing(canPing); diff --git a/src/config/config.devnet.ts b/src/config/config.devnet.ts index 0982a343..d6914c38 100644 --- a/src/config/config.devnet.ts +++ b/src/config/config.devnet.ts @@ -4,6 +4,6 @@ export * from './sharedConfig'; export const API_URL = 'https://devnet-template-api.multiversx.com'; export const contractAddress = - 'erd1qqqqqqqqqqqqqpgqm6ad6xrsjvxlcdcffqe8w58trpec09ug9l5qde96pq'; + 'erd1qqqqqqqqqqqqqpgqg5aesu869nrjqw2fzq8ljj7wtsfd7cr7d8ss8zquav'; export const environment = EnvironmentsEnum.devnet; export const sampleAuthenticatedDomains = [API_URL]; diff --git a/src/contracts/ping-pong.abi.json b/src/contracts/ping-pong.abi.json index 804a17c4..426ecc64 100644 --- a/src/contracts/ping-pong.abi.json +++ b/src/contracts/ping-pong.abi.json @@ -1,20 +1,21 @@ { "buildInfo": { "rustc": { - "version": "1.61.0-nightly", - "commitHash": "1d9c262eea411ec5230f8a4c9ba50b3647064da4", - "commitDate": "2022-03-26", - "channel": "Nightly", - "short": "rustc 1.61.0-nightly (1d9c262ee 2022-03-26)" + "version": "1.91.1", + "commitHash": "ed61e7d7e242494fb7057f2657300d9e77bb4fcb", + "commitDate": "2025-11-07", + "channel": "Stable", + "host": "x86_64-unknown-linux-gnu", + "short": "rustc 1.91.1 (ed61e7d7e 2025-11-07)", + "llvmVersion": "21.1" }, "contractCrate": { "name": "ping-pong", - "version": "0.0.2", - "git_version": "23ff9bd" + "version": "0.0.2" }, "framework": { - "name": "elrond-wasm", - "version": "0.34.1" + "name": "multiversx-sc", + "version": "0.63.3" } }, "docs": [ @@ -31,7 +32,7 @@ "docs": [ "Necessary configuration when deploying:", "`ping_amount` - the exact amount that needs to be sent when `ping`-ing. ", - "`duration_in_seconds` - how much time (in seconds) until `pong` can be called after the initial `ping` call ", + "`duration_in_millis` - how much time (in milliseconds) until `pong` can be called after the initial `ping` call ", "`token_id` - Optional. The Token Identifier of the token that is going to be used. Default is \"EGLD\"." ], "inputs": [ @@ -40,7 +41,7 @@ "type": "BigUint" }, { - "name": "duration_in_seconds", + "name": "duration_in_millis", "type": "u64" }, { @@ -51,6 +52,19 @@ ], "outputs": [] }, + "upgradeConstructor": { + "inputs": [ + { + "name": "ping_amount", + "type": "BigUint" + }, + { + "name": "duration_in_millis", + "type": "u64" + } + ], + "outputs": [] + }, "endpoints": [ { "docs": [ @@ -176,6 +190,7 @@ ] } ], + "esdtAttributes": [], "hasCallback": false, - "types": [] + "types": {} } From d75d9e46a33db2814295dbcd7b2591fb24cc0fc5 Mon Sep 17 00:00:00 2001 From: Tudor Morar Date: Tue, 16 Dec 2025 11:52:01 +0200 Subject: [PATCH 2/2] Fixed different ping states on ABI --- .../PingPongComponent/PingPongComponent.tsx | 11 +++++++---- .../Dashboard/widgets/PingPongAbi/PingPongAbi.tsx | 2 +- .../widgets/PingPongService/helpers/getTimeToPong.ts | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/PingPongComponent/PingPongComponent.tsx b/src/components/PingPongComponent/PingPongComponent.tsx index cfc70e11..3f52e647 100644 --- a/src/components/PingPongComponent/PingPongComponent.tsx +++ b/src/components/PingPongComponent/PingPongComponent.tsx @@ -154,6 +154,9 @@ export const PingPongComponent = ({ return ; } + const isPingDisabled = !hasPing || hasPendingTransactions; + const isPongDisabled = !pongAllowed || hasPing || hasPendingTransactions; + return (
@@ -192,8 +195,8 @@ export const PingPongComponent = ({
{ + const pingAmount = useGetPingAmount(); const { sendPingTransactionFromAbi, sendPongTransactionFromAbi } = useSendPingPongTransaction(); - const pingAmount = useGetPingAmount(); const handlePingTransaction = async (payload: PingTransactionPayloadType) => { if (payload.amount) { diff --git a/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts b/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts index cd4e9317..b8bb168e 100644 --- a/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts +++ b/src/pages/Dashboard/widgets/PingPongService/helpers/getTimeToPong.ts @@ -11,9 +11,14 @@ export const getTimeToPong = async () => { } ); + if (data.timeToPong == null) { + // no timeToPong field → no cooldown + return 0; + } + return data.timeToPong; } catch (err) { console.error(err); - return null; + return 0; } };