Skip to content

Commit 4dd7dac

Browse files
committed
refactor(api): rename notification response structs
1 parent 4bb9d8f commit 4dd7dac

11 files changed

+120
-132
lines changed

backend/pkg/api/handlers/public.go

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

backend/pkg/api/types/notifications.go

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ type NotificationOverviewData struct {
2727
ClientsSubscriptionCount uint64 `db:"clients_subscription_count" json:"clients_subscription_count"`
2828
NetworksSubscriptionCount uint64 `db:"networks_subscription_count" json:"networks_subscription_count"`
2929
}
30-
31-
type InternalGetUserNotificationsResponse ApiDataResponse[NotificationOverviewData]
30+
type GetUserNotificationsResponse ApiDataResponse[NotificationOverviewData]
3231

3332
// ------------------------------------------------------------
3433
// Dashboards Table
@@ -43,8 +42,7 @@ type NotificationDashboardsTableRow struct {
4342
EntityCount uint64 `db:"entity_count" json:"entity_count"`
4443
EventTypes pq.StringArray `db:"event_types" json:"event_types" tstype:"('validator_online' | 'validator_offline' | 'group_efficiency_below' | 'attestation_missed' | 'proposal_success' | 'proposal_missed' | 'proposal_upcoming' | 'max_collateral' | 'min_collateral' | 'sync' | 'withdrawal' | 'validator_got_slashed' | 'validator_has_slashed' | 'incoming_tx' | 'outgoing_tx' | 'transfer_erc20' | 'transfer_erc721' | 'transfer_erc1155')[]" faker:"slice_len=2, oneof: validator_online, validator_offline, group_efficiency_below, attestation_missed, proposal_success, proposal_missed, proposal_upcoming, max_collateral, min_collateral, sync, withdrawal, validator_got_slashed, validator_has_slashed, incoming_tx, outgoing_tx, transfer_erc20, transfer_erc721, transfer_erc1155"`
4544
}
46-
47-
type InternalGetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow]
45+
type GetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow]
4846

4947
// ------------------------------------------------------------
5048
// Validator Dashboard Notification Detail
@@ -53,13 +51,11 @@ type NotificationEventValidatorBackOnline struct {
5351
Index uint64 `json:"index"`
5452
EpochCount uint64 `json:"epoch_count"`
5553
}
56-
5754
type NotificationEventWithdrawal struct {
5855
Index uint64 `json:"index"`
5956
Amount decimal.Decimal `json:"amount"`
6057
Address Address `json:"address"`
6158
}
62-
6359
type NotificationValidatorDashboardDetail struct {
6460
DashboardName string `db:"dashboard_name" json:"dashboard_name"`
6561
GroupName string `db:"group_name" json:"group_name"`
@@ -77,25 +73,22 @@ type NotificationValidatorDashboardDetail struct {
7773
MinCollateral []Address `json:"min_collateral"` // node addresses
7874
MaxCollateral []Address `json:"max_collateral"` // node addresses
7975
}
80-
81-
type InternalGetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail]
76+
type GetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail]
8277

8378
type NotificationEventExecution struct {
8479
Address Address `json:"address"`
8580
Amount decimal.Decimal `json:"amount"`
8681
TransactionHash Hash `json:"transaction_hash"`
8782
TokenName string `json:"token_name"` // this field will prob change depending on how execution stuff is implemented
8883
}
89-
9084
type NotificationAccountDashboardDetail struct {
9185
IncomingTransactions []NotificationEventExecution `json:"incoming_transactions"`
9286
OutgoingTransactions []NotificationEventExecution `json:"outgoing_transactions"`
9387
ERC20TokenTransfers []NotificationEventExecution `json:"erc20_token_transfers"`
9488
ERC721TokenTransfers []NotificationEventExecution `json:"erc721_token_transfers"`
9589
ERC1155TokenTransfers []NotificationEventExecution `json:"erc1155_token_transfers"`
9690
}
97-
98-
type InternalGetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail]
91+
type GetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail]
9992

10093
// ------------------------------------------------------------
10194
// Machines Table
@@ -105,8 +98,7 @@ type NotificationMachinesTableRow struct {
10598
EventType string `json:"event_type" tstype:"'offline' | 'storage' | 'cpu' | 'memory'" faker:"oneof: offline, storage, cpu, memory"`
10699
Timestamp int64 `json:"timestamp"`
107100
}
108-
109-
type InternalGetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow]
101+
type GetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow]
110102

111103
// ------------------------------------------------------------
112104
// Clients Table
@@ -116,8 +108,7 @@ type NotificationClientsTableRow struct {
116108
Url string `json:"url"`
117109
Timestamp int64 `json:"timestamp"`
118110
}
119-
120-
type InternalGetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow]
111+
type GetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow]
121112

122113
// ------------------------------------------------------------
123114
// Networks Table
@@ -127,8 +118,7 @@ type NotificationNetworksTableRow struct {
127118
EventType string `json:"event_type" tstype:"'new_reward_round' | 'gas_above' | 'gas_below' | 'participation_rate'" faker:"oneof: new_reward_round, gas_above, gas_below, participation_rate"`
128119
Threshold decimal.Decimal `json:"threshold,omitempty"` // participation rate threshold should also be passed as decimal string
129120
}
130-
131-
type InternalGetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow]
121+
type GetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow]
132122

133123
// ------------------------------------------------------------
134124
// Notification Settings
@@ -145,24 +135,23 @@ type NotificationNetwork struct {
145135
ChainId uint64 `json:"chain_id"`
146136
Settings NotificationSettingsNetwork `json:"settings"`
147137
}
148-
type InternalPutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork]
138+
type PutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork]
149139

150140
type NotificationPairedDevice struct {
151141
Id uint64 `json:"id"`
152142
PairedTimestamp int64 `json:"paired_timestamp"`
153143
Name string `json:"name,omitempty"`
154144
IsNotificationsEnabled bool `json:"is_notifications_enabled"`
155145
}
156-
type InternalPutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice]
146+
type PutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice]
157147

158148
type NotificationSettingsClient struct {
159149
Id uint64 `json:"id"`
160150
Name string `json:"name"`
161151
Category string `json:"category" tstype:"'execution_layer' | 'consensus_layer' | 'other'" faker:"oneof: execution_layer, consensus_layer, other"`
162152
IsSubscribed bool `json:"is_subscribed"`
163153
}
164-
165-
type InternalPutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient]
154+
type PutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient]
166155

167156
type NotificationSettingsGeneral struct {
168157
DoNotDisturbTimestamp int64 `json:"do_not_disturb_timestamp"` // notifications are disabled until this timestamp
@@ -178,15 +167,16 @@ type NotificationSettingsGeneral struct {
178167
IsMachineMemoryUsageSubscribed bool `json:"is_machine_memory_usage_subscribed"`
179168
MachineMemoryUsageThreshold float64 `json:"machine_memory_usage_threshold" faker:"boundary_start=0, boundary_end=1"`
180169
}
181-
type InternalPutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral]
170+
type PutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral]
171+
182172
type NotificationSettings struct {
183173
GeneralSettings NotificationSettingsGeneral `json:"general_settings"`
184174
HasMachines bool `json:"has_machines"`
185175
Networks []NotificationNetwork `json:"networks"`
186176
PairedDevices []NotificationPairedDevice `json:"paired_devices"`
187177
Clients []NotificationSettingsClient `json:"clients" faker:"slice_len=10"`
188178
}
189-
type InternalGetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings]
179+
type GetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings]
190180

191181
type NotificationSettingsValidatorDashboard struct {
192182
WebhookUrl string `json:"webhook_url" faker:"url"`
@@ -207,8 +197,7 @@ type NotificationSettingsValidatorDashboard struct {
207197
IsMinCollateralSubscribed bool `json:"is_min_collateral_subscribed"`
208198
MinCollateralThreshold float64 `json:"min_collateral_threshold" faker:"boundary_start=0, boundary_end=1"`
209199
}
210-
211-
type InternalPutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard]
200+
type PutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard]
212201

213202
type NotificationSettingsAccountDashboard struct {
214203
WebhookUrl string `json:"webhook_url" faker:"url"`
@@ -223,7 +212,7 @@ type NotificationSettingsAccountDashboard struct {
223212
IsERC721TokenTransfersSubscribed bool `json:"is_erc721_token_transfers_subscribed"`
224213
IsERC1155TokenTransfersSubscribed bool `json:"is_erc1155_token_transfers_subscribed"`
225214
}
226-
type InternalPutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard]
215+
type PutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard]
227216

228217
type NotificationSettingsDashboardsTableRow struct {
229218
IsAccountDashboard bool `json:"is_account_dashboard"` // if false it's a validator dashboard
@@ -235,5 +224,4 @@ type NotificationSettingsDashboardsTableRow struct {
235224
Settings interface{} `json:"settings" tstype:"NotificationSettingsAccountDashboard | NotificationSettingsValidatorDashboard" faker:"-"`
236225
ChainIds []uint64 `json:"chain_ids" faker:"chain_ids"`
237226
}
238-
239-
type InternalGetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow]
227+
type GetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow]

frontend/composables/notifications/useNotificationsManagementDashboards.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import type { TableQueryParams } from '~/types/datatable'
22

33
import type {
4-
InternalGetUserNotificationSettingsDashboardsResponse,
5-
InternalPutUserNotificationSettingsAccountDashboardResponse,
6-
InternalPutUserNotificationSettingsValidatorDashboardResponse,
4+
GetUserNotificationSettingsDashboardsResponse,
75
NotificationSettingsAccountDashboard,
86
NotificationSettingsDashboardsTableRow,
97
NotificationSettingsValidatorDashboard,
8+
PutUserNotificationSettingsAccountDashboardResponse,
9+
PutUserNotificationSettingsValidatorDashboardResponse,
1010
} from '~/types/api/notifications'
1111

1212
export function useNotificationsManagementDashboards() {
1313
const { fetch } = useCustomFetch()
1414
const { refreshOverview } = useNotificationsDashboardOverviewStore()
15-
const data = ref<InternalGetUserNotificationSettingsDashboardsResponse>()
15+
const data = ref<GetUserNotificationSettingsDashboardsResponse>()
1616
const {
1717
cursor,
1818
isStoredQuery,
@@ -36,7 +36,7 @@ export function useNotificationsManagementDashboards() {
3636
isLoading.value = true
3737
setStoredQuery(q)
3838
const res
39-
= await fetch<InternalGetUserNotificationSettingsDashboardsResponse>(
39+
= await fetch<GetUserNotificationSettingsDashboardsResponse>(
4040
'GET_NOTIFICATIONS_SETTINGS_DASHBOARD',
4141
undefined,
4242
undefined,
@@ -72,30 +72,30 @@ export function useNotificationsManagementDashboards() {
7272
settings.webhook_url = ''
7373
settings.is_webhook_discord_enabled = false
7474
if (is_account_dashboard) {
75-
const accountDashboarSettings = settings as NotificationSettingsAccountDashboard
76-
accountDashboarSettings.erc20_token_transfers_value_threshold = 0
77-
accountDashboarSettings.is_erc1155_token_transfers_subscribed = false
78-
accountDashboarSettings.is_erc20_token_transfers_subscribed = false
79-
accountDashboarSettings.is_erc721_token_transfers_subscribed = false
80-
accountDashboarSettings.is_ignore_spam_transactions_enabled = false
81-
accountDashboarSettings.is_incoming_transactions_subscribed = false
82-
accountDashboarSettings.is_outgoing_transactions_subscribed = false
75+
const accountDashboardSettings = settings as NotificationSettingsAccountDashboard
76+
accountDashboardSettings.erc20_token_transfers_value_threshold = 0
77+
accountDashboardSettings.is_erc1155_token_transfers_subscribed = false
78+
accountDashboardSettings.is_erc20_token_transfers_subscribed = false
79+
accountDashboardSettings.is_erc721_token_transfers_subscribed = false
80+
accountDashboardSettings.is_ignore_spam_transactions_enabled = false
81+
accountDashboardSettings.is_incoming_transactions_subscribed = false
82+
accountDashboardSettings.is_outgoing_transactions_subscribed = false
8383
return
8484
}
85-
const accountDashboarSettings = settings as NotificationSettingsValidatorDashboard
86-
accountDashboarSettings.group_efficiency_below_threshold = 0
87-
accountDashboarSettings.is_attestations_missed_subscribed = false
88-
accountDashboarSettings.is_block_proposal_subscribed = false
89-
accountDashboarSettings.is_group_efficiency_below_subscribed = false
90-
accountDashboarSettings.is_max_collateral_subscribed = false
91-
accountDashboarSettings.is_min_collateral_subscribed = false
92-
accountDashboarSettings.is_slashed_subscribed = false
93-
accountDashboarSettings.is_sync_subscribed = false
94-
accountDashboarSettings.is_upcoming_block_proposal_subscribed = false
95-
accountDashboarSettings.is_validator_offline_subscribed = false
96-
accountDashboarSettings.is_withdrawal_processed_subscribed = false
97-
accountDashboarSettings.max_collateral_threshold = 0
98-
accountDashboarSettings.min_collateral_threshold = 0
85+
const accountDashboardSettings = settings as NotificationSettingsValidatorDashboard
86+
accountDashboardSettings.group_efficiency_below_threshold = 0
87+
accountDashboardSettings.is_attestations_missed_subscribed = false
88+
accountDashboardSettings.is_block_proposal_subscribed = false
89+
accountDashboardSettings.is_group_efficiency_below_subscribed = false
90+
accountDashboardSettings.is_max_collateral_subscribed = false
91+
accountDashboardSettings.is_min_collateral_subscribed = false
92+
accountDashboardSettings.is_slashed_subscribed = false
93+
accountDashboardSettings.is_sync_subscribed = false
94+
accountDashboardSettings.is_upcoming_block_proposal_subscribed = false
95+
accountDashboardSettings.is_validator_offline_subscribed = false
96+
accountDashboardSettings.is_withdrawal_processed_subscribed = false
97+
accountDashboardSettings.max_collateral_threshold = 0
98+
accountDashboardSettings.min_collateral_threshold = 0
9999
}
100100
const deleteDashboardNotifications = async (
101101
{
@@ -117,7 +117,7 @@ export function useNotificationsManagementDashboards() {
117117
settings,
118118
})
119119
if (is_account_dashboard) {
120-
return await fetch<InternalPutUserNotificationSettingsAccountDashboardResponse>(
120+
return await fetch<PutUserNotificationSettingsAccountDashboardResponse>(
121121
'NOTIFICATIONS_MANAGEMENT_DASHBOARD_ACCOUNT_SET_NOTIFICATION',
122122
{
123123
body: settings,
@@ -128,7 +128,7 @@ export function useNotificationsManagementDashboards() {
128128
},
129129
)
130130
}
131-
return await fetch<InternalPutUserNotificationSettingsValidatorDashboardResponse>(
131+
return await fetch<PutUserNotificationSettingsValidatorDashboardResponse>(
132132
'NOTIFICATIONS_MANAGEMENT_DASHBOARD_VALIDATOR_SET_NOTIFICATION',
133133
{
134134
body: settings,
@@ -173,7 +173,7 @@ export function useNotificationsManagementDashboards() {
173173
settings: NotificationSettingsValidatorDashboard,
174174
},
175175
) {
176-
await fetch<InternalPutUserNotificationSettingsValidatorDashboardResponse>(
176+
await fetch<PutUserNotificationSettingsValidatorDashboardResponse>(
177177
'SAVE_VALIDATOR_DASHBOARDS_SETTINGS',
178178
{
179179
body: {

frontend/stores/notifications/useNotificationsClientsStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationClientsResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationClientsResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55

66
const notificationsClientStore = defineStore('notifications-clients-store', () => {
7-
const data = ref<InternalGetUserNotificationClientsResponse | undefined>()
7+
const data = ref<GetUserNotificationClientsResponse | undefined>()
88
return { data }
99
})
1010

@@ -24,7 +24,7 @@ export function useNotificationsClientStore() {
2424
isLoading.value = true
2525
setStoredQuery(q)
2626
try {
27-
const result = await fetch<InternalGetUserNotificationClientsResponse>(
27+
const result = await fetch<GetUserNotificationClientsResponse>(
2828
'NOTIFICATIONS_CLIENTS',
2929
undefined,
3030
undefined,

frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
InternalGetUserNotificationsValidatorDashboardResponse,
2+
GetUserNotificationsValidatorDashboardResponse,
33
NotificationDashboardsTableRow, NotificationValidatorDashboardDetail,
44
} from '~/types/api/notifications'
55

@@ -18,7 +18,7 @@ export const useNotificationsDashboardDetailsStore = defineStore('notifications-
1818
search?: string,
1919
},
2020
) => {
21-
return fetch<InternalGetUserNotificationsValidatorDashboardResponse>(
21+
return fetch<GetUserNotificationsValidatorDashboardResponse>(
2222
'NOTIFICATIONS_DASHBOARDS_DETAILS_VALIDATOR',
2323
{
2424
query: {

frontend/stores/notifications/useNotificationsDashboardStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationDashboardsResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationDashboardsResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55
import type { ChainIDs } from '~/types/network'
66

77
const notificationsDashboardStore = defineStore(
88
'notifications-dashboard-store',
99
() => {
10-
const data = ref<InternalGetUserNotificationDashboardsResponse | undefined>()
10+
const data = ref<GetUserNotificationDashboardsResponse | undefined>()
1111
return { data }
1212
},
1313
)
@@ -38,7 +38,7 @@ export function useNotificationsDashboardStore(networkId: globalThis.Ref<ChainID
3838
isLoading.value = true
3939
setStoredQuery(q)
4040
try {
41-
const result = await fetch<InternalGetUserNotificationDashboardsResponse>(
41+
const result = await fetch<GetUserNotificationDashboardsResponse>(
4242
'NOTIFICATIONS_DASHBOARDS',
4343
{ query: { networks: networkId.value } },
4444
undefined,

frontend/stores/notifications/useNotificationsMachineStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationMachinesResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationMachinesResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55

66
const notificationsMachineStore = defineStore('notifications-network-store', () => {
7-
const data = ref<InternalGetUserNotificationMachinesResponse | undefined>()
7+
const data = ref<GetUserNotificationMachinesResponse | undefined>()
88
return { data }
99
})
1010

@@ -24,7 +24,7 @@ export function useNotificationsMachineStore() {
2424
isLoading.value = true
2525
setStoredQuery(q)
2626
try {
27-
const result = await fetch<InternalGetUserNotificationMachinesResponse>(
27+
const result = await fetch<GetUserNotificationMachinesResponse>(
2828
'NOTIFICATIONS_MACHINE',
2929
undefined,
3030
undefined,

0 commit comments

Comments
 (0)