javascript - Wallet.fromV3 不是函数
问题描述
我正在使用ethereumjs-wallet
,并且在我的开发节点环境中,调用Wallet.fromV3
没有问题。在我的生产安装中,发生错误
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
在我的开发环境中:
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
在生产中
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] } }
这与Wallet
从 导出的方式有关node_modules/ethereumjs-wallet/dist/index.js
吗?
exports.default = Wallet;
尽管建议Wallet
通过:加载const { Wallet } = require('ethereumjs-wallet')
,但它是以这种方式加载的: const Wallet = require('ethereumjs-wallet')
,因为它在使用前一种语法的开发中无法正常工作。
ethereumjs-wallet
和的版本truffle-hdwallet-provider
在两种环境中都是一致的。
-- ethereumjs-wallet@1.0.0
-- truffle-hdwallet-provider@1.0.17
知道我的生产系统上发生了什么吗?
解决方案
推荐阅读
- c++ - 基于 MFC 对话框的应用程序无法两次调用对话框
- google-colaboratory - 如何缩小细胞输出?
- c#-4.0 - 在这个问题中,您必须修改一个读取某些产品数据的现有 C# 程序,
- ag-grid - 在 AG Grid 中,有没有办法区分用户何时重新调整单个列的大小与何时重新调整所有列的大小?
- sql - 将一个表格中的电子邮件地址与 1 列中的多个电子表格匹配
- android - PublishedAdView 使 Scrollview 滞后
- git - 如何将此 TFVC 存储库转换为 ONE git 存储库?
- python - 如何更改列表项的视图
- java - 按子搜索用户返回 InvalidParameterException
- android - Android小部件RemoteViewsFactory的getViewAt()方法随机调用