Wallet.fromV3 is not a function

1.2k Views Asked by At

I'm using ethereumjs-wallet, and in my development node environment, a call to Wallet.fromV3 is working without issue. On my production installation, an error occurs

TypeError: Wallet.fromV3 is not a function
    at extractPrivateKey (/usr/src/app/dist/blockchain/library.js:83:23)
    at sendTransaction (/usr/src/app/dist/blockchain/library.js:113:3)
    at Object.callback (/usr/src/app/dist/blockchain/library.js:1052:5)
    at sendTxCallback (/usr/src/app/node_modules/web3/node_modules/web3-core-method/lib/index.js:533:29)
    at /usr/src/app/node_modules/web3/node_modules/web3-core-requestmanager/lib/index.js:293:9
    at XMLHttpRequest.request.onreadystatechange (/usr/src/app/node_modules/web3/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/src/app/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
    at XMLHttpRequest._setReadyState (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
    at XMLHttpRequest._onHttpResponseEnd (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:345:8)
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/xhr2-cookies/xml-http-request.ts:311:39)
    at IncomingMessage.emit (events.js:198:15)

console.log in my dev environment:

   Wallet function Wallet(priv, pub) {
      if (priv && pub) {
        throw new Error('Cannot supply both a private and a public key to the constructor');
      }
    
      if (priv && !ethUtil.isValidPrivate(priv)) {
        throw new Error('Private key does not satisfy the curve requirements (ie. it is invalid)');
      }
    
      if (pub && !ethUtil.isValidPublic(pub)) {
        throw new Error('Invalid public key');
      }
    
      this._privKey = priv;
      this._pubKey = pub;
    }

console.log in production

Wallet { hdkey: [Getter],
  thirdparty: [Getter],
  default:
   { [Function: Wallet]
     generate: [Function],
     generateVanityAddress: [Function],
     fromPublicKey: [Function],
     fromExtendedPublicKey: [Function],
     fromPrivateKey: [Function],
     fromExtendedPrivateKey: [Function],
     fromV1: [Function],
     fromV3: [Function],
     fromEthSale: [Function] } }

Is it something to do with the way Wallet is exported from node_modules/ethereumjs-wallet/dist/index.js?

exports.default = Wallet;

Despite the recommendation of loading Wallet via: const { Wallet } = require('ethereumjs-wallet'), it's being loaded this way: const Wallet = require('ethereumjs-wallet'), because it does not work properly in development with the former syntax.

The versions of ethereumjs-wallet and truffle-hdwallet-provider are consistent on both environments.

-- [email protected] 
-- [email protected]

Any idea what is happening on my production system?

0

There are 0 best solutions below