From af891883417a99a76dae04138e0fb90acf991525 Mon Sep 17 00:00:00 2001 From: truemiller Date: Wed, 11 Sep 2024 15:46:28 +0100 Subject: [PATCH] chore: fix leftover `stakingProgram` references --- .../MainPage/header/AgentButton.tsx | 11 +++---- .../MainPage/modals/MigrationModal.tsx | 6 ++-- .../StakingContractSection/MigrateButton.tsx | 2 +- .../StakingContractSection/index.tsx | 2 +- .../components/ManageStakingPage/index.tsx | 30 +++++++++---------- frontend/service/Services.ts | 4 +-- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/frontend/components/MainPage/header/AgentButton.tsx b/frontend/components/MainPage/header/AgentButton.tsx index af139b538..06fd81b34 100644 --- a/frontend/components/MainPage/header/AgentButton.tsx +++ b/frontend/components/MainPage/header/AgentButton.tsx @@ -107,7 +107,8 @@ const AgentNotRunningButton = () => { } = useBalance(); const { storeState } = useStore(); const { isEligibleForStaking, isAgentEvicted } = useStakingContractInfo(); - const { activeStakingProgramId: activeStakingProgram, defaultStakingProgramId: defaultStakingProgram } = useStakingProgram(); + const { activeStakingProgramId, defaultStakingProgramId } = + useStakingProgram(); // const minStakingDeposit = // stakingContractInfoRecord?.[activeStakingProgram ?? defaultStakingProgram] @@ -115,7 +116,7 @@ const AgentNotRunningButton = () => { const requiredOlas = getMinimumStakedAmountRequired( serviceTemplate, - activeStakingProgram ?? defaultStakingProgram, + activeStakingProgramId ?? defaultStakingProgramId, ); const safeOlasBalance = safeBalance?.OLAS; @@ -154,7 +155,7 @@ const AgentNotRunningButton = () => { // Then create / deploy the service try { await ServicesService.createService({ - stakingProgramId: activeStakingProgram ?? defaultStakingProgram, // overwrite with StakingProgram.Alpha to test migration + stakingProgramId: activeStakingProgramId ?? defaultStakingProgramId, // overwrite with StakingProgram.Alpha to test migration serviceTemplate, deploy: true, }); @@ -187,8 +188,8 @@ const AgentNotRunningButton = () => { setServiceStatus, masterSafeAddress, showNotification, - activeStakingProgram, - defaultStakingProgram, + activeStakingProgramId, + defaultStakingProgramId, serviceTemplate, ]); diff --git a/frontend/components/MainPage/modals/MigrationModal.tsx b/frontend/components/MainPage/modals/MigrationModal.tsx index 4a999f7f4..026cbd203 100644 --- a/frontend/components/MainPage/modals/MigrationModal.tsx +++ b/frontend/components/MainPage/modals/MigrationModal.tsx @@ -12,15 +12,15 @@ export const MigrationSuccessModal = ({ open: boolean; onClose: () => void; }) => { - const { activeStakingProgramId: activeStakingProgram } = useStakingProgram(); + const { activeStakingProgramId } = useStakingProgram(); // Close modal if no active staking program, migration doesn't apply to non-stakers - if (!activeStakingProgram) { + if (!activeStakingProgramId) { onClose(); return null; } - const activeStakingProgramMeta = STAKING_PROGRAM_META[activeStakingProgram]; + const activeStakingProgramMeta = STAKING_PROGRAM_META[activeStakingProgramId]; return ( { goto(Pages.Main); await ServicesService.createService({ - stakingProgramId: stakingProgramId, + stakingProgramId, serviceTemplate, deploy: true, }); diff --git a/frontend/components/ManageStakingPage/StakingContractSection/index.tsx b/frontend/components/ManageStakingPage/StakingContractSection/index.tsx index 63a1f593e..d59b34f7f 100644 --- a/frontend/components/ManageStakingPage/StakingContractSection/index.tsx +++ b/frontend/components/ManageStakingPage/StakingContractSection/index.tsx @@ -22,7 +22,7 @@ const { useToken } = theme; type StakingContractSectionProps = { stakingProgramId: StakingProgramId }; export const StakingContractSection = ({ - stakingProgramId: stakingProgramId, + stakingProgramId, }: StakingContractSectionProps) => { const { activeStakingProgramId, defaultStakingProgramId } = useStakingProgram(); diff --git a/frontend/components/ManageStakingPage/index.tsx b/frontend/components/ManageStakingPage/index.tsx index 8a594acfc..404cbff5b 100644 --- a/frontend/components/ManageStakingPage/index.tsx +++ b/frontend/components/ManageStakingPage/index.tsx @@ -14,25 +14,25 @@ import { WhatAreStakingContractsSection } from './WhatAreStakingContracts'; export const ManageStakingPage = () => { const { goto } = usePageState(); - const { activeStakingProgramId: activeStakingProgram } = useStakingProgram(); + const { activeStakingProgramId } = useStakingProgram(); - const orderedStakingPrograms: StakingProgramId[] = Object.values( + const orderedStakingProgramIds: StakingProgramId[] = Object.values( StakingProgramId, - ).reduce((acc: StakingProgramId[], stakingProgram: StakingProgramId) => { + ).reduce((acc: StakingProgramId[], stakingProgramId: StakingProgramId) => { // put the active staking program at the top - if (stakingProgram === activeStakingProgram) { - return [stakingProgram, ...acc]; + if (stakingProgramId === activeStakingProgramId) { + return [stakingProgramId, ...acc]; } // otherwise, append to the end - return [...acc, stakingProgram]; + return [...acc, stakingProgramId]; }, []); - const otherStakingPrograms = orderedStakingPrograms.filter( - (stakingProgram) => { - const info = STAKING_PROGRAM_META[stakingProgram]; + const otherStakingProgramIds = orderedStakingProgramIds.filter( + (stakingProgramId) => { + const info = STAKING_PROGRAM_META[stakingProgramId]; if (!info) return false; - if (activeStakingProgram === stakingProgram) return false; + if (activeStakingProgramId === stakingProgramId) return false; if (info.deprecated) return false; return true; }, @@ -51,16 +51,16 @@ export const ManageStakingPage = () => { } > - + - {`Browse ${otherStakingPrograms.length} staking contract${otherStakingPrograms.length > 1 ? 's' : ''}.`} + {`Browse ${otherStakingProgramIds.length} staking contract${otherStakingProgramIds.length > 1 ? 's' : ''}.`} - {otherStakingPrograms.map((stakingProgram) => ( + {otherStakingProgramIds.map((stakingProgramId) => ( ))} diff --git a/frontend/service/Services.ts b/frontend/service/Services.ts index 2e277d3ef..be0a2c637 100644 --- a/frontend/service/Services.ts +++ b/frontend/service/Services.ts @@ -32,7 +32,7 @@ const getServices = async (): Promise => const createService = async ({ deploy, serviceTemplate, - stakingProgramId: stakingProgram, + stakingProgramId, }: { deploy: boolean; serviceTemplate: ServiceTemplate; @@ -47,7 +47,7 @@ const createService = async ({ configurations: { 100: { ...serviceTemplate.configurations[100], - staking_program_id: stakingProgram, + staking_program_id: stakingProgramId, rpc: `${process.env.GNOSIS_RPC}`, }, },