diff --git a/backend/.example.env b/backend/.example.env index d527646..89e28ae 100644 --- a/backend/.example.env +++ b/backend/.example.env @@ -15,6 +15,7 @@ NODE1_ETH_ADDRESS= NODE2_ETH_ADDRESS= NODE3_ETH_ADDRESS= RAIDEN_NODE_VERSION=raidennetwork/raiden:develop +HUB_ADDRESS=http://raiden1:5001 DEPLOY_ENV=dev # Prefix used for container names (default: current directory name) diff --git a/backend/docker-compose.yaml b/backend/docker-compose.yaml index 30cbeb2..060642f 100644 --- a/backend/docker-compose.yaml +++ b/backend/docker-compose.yaml @@ -73,6 +73,7 @@ services: environment: PORT: ${ACTIONS_PORT} GRAPHQL_ENDPOINT: graphql-engine:8080/v1/graphql + HUB_ADDRESS: ${HUB_ADDRESS} command: ${ACTIONS_START_COMMAND} restart: always diff --git a/backend/hasura-actions/src/Scheduler.bs.js b/backend/hasura-actions/src/Scheduler.bs.js index 6a48f1d..3cb4735 100644 --- a/backend/hasura-actions/src/Scheduler.bs.js +++ b/backend/hasura-actions/src/Scheduler.bs.js @@ -7,12 +7,16 @@ var Fetch = require("bs-fetch/src/Fetch.bs.js"); var Query = require("./Query.bs.js"); var BnJs = require("bn.js"); var BsCron = require("bs-cron/src/BsCron.bs.js"); +var Dotenv = require("dotenv"); var Js_dict = require("bs-platform/lib/js/js_dict.js"); var CONSTANTS = require("./CONSTANTS.bs.js"); var Belt_Array = require("bs-platform/lib/js/belt_Array.js"); +var Belt_Option = require("bs-platform/lib/js/belt_Option.js"); var Caml_option = require("bs-platform/lib/js/caml_option.js"); var PaymentStreamManager = require("./PaymentStreamManager.bs.js"); +Dotenv.config(); + function makePaymentRequest_encode(v) { return Js_dict.fromArray([ [ @@ -44,7 +48,8 @@ function makePayment(recipientAddress, paymentData) { var newNextPayment = paymentData.nextPayment.add(finalPayment.mul(intervalInSeconds$1)); PaymentStreamManager.updateStreamEntry(paymentData.streamID, newPaymentsMade.toNumber(), newNextPayment.toNumber(), paymentData.nextPayment.toNumber()); } - var requestString = "http://raiden1:5001/api/v1/payments/0xC563388e2e2fdD422166eD5E76971D11eD37A466/" + recipientAddress; + var address = Belt_Option.getWithDefault(process.env.HUB_ADDRESS, "http://raiden1:5001"); + var requestString = address + "/api/v1/payments/0xC563388e2e2fdD422166eD5E76971D11eD37A466/" + recipientAddress; console.log(requestString, finalAmount.toString()); return fetch(requestString, Fetch.RequestInit.make(/* Post */2, { "Content-Type": "application/json" @@ -77,6 +82,7 @@ function getCurrentTimestamp(param) { } function startProcess(param) { + console.log(Belt_Option.getWithDefault(process.env.HUB_ADDRESS, "http://raiden1:5001")); var now = getTimestamp(new Date()); console.log("start timestamp:", now); var job = BsCron.CronJob.make({ @@ -165,4 +171,4 @@ exports.getTimestamp = getTimestamp; exports.fromTimeStampToDate = fromTimeStampToDate; exports.getCurrentTimestamp = getCurrentTimestamp; exports.startProcess = startProcess; -/* Query Not a pure module */ +/* Not a pure module */ diff --git a/backend/hasura-actions/src/Scheduler.res b/backend/hasura-actions/src/Scheduler.res index 8e700bf..3aee64c 100644 --- a/backend/hasura-actions/src/Scheduler.res +++ b/backend/hasura-actions/src/Scheduler.res @@ -1,3 +1,6 @@ +Dotenv.config() +@val external hubAddress: option = "process.env.HUB_ADDRESS" + open BsCron @decco.encode @@ -49,9 +52,9 @@ let makePayment = (~recipientAddress, ~paymentData: streamData) => { ~lastPayment=paymentData.nextPayment->BN.toNumber, ) } + let address = hubAddress->Option.getWithDefault("http://raiden1:5001") let requestString = - "http://raiden1:5001/api/v1/payments/0xC563388e2e2fdD422166eD5E76971D11eD37A466/" ++ - recipientAddress + address ++ "/api/v1/payments/0xC563388e2e2fdD422166eD5E76971D11eD37A466/" ++ recipientAddress Js.log2(requestString, finalAmount->BN.toString) Fetch.fetchWithInit( requestString,