How to use embark-utils - 10 common examples

To help you get started, we’ve selected a few embark-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github embark-framework / embark / packages / embark-blockchain-process / src / simulator.js View on Github external
mnemonicAccount = mnemonicAccount || {};
    const simulatorMnemonic = mnemonicAccount.mnemonic || options.simulatorMnemonic;

    if (simulatorMnemonic) {
      cmds.push("--mnemonic \"" + (simulatorMnemonic) + "\"");
    }
    cmds.push("-a " + (options.numAccounts || mnemonicAccount.numAddresses || 10));
    cmds.push("-e " + (options.defaultBalance || mnemonicAccount.balance || 100));

    // as ganache-cli documentation explains, the simulatorAccounts configuration overrides a mnemonic
    let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
    if (simulatorAccounts && simulatorAccounts.length > 0) {
      let web3 = new (require('web3'))();
      let parsedAccounts;
      try {
        parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, dappPath(), this.logger);
      } catch (e) {
        this.logger.error(e.message);
        process.exit(1);
      }
      parsedAccounts.forEach((account) => {
        let cmd = '--account="' + account.privateKey + ',' + account.hexBalance + '"';
        cmds.push(cmd);
      });
    }

    // adding blocktime only if it is defined in the blockchainConfig or options
    let simulatorBlocktime = this.blockchainConfig.simulatorBlocktime || options.simulatorBlocktime;
    if (simulatorBlocktime) {
      cmds.push("-b \"" + (simulatorBlocktime) + "\"");
    }
github embark-framework / embark / packages / embark / src / cmd / simulator.js View on Github external
mnemonicAccount = mnemonicAccount || {};
    const simulatorMnemonic = mnemonicAccount.mnemonic || options.simulatorMnemonic;

    if (simulatorMnemonic) {
      cmds.push("--mnemonic \"" + (simulatorMnemonic) + "\"");
    }
    cmds.push("-a " + (options.numAccounts || mnemonicAccount.numAddresses || 10));
    cmds.push("-e " + (options.defaultBalance || mnemonicAccount.balance || 100));

    // as ganache-cli documentation explains, the simulatorAccounts configuration overrides a mnemonic
    let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
    if (simulatorAccounts && simulatorAccounts.length > 0) {
      let web3 = new (require('web3'))();
      let parsedAccounts;
      try {
        parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, dappPath(), this.logger);
      } catch (e) {
        this.logger.error(e.message);
        process.exit(1);
      }
      parsedAccounts.forEach((account) => {
        let cmd = '--account="' + account.privateKey + ',' + account.hexBalance + '"';
        cmds.push(cmd);
      });
    }

    // adding blocktime only if it is defined in the blockchainConfig or options
    let simulatorBlocktime = this.blockchainConfig.simulatorBlocktime || options.simulatorBlocktime;
    if (simulatorBlocktime) {
      cmds.push("-b \"" + (simulatorBlocktime) + "\"");
    }
github embark-framework / embark / packages / plugins / geth / src / blockchain.js View on Github external
checkPathLength() {
    let _dappPath = dappPath('');
    if (_dappPath.length > 66) {
      // this.logger.error is captured and sent to the console output regardless of silent setting
      this.logger.error("===============================================================================".yellow);
      this.logger.error("===========> ".yellow + __('WARNING! ÐApp path length is too long: ').yellow + _dappPath.yellow);
      this.logger.error("===========> ".yellow + __('This is known to cause issues with starting geth, please consider reducing your ÐApp path\'s length to 66 characters or less.').yellow);
      this.logger.error("===============================================================================".yellow);
    }
  }
github embark-framework / embark / packages / plugins / accounts-manager / src / index.ts View on Github external
private async parseAndFundAccounts() {
    const web3 = await this.web3;
    const accounts = await this.accounts;

    if (!accounts.length || !this.embark.config.blockchainConfig.isDev) {
      return;
    }
    try {
      const coinbase = await web3.eth.getCoinbase();
      const acctsFromConfig = AccountParser.parseAccountsConfig(this.embark.config.blockchainConfig.accounts, web3, dappPath(), this.logger, accounts);
      const accountsWithBalance = accounts.map((address) => {
        const acctFromConfig = acctsFromConfig.find((acctCfg) => acctCfg.address === address);
        return {
          address,
          hexBalance: acctFromConfig ? acctFromConfig.hexBalance : undefined
        };
      });

      async.eachLimit(accountsWithBalance, 1, (acct, eachCb) => {
        fundAccount(web3, acct.address, coinbase, acct.hexBalance)
          .then(() => {
            eachCb();
          })
          .catch(eachCb);
      });
    } catch (err) {
github embark-framework / embark / packages / core / core / src / config.ts View on Github external
_getFileOrObject(object, filePath, property) {
    if (typeof object === 'object') {
      return object[property] ? dappPath(object[property]) : object[property];
    }
    return dappPath(object, filePath);
  }
github embark-framework / embark / packages / core / core / src / config.ts View on Github external
_getFileOrObject(object, filePath, property) {
    if (typeof object === 'object') {
      return object[property] ? dappPath(object[property]) : object[property];
    }
    return dappPath(object, filePath);
  }
github embark-framework / embark / packages / plugins / ethereum-blockchain-client / src / api.js View on Github external
constructor(embark, web3, blockchainName) {
    this.embark = embark;
    this.blockchainName = blockchainName;
    this.web3 = web3;
    this.requestManager = new Manager(web3.currentProvider);
    this.fs = embark.fs;
    this.logFile = dappPath(".embark", "contractEvents.json");
  }
github embark-framework / embark / packages / embark-pipeline / src / index.js View on Github external
self.events.request('code-generator:contract', contract.className, (err, contractPath) => {
              if (err) {
                return eachCb(err);
              }
              importsList["Embark/contracts/" + contract.className] = dappPath(contractPath);

              eachCb();
            });
          }, next);
github embark-framework / embark / packages / plugins / scaffolding / src / contractLanguage / solidityBuilder / index.ts View on Github external
private saveFile(contractName: string, code: string) {
    const filename = `${contractName}.sol`;
    const contractDirs = this.embark.config.embarkConfig.contracts;
    const contractDir = Array.isArray(contractDirs) ? contractDirs[0] : contractDirs;
    const filePath = dappPath(contractDir.replace(/\*/g, ""), filename);
    if (!this.options.overwrite && this.embark.fs.existsSync(filePath)) {
      this.embark.logger.error(__(`The contract ${contractName} already exists, skipping.`));
      return;
    }

    this.embark.fs.writeFileSync(filePath, code);
    return filePath;
  }
github embark-framework / embark / packages / plugins / scaffolding / src / framework / reactBuilder / index.ts View on Github external
private installDependencies() {
    let pkgManager = 'npm install';
    if (this.embark.fs.existsSync(utils.dappPath('yarn.lock'))) {
      pkgManager = 'yarn add';
    }
    const cmd = `${pkgManager} react react-bootstrap@^0.33.1 react-dom`;
    return new Promise((resolve, reject) => {
      utils.runCmd(cmd, null, (error: string) => {
        if (error) {
          return reject(new Error(error));
        }

        resolve();
      });
    });
  }

embark-utils

Utils used by Embark

MIT
Latest version published 5 years ago

Package Health Score

54 / 100
Full package analysis

Popular embark-utils functions