denotify-client 1.1.6 → 1.1.7

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.
@@ -1,57 +1,47 @@
1
+ import { AlertBuilder } from "../alertbuilder.js";
1
2
  import { DeNotifyClient } from "../denotifyclient.js";
3
+ import { FunctionBuilder } from "../functionbuilder.js";
4
+ import { FilterBuilder } from "../util/filter.js";
2
5
  // Simple App to demonstrate usage. Created a balance monitoring alert, updates it and deletes it
3
6
  async function main() {
4
7
  const api = await DeNotifyClient.create({
5
- email: 's.battenally@gmail.com',
6
- password: 'Password',
8
+ email: process.env.EMAIL,
9
+ password: process.env.PASSWORD,
7
10
  });
8
- // const alerts = await api.getAlerts()
9
- const size = 100;
10
- let page = 1;
11
- let len = size;
12
- while (len === size) {
13
- console.log(`fetching page: ${page}, size: ${size}, id: ${123}`);
14
- const ret = await api.alertHistory(123, { page, size });
15
- console.log('success!');
16
- console.log('length:', ret.history.length);
17
- len = ret.history.length;
18
- page++;
19
- }
20
- // const network = 'avalanche'
21
- // const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538'
22
- // const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87'
23
- // const { abi } = await api.getAbi(network, address)
24
- // const webhook = process.env.DISCORD_WEBHOOK as string
25
- // const builder = FunctionBuilder.create(api)
26
- // await builder.addFunction(address, 'getBalance', [myAddress], abi)
27
- // // Create the Balance Monitor alert
28
- // const alert = await AlertBuilder.create('Test Alert')
29
- // .onNetwork('avalanche')
30
- // .withTrigger<PollFunctionV2>('PollFunctionV2', {
31
- // timeBase: 'time',
32
- // timePeriod: '100s',
33
- // functions: builder.get(),
34
- // triggerOn: 'always',
35
- // })
36
- // .withNotification<DiscordWebhook>('Discord', {
37
- // url: webhook,
38
- // message:
39
- // `Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})`,
40
- // })
41
- // .config()
42
- // // Create the alert with the API
43
- // const triggerId = await api.createAlert(alert)
44
- // console.log(triggerId)
45
- // // Update the period to every 10s
46
- // await api.updateTrigger(triggerId, { timePeriod: '10s' })
47
- // // Update the Filter using the filter builder
48
- // const filter = FilterBuilder.new()
49
- // .addCondition('WHERE', 'func_0_ret_0', 'Number', 'gt', 3)
50
- // .finalise()
51
- // await api.updateTrigger(13, { triggerOn: 'filter', filter, filterVersion: FilterBuilder.version() })
52
- // // Delete the filter in 10s
53
- // setTimeout(async () => {
54
- // await api.deleteAlert(triggerId)
55
- // }, 10 * 1000)
11
+ const network = 'avalanche';
12
+ const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538';
13
+ const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87';
14
+ const { abi } = await api.getAbi(network, address);
15
+ const webhook = process.env.DISCORD_WEBHOOK;
16
+ const builder = FunctionBuilder.create(api);
17
+ await builder.addFunction(address, 'getBalance', [myAddress], abi);
18
+ // Create the Balance Monitor alert
19
+ const alert = await AlertBuilder.create('Test Alert')
20
+ .onNetwork('avalanche')
21
+ .withTrigger('PollFunctionV2', {
22
+ timeBase: 'time',
23
+ timePeriod: '100s',
24
+ functions: builder.get(),
25
+ triggerOn: 'always',
26
+ })
27
+ .withNotification('Discord', {
28
+ url: webhook,
29
+ message: `Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})`,
30
+ })
31
+ .config();
32
+ // Create the alert with the API
33
+ const triggerId = await api.createAlert(alert);
34
+ console.log(triggerId);
35
+ // Update the period to every 10s
36
+ await api.updateTrigger(triggerId, { timePeriod: '10s' });
37
+ // Update the Filter using the filter builder
38
+ const filter = FilterBuilder.new()
39
+ .addCondition('WHERE', 'func_0_ret_0', 'Number', 'gt', 3)
40
+ .finalise();
41
+ await api.updateTrigger(13, { triggerOn: 'filter', filter, filterVersion: FilterBuilder.version() });
42
+ // Delete the filter in 10s
43
+ setTimeout(async () => {
44
+ await api.deleteAlert(triggerId);
45
+ }, 10 * 1000);
56
46
  }
57
47
  main();
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.6",
2
+ "version": "1.1.7",
3
3
  "name": "denotify-client",
4
4
  "umd:name": "denotify-client",
5
5
  "repository": "robo-labs/denotify-client",
@@ -1,47 +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
- // Simple App to demonstrate usage. Created a balance monitoring alert, updates it and deletes it
6
- async function main() {
7
- const api = await DeNotifyClient.create({
8
- email: process.env.EMAIL,
9
- password: process.env.PASSWORD,
10
- });
11
- const network = 'avalanche';
12
- const address = '0x26985888d5b7019ff2A7444fB567D8F386c3b538';
13
- const myAddress = '0x7601630eC802952ba1ED2B6e4db16F699A0a5A87';
14
- const { abi } = await api.getAbi(network, address);
15
- const webhook = process.env.DISCORD_WEBHOOK;
16
- const builder = FunctionBuilder.create(api);
17
- await builder.addFunction(address, 'getBalance', [myAddress], abi);
18
- // Create the Balance Monitor alert
19
- const alert = AlertBuilder.create('Test Alert')
20
- .onNetwork('avalanche')
21
- .withTrigger('PollFunctionV2', {
22
- timeBase: 'time',
23
- timePeriod: '100s',
24
- functions: builder.get(),
25
- triggerOn: 'always',
26
- })
27
- .withNotification('Discord', {
28
- url: webhook,
29
- message: `Your avax balance is [{func_0_ret_0 / 1e18}](https://snowtrace.io/address/${myAddress})`,
30
- })
31
- .config();
32
- // Create the alert with the API
33
- const triggerId = await api.createAlert(alert);
34
- console.log(triggerId);
35
- // Update the period to every 10s
36
- await api.updateTrigger(triggerId, { timePeriod: '10s' });
37
- // Update the Filter using the filter builder
38
- const filter = FilterBuilder.new()
39
- .addCondition('WHERE', 'func_0_ret_0', 'Number', 'gt', 3)
40
- .finalise();
41
- await api.updateTrigger(13, { triggerOn: 'filter', filter, filterVersion: FilterBuilder.version() });
42
- // Delete the filter in 10s
43
- setTimeout(async () => {
44
- await api.deleteAlert(triggerId);
45
- }, 10 * 1000);
46
- }
47
- main();