How to use the @ledgerhq/live-common/lib/account.getMainAccount function in @ledgerhq/live-common

To help you get started, we’ve selected a few @ledgerhq/live-common 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 LedgerHQ / ledger-live-desktop / src / components / modals / Send / steps / StepSummary.js View on Github external
render() {
    const { account, parentAccount, transaction, status } = this.props
    if (!account) return null
    const mainAccount = getMainAccount(account, parentAccount)
    if (!mainAccount || !transaction) return null
    const { estimatedFees, amount, totalSpent, warnings } = status
    const feeTooHigh = warnings.feeTooHigh
    const currency = getAccountCurrency(account)
    const feesUnit = getAccountUnit(mainAccount)
    const unit = getAccountUnit(account)

    return (
github LedgerHQ / ledger-live-desktop / src / families / tezos / Delegation / Row.js View on Github external
const Row = ({ account, parentAccount, delegation }: Props) => {
  const unit = getAccountUnit(account)
  const currency = getAccountCurrency(account)

  const mainAccount = getMainAccount(account, parentAccount)

  const name = delegation.baker ? delegation.baker.name : shortAddressPreview(delegation.address)

  const diffInDays = useMemo(() => moment().diff(delegation.operation.date, 'days'), [
    delegation.operation.date,
  ])

  const explorerView = getDefaultExplorerView(mainAccount.currency)
  const bakerURL = getAddressExplorer(explorerView, delegation.address)
  const txURL = getTransactionExplorer(explorerView, delegation.operation.hash)

  const openBaker = useCallback(() => {
    if (bakerURL) openURL(bakerURL)
  }, [bakerURL])

  const openTx = useCallback(() => {
github LedgerHQ / ledger-live-mobile / src / screens / SendFunds / 04-Summary.js View on Github external
onAcceptFees = async () => {
    const { account, parentAccount, navigation } = this.props;
    if (!account) return;
    const transaction = navigation.getParam("transaction");
    const bridge = getAccountBridge(account, parentAccount);
    const mainAccount = getMainAccount(account, parentAccount);
    await bridge.checkValidTransaction(mainAccount, transaction);

    navigation.navigate("SendConnectDevice", {
      accountId: account.id,
      parentId: parentAccount && parentAccount.id,
      transaction,
    });
    this.setState({ highFeesOpen: false });
  };
github LedgerHQ / ledger-live-mobile / src / screens / OperationDetails / index.js View on Github external
render() {
    const { navigation, account, parentAccount } = this.props;
    if (!account) return null;
    const operation = navigation.getParam("operation");
    const mainAccount = getMainAccount(account, parentAccount);
    const url = getTransactionExplorer(
      getDefaultExplorerView(mainAccount.currency),
      operation.hash,
    );
    return (
github LedgerHQ / ledger-live-mobile / src / screens / Account / EmptyStateAccount.js View on Github external
render() {
    const { account, parentAccount } = this.props;
    const mainAccount = getMainAccount(account, parentAccount);
    const hasSubAccounts = Array.isArray(mainAccount.subAccounts);
    const isToken =
      listTokenTypesForCryptoCurrency(mainAccount.currency).length > 0;

    return (
github LedgerHQ / ledger-live-desktop / src / components / OperationsList / ConfirmationCell.js View on Github external
render() {
    const { account, parentAccount, confirmationsNb, t, operation, marketIndicator } = this.props
    const mainAccount = getMainAccount(account, parentAccount)

    const amount = getOperationAmountNumber(operation)

    const isNegative = amount.isNegative()

    const isConfirmed =
      (operation.blockHeight ? mainAccount.blockHeight - operation.blockHeight : 0) >
      confirmationsNb

    const marketColor = getMarketColor({
      marketIndicator,
      isNegative,
    })

    return (
github LedgerHQ / ledger-live-desktop / src / components / modals / Receive / steps / StepAccount.js View on Github external
export default function StepAccount({
  token,
  account,
  parentAccount,
  receiveTokenMode,
  onChangeAccount,
  onChangeToken,
}: StepProps) {
  const mainAccount = account ? getMainAccount(account, parentAccount) : null
  const error = account ? getReceiveFlowError(account, parentAccount) : null

  return (
    
      
      {mainAccount ?  : null}
      {error ?  : null}
      {receiveTokenMode && mainAccount ? (
        
      ) : (
        
      )}
      {receiveTokenMode && mainAccount ? (
github LedgerHQ / ledger-live-desktop / src / components / AccountPage / AccountHeaderActions.js View on Github external
render() {
    const { account, parentAccount, openModal, t } = this.props
    const mainAccount = getMainAccount(account, parentAccount)
    let cap
    try {
      const bridge = getAccountBridge(account, parentAccount)
      cap = bridge.getCapabilities(mainAccount)
    } catch (e) {
      return null
    }
    return (
      
        {!isAccountEmpty(account) ? (
          
            {cap.canSend ? (
              <button> openModal(MODAL_SEND, { parentAccount, account })}</button>
github LedgerHQ / ledger-live-desktop / src / components / modals / Send / steps / StepRecipient.js View on Github external
export default ({
  t,
  account,
  parentAccount,
  openedFromAccount,
  transaction,
  onChangeAccount,
  onChangeTransaction,
  error,
  status,
  bridgePending,
}: StepProps) =&gt; {
  if (!status) return null
  const mainAccount = account ? getMainAccount(account, parentAccount) : null

  return (
    
      
      {mainAccount ?  : null}
      {error ?  : null}
      
        <label>{t('send.steps.details.selectAccountDebit')}</label>
github LedgerHQ / ledger-live-desktop / src / components / modals / Send / steps / StepAmount.js View on Github external
render() {
    const { t, account, parentAccount, status, bridgePending } = this.props
    const { errors } = status
    if (!account) return null

    const mainAccount = getMainAccount(account, parentAccount)
    const isTerminated = mainAccount.currency.terminated
    const hasErrors = Object.keys(errors).length
    const canNext = !bridgePending &amp;&amp; !hasErrors &amp;&amp; !isTerminated

    return (
      
        
        <button disabled="{!canNext}">
          {t('common.continue')}
        </button>
      
    )
  }
}