UNPKG

@ledgerhq/coin-stellar

Version:
57 lines 2.13 kB
import { getSerializedAddressParameters, updateTransaction, makeAccountBridgeReceive, makeScanAccounts, makeSync, } from "@ledgerhq/coin-framework/bridge/jsHelpers"; import { estimateMaxSpendable } from "./estimateMaxSpendable"; import { getTransactionStatus } from "./getTransactionStatus"; import { prepareTransaction } from "./prepareTransaction"; import { createTransaction } from "./createTransaction"; import { buildSignOperation } from "./signOperation"; import { broadcast } from "./broadcast"; import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper"; import signerGetAddress from "../signer"; import { getAccountShape } from "./synchronization"; import stellarCoinConfig from "../config"; const PRELOAD_MAX_AGE = 30 * 60 * 1000; // 30 minutes function buildCurrencyBridge(signerContext) { const getAddress = signerGetAddress(signerContext); const scanAccounts = makeScanAccounts({ getAccountShape, getAddressFn: getAddress, }); function getPreloadStrategy() { return { preloadMaxAge: PRELOAD_MAX_AGE, }; } return { getPreloadStrategy, preload: async () => { }, hydrate: () => { }, scanAccounts, }; } function buildAccountBridge(signerContext) { const getAddress = signerGetAddress(signerContext); const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress)); const signOperation = buildSignOperation(signerContext); const sync = makeSync({ getAccountShape }); const accountBridge = { createTransaction, updateTransaction, prepareTransaction, estimateMaxSpendable, getTransactionStatus, sync, receive, signOperation, broadcast, getSerializedAddressParameters, }; return accountBridge; } export function createBridges(signerContext, coinConfig) { stellarCoinConfig.setCoinConfig(coinConfig); return { currencyBridge: buildCurrencyBridge(signerContext), accountBridge: buildAccountBridge(signerContext), }; } //# sourceMappingURL=index.js.map