Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import logger from 'logger'
import { BigNumber } from 'bignumber.js'
import { RippleAPI } from 'ripple-lib'
import {
parseCurrencyUnit,
getCryptoCurrencyById,
formatCurrencyUnit,
} from '@ledgerhq/live-common/lib/currencies'
const rippleUnit = getCryptoCurrencyById('ripple').units[0]
export const defaultEndpoint = 'wss://s2.ripple.com'
export const apiForEndpointConfig = (endpointConfig: ?string = null) => {
const server = endpointConfig || defaultEndpoint
const api = new RippleAPI({ server })
api.on('error', (errorCode, errorMessage) => {
logger.warn(`Ripple API error: ${errorCode}: ${errorMessage}`)
})
return api
}
export const parseAPIValue = (value: string) => parseCurrencyUnit(rippleUnit, value)
export const parseAPICurrencyObject = ({
currency,
currency: getCryptoCurrencyById("bitcoin"),
exchange: null,
value: 0.5
},
{
currency: getCryptoCurrencyById("litecoin"),
exchange: "BINANCE",
value: 2
},
{
currency: getCryptoCurrencyById("ethereum"),
exchange: "BINANCE",
value: 1
},
{
currency: getCryptoCurrencyById("zencash"),
exchange: "BINANCE",
value: 10
}
]
};
const reducers: { [_: string]: (State, *) => State } = {
SET_COUNTERVALUE_CURRENCY: (state, { currency }) => ({
...state,
countervalueCurrency: currency
}),
SET_COUNTERVALUE_EXCHANGE: (state, { exchange }) => ({
...state,
countervalueExchange: exchange
}),
const notEnoughMemoryToInstall = useMemo(
() => isOutOfMemoryState(predictOptimisticState(reducer(state, { type: 'install', name }))),
[name, state],
)
const isLiveSupported =
app.currencyId && isCurrencySupported(getCryptoCurrencyById(app.currencyId))
return (
<img height="{40}" width="{40}" src="{manager.getIconUrl(app.icon)}" alt="">
{formatSize(
((installed && installed.blocks) || 0) * deviceModel.deviceSize || app.bytes || 0,
)}
{isLiveSupported ? (
}>
Observable.create(o => {
let unsubscribed = false;
const currency = getCryptoCurrencyById(currencyId);
const isCancelled = () => unsubscribed;
doSignAndBroadcast({
accountId,
currency,
blockHeight,
derivationMode,
seedIdentifier,
xpub,
index,
transaction,
deviceId,
isCancelled,
onSigning: () => {
o.next({ type: "signing" });
},
onSigned: () => {
const before = window.performance.now()
const res = await job()
const after = window.performance.now()
this.log(
`benchmark: ${Math.round((after - before) * 100) / 100}ms: ${name} => ${String(res)}`,
)
}
await run('ping process', () => ping.send().toPromise())
await run('libcore version', () =>
libcoreGetVersion
.send()
.toPromise()
.then(o => o.stringVersion),
)
const currency = getCryptoCurrencyById('bitcoin')
const derivationScheme = getDerivationScheme({
currency,
derivationMode: 'segwit',
})
const obj = {
path: runDerivationScheme(derivationScheme, currency),
currencyId: currency.id,
devicePath: device.path,
derivationMode: 'segwit',
}
await run('getAddress', () =>
getAddress
.send(obj)
.toPromise()
.then(o => o.address),
)
getCryptoCurrencyById,
getFiatCurrencyByTicker,
} from '@ledgerhq/live-common/lib/currencies'
import { getLanguages } from 'config/languages'
import { createSelector } from 'reselect'
import type { InputSelector as Selector } from 'reselect'
import type { CryptoCurrency, Currency } from '@ledgerhq/live-common/lib/types'
import { getEnv } from '@ledgerhq/live-common/lib/env'
import { currencySettingsDefaults } from 'helpers/SettingsDefaults'
import { getSystemLocale } from 'helpers/systemLocale'
import type { CurrencySettings } from 'types/common'
import type { State } from 'reducers'
const bitcoin = getCryptoCurrencyById('bitcoin')
const ethereum = getCryptoCurrencyById('ethereum')
export const possibleIntermediaries = [bitcoin, ethereum]
export const intermediaryCurrency = (from: Currency, _to: Currency) => {
if (from === ethereum || from.type === 'TokenCurrency') return ethereum
return bitcoin
}
export const timeRangeDaysByKey = {
week: 7,
month: 30,
year: 365,
}
export type TimeRange = $Keys
export type { CurrencySettings }
({ currencyId, xpub, derivationMode, seedIdentifier }) => {
const currency = getCryptoCurrencyById(currencyId)
const freshAddress = ''
const freshAddressPath = runDerivationScheme(derivationMode, getCryptoCurrencyById(currencyId))
const account: $Exact = {
type: 'Account',
name: `(DEV) ${currencyId}`,
xpub,
seedIdentifier,
id: encodeAccountId({
type: 'libcore_dev',
version: '1',
currencyId,
xpubOrAddress: xpub,
derivationMode,
}),
derivationMode,
currency,
countervalueCurrency: getFiatCurrencyByTicker("USD"),
countervalueExchange: "Kraken",
intermediaryCurrency: getCryptoCurrencyById("bitcoin"),
rows: [
{
currency: getCryptoCurrencyById("bitcoin"),
exchange: null,
value: 0.5
},
{
currency: getCryptoCurrencyById("litecoin"),
exchange: "BINANCE",
value: 2
},
{
currency: getCryptoCurrencyById("ethereum"),
exchange: "BINANCE",
value: 1
},
{
currency: getCryptoCurrencyById("zencash"),
exchange: "BINANCE",
value: 10
}
]
};
const reducers: { [_: string]: (State, *) => State } = {
SET_COUNTERVALUE_CURRENCY: (state, { currency }) => ({
...state,
countervalueCurrency: currency
}),
import { genStoreState } from '@ledgerhq/live-common/lib/countervalues/mock'
import {
getCryptoCurrencyById,
getFiatCurrencyByTicker,
} from '@ledgerhq/live-common/lib/currencies'
export default {
countervalues: genStoreState([
{
from: getCryptoCurrencyById('bitcoin'),
to: getFiatCurrencyByTicker('USD'),
exchange: 'KRAKEN',
dateFrom: new Date(2015, 1, 1),
dateTo: new Date(),
rate: d => 0.007 + 0.003 * Math.max(0, (d / 1e12 + Math.sin(d / 1e9)) / 2),
},
]),
}
TextInput,
Platform,
} from "react-native";
import { BigNumber } from "bignumber.js";
import {
sanitizeValueString,
getCryptoCurrencyById,
} from "@ledgerhq/live-common/lib/currencies";
import LText from "../../../components/LText/index";
import Check from "../../../icons/Check";
import colors from "../../../colors";
import { CUSTOM_FEES_CAP } from "../../../constants";
const bitcoinCurrency = getCryptoCurrencyById("bitcoin");
const satoshiUnit = bitcoinCurrency.units[bitcoinCurrency.units.length - 1];
type Props = {
title: React$Node,
last?: boolean,
initialValue: ?BigNumber,
onPress: BigNumber => void,
isSelected: boolean,
isValid?: boolean,
};
type State = {
fees: ?string,
};
class FeesRow extends Component {