-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from api3dao/validate-dapi-name
Validate provided dAPI names to the scripts
- Loading branch information
Showing
6 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const api3DapiManagement = require('@api3/dapi-management'); | ||
|
||
module.exports = { | ||
validateDapiName: (dapiName) => { | ||
const dapi = api3DapiManagement.dapis.find((dapi) => dapi.name === dapiName); | ||
if (!dapi) { | ||
throw new Error(`dAPI with name ${dapiName} does not exist`); | ||
} | ||
if (dapi.stage === 'deprecated') { | ||
console.warn(`dAPI with name ${dapiName} is deprecated`); | ||
} else if (dapi.stage !== 'active') { | ||
throw new Error(`dAPI with name ${dapiName} is not active, its current state is ${dapi.stage}`); | ||
} | ||
}, | ||
}; |