denotify-client 1.1.9 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env ADDED
@@ -0,0 +1,9 @@
1
+ DISCORD_WEBHOOK=https://discord.com/api/webhooks/1063967722276388874/VrdsvfyCTEtnRIk5Vzhj1Y0Fi7pFueN5dH9Bz7OeXyNpwJUI7ucIzdIQwpOq8amVgCbW
2
+
3
+
4
+
5
+ PROJECT_ID=xfxplbmdcoukaitzxzei
6
+ ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhmeHBsYm1kY291a2FpdHp4emVpIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzgwMDg4NzMsImV4cCI6MTk5MzU4NDg3M30.WLk7bR5syQ4YJ8_jNOAuaT1UMvl7E2MS_VYMs7sN56c
7
+
8
+ EMAIL=s.battenally@gmail.com
9
+ PASSWORD=Password
package/.eslintignore ADDED
@@ -0,0 +1,8 @@
1
+ .history
2
+ .husky
3
+ .vscode
4
+ coverage
5
+ dist
6
+ node_modules
7
+ vite.config.ts
8
+ jest.config.ts
package/.eslintrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "plugins": ["@typescript-eslint", "prettier"],
5
+ "extends": [
6
+ "eslint:recommended",
7
+ "plugin:@typescript-eslint/eslint-recommended",
8
+ "plugin:@typescript-eslint/recommended",
9
+ "prettier"
10
+ ],
11
+ "env": {
12
+ "browser": true,
13
+ "node": true
14
+ },
15
+ "rules": {
16
+ "prettier/prettier": "error"
17
+ }
18
+ }
package/.lintstagedrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "./**/*.{ts,html,json}": "npm run format:scripts",
3
+ "./**/*.{css,scss}": "npm run format:styles"
4
+ }
@@ -0,0 +1,8 @@
1
+ .history
2
+ .husky
3
+ .vscode
4
+ coverage
5
+ dist
6
+ node_modules
7
+ vite.config.ts
8
+ jest.config.ts
package/.prettierrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "printWidth": 80,
3
+ "tabWidth": 2,
4
+ "singleQuote": false,
5
+ "trailingComma": "es5",
6
+ "arrowParens": "avoid",
7
+ "bracketSpacing": true,
8
+ "useTabs": false,
9
+ "endOfLine": "auto",
10
+ "singleAttributePerLine": false,
11
+ "bracketSameLine": false,
12
+ "jsxBracketSameLine": false,
13
+ "jsxSingleQuote": false,
14
+ "quoteProps": "as-needed",
15
+ "semi": true
16
+ }
@@ -0,0 +1,8 @@
1
+ .history
2
+ .husky
3
+ .vscode
4
+ coverage
5
+ dist
6
+ node_modules
7
+ vite.config.ts
8
+ jest.config.ts
package/.stylelintrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": [
3
+ "stylelint-config-recommended",
4
+ "stylelint-config-sass-guidelines"
5
+ ],
6
+ "overrides": [
7
+ {
8
+ "files": ["**/*.scss"],
9
+ "customSyntax": "postcss-scss"
10
+ }
11
+ ],
12
+ "rules": {
13
+ "function-parentheses-space-inside": null,
14
+ "no-descending-specificity": null,
15
+ "max-nesting-depth": 2,
16
+ "selector-max-id": 1
17
+ }
18
+ }
package/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,18 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2
+ const packageJson = require("./package.json");
3
+
4
+ const getPackageName = () => {
5
+ return packageJson.name;
6
+ };
7
+
8
+ const config = {
9
+ entries: [
10
+ {
11
+ filePath: "./src/index.ts",
12
+ outFile: `./dist/${getPackageName()}.d.ts`,
13
+ noCheck: false,
14
+ },
15
+ ],
16
+ };
17
+
18
+ module.exports = config;
package/favicon.svg ADDED
@@ -0,0 +1,15 @@
1
+ <svg width="410" height="404" viewBox="0 0 410 404" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z" fill="url(#paint0_linear)"/>
3
+ <path d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z" fill="url(#paint1_linear)"/>
4
+ <defs>
5
+ <linearGradient id="paint0_linear" x1="6.00017" y1="32.9999" x2="235" y2="344" gradientUnits="userSpaceOnUse">
6
+ <stop stop-color="#41D1FF"/>
7
+ <stop offset="1" stop-color="#BD34FE"/>
8
+ </linearGradient>
9
+ <linearGradient id="paint1_linear" x1="194.651" y1="8.81818" x2="236.076" y2="292.989" gradientUnits="userSpaceOnUse">
10
+ <stop stop-color="#FFEA83"/>
11
+ <stop offset="0.0833333" stop-color="#FFDD35"/>
12
+ <stop offset="1" stop-color="#FFA800"/>
13
+ </linearGradient>
14
+ </defs>
15
+ </svg>
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite App</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/index.ts"></script>
12
+ </body>
13
+ </html>
package/jest.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ testEnvironment: "node",
4
+ transform: {
5
+ "^.+\\.(ts|tsx)$": "ts-jest",
6
+ },
7
+ modulePathIgnorePatterns: ["./dist/", "./test/mocks.ts"],
8
+ coveragePathIgnorePatterns: ["./test/mocks.ts"],
9
+ };
package/package.json CHANGED
@@ -1,64 +1,53 @@
1
1
  {
2
- "version": "1.1.9",
3
- "name": "denotify-client",
4
- "umd:name": "denotify-client",
5
- "repository": "robo-labs/denotify-client",
6
- "description": "Client module for the Robo Labs DeNotify Crypto Alerts API",
7
- "unpkg": "dist/index.min.js",
8
- "module": "dist/index.mjs",
9
- "main": "dist/index.js",
10
- "types": "types/index.d.ts",
11
- "license": "MIT",
12
- "type": "module",
13
- "author": {
14
- "name": "Robo Labs",
15
- "email": "info@robolabs.biz",
16
- "url": "https://robolabs.biz"
17
- },
18
- "files": [
19
- "dist",
20
- "types"
21
- ],
22
- "exports": {
23
- ".": {
24
- "import": "./dist/index.mjs",
25
- "require": "./dist/index.js"
26
- },
27
- "./package.json": "./package.json"
28
- },
29
- "engines": {
30
- "node": ">=12"
31
- },
32
- "scripts": {
33
- "build": "rollup -c",
34
- "prepublishOnly": "npm run build",
35
- "types": "tsc --noEmit",
36
- "test": "uvu -r tsm test"
37
- },
38
- "keywords": [
39
- "crypto",
40
- "web3",
41
- "alerts",
42
- "ethereum",
43
- "module",
44
- "keywords"
45
- ],
46
- "devDependencies": {
47
- "@rollup/plugin-node-resolve": "13.1.3",
48
- "@supabase/supabase-js": "^2.10.0",
49
- "ethers": "^6.0.8",
50
- "rollup": "^2.66.1",
51
- "rollup-plugin-terser": "7.0.2",
52
- "rollup-plugin-typescript2": "0.27.1",
53
- "tsm": "2.2.1",
54
- "typescript": "^4.9.5",
55
- "uvu": "0.5.3",
56
- "dotenv": "^16.0.3"
57
- },
58
- "dependencies": {
59
- "@supabase/supabase-js": "^2.10.0",
60
- "ethers": "^6.0.8",
61
- "node-fetch": "^3.3.0",
62
- "yup": "^1.0.2"
63
- }
2
+ "name": "denotify-client",
3
+ "private": false,
4
+ "version": "1.1.11",
5
+ "main": "./dist/denotify-client.cjs",
6
+ "module": "./dist/denotify-client.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/denotify-client.cjs",
10
+ "import": "./dist/denotify-client.mjs"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "dev": "vite --host",
15
+ "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",
16
+ "test": "jest --runInBand",
17
+ "test:coverage": "jest --runInBand --coverage",
18
+ "lint:scripts": "eslint . --ext .ts",
19
+ "lint:styles": "stylelint ./**/*.{css,scss}",
20
+ "format:scripts": "prettier . --write",
21
+ "format:styles": "stylelint ./**/*.{css,scss} --fix",
22
+ "format": "npm run format:scripts && npm run format:styles",
23
+ "uninstall-husky": "npm uninstall husky --no-save && git config --unset core.hooksPath && npx rimraf .husky"
24
+ },
25
+ "devDependencies": {
26
+ "@types/jest": "^29.2.5",
27
+ "@types/jsdom": "^20.0.1",
28
+ "@types/node": "^18.11.18",
29
+ "@typescript-eslint/eslint-plugin": "^5.48.2",
30
+ "@typescript-eslint/parser": "^5.48.2",
31
+ "dts-bundle-generator": "^7.1.0",
32
+ "eslint": "^8.32.0",
33
+ "eslint-config-prettier": "^8.6.0",
34
+ "eslint-plugin-prettier": "^4.2.1",
35
+ "husky": "^8.0.3",
36
+ "jest": "^29.3.1",
37
+ "lint-staged": "^13.1.0",
38
+ "prettier": "^2.8.3",
39
+ "stylelint": "^14.16.1",
40
+ "stylelint-config-recommended": "^9.0.0",
41
+ "stylelint-config-sass-guidelines": "^9.0.1",
42
+ "ts-jest": "^29.0.5",
43
+ "ts-node": "^10.9.1",
44
+ "typescript": "^4.9.4",
45
+ "vite": "^4.0.4"
46
+ },
47
+ "dependencies": {
48
+ "@supabase/supabase-js": "^2.10.0",
49
+ "axios": "^1.3.4",
50
+ "ethers": "^6.1.0",
51
+ "yup": "^1.0.2"
52
+ }
64
53
  }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "./src",
4
+ "target": "ESNext",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "lib": ["ESNext", "DOM"],
8
+ "moduleResolution": "nodenext",
9
+ "strict": true,
10
+ "sourceMap": true,
11
+ "resolveJsonModule": true,
12
+ "esModuleInterop": true,
13
+ "noEmit": true,
14
+ "noUnusedLocals": true,
15
+ "noUnusedParameters": true,
16
+ "noImplicitReturns": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "types": ["vite/client", "node", "jest"]
19
+ },
20
+ "include": ["src"],
21
+ "exclude": ["**/*.test.ts", "node_modules", "test/**", ".history/**"]
22
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,35 @@
1
+ import path from "path";
2
+ import { defineConfig } from "vite";
3
+ import packageJson from "./package.json";
4
+
5
+ const getPackageName = () => {
6
+ return packageJson.name;
7
+ };
8
+
9
+ const getPackageNameCamelCase = () => {
10
+ try {
11
+ return getPackageName().replace(/-./g, (char) => char[1].toUpperCase());
12
+ } catch (err) {
13
+ throw new Error("Name property in package.json is missing.");
14
+ }
15
+ };
16
+
17
+ const fileName = {
18
+ es: `${getPackageName()}.mjs`,
19
+ cjs: `${getPackageName()}.cjs`,
20
+ iife: `${getPackageName()}.iife.js`,
21
+ };
22
+
23
+ const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
24
+
25
+ module.exports = defineConfig({
26
+ base: "./",
27
+ build: {
28
+ lib: {
29
+ entry: path.resolve(__dirname, "src/index.ts"),
30
+ name: getPackageNameCamelCase(),
31
+ formats,
32
+ fileName: (format) => fileName[format],
33
+ },
34
+ },
35
+ });
@@ -1,67 +0,0 @@
1
- import { NotifyDiscordWebhook } from "./notifications/notify_discord_webhook.js";
2
- import { HandlerFunctionCall } from "./triggers/handler_function_call.js";
3
- import { HandlerFunctionCallV2 } from "./triggers/handler_function_call_v2.js";
4
- import { HandlerOnchainEvent } from "./triggers/handler_onchain_event.js";
5
- export class AlertBuilder {
6
- name;
7
- network;
8
- triggerId;
9
- trigger;
10
- notificationId;
11
- notification;
12
- constructor(name) {
13
- this.name = name;
14
- }
15
- static create(name) {
16
- return new AlertBuilder(name);
17
- }
18
- onNetwork(network) {
19
- this.network = network;
20
- return this;
21
- }
22
- /**
23
- * Call withTrigger with one of the TriggerConfig types:
24
- * PollFunctionV2 | PollFunctionV1 | OnchainEventV1
25
- * @param id Simple ID
26
- * @param options Desired trigger configuration
27
- * @returns self for piping
28
- */
29
- withTrigger(id, options) {
30
- this.triggerId = id;
31
- this.trigger = options;
32
- return this;
33
- }
34
- withNotification(id, options) {
35
- this.notificationId = id;
36
- this.notification = options;
37
- return this;
38
- }
39
- async validate() {
40
- // Validate trigger
41
- switch (this.triggerId) {
42
- case 'OnchainEventV1': return HandlerOnchainEvent.validateCreate(this.trigger);
43
- case 'PollFunctionV1': return HandlerFunctionCall.validateCreate(this.trigger);
44
- case 'PollFunctionV2': return HandlerFunctionCallV2.validateCreate(this.trigger);
45
- }
46
- switch (this.notificationId) {
47
- case 'Discord': return NotifyDiscordWebhook.validateCreate(this.notification);
48
- }
49
- }
50
- async config() {
51
- if (this.trigger === undefined || this.triggerId === undefined)
52
- throw new Error('Trigger not configured');
53
- if (this.notification === undefined || this.notificationId === undefined)
54
- throw new Error('Notification not configured');
55
- if (this.network === undefined)
56
- throw new Error('Network not configured');
57
- await this.validate();
58
- return {
59
- name: this.name,
60
- network: this.network,
61
- triggerId: this.triggerId,
62
- trigger: this.trigger,
63
- notificationId: this.notificationId,
64
- notification: this.notification,
65
- };
66
- }
67
- }
@@ -1,125 +0,0 @@
1
- import { createClient } from "@supabase/supabase-js";
2
- import { Notification } from "./notifications/notification.js";
3
- import { Trigger } from "./triggers/trigger.js";
4
- import fetch from 'node-fetch';
5
- const toFunctionsUrl = (id) => {
6
- return `https://${id}.functions.supabase.co/`;
7
- };
8
- const toApiUrl = (id) => {
9
- return `https://${id}.supabase.co/`;
10
- };
11
- const PROD_PROJECT_ID = 'fdgtrxmmrtlokhgkvcjz';
12
- // const API_URL = ''
13
- const ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4';
14
- export class DeNotifyClient {
15
- url;
16
- token;
17
- headers = {};
18
- constructor(url, token) {
19
- this.url = url;
20
- this.token = token;
21
- this.headers = {
22
- 'Authorization': `Bearer ${token}`,
23
- 'Content-Type': 'application/json'
24
- };
25
- }
26
- static async create(options) {
27
- if (options.key) {
28
- // TODO
29
- throw new Error('Auth by key not yet supported');
30
- }
31
- else if (options.email && options.password) {
32
- const url = options.projectId ? toApiUrl(options.projectId) : toApiUrl(PROD_PROJECT_ID);
33
- const functionsUrl = options.projectId ? toFunctionsUrl(options.projectId) : toFunctionsUrl(PROD_PROJECT_ID);
34
- const anonKey = options.anonKey ? options.anonKey : ANON_KEY;
35
- const supabase = createClient(url, anonKey);
36
- const { data: login, error } = await supabase.auth.signInWithPassword({
37
- email: options.email,
38
- password: options.password,
39
- });
40
- if (error)
41
- throw error;
42
- if (login.session?.access_token === undefined)
43
- throw new Error('Access token not found');
44
- return new DeNotifyClient(functionsUrl, login.session?.access_token);
45
- }
46
- else {
47
- throw new Error('Authentication Required. DeNotify supports either username/password or API key authentication');
48
- }
49
- }
50
- async alertHistory(id, pagination) {
51
- const url = `alert-history`;
52
- const params = pagination ? pagination : {};
53
- if (id)
54
- params.id = id;
55
- if (Object.keys(params).length > 0) {
56
- return await this.request('get', url, { params: pagination });
57
- }
58
- else {
59
- return await this.request('get', url);
60
- }
61
- }
62
- // TODO - Beutify the reponse
63
- async getAlert(id) {
64
- const alerts = await this.request('get', `alerts/${id}`);
65
- return alerts[0];
66
- }
67
- async getAlerts() {
68
- const alerts = await this.request('get', 'alerts');
69
- return alerts;
70
- }
71
- async createAlert(config) {
72
- const trigger = Trigger.SimpleToRaw(config.name, config.triggerId, config.network, config.trigger);
73
- const notification = Notification.SimpleToRaw(config.notificationId, config.notification);
74
- const alert = await this.request('post', `alerts`, { body: { trigger, notification } });
75
- return alert;
76
- }
77
- async deleteAlert(id) {
78
- const alerts = await this.request('delete', `alerts/${id}`);
79
- return alerts;
80
- }
81
- async request(method, path, options = {}) {
82
- const url = new URL(`${this.url}${path}`);
83
- // append params
84
- if (options.params) {
85
- for (const param of Object.keys(options.params)) {
86
- url.searchParams.append(param, options.params[param]);
87
- }
88
- }
89
- const payload = {
90
- method,
91
- headers: this.headers
92
- };
93
- if (options.body)
94
- payload.body = JSON.stringify(options.body);
95
- const res = await fetch(url.toString(), payload);
96
- if (!res.ok)
97
- throw new Error(`unexpected response ${res.statusText}`);
98
- return await res.json();
99
- }
100
- async getAbi(network, address) {
101
- const ret = await this.request('get', `abi/${network}/${address}`);
102
- return ret;
103
- }
104
- async getAbiHash(abi) {
105
- const ret = await this.request('post', 'abi', { body: abi });
106
- return ret.hash;
107
- }
108
- async setAlertName(triggerId, name) {
109
- throw new Error('Not yet supported - Sorry!');
110
- }
111
- async enableAlert(triggerId) {
112
- throw new Error('Not yet supported - Sorry!');
113
- }
114
- async disableAlert(triggerId) {
115
- throw new Error('Not yet supported - Sorry!');
116
- }
117
- async updateNotification(triggerId) {
118
- throw new Error('Not yet supported - Sorry!');
119
- }
120
- async updateTrigger(triggerId, update) {
121
- // TODO - Input validation
122
- const ret = await this.request('patch', `alerts/trigger-handler/${triggerId}`, { body: update });
123
- return ret;
124
- }
125
- }
@@ -1,54 +0,0 @@
1
- import { AlertBuilder } from "../alertbuilder.js";
2
- import { DeNotifyClient } from "../denotifyclient.js";
3
- import { FunctionBuilder } from "../functionbuilder.js";
4
- import { FilterBuilder } from "../util/filter.js";
5
- import * as dotenv from 'dotenv';
6
- // Load config from .env file in root directory
7
- // See dotenv package for info
8
- dotenv.config();
9
- // Simple App to demonstrate usage. Created a balance monitoring alert, updates it and deletes it
10
- async function main() {
11
- const api = await DeNotifyClient.create({
12
- email: process.env.EMAIL,
13
- password: process.env.PASSWORD,
14
- anonKey: process.env.ANON_KEY,
15
- projectId: process.env.PROJECT_ID
16
- });
17
- const network = 'avalanche';
18
- const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538';
19
- const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87';
20
- const { abi } = await api.getAbi(network, address);
21
- const webhook = process.env.DISCORD_WEBHOOK;
22
- console.log(abi);
23
- const builder = FunctionBuilder.create(api);
24
- await builder.addFunction(address, 'getBalance', [myAddress], abi);
25
- // Create the Balance Monitor alert
26
- const alert = await AlertBuilder.create('Test Alert')
27
- .onNetwork('avalanche')
28
- .withTrigger('PollFunctionV2', {
29
- timeBase: 'time',
30
- timePeriod: '100s',
31
- functions: builder.get(),
32
- triggerOn: 'always',
33
- })
34
- .withNotification('Discord', {
35
- url: webhook,
36
- message: `Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})`,
37
- })
38
- .config();
39
- // Create the alert with the API
40
- const triggerId = await api.createAlert(alert);
41
- console.log(triggerId);
42
- // Update the period to every 10s
43
- await api.updateTrigger(triggerId, { timePeriod: '10s' });
44
- // Update the Filter using the filter builder
45
- const filter = FilterBuilder.new()
46
- .addCondition('WHERE', 'func_0_ret_0', 'Number', 'gt', 3)
47
- .finalise();
48
- await api.updateTrigger(13, { triggerOn: 'filter', filter, filterVersion: FilterBuilder.version() });
49
- // Delete the filter in 10s
50
- setTimeout(async () => {
51
- await api.deleteAlert(triggerId);
52
- }, 10 * 1000);
53
- }
54
- main();
@@ -1,11 +0,0 @@
1
- import { DeNotifyClient } from "../denotifyclient.js";
2
- // Simple App to demonstrate deleting an alert
3
- async function main() {
4
- const api = await DeNotifyClient.create({
5
- email: process.env.EMAIL,
6
- password: process.env.PASSWORD,
7
- });
8
- const alertId = 11;
9
- await api.deleteAlert(alertId);
10
- }
11
- main();
@@ -1,41 +0,0 @@
1
- import { ethers } from "ethers";
2
- import * as yup from 'yup';
3
- export class FunctionBuilder {
4
- api;
5
- data = [];
6
- constructor(api) {
7
- this.api = api;
8
- }
9
- static create(api) {
10
- return new FunctionBuilder(api);
11
- }
12
- getAbiHash(abi) {
13
- if (this.api === undefined)
14
- throw new Error('FunctionBuilder must be initialised with api');
15
- return this.api.getAbiHash(abi);
16
- }
17
- async addFunction(address, func, args, abi) {
18
- const contract = new ethers.Contract(address, abi);
19
- contract.interface.encodeFunctionData(func, args);
20
- const abiHash = await this.getAbiHash(abi);
21
- console.log(abiHash);
22
- this.data.push({
23
- address,
24
- bytecode: contract.interface.encodeFunctionData(func, args),
25
- abiHash,
26
- function: func,
27
- });
28
- return this;
29
- }
30
- get() {
31
- return this.data;
32
- }
33
- static schema() {
34
- return yup.array().of(yup.object({
35
- address: yup.string().required(),
36
- bytecode: yup.string().matches(/^(0x)?([0-9a-fA-F]{2})*$/).required(),
37
- abiHash: yup.string().matches(/^[A-Fa-f0-9]{64}/).required(),
38
- function: yup.string().required()
39
- }));
40
- }
41
- }