@energyweb/node-red-contrib-green-proof-worker
Version:
## Peer dependencies
40 lines (39 loc) • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VotingServiceConfig = exports.Config = void 0;
const tslib_1 = require("tslib");
const z = tslib_1.__importStar(require("zod"));
const input_message_1 = require("../input-message");
const node_1 = require("../node");
const nodes_config_env_1 = require("../nodes-config-env");
const InputMessage = z.union([
input_message_1.InputMessages.UnitsChanged({}, z.literal('tx_correct')),
input_message_1.InputMessages.UnitsChanged({}, z.literal('tx_wrong')),
]);
exports.Config = z.object({
workerSeed: z.string(),
votingUrl: z.string().url(),
indexerUrl: z.string().url(),
workerAddress: z.string(),
solutionNamespace: z.string(),
});
const VotingServiceConfig = (api) => class VotingService extends node_1.Node {
constructor(rawConfig) {
super(api, rawConfig, InputMessage);
const envConfig = this.getNodeEnvConfig();
const parsedConfig = (async () => exports.Config.parse({
workerSeed: rawConfig.workerSeed || nodes_config_env_1.nodesGlobalEnvConfig.VOTING_SERVICE_CONFIG_WORKER_SEED,
votingUrl: rawConfig.votingUrl || nodes_config_env_1.nodesGlobalEnvConfig.VOTING_SERVICE_CONFIG_VOTING_URL,
solutionNamespace: rawConfig.solutionNamespace || envConfig.EWX_SOLUTION_ID || nodes_config_env_1.nodesGlobalEnvConfig.VOTING_SERVICE_CONFIG_SOLUTION_NAMESPACE,
indexerUrl: rawConfig.indexerUrl
|| nodes_config_env_1.nodesGlobalEnvConfig.VOTING_SERVICE_CONFIG_INDEXER_URL
|| await this.getBaseUrls()
.then(c => c.indexer_url),
workerAddress: rawConfig.workerAddress || envConfig.EWX_WORKER_ADDRESS || nodes_config_env_1.nodesGlobalEnvConfig.VOTING_SERVICE_CONFIG_WORKER_ADDRESS,
}))();
this.config = parsedConfig;
}
async onInput(_message) {
}
};
exports.VotingServiceConfig = VotingServiceConfig;