forked from ironoa/polkadot-k8s-payouts
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from w3f/notifier
matrix notifier
- Loading branch information
Showing
18 changed files
with
600 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
description: Polkadot K8s Payouts | ||
name: polkadot-k8s-payouts | ||
version: v1.2.14 | ||
appVersion: v1.2.14 | ||
version: v1.3.0 | ||
appVersion: v1.3.0 | ||
apiVersion: v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ if eq .Values.config.matrix.enabled true }} | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ .Release.Name }}-store | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Mi | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "polkadot-payouts", | ||
"version": "1.2.14", | ||
"version": "1.3.0", | ||
"description": "Automated transfers among accounts", | ||
"repository": "[email protected]:w3f/accountant.git", | ||
"author": "W3F Infrastructure Team <[email protected]>", | ||
|
@@ -20,13 +20,16 @@ | |
"start": "NODE_OPTIONS='--max-old-space-size=4096' node ./dist/index.js start" | ||
}, | ||
"dependencies": { | ||
"@matrix-org/olm": "https://gitlab.matrix.org/matrix-org/olm/-/package_files/2572/download", | ||
"@polkadot/api": "^12.3.1", | ||
"@w3f/config": "^0.1.1", | ||
"@w3f/logger": "^0.4.3", | ||
"async-wait-until": "^1.2.6", | ||
"bn.js": "^5.1.3", | ||
"commander": "^4.1.1", | ||
"matrix-js-sdk": "^25", | ||
"node-fetch": "^2.6.6", | ||
"node-localstorage": "^2", | ||
"yaml": "^2.2.1" | ||
}, | ||
"devDependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export const batchSize = 9 | ||
export const batchSize = 2 | ||
export const isDeepCheckEnabled = false | ||
export const gracePeriod = {enabled: false, eras: 0} | ||
export const runAttempts = 3 | ||
export const claimAttempts = 3 | ||
export const claimAttempts = 3 | ||
export const storeDir = "./store" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { NewPayoutData } from "../types"; | ||
|
||
export interface Notifier { | ||
newPayout(data: NewPayoutData): Promise<boolean>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { InputConfig } from "../types"; | ||
import { Notifier } from "./INotifier"; | ||
import { Disabled } from "./disabled"; | ||
import { Matrix } from "./matrix"; | ||
|
||
export class NotifierFactory { | ||
constructor(private readonly cfg: InputConfig){} | ||
makeNotifier = async (): Promise<Notifier> => { | ||
|
||
if(!this.cfg.matrix?.enabled) | ||
return new Disabled() | ||
|
||
const matrix = new Matrix(this.cfg) | ||
await matrix.start() | ||
return matrix | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Logger, LoggerSingleton } from '../logger'; | ||
|
||
import { | ||
NewPayoutData, | ||
} from '../types'; | ||
import { Notifier } from './INotifier'; | ||
|
||
|
||
export class Disabled implements Notifier { | ||
private readonly logger: Logger = LoggerSingleton.getInstance() | ||
newPayout = async (_data: NewPayoutData): Promise<boolean> =>{ | ||
this.logger.info("Notifier disabled...") | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* This file is responsible for setting up the globals correctly before | ||
* importing matrix and then exporting it. | ||
*/ | ||
|
||
/** | ||
* We must import olm and assign it to the global before importing matrix. | ||
*/ | ||
import olm from "@matrix-org/olm"; | ||
|
||
global.Olm = olm; | ||
|
||
/** | ||
* We must also override the default fetch global to use the FS module when | ||
* attempting to fetch the wasm since the default fetch does not support local | ||
* files. | ||
*/ | ||
import fs from "fs/promises"; | ||
|
||
const oldFetch = fetch; | ||
|
||
global.fetch = async (input: RequestInfo | URL | string, init?: RequestInit): Promise<Response> => { | ||
// Here we need to check if it is attempting to fetch the wasm file. | ||
if (typeof input == "string" && input.charAt(0) === "/") { | ||
const data = await fs.readFile(input); | ||
|
||
// Return the wasm data as a typical response. | ||
return new Response(data, { | ||
headers: { "content-type": "application/wasm" } | ||
}); | ||
} | ||
|
||
// Since this is not fetching the wasm we can just use the old implementation. | ||
return await oldFetch(input, init); | ||
}; | ||
|
||
/** | ||
* We will increase the logger severity to reduce clutter. | ||
*/ | ||
// import { logger } from "../../../lib/logger.js"; | ||
|
||
// logger.setLevel(5); | ||
|
||
/** | ||
* Now we can import and export the matrix sdk. | ||
*/ | ||
import * as sdk from "matrix-js-sdk"; | ||
|
||
export default sdk; |
Oops, something went wrong.