How to use the @shapeshiftoss/hdwallet-core.Keyring function in @shapeshiftoss/hdwallet-core

To help you get started, we’ve selected a few @shapeshiftoss/hdwallet-core 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 shapeshift / hdwallet / packages / hdwallet-portis / src / portis.ts View on Github external
export function isPortis(wallet: HDWallet): wallet is PortisHDWallet {
  return isObject(wallet) && (wallet as any)._isPortis
}

export class PortisHDWallet implements HDWallet, ETHWallet, BTCWallet {
  _supportsETH: boolean = true
  _supportsETHInfo: boolean = true
  _supportsBTCInfo: boolean = true
  _supportsBTC: boolean = true
  _supportsCosmosInfo: boolean = false
  _supportsCosmos: boolean = false
  _supportsDebugLink: boolean = false
  _isPortis: boolean = true

  transport = new PortisTransport(new Keyring())

  portis: any
  web3: any
  info: PortisHDWalletInfo & HDWalletInfo
  ethAddress: string

  // used as a mutex to ensure calls to portis.getExtendedPublicKey cannot happen before a previous call has resolved
  portisCallInProgress: Promise = Promise.resolve()

  constructor(portis) {
    this.portis = portis
    this.web3 = new Web3(portis.provider)
    this.info = new PortisHDWalletInfo()
  }

  public async isLocked(): Promise {
github shapeshift / hdwallet / packages / hdwallet-metamask / src / metamask.ts View on Github external
public call (...args: any[]): Promise {
    return Promise.resolve()
  }

}

export class MetaMaskHDWallet implements HDWallet, ETHWallet {
  _supportsETH: boolean = true
  _supportsETHInfo: boolean = true
  _supportsBTCInfo: boolean = false
  _supportsBTC: boolean = false
  _supportsDebugLink: boolean = false
  _isMetaMask: boolean = true

  transport = new MetaMaskTransport(new Keyring())

  info: MetaMaskHDWalletInfo & HDWalletInfo
  ethereum: any
  accounts: string[]

  constructor(ethereum) {
    console.log('runnin with the devil')
    this.ethereum = ethereum
    this.info = new MetaMaskHDWalletInfo()
    this.accounts = []
  }

  public async isLocked(): Promise {
    return false
  }
github shapeshift / hdwallet / integration / src / wallets / keepkey.ts View on Github external
export async function createWallet (): Promise {
  const keyring = new Keyring()

  let wallet = await getDevice(keyring) || await getEmulator(keyring)

  if (!wallet)
    throw new Error("No suitable test KeepKey found")

  wallet.transport.on(Events.BUTTON_REQUEST, async () => {
    if (autoButton && supportsDebugLink(wallet)) {
      await wallet.pressYes()
    }
  })

  wallet.transport.onAny((event: string[], ...values: any[]) => {
    //console.info(event, ...values)
  })
github shapeshift / hdwallet / packages / hdwallet-react / src / context / HDWalletContext.tsx View on Github external
import { WebUSBKeepKeyAdapter } from "@shapeshiftoss/hdwallet-keepkey-webusb";
import { TrezorAdapter } from "@shapeshiftoss/hdwallet-trezor-connect";

export interface HDWalletContextValue {
  keyring: Keyring;
  pairedDevices: { [index: string]: HDWallet };
  getAdapter: (
    adapterName: string
  ) => WebUSBKeepKeyAdapter | TrezorAdapter | any;
}

let hdWalletContext: React.Context;

const initialValue = {
  keyring: new Keyring(),
  pairedDevices: {},
  getAdapter: () => {}
};

export function getHDWalletContext() {
  if (!hdWalletContext) {
    hdWalletContext = React.createContext(initialValue);
  }
  return hdWalletContext;
}

export function resethdWalletContext() {
  hdWalletContext = React.createContext(initialValue);
}
github shapeshift / hdwallet / integration / src / wallets / trezor.ts View on Github external
export async function createWallet (): Promise {
  let keyring = new Keyring()
  let transport = new MockTransport(keyring)
  return createTrezor(transport as TrezorTransport, true)
}
github shapeshift / hdwallet / examples / sandbox / index.ts View on Github external
import { PortisAdapter } from '@shapeshiftoss/hdwallet-portis'

import {
  BTCInputScriptType,
  BTCOutputScriptType,
  BTCOutputAddressType,
} from '@shapeshiftoss/hdwallet-core/src/bitcoin'

import * as btcBech32TxJson from './json/btcBech32Tx.json'
import * as btcTxJson from './json/btcTx.json'
import * as btcSegWitTxJson from './json/btcSegWitTx.json'
import * as dashTxJson from './json/dashTx.json'
import * as dogeTxJson from './json/dogeTx.json'
import * as ltcTxJson from './json/ltcTx.json'

const keyring = new Keyring()

const portisAppId = 'ff763d3d-9e34-45a1-81d1-caa39b9c64f9'

const keepkeyAdapter = WebUSBKeepKeyAdapter.useKeyring(keyring)
const kkemuAdapter = TCPKeepKeyAdapter.useKeyring(keyring)
const portisAdapter = PortisAdapter.useKeyring(keyring, { portisAppId })

const log = debug.default('hdwallet')

keyring.onAny((name: string[], ...values: any[]) => {
  const [[ , event ]] = values
  const { from_wallet = false } = event
  let direction = from_wallet ? "🔑" : "💻"
  log(direction + ' ' + name.join('.'), event)
})
github shapeshift / hdwallet / integration / src / wallets / ledger.ts View on Github external
export async function createWallet (type: any = 'Bitcoin'): Promise {
  let keyring = new Keyring()
  let transport = new MockTransport(keyring, type)
  return createLedger(transport as any)
}