question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: input.charCodeAt is not a function

See original GitHub issue

I get the following error:

Generating coverage environment
Running: truffle compile --network coverage 
(this can take a few seconds)...
Compiling ./contracts/InterfacePatientRecords.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/PatientRecords.sol...
Compiling ./contracts/SpringToken.sol...
Compiling ./contracts/TokenDestructible.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/ownership/Ownable.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/ERC20/StandardToken.sol...

Compilation warnings encountered:

zeppelin-solidity/contracts/token/ERC20/BasicToken.sol:38:5: Warning: Invoking events without "emit" prefix is deprecated.
    Transfer(msg.sender, _to, _value);
    ^-------------------------------^
,zeppelin-solidity/contracts/token/ERC20/StandardToken.sol:33:5: Warning: Invoking events without "emit" prefix is deprecated.
    Transfer(_from, _to, _value);
    ^--------------------------^
,zeppelin-solidity/contracts/token/ERC20/StandardToken.sol:49:5: Warning: Invoking events without "emit" prefix is deprecated.
    Approval(msg.sender, _spender, _value);
    ^------------------------------------^
,zeppelin-solidity/contracts/token/ERC20/StandardToken.sol:75:5: Warning: Invoking events without "emit" prefix is deprecated.
    Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    ^-----------------------------------------------------------^
,zeppelin-solidity/contracts/token/ERC20/StandardToken.sol:96:5: Warning: Invoking events without "emit" prefix is deprecated.
    Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    ^-----------------------------------------------------------^
,zeppelin-solidity/contracts/ownership/Ownable.sol:38:5: Warning: Invoking events without "emit" prefix is deprecated.
    OwnershipTransferred(owner, newOwner);
    ^-----------------------------------^
,/home/nico/Desktop/public_repos/hospital_network/coverageEnv/contracts/SpringToken.sol:26:5: Warning: Invoking events without "emit" prefix is deprecated.
    Transfer(0x0, msg.sender, INITIAL_SUPPLY);
    ^---------------------------------------^

Writing artifacts to ./build/contracts

Instrumenting  ./coverageEnv/contracts/InterfacePatientRecords.sol
Skipping instrumentation of  ./coverageEnv/contracts/Migrations.sol
Instrumenting  ./coverageEnv/contracts/PatientRecords.sol
Cleaning up...
There was a problem instrumenting ./coverageEnv/contracts/PatientRecords.sol: TypeError: input.charCodeAt is not a function
Exiting without generating coverage...

truffle.js:

require('dotenv').config()
require('babel-register')({
  ignore: /node_modules\/(?!zeppelin-solidity\/test\/helpers)/
})
require('babel-polyfill')

const Web3 = require("web3")
const web3 = new Web3()
const WalletProvider = require("truffle-wallet-provider")
const Wallet = require('ethereumjs-wallet')

const rinkebyPrivateKey = new Buffer(process.env["RINKEBY_PRIVATE_KEY"], "hex")
const rinkebyWallet = Wallet.fromPrivateKey(rinkebyPrivateKey)
const rinkebyProvider = new WalletProvider(rinkebyWallet, "https://rinkeby.infura.io/")

module.exports = {
  migrations_directory: "./migrations",
  networks: {
    development: {
      host: "localhost",
      port: 9545,
      network_id: "*" // Match any network id
    },
    coverage: {
      host: "localhost",
      network_id: "*",
      port: 8555,         // <-- If you change this, also set the port option in .solcover.js.
      gas: 0xfffffffffff, // <-- Use this high gas value
      gasPrice: 0x01      // <-- Use this low gas price
    },
    ganache: {
      host: "127.0.0.1",
      port: 7545,
      network_id: 5777
    },
    rinkeby: {
      provider: rinkebyProvider,
      // You can get the current gasLimit by running
      // truffle deploy --network rinkeby
      // truffle(rinkeby)> web3.eth.getBlock("pending", (error, result) =>
      //   console.log(result.gasLimit))
      gas: 6721975,
      gasPrice: web3.toWei("50", "gwei"),
      network_id: "4",
    }
  },
  solc: {
    optimizer: {
      enabled: true,
      runs: 500
    }
  }
}

.solcover.js

module.exports = {
  copyNodeModules: true
}

Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cgeweckecommented, Apr 20, 2018

@NFhbar This should be fixed in 0.5.0. Thanks!

0reactions
NFhbarcommented, Apr 14, 2018

I can confirm that changing

if (msg.value > 0) 
   emit Deposit(msg.sender, msg.value);

to

if (msg.value > 0) {
   emit Deposit(msg.sender, msg.value);
 }

Solves the problem. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: str.charCodeAt is not a function - Stack Overflow
I updated to node version 6 today and that might've broke something. I tried to get back to node 5.10 but the issue...
Read more >
TypeError: this.input.charCodeAt is not a function · Issue #3089
Exception has occurred: TypeError TypeError: this.input.charCodeAt is not a function at Parser.
Read more >
charcodeat is not a function javascript, typeerror
charcodeat is not a function javascript. The charCodeAt() method returns the Unicode of the character at the specified index in a string.
Read more >
t.charcodeat is not a function - You.com | The AI Search ...
TypeError: str.charCodeAt is not a function - Stack Overflow ... This could be an issue with some module not being entirely compatible with...
Read more >
String.prototype.charCodeAt() - JavaScript - MDN Web Docs
If index is not a number, it defaults to 0 . Return value. A number representing the UTF-16 code unit value of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found