Skip to content

Commit

Permalink
refactor(renterd-libs): remove autopilots API
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Nov 22, 2024
1 parent bccea15 commit 63f8b69
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 37 deletions.
7 changes: 7 additions & 0 deletions .changeset/giant-seals-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Add enabled flag to autopilot config type.
7 changes: 7 additions & 0 deletions .changeset/light-games-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Removed autopilots API.
5 changes: 5 additions & 0 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ describe('tansforms', () => {
undefined
)
).toEqual({
enabled: true,
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
Expand Down Expand Up @@ -187,6 +188,7 @@ describe('tansforms', () => {
},
{
foobar1: 'value',
enabled: false,
contracts: {
foobar: 'value',
period: 7777,
Expand All @@ -199,6 +201,7 @@ describe('tansforms', () => {
)
).toEqual({
foobar1: 'value',
enabled: false,
hosts: {
foobar: 'value',
allowRedundantIPs: false,
Expand Down Expand Up @@ -247,6 +250,7 @@ describe('tansforms', () => {
} as any
)
).toEqual({
enabled: true,
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
Expand Down Expand Up @@ -536,6 +540,7 @@ function buildAllResponses() {
startTime: new Date().getTime(),
} as AutopilotState,
autopilot: {
enabled: false,
hosts: {
allowRedundantIPs: false,
maxDowntimeHours: 1440,
Expand Down
2 changes: 2 additions & 0 deletions apps/renterd/contexts/config/transformUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
9 changes: 0 additions & 9 deletions libs/renterd-js/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ import {
busWalletRedistributeRoute,
busWalletRoute,
busWalletSendRoute,
busAutopilotsRoute,
AutopilotsParams,
AutopilotsPayload,
AutopilotsResponse,
busWalletEventsRoute,
busObjectsPrefixRoute,
SettingsGougingParams,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions libs/renterd-react/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ import {
WalletSendPayload,
WalletSendResponse,
busWalletSendRoute,
busAutopilotsRoute,
AutopilotsParams,
AutopilotsResponse,
WalletEventsParams,
WalletEventsResponse,
busWalletEventsRoute,
Expand Down Expand Up @@ -263,17 +260,6 @@ export function useBusState(
})
}

// autopilots

export function useAutopilots(
args?: HookArgsSwr<AutopilotsParams, AutopilotsResponse>
) {
return useGetSwr({
...args,
route: busAutopilotsRoute,
})
}

// consensus

export function useConsensusState(
Expand Down
8 changes: 0 additions & 8 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
WalletEvent,
} from '@siafoundation/types'
import {
Autopilot,
ConsensusState,
Contract,
ContractRevision,
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions libs/renterd-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 63f8b69

Please sign in to comment.