Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,25 @@ Both systems use a config-driven approach where modules are loaded dynamically f

```json
{
"modules": [
"core/arweave",
"core/prover",
"core/streamr",
"core/is_on",
"core/prune_sync"
],
"uiModules": {
"streamr": "core/streamr/ui"
},
"streamr": {
"streamId": ["0x.../m3tering/test"],
"cronSchedule": "0 * * * *"
}
"modules": [
"core/arweave",
"core/prover",
"core/streamr",
"core/is_on",
"core/prune_sync"
],
"uiModules": {
"streamr": "core/streamr/ui"
},
"streamr": {
"streamId": [
"0x567853282663b601bfdb9203819b1fbb3fe18926/m3tering/test"
],
"cronSchedule": "0 * * * *"
},
"prune_sync": {
"cronSchedule": "0 * * * *"
}
}
```

Expand Down
11 changes: 9 additions & 2 deletions src/lib/core/streamr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ export default class implements Hooks {
});

try {
const stream = await streamrClient.getStream(STREAMR_STREAM_ID!);
const stream = await retry(
() => streamrClient.getStream(STREAMR_STREAM_ID!),
3,
2000
);

await new Promise((resolve) => setTimeout(resolve, 2000));

const batchPayload = buildBatchPayload(pendingTransactions);

await stream.publish(batchPayload);

await new Promise((resolve) => setTimeout(resolve, 2000));
} catch (error) {
console.error(`Failed to publish to Streamr: ${(error as Error).message}`);
throw error;
Expand Down
22 changes: 18 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import fs from "fs";
import path from "path";
import { createPublicKey, verify } from "crypto";
import type { TransactionRecord, BatchTransactionPayload, Hooks, AppConfig, UIHooks, UIAppIcon, UIAppWindow, UIAction } from "../types";
import type {
TransactionRecord,
BatchTransactionPayload,
Hooks,
AppConfig,
UIHooks,
UIAppIcon,
UIAppWindow,
UIAction,
} from "../types";

const extensions: Hooks[] = [];
const uiExtensions: Map<string, UIHooks> = new Map();
export const defaultConfigurations: AppConfig = {
modules: ["core/arweave", "core/prover", "core/streamr", "core/is_on", "core/prune_sync"],
uiModules: {
streamr: "core/streamr/ui",
},
streamr: {
streamId: ["0x567853282663b601bfdb9203819b1fbb3fe18926/m3tering/test"],
cronSchedule: "0 * * * *",
Expand All @@ -21,7 +33,7 @@ export function loadConfigurations(configPath: string = "console.config.json"):
const config: AppConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
return config;
} catch (error) {
console.warn(`Could not load configuration from ${configPath}, using default configurations.` );
console.warn(`Could not load configuration from ${configPath}, using default configurations.`);
return defaultConfigurations;
}
}
Expand Down Expand Up @@ -63,7 +75,9 @@ export async function runHook<K extends keyof Hooks>(hook: K, ...args: Parameter
* Load UI extensions from configuration file
* Looks for 'uiModules' key in config, which maps module IDs to their paths
*/
export async function loadUIExtensionsFromConfig(configPath: string = "console.config.json"): Promise<Map<string, UIHooks>> {
export async function loadUIExtensionsFromConfig(
configPath: string = "console.config.json",
): Promise<Map<string, UIHooks>> {
const config = loadConfigurations(configPath) as AppConfig & { uiModules?: Record<string, string> };

if (!config.uiModules) {
Expand Down Expand Up @@ -132,7 +146,7 @@ export function getUIExtension(moduleId: string): UIHooks | undefined {
*/
export async function invokeUIAction(
moduleId: string,
actionId: string
actionId: string,
): Promise<{ success: boolean; message?: string; data?: any }> {
const ext = uiExtensions.get(moduleId);
if (!ext) {
Expand Down