How to use the @ethersproject/hdnode.mnemonicToSeed function in @ethersproject/hdnode

To help you get started, we’ve selected a few @ethersproject/hdnode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3box / 3box-js / src / 3id / index.js View on Github external
async _initKeyringByName (name) {
    if (this._has3idProv) throw new Error('Can not initKeyringByName of IdentityWallet')
    if (!this._keyrings[name]) {
      const sig = await utils.openSpaceConsent(this.managementAddress, this._provider, name)
      const entropy = '0x' + utils.sha256(sig.slice(2))
      const seed = mnemonicToSeed(entropyToMnemonic(entropy))
      this._keyrings[name] = new Keyring(seed)
      this._subDIDs[name] = await this._init3ID(name)
      localstorage.set(STORAGE_KEY + this.managementAddress, this.serializeState())
      return true
    } else {
      return false
    }
  }
github 3box / 3box-js / src / 3id / index.js View on Github external
} else {
      const normalizedAddress = address.toLowerCase()
      let serialized3id = localstorage.get(STORAGE_KEY + normalizedAddress)
      if (serialized3id) {
        if (opts.consentCallback) opts.consentCallback(false)
      } else {
        let sig
        if (opts.contentSignature) {
          sig = opts.contentSignature
        } else {
          sig = await utils.openBoxConsent(normalizedAddress, provider)
        }
        if (opts.consentCallback) opts.consentCallback(true)
        const entropy = '0x' + utils.sha256(sig.slice(2))
        const mnemonic = entropyToMnemonic(entropy)
        const seed = mnemonicToSeed(mnemonic)
        serialized3id = JSON.stringify({
          managementAddress: normalizedAddress,
          seed,
          spaceSeeds: {}
        })
      }
      const threeId = new ThreeId(provider, ipfs, opts)
      threeId._initKeys(serialized3id)
      await threeId._initDID()
      return threeId
    }
  }
}