UNPKG

@ledgerhq/coin-celo

Version:
37 lines 1.62 kB
import invariant from "invariant"; import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index"; import { parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies/parseCurrencyUnit"; import { pickSiblings } from "@ledgerhq/coin-framework/bot/specs"; const maxAccount = 10; const currency = getCryptoCurrencyById("celo"); export const minimalAmount = parseCurrencyUnit(currency.units[0], "0.01"); export const createSend50PercentMutation = () => ({ name: "Celo: Move 50% to another account", feature: "send", maxRun: 1, transaction: ({ account, siblings, bridge, maxSpendable }) => { invariant(maxSpendable.gt(minimalAmount), "Celo: Move 50% | balance is too low"); const sibling = pickSiblings(siblings, maxAccount); const recipient = sibling.freshAddress; const amount = maxSpendable.div(2).integerValue(); return { transaction: bridge.createTransaction(account), updates: [{ recipient }, { amount }], }; }, }); export const createSendMaxMutation = () => ({ name: "Celo: Send max to another account", feature: "sendMax", maxRun: 1, transaction: ({ account, siblings, bridge, maxSpendable }) => { invariant(maxSpendable.gt(minimalAmount), "Celo: Send Max | Balance is too low"); const sibling = pickSiblings(siblings, maxAccount); const recipient = sibling.freshAddress; return { transaction: bridge.createTransaction(account), updates: [{ recipient }, { useAllAmount: true }], }; }, }); //# sourceMappingURL=createSendMutation.js.map