@ledgerhq/coin-icon
Version:
Ledger Icon Coin integration
54 lines • 2.09 kB
JavaScript
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import { getSerializedAddressParameters, updateTransaction, makeAccountBridgeReceive, makeScanAccounts, makeSync, } from "@ledgerhq/coin-framework/bridge/jsHelpers";
import resolver from "../hw-getAddress";
import { initAccount } from "../initAccount";
import { broadcast } from "../broadcast";
import { createTransaction } from "../createTransaction";
import { estimateMaxSpendable } from "../estimateMaxSpendable";
import { getTransactionStatus } from "../getTransactionStatus";
import { prepareTransaction } from "../prepareTransaction";
import { buildSignOperation } from "../signOperation";
import { getAccountShape } from "../synchronization";
import { assignFromAccountRaw, assignToAccountRaw } from "../serialization";
import { setCoinConfig } from "../config";
export function buildCurrencyBridge(signerContext) {
const getAddress = resolver(signerContext);
const scanAccounts = makeScanAccounts({
getAccountShape,
getAddressFn: getAddress,
});
return {
preload: async () => Promise.resolve({}),
hydrate: () => { },
scanAccounts,
};
}
export function buildAccountBridge(signerContext) {
const getAddress = resolver(signerContext);
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
const signOperation = buildSignOperation(signerContext);
const sync = makeSync({ getAccountShape });
return {
createTransaction,
updateTransaction,
prepareTransaction,
getTransactionStatus,
sync,
receive,
assignToAccountRaw,
assignFromAccountRaw,
initAccount,
signOperation,
broadcast,
estimateMaxSpendable,
getSerializedAddressParameters,
};
}
export function createBridges(signerContext, coinConfig) {
setCoinConfig(coinConfig);
return {
currencyBridge: buildCurrencyBridge(signerContext),
accountBridge: buildAccountBridge(signerContext),
};
}
//# sourceMappingURL=index.js.map