diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6e15d9b4..8f97d1c9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -90,11 +90,6 @@ updates: schedule: interval: daily - - package-ecosystem: npm - directory: /examples/update-notification-category - schedule: - interval: daily - - package-ecosystem: npm directory: /examples/update-relayer schedule: diff --git a/examples/create-monitor/index.js b/examples/create-monitor/index.js index 24aadc9d..73bf5c83 100644 --- a/examples/create-monitor/index.js +++ b/examples/create-monitor/index.js @@ -58,6 +58,8 @@ async function main() { // optional alertTimeoutMs: 0, notificationChannels: [notification.notificationId], + // optional (LOW, MEDIUM, HIGH) + severityLevel: 'LOW', // optional riskCategory: 'TECHNICAL', }; diff --git a/examples/update-monitor/index.js b/examples/update-monitor/index.js index 0fc75996..76951f91 100644 --- a/examples/update-monitor/index.js +++ b/examples/update-monitor/index.js @@ -61,6 +61,8 @@ async function main() { // optional alertTimeoutMs: 0, notificationChannels: [notification.notificationId], + // optional (LOW, MEDIUM, HIGH) + severityLevel: 'MEDIUM', // optional riskCategory: 'TECHNICAL', }; diff --git a/examples/update-notification-category/CHANGELOG.md b/examples/update-notification-category/CHANGELOG.md deleted file mode 100644 index d8d68e37..00000000 --- a/examples/update-notification-category/CHANGELOG.md +++ /dev/null @@ -1,201 +0,0 @@ -# @openzeppelin/defender-sdk-example-update-notification-category - -## 1.11.0 - -### Minor Changes - -- 49c1994: refactor: Deprecate optimism-goerli network - chore: Enable zkEVM networks - chore: Upgrade npm packages - -### Patch Changes - -- Updated dependencies [49c1994] - - @openzeppelin/defender-sdk@1.11.0 - -## 1.10.0 - -### Minor Changes - -- 7e14499: fix: Add missing dependencies for cli tool to manage actions. - fix: Add confirmation property to tx override. - refactor: Remove deprecated config resources - -### Patch Changes - -- Updated dependencies [7e14499] - - @openzeppelin/defender-sdk@1.10.0 - -## 1.9.0 - -### Minor Changes - -- ed29a58: - chore: Autotask & actions condition names. - - feat: Add Web3 & list contract examples. - - feat: Add support to Zksync sepolia. - - feat: Upgrade dependencies. - -### Patch Changes - -- Updated dependencies [ed29a58] - - @openzeppelin/defender-sdk@1.9.0 - -## 1.8.0 - -### Minor Changes - -- 688e4de: chore: Remove all non-required attributes from artifact - feat: Add new private network endpoints - feat: Add abi configuration for listing contracts - chore: Add missing artifact attributes - chore: Rename simulation transaction type - chore: Add txOverrides parameter - -### Patch Changes - -- Updated dependencies [688e4de] - - @openzeppelin/defender-sdk@1.8.0 - -## 1.7.0 - -### Minor Changes - -- 97d593c: Feat: Add support to Base Sepolia & Optimism Sepolia networks. - Feat: Add support to ethers v6 - -### Patch Changes - -- Updated dependencies [97d593c] - - @openzeppelin/defender-sdk@1.7.0 - -## 1.6.0 - -### Minor Changes - -- 9583851: Feat: Support Arbitrum sepolia - -### Patch Changes - -- Updated dependencies [9583851] - - @openzeppelin/defender-sdk@1.6.0 - -## 1.5.0 - -### Minor Changes - -- 29be958: feat: add environment variable endpoints to actions - feat: add meld network - -### Patch Changes - -- Updated dependencies [29be958] - - @openzeppelin/defender-sdk@1.5.0 - -## 1.4.0 - -### Minor Changes - -- c538fb7: - feat: Add support to scroll mainnet - - feat: Added missing actions utilities - - chore: Bump platform SDK dependencies - -### Patch Changes - -- Updated dependencies [c538fb7] - - @openzeppelin/defender-sdk@1.4.0 - -## 1.3.0 - -### Minor Changes - -- 001029a: - feat: add scroll sepolia network - - feat: enforce base package to build first - - feat: export created types - - feat: changed sentinel attribute by monitor - -### Patch Changes - -- Updated dependencies [001029a] - - @openzeppelin/defender-sdk@1.3.0 - -## 1.2.0 - -### Minor Changes - -- 37edbc7: - feat: forked networks support - - feat: network client - - ci: security updates - - fix: actions example - -### Patch Changes - -- Updated dependencies [37edbc7] - - @openzeppelin/defender-sdk@1.2.0 - -## 1.1.0 - -### Minor Changes - -- 0851ae2: - Fix: Create relayer key bug - - Fix: Notification client typo - - Fix: Patch security vulnerabilities - -### Patch Changes - -- Updated dependencies [0851ae2] - - @openzeppelin/defender-sdk@1.1.0 - -## 1.0.0 - -### Major Changes - -- 8711a12: - Migrate platform-sdk to defender-sdk - -### Patch Changes - -- Updated dependencies [8711a12] - - @openzeppelin/defender-sdk@1.0.0 - -## 0.3.0 - -### Minor Changes - -- be73034: Feat: Support linea & base - -### Patch Changes - -- Updated dependencies [be73034] - - @openzeppelin/platform-sdk@0.4.0 - -## 0.2.2 - -### Patch Changes - -- Updated dependencies [3c336b7] - - @openzeppelin/platform-sdk@0.3.1 - -## 0.2.1 - -### Patch Changes - -- Updated dependencies [efefd68] - - @openzeppelin/defender-sdk@0.3.0 - -## 0.2.0 - -### Minor Changes - -- 496f88d: ### CHANGES - - - feat: list network endpoints - - ci: fix ci bugs - - fix: type with actionId - - feat: add support to base mainnet - - feat: add `skipABIValidation` flag to monitor create request - - ci: add changeset actions - - ci: remove provenance - -### Patch Changes - -- Updated dependencies [496f88d] - - @openzeppelin/defender-sdk@0.2.0 diff --git a/examples/update-notification-category/index.js b/examples/update-notification-category/index.js deleted file mode 100644 index 659d71ec..00000000 --- a/examples/update-notification-category/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -require('dotenv').config(); - -const { Defender } = require('@openzeppelin/defender-sdk'); - -async function main() { - const creds = { apiKey: process.env.API_KEY, apiSecret: process.env.API_SECRET }; - const client = new Defender(creds); - - let notification; - // use an existing notification channel - const notificationChannels = await client.notificationChannel.list(); - if (notificationChannels.length > 0) { - // Select your desired notification channel - notification = notificationChannels[0]; - } else { - // OR create a new notification channel - notification = await client.notificationChannel.create({ - type: 'email', - name: 'MyEmailNotification', - config: { - emails: ['john@example.com'], - }, - paused: false, - }); - } - - const getExistingCategory = (await client.monitor.listNotificationCategories())[0]; - - const category = { - ...getExistingCategory, - description: 'Attach this category to high-risk monitors', - notificationIds: [{ notificationId: notification.notificationId, type: notification.type }], - }; - // call update with the request parameters - const response = await client.monitor.updateNotificationCategory(getExistingCategory.categoryId, category); - console.log(response); -} - -if (require.main === module) { - main().catch(console.error); -} diff --git a/examples/update-notification-category/package.json b/examples/update-notification-category/package.json deleted file mode 100644 index c119b0cf..00000000 --- a/examples/update-notification-category/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@openzeppelin/defender-sdk-example-update-notification-category", - "version": "1.11.0", - "private": true, - "main": "index.js", - "author": "Nami Shah ", - "license": "MIT", - "scripts": { - "start": "node index.js" - }, - "dependencies": { - "@openzeppelin/defender-sdk": "1.11.0", - "dotenv": "^16.3.1" - } -} diff --git a/packages/monitor/src/api/index.ts b/packages/monitor/src/api/index.ts index e7ed2779..52c29ece 100644 --- a/packages/monitor/src/api/index.ts +++ b/packages/monitor/src/api/index.ts @@ -17,10 +17,6 @@ import { BlockWatcher } from '../models/blockwatcher'; import _ from 'lodash'; import getConditionSets, { getMonitorConditions } from '../utils'; -import { - NotificationCategory as NotificationCategoryResponse, - UpdateNotificationCategoryRequest, -} from '../models/category'; import { NotificationResponse } from '..'; import { CreateNotificationRequest, NotificationType, UpdateNotificationRequest } from '../models/notification'; @@ -83,27 +79,6 @@ export class MonitorClient extends BaseApiClient { }); } - public async listNotificationCategories(): Promise { - return this.apiCall(async (api) => { - return await api.get(`/notifications/categories`); - }); - } - - public async getNotificationCategory(id: string): Promise { - return this.apiCall(async (api) => { - return await api.get(`/notifications/categories/${id}`); - }); - } - - public async updateNotificationCategory( - id: string, - params: UpdateNotificationCategoryRequest, - ): Promise { - return this.apiCall(async (api) => { - return await api.put(`/notifications/categories/${id}`, params); - }); - } - // TODO: should this be part of public API? public async listBlockwatchers(): Promise { return this.apiCall(async (api) => { @@ -286,7 +261,7 @@ export class MonitorClient extends BaseApiClient { alertThreshold: monitor.alertThreshold, notifyConfig: { notifications: notificationChannels, - notificationCategoryId: _.isEmpty(notificationChannels) ? monitor.notificationCategoryId : undefined, + severityLevel: monitor.severityLevel, actionId: monitor.actionTrigger ? monitor.actionTrigger : undefined, timeoutMs: monitor.alertTimeoutMs ? monitor.alertTimeoutMs : 0, messageBody: monitor.alertMessageBody ? monitor.alertMessageBody : undefined, @@ -328,7 +303,7 @@ export class MonitorClient extends BaseApiClient { alertMessageSubject: monitor.notifyConfig?.messageSubject, alertMessageBody: monitor.notifyConfig?.messageBody, notificationChannels: monitor.notifyConfig?.notifications?.map(({ notificationId }) => notificationId) ?? [], - notificationCategoryId: monitor.notifyConfig?.notificationCategoryId, + severityLevel: monitor.notifyConfig?.severityLevel, network: monitor.network, confirmLevel: parseInt(_.last(monitor.blockWatcherId.split('-')) as string), // We're sure there is always a last number if the convention is followd }; @@ -346,7 +321,7 @@ export class MonitorClient extends BaseApiClient { alertMessageSubject: monitor.notifyConfig?.messageSubject, alertMessageBody: monitor.notifyConfig?.messageBody, notificationChannels: monitor.notifyConfig?.notifications?.map(({ notificationId }) => notificationId) ?? [], - notificationCategoryId: monitor.notifyConfig?.notificationCategoryId, + severityLevel: monitor.notifyConfig?.severityLevel, network: monitor.network, fortaLastProcessedTime: monitor.fortaLastProcessedTime, addresses: monitor.fortaRule.addresses, diff --git a/packages/monitor/src/models/category.ts b/packages/monitor/src/models/category.ts deleted file mode 100644 index 7e1182d7..00000000 --- a/packages/monitor/src/models/category.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { NotificationType } from './notification'; - -// copied from /models/src/types/notification-category.req.d.ts -export interface SaveNotificationCategoryRequest { - name: string; - description?: string; - /** - * @maxItems 2 - */ - notificationIds: [] | [NotificationReference] | [NotificationReference, NotificationReference]; - stackResourceId?: string; -} - -// copied from /models/src/types/notification-category.res.d.ts -export interface NotificationCategory { - categoryId: string; - name: string; - description?: string; - /** - * @maxItems 2 - */ - notificationIds?: [] | [NotificationReference] | [NotificationReference, NotificationReference]; - stackResourceId?: string; -} -export interface NotificationReference { - notificationId: string; - type: NotificationType; - sendCount?: number; - [k: string]: unknown; -} - -export type UpdateNotificationCategoryRequest = NotificationCategory; -export type CreateNotificationCategoryRequest = SaveNotificationCategoryRequest; diff --git a/packages/monitor/src/models/monitor.ts b/packages/monitor/src/models/monitor.ts index f1c4b59b..060df0e4 100644 --- a/packages/monitor/src/models/monitor.ts +++ b/packages/monitor/src/models/monitor.ts @@ -5,6 +5,8 @@ export type ExternalUpdateMonitorRequest = ExternalUpdateBlockMonitorRequest | E export interface ExternalBaseCreateMonitorRequest { name: string; addresses?: string[]; + type: 'FORTA' | 'BLOCK'; + notificationChannels: string[]; abi?: string; paused?: boolean; alertThreshold?: Threshold; @@ -13,9 +15,7 @@ export interface ExternalBaseCreateMonitorRequest { alertTimeoutMs?: number; alertMessageBody?: string; alertMessageSubject?: string; - notificationChannels: string[]; - notificationCategoryId?: string; - type: 'FORTA' | 'BLOCK'; + severityLevel?: NotificationSeverityLevel; riskCategory?: MonitorRiskCategory; stackResourceId?: string; } @@ -128,6 +128,7 @@ export enum MonitorType { } export type MonitorRiskCategory = 'NONE' | 'GOVERNANCE' | 'ACCESS-CONTROL' | 'SUSPICIOUS' | 'FINANCIAL' | 'TECHNICAL'; +export type NotificationSeverityLevel = 'LOW' | 'MEDIUM' | 'HIGH'; export type Address = string; export interface AddressRule { @@ -162,7 +163,7 @@ export interface Threshold { } export interface Notifications { notifications: NotificationReference[]; - notificationCategoryId?: string; + severityLevel?: NotificationSeverityLevel; actionId?: string; messageBody?: string; messageSubject?: string; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16c47984..39b5651a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -268,15 +268,6 @@ importers: specifier: ^16.3.1 version: 16.3.1 - examples/update-notification-category: - dependencies: - '@openzeppelin/defender-sdk': - specifier: 1.11.0 - version: link:../../packages/defender-sdk - dotenv: - specifier: ^16.3.1 - version: 16.3.1 - examples/update-relayer: dependencies: '@openzeppelin/defender-sdk':