@ledgerhq/coin-canton
Version:
45 lines • 1.88 kB
JavaScript
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import { getSerializedAddressParameters, makeAccountBridgeReceive, makeScanAccounts, makeSync, } from "@ledgerhq/coin-framework/bridge/jsHelpers";
import cantonCoinConfig from "../config";
import resolver from "../signer";
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 "./sync";
import { updateTransaction } from "./updateTransaction";
export function createBridges(signerContext, coinConfig) {
cantonCoinConfig.setCoinConfig(coinConfig);
const getAddress = resolver(signerContext);
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
const scanAccounts = makeScanAccounts({ getAccountShape, getAddressFn: getAddress });
const currencyBridge = {
preload: () => Promise.resolve({}),
hydrate: () => { },
scanAccounts,
};
const signOperation = buildSignOperation(signerContext);
const sync = makeSync({ getAccountShape });
// we want one method per file
const accountBridge = {
broadcast,
createTransaction,
updateTransaction,
// NOTE: use updateTransaction: defaultUpdateTransaction<Transaction>,
// if you don't need to update the transaction patch object
prepareTransaction,
getTransactionStatus,
estimateMaxSpendable,
sync,
receive,
signOperation,
getSerializedAddressParameters,
};
return {
currencyBridge,
accountBridge,
};
}
//# sourceMappingURL=index.js.map