Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError during Deposit (web3 <= v1.2.2) #283

Open
deeintech opened this issue Apr 17, 2020 · 0 comments
Open

Uncaught ReferenceError during Deposit (web3 <= v1.2.2) #283

deeintech opened this issue Apr 17, 2020 · 0 comments

Comments

@deeintech
Copy link
Contributor

deeintech commented Apr 17, 2020

Description

When running code examples as a separate project, deposit returns Uncaught ReferenceError: regeneratorRuntime preventing from executing any subsequent code. That's a direct issue of web3 that supposed to be fixed in v1.2.2 but probably was fixed in the later versions. Having up-to-date web3 dependency should fix the problem.

Expected behavior

No errors during deposit function, subsequent code runs as it should.

Actual behavior

Deposit happens but returns an issue and blocks any other code from executing.

Steps to reproduce the behavior

  1. Create a new node.js project.
  2. Install web3 <=v1.2.2 (or earlier) and other dependencies from Example folder.
  3. Modify env file or config.js directly (if env doesn't work for some reason) with required values.
  4. Create a new .js file. Instert the following code:
import BigNumber from "bn.js";
import Web3 from "web3";
import { ChildChain, RootChain, OmgUtil } from "@omisego/omg-js";
import config from "../config.js";

const web3 = new Web3(new Web3.providers.HttpProvider(config.eth_node), null, {
  transactionConfirmationBlocks: 1,
});
const rootChain = new RootChain({
  web3,
  plasmaContractAddress: config.plasmaframework_contract_address,
});
const childChain = new ChildChain({
  watcherUrl: config.watcher_url,
  watcherProxyUrl: config.watcher_proxy_url,
  plasmaContractAddress: config.plasmaframework_contract_address,
});
const aliceAddress = config.alice_eth_address;
const alicePrivateKey = config.alice_eth_address_private_key;
const depositAmount = new BigNumber(
  web3.utils.toWei(config.alice_eth_deposit_amount, "ether")
);

async function childchainDepositEth() {
  console.log(
    `Depositing ${web3.utils.fromWei(
      depositAmount.toString(),
      "ether"
    )} ETH from the rootchain to the childchain`
  );
  const transactionReceipt = await rootChain.deposit({
    amount: depositAmount,
    txOptions: {
      from: aliceAddress,
      privateKey: alicePrivateKey,
      gas: 6000000,
    },
  });
  console.log("Deposit successful: ", transactionReceipt.transactionHash);
}

childchainDepositEth();
  1. Run the code with node, webpack, browserify, or another preferable way.

Error Logs

Uncaught ReferenceError: regeneratorRuntime is not defined
    at eval (web3.min.js:4)
    at n (web3.min.js:4)

Versions

  • web3.js: 1.2.2 (and earlier versions)
  • browser: Chrome 80.0.3987.163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant