Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const axios = require('axios')
// This overrides console.table in nodejs >= 9.x
require('console.table')
const CONTENT_TYPE_JSON = 'application/vnd.api+json'
const FETCH_TIMEOUT = 5000
const SERVICE_AGREEMENTS_PATH = '/v2/service_agreements'
const ACCOUNT_BALANCE_PATH = '/v2/user/balances'
function urlWithPath(t, path) {
const u = new URL(t)
u.pathname = path
return u.toString()
}
class SaRequester extends command.Command {
async run() {
const { args, flags } = this.parse(SaRequester)
const agreement = JSON.parse(fs.readFileSync(flags.agreement, 'utf8'))
const oracleURLs = args.file.split(/\s+/)
const addresses = await getOracleAddresses(oracleURLs)
createServiceAgreements(agreement, addresses, oracleURLs)
.then(signatures => console.table(['address', 'signature'], signatures))
.catch(e =>
console.log('Unable to create SA, got error:\n\n\t%s\n', e.message),
)
}
}
const parseError = ({ response }) => {
if (response.status === 422) {
});
exports.ConfigDestroy = void 0;
var _command = require("@oclif/command");
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _fsExtra = _interopRequireDefault(require("fs-extra"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class ConfigDestroy extends _command.Command {
async run() {
cov_1bgc42zmjt.f[0]++;
cov_1bgc42zmjt.s[0]++;
try {
cov_1bgc42zmjt.s[1]++;
await _fsExtra.default.remove(_path.default.join(this.config.configDir, 'config.json'));
cov_1bgc42zmjt.s[2]++;
this.log(`Config destroyed. Run the command ${_chalk.default.blue.bold('config:set')} to generate a new config.`, _nodeEmoji.default.get('rocket'));
cov_1bgc42zmjt.s[3]++;
this.exit(0);
} catch (err) {
cov_1bgc42zmjt.s[4]++;
this.error(err, {
exit: 1
});
var _command = require("@oclif/command");
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class UserRemove extends _command.Command {
async run() {
cov_1ws4rif622.f[0]++;
const {
flags
} = (cov_1ws4rif622.s[0]++, this.parse(UserRemove));
cov_1ws4rif622.s[1]++;
try {
const client = (cov_1ws4rif622.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
const channel = (cov_1ws4rif622.s[3]++, await client.channel(flags.type, flags.id));
cov_1ws4rif622.s[4]++;
await channel.demoteModerators(flags.moderators.split(','));
cov_1ws4rif622.s[5]++;
this.log(`${flags.moderators} have been removed as moderators from the ${flags.type} channel ${flags.id}`, _nodeEmoji.default.get('warning'));
cov_1ws4rif622.s[6]++;
this.exit(0);
var _command = require("@oclif/command");
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class UserAdd extends _command.Command {
async run() {
cov_2nmzwr8l86.f[0]++;
const {
flags
} = (cov_2nmzwr8l86.s[0]++, this.parse(UserAdd));
cov_2nmzwr8l86.s[1]++;
try {
const client = (cov_2nmzwr8l86.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
const channel = (cov_2nmzwr8l86.s[3]++, await client.channel(flags.type, flags.id));
cov_2nmzwr8l86.s[4]++;
await channel.addModerators(flags.moderators.split(','));
cov_2nmzwr8l86.s[5]++;
this.log(`${flags.moderators} have been added as moderators to channel ${flags.type}:${flags.id}`, _nodeEmoji.default.get('rocket'));
cov_2nmzwr8l86.s[6]++;
this.exit(0);
var _command = require("@oclif/command");
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class MessageRemove extends _command.Command {
async run() {
cov_76s8w6qau.f[0]++;
const {
flags
} = (cov_76s8w6qau.s[0]++, this.parse(MessageRemove));
cov_76s8w6qau.s[1]++;
try {
const client = (cov_76s8w6qau.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
cov_76s8w6qau.s[3]++;
await client.deleteMessage(flags.id);
cov_76s8w6qau.s[4]++;
this.log(`The message ${flags.id} has been removed!`, _nodeEmoji.default.get('wastebasket'));
cov_76s8w6qau.s[5]++;
this.exit(0);
} catch (err) {
var _command = require("@oclif/command");
var _cliTable = _interopRequireDefault(require("cli-table"));
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _config = require("../../utils/config");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class ConfigGet extends _command.Command {
async run() {
cov_sebwynz2l.f[0]++;
const config = (cov_sebwynz2l.s[0]++, _path.default.join(this.config.configDir, 'config.json'));
const {
apiKey,
apiSecret
} = (cov_sebwynz2l.s[1]++, await (0, _config.credentials)(config, this));
cov_sebwynz2l.s[2]++;
if ((cov_sebwynz2l.b[1][0]++, apiKey) && (cov_sebwynz2l.b[1][1]++, apiSecret)) {
cov_sebwynz2l.b[0][0]++;
const table = (cov_sebwynz2l.s[3]++, new _cliTable.default({
head: ['API Key', 'API Secret'],
colWidths: [25, 75]
}));
cov_sebwynz2l.s[4]++;
});
exports.ChannelList = void 0;
var _command = require("@oclif/command");
var _nodeEmoji = _interopRequireDefault(require("node-emoji"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class ChannelList extends _command.Command {
async run() {
cov_18k8aj0gfc.f[0]++;
cov_18k8aj0gfc.s[0]++;
try {
const client = (cov_18k8aj0gfc.s[1]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
const channels = (cov_18k8aj0gfc.s[2]++, await client.queryChannels({}, {
last_message_at: -1
}, {
subscribe: false
}));
cov_18k8aj0gfc.s[3]++;
if (channels.length) {
cov_18k8aj0gfc.b[0][0]++;
cov_18k8aj0gfc.s[4]++;
var _cliTable = _interopRequireDefault(require("cli-table"));
var _numeral = _interopRequireDefault(require("numeral"));
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class ChannelGet extends _command.Command {
async run() {
cov_226fhj8cn2.f[0]++;
const {
flags
} = (cov_226fhj8cn2.s[0]++, this.parse(ChannelGet));
cov_226fhj8cn2.s[1]++;
try {
const client = (cov_226fhj8cn2.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
const channel = (cov_226fhj8cn2.s[3]++, await client.queryChannels({
id: flags.id,
type: flags.type
}, {
last_message_at: -1
}, {
subscribe: false
var _command = require("@oclif/command");
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _v = _interopRequireDefault(require("uuid/v4"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class ChannelInit extends _command.Command {
async run() {
cov_i783mv28z.f[0]++;
const {
flags
} = (cov_i783mv28z.s[0]++, this.parse(ChannelInit));
cov_i783mv28z.s[1]++;
try {
const client = (cov_i783mv28z.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
let payload = (cov_i783mv28z.s[3]++, {
name: flags.name,
created_by: {
id: (0, _v.default)(),
name: 'CLI'
}
});
var _command = require("@oclif/command");
var _chalk = _interopRequireDefault(require("chalk"));
var _path = _interopRequireDefault(require("path"));
var _v = _interopRequireDefault(require("uuid/v4"));
var _auth = require("../../utils/auth");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class ChannelQuery extends _command.Command {
async run() {
cov_1padvcu0s.f[0]++;
const {
flags
} = (cov_1padvcu0s.s[0]++, this.parse(ChannelQuery));
cov_1padvcu0s.s[1]++;
try {
const client = (cov_1padvcu0s.s[2]++, await (0, _auth.auth)(_path.default.join(this.config.configDir, 'config.json'), this));
const filter = (cov_1padvcu0s.s[3]++, flags.filters ? (cov_1padvcu0s.b[0][0]++, JSON.parse(flags.filters)) : (cov_1padvcu0s.b[0][1]++, {}));
const sort = (cov_1padvcu0s.s[4]++, flags.sort ? (cov_1padvcu0s.b[1][0]++, JSON.parse(flags.sort)) : (cov_1padvcu0s.b[1][1]++, {}));
const channels = (cov_1padvcu0s.s[5]++, await client.queryChannels(filter, sort, {
subscribe: false
}));
cov_1padvcu0s.s[6]++;
this.log(channels[0].data);