UNPKG

@ledgerhq/coin-celo

Version:
31 lines 1.44 kB
import invariant from "invariant"; import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index"; import { parseCurrencyUnit } from "@ledgerhq/coin-framework/currencies/parseCurrencyUnit"; const currency = getCryptoCurrencyById("celo"); const minimalAmount = parseCurrencyUnit(currency.units[0], "0.001"); export const createRevokeVoteMutation = () => ({ name: "Celo: RevokeVote", feature: "staking", maxRun: 1, transaction: ({ account, bridge, maxSpendable }) => { invariant(maxSpendable.gt(minimalAmount), "Celo: Revoke Vote | balance is too low"); const { celoResources } = account; invariant(celoResources?.registrationStatus, "Celo: RevokeVote | Account is not registered"); const revokableVote = celoResources?.votes?.find(vote => vote.revokable); invariant(!!revokableVote, "Celo: RevokeVote | Revokable vote not found"); return { transaction: bridge.createTransaction(account), updates: [ { mode: "revoke", recipient: revokableVote.validatorGroup, group: revokableVote.validatorGroup, address: account.celoResources?.electionAddress, index: revokableVote.index, amount: revokableVote.amount, }, ], }; }, }); //# sourceMappingURL=createRevokeVoteMutation.js.map