Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
// @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 }
})
// @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 }
})
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 };
});
import { createActions } from 'spunky';
import getBalances from '../util/getBalances';
export const ID = 'balances';
export default createActions(ID, ({ net, address } = {}) => async () => {
return getBalances({ net, address });
});
export default function makeSendActions(sessionId, requestId, ...args) {
const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);
return createActions(id, (options) => () => sendAsset(options, ...args));
}
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 });
});
}
export default function makeClaimActions(sessionId, requestId, call = claimGas) {
const id = generateDAppActionId(sessionId, `${ID}-${requestId}`);
return createActions(id, (options) => () => call(options));
}
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 });
}
);
}
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 });
});
}