From 63f8b69c40006666cd6074350f97a0aa1008a63b Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Thu, 21 Nov 2024 09:48:03 -0500 Subject: [PATCH] refactor(renterd-libs): remove autopilots API --- .changeset/giant-seals-tickle.md | 7 +++++++ .changeset/light-games-unite.md | 7 +++++++ apps/renterd/contexts/config/transform.spec.ts | 5 +++++ apps/renterd/contexts/config/transformUp.ts | 2 ++ libs/renterd-js/src/bus.ts | 9 --------- libs/renterd-react/src/bus.ts | 14 -------------- libs/renterd-types/src/bus.ts | 8 -------- libs/renterd-types/src/types.ts | 7 +------ 8 files changed, 22 insertions(+), 37 deletions(-) create mode 100644 .changeset/giant-seals-tickle.md create mode 100644 .changeset/light-games-unite.md diff --git a/.changeset/giant-seals-tickle.md b/.changeset/giant-seals-tickle.md new file mode 100644 index 000000000..63951c642 --- /dev/null +++ b/.changeset/giant-seals-tickle.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Add enabled flag to autopilot config type. diff --git a/.changeset/light-games-unite.md b/.changeset/light-games-unite.md new file mode 100644 index 000000000..0ff046b5e --- /dev/null +++ b/.changeset/light-games-unite.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Removed autopilots API. diff --git a/apps/renterd/contexts/config/transform.spec.ts b/apps/renterd/contexts/config/transform.spec.ts index 2d86796c5..d833e68da 100644 --- a/apps/renterd/contexts/config/transform.spec.ts +++ b/apps/renterd/contexts/config/transform.spec.ts @@ -148,6 +148,7 @@ describe('tansforms', () => { undefined ) ).toEqual({ + enabled: true, hosts: { allowRedundantIPs: false, maxDowntimeHours: 1440, @@ -187,6 +188,7 @@ describe('tansforms', () => { }, { foobar1: 'value', + enabled: false, contracts: { foobar: 'value', period: 7777, @@ -199,6 +201,7 @@ describe('tansforms', () => { ) ).toEqual({ foobar1: 'value', + enabled: false, hosts: { foobar: 'value', allowRedundantIPs: false, @@ -247,6 +250,7 @@ describe('tansforms', () => { } as any ) ).toEqual({ + enabled: true, hosts: { allowRedundantIPs: false, maxDowntimeHours: 1440, @@ -536,6 +540,7 @@ function buildAllResponses() { startTime: new Date().getTime(), } as AutopilotState, autopilot: { + enabled: false, hosts: { allowRedundantIPs: false, maxDowntimeHours: 1440, diff --git a/apps/renterd/contexts/config/transformUp.ts b/apps/renterd/contexts/config/transformUp.ts index 429d898a7..11323de57 100644 --- a/apps/renterd/contexts/config/transformUp.ts +++ b/apps/renterd/contexts/config/transformUp.ts @@ -48,6 +48,8 @@ export function transformUpAutopilot( return { ...existingValues, + enabled: + existingValues?.enabled !== undefined ? existingValues.enabled : true, contracts: { ...existingValues?.contracts, amount: Math.round(v.amountHosts.toNumber()), diff --git a/libs/renterd-js/src/bus.ts b/libs/renterd-js/src/bus.ts index 1b39aef4e..0f5a65406 100644 --- a/libs/renterd-js/src/bus.ts +++ b/libs/renterd-js/src/bus.ts @@ -217,10 +217,6 @@ import { busWalletRedistributeRoute, busWalletRoute, busWalletSendRoute, - busAutopilotsRoute, - AutopilotsParams, - AutopilotsPayload, - AutopilotsResponse, busWalletEventsRoute, busObjectsPrefixRoute, SettingsGougingParams, @@ -272,11 +268,6 @@ export function Bus({ api, password }: { api: string; password?: string }) { BusStatePayload, BusStateResponse >(axios, 'get', busStateRoute), - autopilots: buildRequestHandler< - AutopilotsParams, - AutopilotsPayload, - AutopilotsResponse - >(axios, 'get', busAutopilotsRoute), consensusState: buildRequestHandler< ConsensusStateParams, ConsensusStatePayload, diff --git a/libs/renterd-react/src/bus.ts b/libs/renterd-react/src/bus.ts index 456e06aba..bf1bdcff5 100644 --- a/libs/renterd-react/src/bus.ts +++ b/libs/renterd-react/src/bus.ts @@ -210,9 +210,6 @@ import { WalletSendPayload, WalletSendResponse, busWalletSendRoute, - busAutopilotsRoute, - AutopilotsParams, - AutopilotsResponse, WalletEventsParams, WalletEventsResponse, busWalletEventsRoute, @@ -263,17 +260,6 @@ export function useBusState( }) } -// autopilots - -export function useAutopilots( - args?: HookArgsSwr -) { - return useGetSwr({ - ...args, - route: busAutopilotsRoute, - }) -} - // consensus export function useConsensusState( diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts index eda3bb93c..d888f5b88 100644 --- a/libs/renterd-types/src/bus.ts +++ b/libs/renterd-types/src/bus.ts @@ -11,7 +11,6 @@ import { WalletEvent, } from '@siafoundation/types' import { - Autopilot, ConsensusState, Contract, ContractRevision, @@ -26,7 +25,6 @@ import { } from './types' export const busStateRoute = '/bus/state' -export const busAutopilotsRoute = '/bus/autopilots' export const busConsensusNetworkRoute = '/bus/consensus/network' export const busConsensusStateRoute = '/bus/consensus/state' export const busConsensusAcceptblockRoute = '/bus/consensus/acceptblock' @@ -110,12 +108,6 @@ export type BusStateResponse = BuildState & { } } -// autopilots - -export type AutopilotsParams = void -export type AutopilotsPayload = void -export type AutopilotsResponse = Autopilot[] - // consensus export type ConsensusStateParams = void diff --git a/libs/renterd-types/src/types.ts b/libs/renterd-types/src/types.ts index df49e914a..feeb4b159 100644 --- a/libs/renterd-types/src/types.ts +++ b/libs/renterd-types/src/types.ts @@ -246,16 +246,11 @@ export type AutopilotContractsConfig = { } export type AutopilotConfig = { + enabled: boolean hosts: AutopilotHostsConfig contracts: AutopilotContractsConfig } -export type Autopilot = { - id: string - config: AutopilotConfig - currentPeriod: number -} - export type WalletTransaction = { raw: Transaction index: ChainIndex