diff --git a/docker-compose/.env.example b/docker-compose/.env.example index 62a84ab..512557e 100644 --- a/docker-compose/.env.example +++ b/docker-compose/.env.example @@ -2,14 +2,3 @@ DB_USER=myuser DB_PASSWORD=mypassword DB_NAME=mydatabase DOCKER_NETWORK=backend -WALLET_JSON = '{ - "kty": "RSA", - "e": "test", - "n": "test", - "d": "test", - "p": "test", - "q": "test", - "dp": "test", - "dq": "test", - "qi": "test" -}' diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index a76a590..da14667 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -29,7 +29,6 @@ services: DB_PASSWORD: ${DB_PASSWORD:-mypassword} DB_NAME: ${DB_NAME:-mydatabase} PATH_TO_WALLET: /app/wallet.json # Path inside the container - WALLET_JSON: ${WALLET_JSON} DOCKER_NETWORK: backend # Passing the network name networks: - backend diff --git a/orchestrator/src/app.ts b/orchestrator/src/app.ts index 5a8806c..4c5720a 100644 --- a/orchestrator/src/app.ts +++ b/orchestrator/src/app.ts @@ -1,3 +1,4 @@ +import { readFile } from 'node:fs/promises'; import Docker from 'dockerode'; import AWS from 'aws-sdk'; import { connectWithRetry, setupDatabase } from './db_tools.js'; @@ -5,7 +6,10 @@ import Arweave from 'arweave'; import { checkAndFetchIfNeeded, cleanupFulfilledEntries, getProviderRequests, processChallengeRequests, processOutputRequests, shutdown } from './helperFunctions.js'; import {monitorDockerContainers } from './containerManagment.js'; - +if (!process.env.PATH_TO_WALLET) { + console.error("Env var PATH_TO_WALLET is not set!"); + process.exit(1); +} export const docker = new Docker(); export const ecs = new AWS.ECS({ region: process.env.AWS_REGION || 'us-east-1' }); @@ -126,10 +130,8 @@ async function run(): Promise { const client = await connectWithRetry(); await setupDatabase(client); - arweave.wallets.jwkToAddress(JSON.parse(process.env.WALLET_JSON!)).then((address) => { - console.log(address); - PROVIDER_ID = address - }); + const providerAddress = arweave.wallets.jwkToAddress(JSON.parse(await readFile(process.env.PATH_TO_WALLET!, 'utf8'))); + console.log('Provider address:', providerAddress); // setInterval(async () => { // const res = await client.query('SELECT COUNT(*) as count FROM time_lock_puzzles'); diff --git a/orchestrator/src/helperFunctions.ts b/orchestrator/src/helperFunctions.ts index 1ff00d1..21def45 100644 --- a/orchestrator/src/helperFunctions.ts +++ b/orchestrator/src/helperFunctions.ts @@ -1,3 +1,4 @@ +import { readFile } from 'node:fs/promises'; import { GetOpenRandomRequestsResponse, GetProviderAvailableValuesResponse, Logger, LogLevel, RandomClient, RequestList } from "ao-process-clients"; import { Client } from "pg"; import { COMPLETION_RETENTION_PERIOD_MS, MINIMUM_ENTRIES, UNCHAIN_VS_OFFCHAIN_MAX_DIF } from "./app"; @@ -27,7 +28,7 @@ export async function getRandomClient(): Promise { if (!randomClientInstance || (currentTime - lastInitTime) > REINIT_INTERVAL) { randomClientInstance = ((await RandomClient.defaultBuilder())) //.withAOConfig(AO_CONFIG) - .withWallet(JSON.parse(process.env.WALLET_JSON!)) + .withWallet(JSON.parse(await readFile(process.env.PATH_TO_WALLET!, 'utf8'))) .build(); lastInitTime = currentTime; }