我想使用github的kadena-io/cardano-crypto.js。这是cardano-crypto.js链接:https://github.com/kadena-io/cardano-crypto.js。但是使用的时候就报错了。我已经尝试了很多方法来修复该错误,但它不起作用。要在 cardano-crypto.js 中获取 lib.js 文件,首先我必须安装 npm。我就是这么做的。然后是 lib.js 文件。然后我尝试将cardano-crypto.js的mnemonicToRootKeyPair函数导入到我的react-native钱包中。但有一个错误。为了解决该错误,首先我尝试使用节点模块导入cardano-crypto.js。然后我尝试在没有node_module的情况下导入。我已经通过多种方式导入了。
从“路径”导入 {}
,
_importDefault(需要('路径'))
。但不知何故,Cardano-crypto.js 的 mnemonicToRootKeyPair 无法运行/导入。错误提示 lib.js: 找不到路径。但 lib.js 文件就在那里。现在我该如何解决这个如何在我们的反应本机钱包中使用cardano-crypto.js的mnemonicToRootKeyPair?
这是我想要使用的cardano-crypto.js mnemonicToRootKeyPair 函数代码:
async function mnemonicToRootKeypair(mnemonic, derivationScheme) {
validateDerivationScheme(derivationScheme)
if (derivationScheme === 1) {
return mnemonicToRootKeypairV1(mnemonic)
} else if (derivationScheme === 2) {
return mnemonicToRootKeypairV2(mnemonic, '')
} else {
throw Error(`Derivation scheme ${derivationScheme} not implemented`)
}
}
这是我在反应本机钱包中使用该函数时出现的错误:
构建 JavaScript 包失败。
无法从 C:\Users\DCL\Desktop\app\cardanoCrypto\lib.js 解析模块路径:在项目中找不到路径。
I want to use github's kadena-io/cardano-crypto.js.This is the cardano-crypto.js Link: https://github.com/kadena-io/cardano-crypto.js. But it is an error when used. I've tried a lot to fix the error, but it doesn't work. To get lib.js file in cardano-crypto.js, first I have to install npm. I did that. Then came the lib.js file. Then I tried to import cardano-crypto.js's mnemonicToRootKeyPair function to my react-native wallet. But there is an error. To solve the error, first I tried to import cardano-crypto.js with node module. Then I tried to import without node_module. I have imported in several ways.
import {} from 'path'
,
_importDefault (require ('path'))
. But somehow Cardano-crypto.js's mnemonicToRootKeyPair could not run/import. Error says lib.js: path could not be found. But the lib.js file is there. Now how do I solve this how to use mnemonicToRootKeyPair of cardano-crypto.js in our react native wallet?
This is the cardano-crypto.js mnemonicToRootKeyPair function code that I want to use:
async function mnemonicToRootKeypair(mnemonic, derivationScheme) {
validateDerivationScheme(derivationScheme)
if (derivationScheme === 1) {
return mnemonicToRootKeypairV1(mnemonic)
} else if (derivationScheme === 2) {
return mnemonicToRootKeypairV2(mnemonic, '')
} else {
throw Error(`Derivation scheme ${derivationScheme} not implemented`)
}
}
And this is the error when I use the function in my react native wallet:
Failed building JavaScript bundle.
Unable to resolve module path from C:\Users\DCL\Desktop\app\cardanoCrypto\lib.js: path could not be found within the project.
发布评论