Skip to content

Commit

Permalink
feat: requiring env for external adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbn committed Jun 17, 2021
1 parent 57cff26 commit 74b5ee8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 11 additions & 0 deletions enabled-networks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { NETWORKS } from './constants';

export const enabledNetworks = [
{ name: NETWORKS.DEVELOP, enabled: true },
{ name: NETWORKS.KOVAN, enabled: false },
{ name: NETWORKS.MUMBAI, enabled: false },
{ name: NETWORKS.HARMONYTESTNET, enabled: false },
{ name: NETWORKS.ETHEREUM, enabled: false },
{ name: NETWORKS.HARMONY, enabled: false },
{ name: NETWORKS.POLYGON, enabled: false },
];
20 changes: 12 additions & 8 deletions services/external-adapter/env-validation.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import hardhat from 'hardhat';

const Joi = require('joi');
import { NETWORKS } from '../../constants';
require('dotenv').config();

const networksObject = Object.keys(NETWORKS).reduce(
(r, networkName) => ({
...r,
[`${networkName}_URI`]: Joi.string().uri().required(),
}),
{}
);
const networksObject = Object.keys(hardhat.config.networks)
.filter((network) => !['hardhat', 'localhost'].includes(network))
.reduce(
(r, network) => ({
...r,
[`${network.toUpperCase()}_URI`]: Joi.string().uri().required(),
}),
{}
);

const schema = Joi.object({
IPFS_URI: Joi.string().uri().required(),
...networksObject,
Expand Down

0 comments on commit 74b5ee8

Please sign in to comment.