How to use the @ledgerhq/live-common/lib/bridge.getAccountBridge 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-common / cli / src / __tests__ / bridges.js View on Github external
.map(({ account, ...rest }) => {
    const bridge = getAccountBridge(account, null);
    if (!bridge) throw new Error("no bridge for " + account.id);
    let accountSyncedPromise;
    // lazy eval so we don't run this yet
    const getSynced = () =>
      accountSyncedPromise ||
      (accountSyncedPromise = syncAccount(bridge, account));
    return { getSynced, bridge, initialAccount: account, ...rest };
  })
  .forEach(arg => {
github LedgerHQ / ledger-live-mobile / src / screens / AccountSettings / AccountNodeRow.js View on Github external
render() {
    const { navigation, account } = this.props;
    const bridge = getAccountBridge(account);

    return (
      }
        desc={}
        arrowRight
        alignedTop
        onPress={() =>
          navigation.navigate("EditAccountNode", {
            accountId: account.id,
          })
        }
      >
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 / families / helpers.js View on Github external
export const editTxFeeByFamily = (
  account: Account,
  navigation: NavigationScreenProp<*>,
  field: string,
  fee: ?BigNumber,
) => {
  const transaction = navigation.getParam("transaction");
  const bridge = getAccountBridge(account);
  return bridge.editTransactionExtra(account, transaction, field, fee);
};
github LedgerHQ / ledger-live-common / cli / src / commands.js View on Github external
defer(() =>
                        getAccountBridge(account)
                          .getTransactionStatus(account, transaction)
                          .then(status => ({ transaction, status }))
                      )
github LedgerHQ / ledger-live-mobile / src / screens / SendFunds / ScanRecipient.js View on Github external
onResult = (result: string) => {
    const { account, parentAccount, navigation } = this.props;
    if (!account) return;
    const bridge = getAccountBridge(account, parentAccount);
    const { amount, address, currency, ...rest } = decodeURIScheme(result);
    const transaction = navigation.getParam("transaction");
    const patch: Object = {};
    patch.recipient = address;
    if (amount) {
      patch.amount = amount;
    }
    for (const k in rest) {
      if (k in transaction) {
        patch[k] = rest[k];
      }
    }

    this.props.navigation.navigate("SendSelectRecipient", {
      accountId: account.id,
      parentId: parentAccount && parentAccount.id,
github LedgerHQ / ledger-live-desktop / src / bridge / BridgeSyncContext.js View on Github external
return
      }
      const account = this.props.accounts.find(a => a.id === accountId)
      if (!account) {
        next()
        return
      }

      const downStatus = currencyDownStatusLocal(this.props.currenciesStatus, account.currency)
      if (downStatus && !downStatus.keepSync) {
        next()
        return
      }

      try {
        const bridge = getAccountBridge(account)
        this.props.setAccountSyncState(accountId, { pending: true, error: null })

        const startSyncTime = Date.now()
        const trackedRecently =
          lastTimeAnalyticsTrackPerAccountId[accountId] &&
          startSyncTime - lastTimeAnalyticsTrackPerAccountId[accountId] < 90 * 1000
        if (!trackedRecently) {
          lastTimeAnalyticsTrackPerAccountId[accountId] = startSyncTime
        }
        const trackEnd = event => {
          if (trackedRecently) return
          const account = this.props.accounts.find(a => a.id === accountId)
          if (!account) return
          const subAccounts = account.subAccounts || []
          track(event, {
            duration: (Date.now() - startSyncTime) / 1000,
github LedgerHQ / ledger-live-mobile / src / families / EditFeeUnit.js View on Github external
updateTransaction = (item: any) => {
    const { account, navigation } = this.props;
    const transaction = navigation.getParam("transaction");
    const bridge = getAccountBridge(account);
    navigation.setParams({
      transaction: bridge.editTransactionExtra(
        account,
        transaction,
        "feeCustomUnit",
        item,
      ),
    });
    this.onRequestClose();
  };
github LedgerHQ / ledger-live-mobile / src / screens / AccountSettings / EditAccountNode.js View on Github external
validateNode = async () => {
    const { account } = this.props;
    const { accountNode } = this.state;

    const bridge = getAccountBridge(account);

    try {
      if (bridge.validateEndpointConfig) {
        await bridge.validateEndpointConfig(accountNode);
      }
      return true;
    } catch (error) {
      this.setState({ error });
      return false;
    }
  };
github LedgerHQ / ledger-live-mobile / src / families / ethereum / EditFeeUnitEthereum.js View on Github external
const EditFeeUnitEthereum = ({
  account,
  parentAccount,
  transaction,
  t,
  navigation,
}: Props) => {
  const { setAccount, setTransaction } = useBridgeTransaction();

  useMemo(() => {
    setAccount(account, parentAccount);
    setTransaction(transaction);
  }, [setAccount, setTransaction, account, parentAccount, transaction]);

  const mainAccount = getMainAccount(account, parentAccount);
  const bridge = getAccountBridge(account, parentAccount);

  const [gasPrice, setGasPrice] = useState(() => transaction.gasPrice);
  const feeCustomUnit = transaction.feeCustomUnit;

  const onChangeF = useCallback(
    value => {
      const { gasPrice } = bridge.updateTransaction(transaction, {
        gasPrice: value,
      });
      setGasPrice(gasPrice);
    },
    [bridge, transaction],
  );

  const onValidateFees = useCallback(() => {
    navigation.navigate("SendSummary", {