如何在React Native钱包中使用github的kadena-io/cardano-crypto.js助记词

发布于 2025-01-18 06:59:38 字数 1388 浏览 5 评论 0 原文

我想使用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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文