Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { isFunction } from 'lodash'
import WalletProvider from '@liquality/wallet-provider'
import { formatEthResponse } from '@liquality/ethereum-utils'
import { WalletError } from '@liquality/errors'
import Debug from '@liquality/debug'
import { version } from '../package.json'
const debug = Debug('metamask')
export default class MetaMaskProvider extends WalletProvider {
constructor (metamaskProvider, network) {
super(network)
if (!isFunction(metamaskProvider.sendAsync)) {
throw new Error('Invalid MetaMask Provider')
}
this._metamaskProvider = metamaskProvider
this._network = network
}
async metamask (method, ...params) {
if (global.window) {
await global.window.ethereum.enable() // Ensure access to MetaMask is granted
import axios from 'axios'
import JSONBigInt from 'json-bigint'
import { get, has } from 'lodash'
import Provider from '@liquality/provider'
import Debug from '@liquality/debug'
import { NodeError, RpcError } from '@liquality/errors'
import { version } from '../package.json'
const debug = Debug('jsonrpc')
const { parse } = JSONBigInt({ storeAsString: true, strict: true })
export default class JsonRpcProvider extends Provider {
constructor (uri, username, password) {
super()
this._uri = uri
this._axios = axios.create({
baseURL: uri,
responseType: 'text',
transformResponse: undefined, // https://github.com/axios/axios/issues/907,
validateStatus: (status) => true
})
import WalletProvider from '@liquality/wallet-provider'
import { WalletError } from '@liquality/errors'
import Debug from '@liquality/debug'
import getTransport from './LedgerNodeTransport'
import { version } from '../package.json'
const debug = Debug('ledger')
export default class LedgerProvider extends WalletProvider {
static getTransport (config = { useWebBle: false }) {
return getTransport(config)
}
static isSupported (config) {
return getTransport(config).isSupported()
}
constructor (App, baseDerivationPath, network, ledgerScrambleKey) {
super(network)
this._App = App
this._baseDerivationPath = baseDerivationPath
this._network = network
import WalletProvider from '@liquality/wallet-provider'
import { WalletError } from '@liquality/errors'
import Debug from '@liquality/debug'
import getTransport from './LedgerNodeTransport'
import { version } from '../package.json'
const debug = Debug('ledger')
export default class LedgerProvider extends WalletProvider {
static getTransport (config = { useWebBle: false, useU2F: false }) {
return getTransport(config)
}
static isSupported (config) {
return getTransport(config).isSupported()
}
constructor (App, baseDerivationPath, network, ledgerScrambleKey) {
super(network)
this._App = App
this._baseDerivationPath = baseDerivationPath
this._network = network