Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Tsymbal committed Apr 12, 2022
1 parent b84dbfa commit 84121dd
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 70 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@dialectlabs/monitor": "0.1.22",
"@dialectlabs/monitor": "^1.2.6",
"@dialectlabs/web3": "^0.2.0",
"@project-serum/anchor": "0.23.0",
"@gokiprotocol/client": "^0.6.1",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/schedule": "^1.0.2",
"@project-serum/anchor": "^0.21.0",
"@quarryprotocol/gauge": "^0.2.2",
"@quarryprotocol/quarry-sdk": "^2.0.1",
"@saberhq/anchor-contrib": "^1.12.45",
Expand Down
8 changes: 0 additions & 8 deletions src/monitor/console-notification-sink.ts

This file was deleted.

33 changes: 16 additions & 17 deletions src/monitor/saber-monitoring-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Context,
Monitor,
Monitors,
NotificationSink,
Pipelines,
SourceData,
Trace,
Expand All @@ -21,7 +20,7 @@ import { TwitterNotificationSink } from './twitter-notification-sink';

@Injectable()
export class SaberMonitoringService implements OnModuleInit, OnModuleDestroy {
private readonly notificationSink: NotificationSink =
private readonly notificationSink: TwitterNotificationSink =
new TwitterNotificationSink();

private readonly logger = new Logger(SaberMonitoringService.name);
Expand All @@ -32,10 +31,10 @@ export class SaberMonitoringService implements OnModuleInit, OnModuleDestroy {

const monitor: Monitor<PoolInfo> = Monitors.builder({
subscriberRepository: new NoopSubscriberRepository(),
notificationSink: this.notificationSink,
})
.defineDataSource<PoolInfo>()
.poll(async () => {
this.logger.log('Polling saber wars data');
const warsInfo = await getWarsInfo();
const sourceData: SourceData<PoolInfo>[] = warsInfo.poolsInfo.map(
(data) => ({
Expand All @@ -45,23 +44,23 @@ export class SaberMonitoringService implements OnModuleInit, OnModuleDestroy {
);
return Promise.resolve(sourceData);
}, Duration.fromObject({ minutes: 1 }))
.transform<number>({
.transform<number, number>({
keys: ['nextEpochAbsoluteShare'],
pipelines: [
Pipelines.threshold(
{
type: 'increase',
threshold,
},
{
messageBuilder: ({ context }) => {
this.logger.log('Building whale alert');
return this.createWhaleAlert(context);
},
},
),
Pipelines.threshold({
type: 'increase',
threshold,
}),
],
})
.notify()
.custom(({ context }) => {
this.logger.log('Building whale alert');
return {
message: this.createWhaleAlert(context),
};
}, this.notificationSink)
.and()
.dispatch('unicast')
.build();
monitor.start();
Expand Down Expand Up @@ -122,7 +121,7 @@ Time remaining in epoch: ${epochInfo.currentEpochRemainingTime.toFormat(
)}
⚔️⚔️⚔️⚔️⚔️#SABERWARS⚔️⚔️⚔️⚔️⚔️`;
await this.notificationSink.push({ message }, []);
await this.notificationSink.push({ message });
}

async onModuleDestroy() {
Expand Down
8 changes: 5 additions & 3 deletions src/monitor/twitter-notification-sink.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Notification, NotificationSink } from '@dialectlabs/monitor';
import { DialectNotification, NotificationSink } from '@dialectlabs/monitor';
import { TwitterApi } from 'twitter-api-v2';
import { Logger } from '@nestjs/common';

export class TwitterNotificationSink implements NotificationSink {
export class TwitterNotificationSink
implements NotificationSink<DialectNotification>
{
private readonly logger = new Logger(TwitterNotificationSink.name);
// Instanciate with desired auth type (here's Bearer v2 auth)
private twitterClient = new TwitterApi({
Expand All @@ -12,7 +14,7 @@ export class TwitterNotificationSink implements NotificationSink {
accessSecret: process.env.TWITTER_ACCESS_SECRET,
});

async push({ message: text }: Notification): Promise<void> {
async push({ message: text }: DialectNotification): Promise<void> {
this.logger.log(text);
return this.twitterClient.v2
.tweet({
Expand Down
113 changes: 73 additions & 40 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -370,23 +370,24 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@dialectlabs/[email protected]":
version "0.1.22"
resolved "https://registry.yarnpkg.com/@dialectlabs/monitor/-/monitor-0.1.22.tgz#e6b414f541ef9b8fdfb9681b29fdce6eece7a654"
integrity sha512-F8hsdTf24UxN0ZzP2SmySry3wV9FsPQjUO6zjrq+CF9QMsmt7I6d8/Fu469vQQLJPcEV0oPlSfmKJSyls7fK/Q==
dependencies:
"@dialectlabs/web3" "^0.1.4"
"@project-serum/anchor" "^0.18.0"
"@dialectlabs/monitor@^1.2.6":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@dialectlabs/monitor/-/monitor-1.2.6.tgz#47e4a763bab1895725d8dd0459b9a76c4fee6bcd"
integrity sha512-/BWnJuLzuMVaUGMrxyqpnqGMt7Zbf8gmWHyWLy7edsNFYm5HMQX9xsniupVNeRE/YqyeuSAAJedm6PqmcEUiMQ==
dependencies:
"@dialectlabs/web3" "^0.2.0"
"@project-serum/anchor" "0.23.0"
"@sendgrid/mail" "^7.6.2"
"@solana/web3.js" "^1.27.0"
luxon "^2.3.0"
rxjs "^7.5.2"

"@dialectlabs/web3@^0.1.4":
version "0.1.4"
resolved "https://registry.yarnpkg.com/@dialectlabs/web3/-/web3-0.1.4.tgz#856863065d6ca560e77236b2d7c546f7ebf353eb"
integrity sha512-TgPHNHhha7ip+2H9ZwENgVU3ZM2ldIaLpTNUh55oKf662vbe/NmRRrylazJzSqlTIq8AzhtfycLW76zK61HlRA==
"@dialectlabs/web3@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@dialectlabs/web3/-/web3-0.2.0.tgz#8ea5f9a63e1ef37f8c8611a17cbcb3ea7089c338"
integrity sha512-NgRV7s7y5brWDZCIcReFpIZRDoygNL13hHwuXq2U30xK1EY1HSr1S+oJMjHYqAAwt0jDraRetoq2ZyJm4xGAOg==
dependencies:
"@project-serum/anchor" "0.18.2"
"@project-serum/anchor" "0.23.0"
"@solana/spl-token" "^0.1.8"
"@solana/web3.js" "^1.22.0"
bytebuffer "^5.0.1"
Expand Down Expand Up @@ -776,33 +777,13 @@
consola "^2.15.0"
node-fetch "^2.6.1"

"@project-serum/[email protected]", "@project-serum/anchor@^0.18.0":
version "0.18.2"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.18.2.tgz#0f13b5c2046446b7c24cf28763eec90febb28485"
integrity sha512-uyjiN/3Ipp+4hrZRm/hG18HzGLZyvP790LXrCsGO3IWxSl28YRhiGEpKnZycfMW94R7nxdUoE3wY67V+ZHSQBQ==
dependencies:
"@project-serum/borsh" "^0.2.2"
"@solana/web3.js" "^1.17.0"
base64-js "^1.5.1"
bn.js "^5.1.2"
bs58 "^4.0.1"
buffer-layout "^1.2.0"
camelcase "^5.3.1"
crypto-hash "^1.3.0"
eventemitter3 "^4.0.7"
find "^0.3.0"
js-sha256 "^0.9.0"
pako "^2.0.3"
snake-case "^3.0.4"
toml "^3.0.0"

"@project-serum/anchor@^0.21.0":
version "0.21.0"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.21.0.tgz#ad5fb33744991ec1900cdb2fd22707c908b12b5f"
integrity sha512-flRuW/F+iC8mitNokx82LOXyND7Dyk6n5UUPJpQv/+NfySFrNFlzuQZaBZJ4CG5g9s8HS/uaaIz1nVkDR8V/QA==
"@project-serum/[email protected]":
version "0.23.0"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.23.0.tgz#2b2eb6b51601b073e8db26663aa2d6c2f2841771"
integrity sha512-LV2/ifZOJVFTZ4GbEloXln3iVfCvO1YM8i7BBCrUm4tehP7irMx4nr4/IabHWOzrQcQElsxSP/lb1tBp+2ff8A==
dependencies:
"@project-serum/borsh" "^0.2.4"
"@solana/web3.js" "^1.17.0"
"@project-serum/borsh" "^0.2.5"
"@solana/web3.js" "^1.36.0"
base64-js "^1.5.1"
bn.js "^5.1.2"
bs58 "^4.0.1"
Expand All @@ -817,7 +798,7 @@
snake-case "^3.0.4"
toml "^3.0.0"

"@project-serum/borsh@^0.2.2", "@project-serum/borsh@^0.2.4":
"@project-serum/borsh@^0.2.5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz#6059287aa624ecebbfc0edd35e4c28ff987d8663"
integrity sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==
Expand Down Expand Up @@ -876,6 +857,29 @@
tiny-invariant "^1.2.0"
tslib "^2.3.1"

"@sendgrid/client@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@sendgrid/client/-/client-7.6.2.tgz#5d08949120dad679f34260f1b875b4f57a8d688e"
integrity sha512-Yw3i3vPBBwfiIi+4i7+1f1rwQoLlLsu3qW16d1UuRp6RgX6H6yHYb2/PfqwNyCC0qzqIWGUKPWwYe5ggcr5Guw==
dependencies:
"@sendgrid/helpers" "^7.6.2"
axios "^0.26.0"

"@sendgrid/helpers@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@sendgrid/helpers/-/helpers-7.6.2.tgz#e4abdd4e259611ed549ae8e0f4a46cd4f587e5d1"
integrity sha512-kGW0kM2AOHfXjcvB6Lgwa/nMv8IALu0KyNY9X4HSa3MtLohymuhbG9HgjrOh66+BkbsfA03H3bcT0+sPVJ0GKQ==
dependencies:
deepmerge "^4.2.2"

"@sendgrid/mail@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@sendgrid/mail/-/mail-7.6.2.tgz#118650afbb58be82e3178fa172869d929d937118"
integrity sha512-IHHZFvgU95aqb11AevQvAfautj2pb8iW8UCiUJ2ae9pRF37e6EkBmU9NgdFjbQ/8Xhhm+KDVDzn/JLxDN/GiBw==
dependencies:
"@sendgrid/client" "^7.6.2"
"@sendgrid/helpers" "^7.6.2"

"@sinonjs/commons@^1.7.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
Expand Down Expand Up @@ -916,7 +920,7 @@
buffer-layout "^1.2.0"
dotenv "10.0.0"

"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.34.0":
"@solana/web3.js@^1.21.0", "@solana/web3.js@^1.34.0":
version "1.34.0"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.34.0.tgz#33becf2c7e87497d73406374185e54e0b7bc235d"
integrity sha512-6QvqN2DqEELvuV+5yUQM8P9fRiSG+6SzQ58HjumJqODu14r7eu5HXVWEymvKAvMLGME+0TmAdJHjw9xD5NgUWA==
Expand Down Expand Up @@ -956,6 +960,26 @@
superstruct "^0.14.2"
tweetnacl "^1.0.0"

"@solana/web3.js@^1.36.0":
version "1.37.1"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.37.1.tgz#5a4d30a4cf79c4598e0a437e841c7942e31be74c"
integrity sha512-1zm1blRU6ANb8bOfONibKkNKoMyzE1e0Z88MagyRLF1AmfHc+18lFvqxSQKUdazLMHcioZ28h+GfyAaeCT63iA==
dependencies:
"@babel/runtime" "^7.12.5"
"@ethersproject/sha2" "^5.5.0"
"@solana/buffer-layout" "^4.0.0"
bn.js "^5.0.0"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.1"
cross-fetch "^3.1.4"
jayson "^3.4.4"
js-sha3 "^0.8.0"
rpc-websockets "^7.4.2"
secp256k1 "^4.0.2"
superstruct "^0.14.2"
tweetnacl "^1.0.0"

"@tootallnate/once@1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
Expand Down Expand Up @@ -1830,6 +1854,15 @@ borsh@^0.4.0:
bs58 "^4.0.0"
text-encoding-utf-8 "^1.0.2"

borsh@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a"
integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==
dependencies:
bn.js "^5.2.0"
bs58 "^4.0.0"
text-encoding-utf-8 "^1.0.2"

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
Expand Down

0 comments on commit 84121dd

Please sign in to comment.