From 6adf8c6ae7c09edfd28aa692742f2a9dfdd577c5 Mon Sep 17 00:00:00 2001 From: emizzle Date: Fri, 13 Mar 2020 16:07:21 +1100 Subject: [PATCH] fix: Remove trial credentials and update MYTHX_ETH_ADDRESS to MYTHX_USERNAME Remove automatically provided trial credentials when MythX API login environment variables are not provided by the user. Deprecate the use of `MYTHX_ETH_ADDRESS` in favour of `MYTHX_USERNAME` environment variable. --- README.md | 13 +++++++++++-- mythx.js | 15 +++++++++------ package-lock.json | 2 +- package.json | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7b33e18..001ef11 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,22 @@ This plugin brings MythX to Status Embark. Simply call `verify` from the Embark ## QuickStart -1. Create a `.env` file in the root of your project and provide your MythX login information. If omitted, MythX will run in trial mode. +1. Create a `.env` file in the root of your project and provide your MythX login information. Free MythX accounts can be created at https://dashboard.mythx.io/#/registration. ```json -MYTHX_ETH_ADDRESS="" +MYTHX_USERNAME="" MYTHX_PASSWORD="" ``` +> **NOTE:** `MYTHX_ETH_ADDRESS` in favour of `MYTHX_USERNAME` and will be removed in future versions. Please update your .env file or your environment variables accordingly. + +`MYTHX_USERNAME` may be either of: +* MythX User ID (assigned by MythX API to any registered user); +* Ethereum address, if user account is associated with an address; +* A verified email address, if the user account is associated with an email address, and that address has been verified by visiting the verification link in the verification email sent by the MythX API each time when user email is set or modified in the MythX settings. + +For more information, please see the [MythX API Login documentation](https://api.mythx.io/v1/openapi#operation/login). + 2. Run `verify [options] [contracts]` in the Embark console. When the call returns, it will look something like this: ```bash diff --git a/mythx.js b/mythx.js index 796f14c..9b597fc 100644 --- a/mythx.js +++ b/mythx.js @@ -25,18 +25,21 @@ async function analyse(contracts, cfg, embark) { return 1 } + if (process.env.MYTHX_ETH_ADDRESS) { + process.env.MYTHX_USERNAME = process.env.MYTHX_ETH_ADDRESS; + embark.logger.warn("The environment variable MYTHX_ETH_ADDRESS in favour of MYTHX_USERNAME and will be removed in future versions. Please update your .env file or your environment variables accordingly."); + } + // Connect to MythX via armlet - if(!process.env.MYTHX_ETH_ADDRESS || !process.env.MYTHX_PASSWORD) { - embark.logger.error("Environment variables 'MYTHX_ETH_ADDRESS' and 'MYTHX_PASSWORD' not found. Continuing in evaluation mode.") - process.env.MYTHX_ETH_ADDRESS = "0x0000000000000000000000000000000000000000" - process.env.MYTHX_PASSWORD = "trial" + if(!process.env.MYTHX_USERNAME || !process.env.MYTHX_PASSWORD) { + throw new Error("Environment variables 'MYTHX_USERNAME' and 'MYTHX_PASSWORD' not found. Place these in a .env file in the root of your ÐApp, add them in the CLI command, ie 'MYTHX_USERNAME=xyz MYTHX_PASSWORD=123 embark run', or add them to your system's environment variables."); } const armletClient = new armlet.Client( { clientToolName: "embark-mythx", password: process.env.MYTHX_PASSWORD, - ethAddress: process.env.MYTHX_ETH_ADDRESS, + ethAddress: process.env.MYTHX_USERNAME, }) // Filter contracts based on parameter choice @@ -85,7 +88,7 @@ async function getStatus(uuid, embark) { { clientToolName: "embark-mythx", password: process.env.MYTHX_PASSWORD, - ethAddress: process.env.MYTHX_ETH_ADDRESS, + ethAddress: process.env.MYTHX_USERNAME, }) try { diff --git a/package-lock.json b/package-lock.json index 9b88fcb..0730792 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "embark-mythx", - "version": "1.0.2", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ebc6bdf..0c2d139 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-mythx", - "version": "1.0.2", + "version": "1.0.4", "description": "MythX plugin for Status Embark", "repository": "github:flex-dapps/embark-mythx", "main": "index.js",