@ledgerhq/coin-tron
Version:
Ledger Tron Coin integration
59 lines • 2.31 kB
JavaScript
import getAddressWrapper from "@ledgerhq/ledger-wallet-framework/bridge/getAddressWrapper";
import { getSerializedAddressParameters, updateTransaction, makeAccountBridgeReceive, makeScanAccounts, } from "@ledgerhq/ledger-wallet-framework/bridge/jsHelpers";
import tronCoinConfig from "../config";
import { validateAddress } from "../logic";
import signerGetAddress from "../signer";
import broadcast from "./broadcast";
import createTransaction from "./createTransaction";
import estimateMaxSpendable from "./estimateMaxSpendable";
import getTransactionStatus from "./getTransactionStatus";
import { prepareTransaction } from "./prepareTransaction";
import { assignFromAccountRaw, assignToAccountRaw, fromOperationExtraRaw, toOperationExtraRaw, } from "./serialization";
import { buildSignOperation } from "./signOperation";
import { getAccountShape, postSync, sync } from "./synchronization";
function buildCurrencyBridge(signerContext) {
const getAddress = signerGetAddress(signerContext);
const scanAccounts = makeScanAccounts({
getAccountShape,
getAddressFn: getAddressWrapper(getAddress),
postSync,
});
return {
preload: () => Promise.resolve({}),
hydrate: () => undefined,
scanAccounts,
};
}
function buildAccountBridge(signerContext) {
const getAddress = signerGetAddress(signerContext);
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
const signOperation = buildSignOperation(signerContext);
return {
estimateMaxSpendable,
createTransaction,
updateTransaction,
getTransactionStatus,
prepareTransaction,
sync,
receive,
signOperation,
signRawOperation: () => {
throw new Error("signRawOperation is not supported");
},
broadcast,
assignFromAccountRaw,
assignToAccountRaw,
fromOperationExtraRaw,
toOperationExtraRaw,
getSerializedAddressParameters,
validateAddress,
};
}
export function createBridges(signerContext, coinConfig) {
tronCoinConfig.setCoinConfig(coinConfig);
return {
currencyBridge: buildCurrencyBridge(signerContext),
accountBridge: buildAccountBridge(signerContext),
};
}
//# sourceMappingURL=index.js.map