How to use the spunky.createActions function in spunky

To help you get started, we’ve selected a few spunky examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nos / client / src / renderer / settings / actions / feeActions.js View on Github external
import BigNumber from 'bignumber.js';
import { createActions } from 'spunky';

import { getStorage, setStorage } from 'shared/lib/storage';

const DEFAULT_FEE = '0.00000000';

export const ID = 'fee';

// Setters
export const setFee = createActions(ID, (fee) => async () => {
  const value = new BigNumber(fee);

  if (value.isNaN()) {
    throw new Error(`Invalid fee value: "${fee}"`);
  }

  const formattedValue = value.toFixed(8);

  await setStorage(ID, formattedValue);
  return formattedValue;
});

// Getters
export default createActions(ID, () => async () => {
  const fee = await getStorage(ID);
  return typeof fee === 'string' ? fee : DEFAULT_FEE;
github CityOfZion / neon-wallet / app / actions / claimsActions.js View on Github external
// @flow
import { api, u } from 'neon-js'
import { createActions } from 'spunky'

type Props = {
  net: string,
  address: string
}

export const ID = 'CLAIMS'

export default createActions(ID, ({ net, address }: Props = {}) => async (state: Object): Promise => {
  const total = await api.getMaxClaimAmountFrom({ net, address }, api.neoscan)
  return { total: total instanceof u.Fixed8 ? total.toString() : null }
})
github CityOfZion / neon-wallet / app / actions / ledgerActions.js View on Github external
// @flow
import { createActions } from 'spunky'

import { getDeviceInfo, getPublicKey } from '../ledger/ledgerNanoS'

export const ID = 'LEDGER'

export default createActions(ID, () => async (state: Object) => {
  const deviceInfo = await getDeviceInfo()
  const publicKey = await getPublicKey()

  return { publicKey, deviceInfo }
})
github nos / client / src / renderer / login / actions / ledgerActions.js View on Github external
import { createActions } from 'spunky';

import { getDeviceInfo, getPublicKey } from '../util/ledger';

export const ID = 'ledger';

export default createActions(ID, () => async () => {
  const deviceInfo = await getDeviceInfo();
  const publicKey = await getPublicKey();

  return { publicKey, deviceInfo };
});
github nos / client / src / renderer / shared / actions / balancesActions.js View on Github external
import { createActions } from 'spunky';

import getBalances from '../util/getBalances';

export const ID = 'balances';

export default createActions(ID, ({ net, address } = {}) => async () => {
  return getBalances({ net, address });
});
github nos / client / src / renderer / browser / actions / makeSendActions.js View on Github external
export default function makeSendActions(sessionId, requestId, ...args) {
  const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);
  return createActions(id, (options) => () => sendAsset(options, ...args));
}
github nos / client / src / actions / dapps / makeSendActions.js View on Github external
export default function makeSendActions(sessionId, requestId) {
  const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);

  return createActions(id, ({ net, asset, amount, receiver, address, wif }) => () => {
    return send({ net, asset, amount, receiver, address, wif });
  });
}
github nos / client / src / renderer / browser / actions / makeClaimActions.js View on Github external
export default function makeClaimActions(sessionId, requestId, call = claimGas) {
  const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);

  return createActions(id, (options) => () => call(options));
}
github nos / client / src / renderer / browser / actions / makeStorageActions.js View on Github external
export default function makeStorageActions(sessionId, requestId, call = getStorage) {
  const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);

  return createActions(
    id,
    ({ net, scriptHash, key, encodeInput = true, decodeOutput = true }) => async () => {
      return call({ net, scriptHash, key, encodeInput, decodeOutput });
    }
  );
}
github nos / client / src / renderer / browser / actions / makeDecryptActions.js View on Github external
export default function makeDecryptActions(sessionId, requestId) {
  const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);

  return createActions(id, ({ senderPublicKey, wif, iv, mac, data }) => () => {
    return decrypt({ senderPublicKey, wif, iv, mac, data });
  });
}

spunky

Lifecycle management for react-redux

MIT
Latest version published 6 years ago

Package Health Score

36 / 100
Full package analysis