Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { renameKeys } = require('ramda-adjunct');
const { compose, ifElse, propEq, omit } = require('ramda');
const hasEmptyProofs = propEq('proofs', []);
const processProofsAndSignature = ifElse(
hasEmptyProofs,
omit(['proofs']),
omit(['signature'])
);
/** transformTxInfo:: RawTxInfo -> TxInfo */
const transformTxInfo = compose(
processProofsAndSignature,
renameKeys({
tx_type: 'type',
tx_version: 'version',
sender_public_key: 'senderPublicKey',
asset_id: 'assetId',
fee_asset: 'feeAsset',
time_stamp: 'timestamp',
volume_waves: 'volumeWaves',
})
);
module.exports = { transformTxInfo };
formFields => {
const filters = R.omit([fieldNames.searchString], formFields);
const filtersValuesFormattersMap = selectFiltersValuesFormatters(this.props);
const filtersLabels = selectFiltersLabels(this.props);
const filtersWithFormattedValues = R.mapObjIndexed(
(value: any, key: keyof typeof filters) => {
const formatterForCurrentKey = key in filtersValuesFormattersMap
? (filtersValuesFormattersMap as any)[key]
: R.identity;
return formatterForCurrentKey(value);
},
filters,
);
return RA.renameKeys(filtersLabels, filtersWithFormattedValues) as Record;
});
export const transformCandle = ([time, c]: [string, RawCandle]): Candle => {
const isEmpty = (c: RawCandle) => c.txs_count === 0;
const renameFields = renameKeys({
quote_volume: 'quoteVolume',
weighted_average_price: 'weightedAveragePrice',
max_height: 'maxHeight',
txs_count: 'txsCount',
time_start: 'time',
});
return compose(
(c: any): Candle => candle(c),
omit(['a_dec', 'p_dec']),
renameFields,
assoc('time_start', time),
assoc('txs_count', c.txs_count),
ifElse(isEmpty, map(always(null)), identity)
)(c);
};
const { compose, isNil, reject } = require('ramda');
const { renameKeys } = require('ramda-adjunct');
const { transformTxInfo } = require('../_common/transformTxInfo');
module.exports = compose(
transformTxInfo,
renameKeys({
dapp: 'dApp',
}),
reject(isNil)
);
import { compose } from 'ramda';
import { renameKeys } from 'ramda-adjunct';
import { transformTxInfo } from '../_common/transformTxInfo';
export default compose(
transformTxInfo,
renameKeys({
asset_name: 'name',
asset_id: 'assetId',
})
);
import { compose } from 'ramda';
import { renameKeys } from 'ramda-adjunct';
import { transformTxInfo } from '../_common/transformTxInfo';
export default compose(
transformTxInfo,
renameKeys({
asset_id: 'assetId',
})
);
const { compose } = require('ramda');
const { renameKeys } = require('ramda-adjunct');
const { transformTxInfo } = require('../_common/transformTxInfo');
module.exports = compose(
transformTxInfo,
renameKeys({
min_sponsored_asset_fee: 'minSponsoredAssetFee',
asset_id: 'assetId',
})
);
const { renameKeys } = require('ramda-adjunct');
const { compose, reject, isNil } = require('ramda');
const { Asset } = require('@waves/data-entities');
/** transformAssetInfo:: RawAssetInfo -> AssetInfo */
const transformAsset = compose(
obj => new Asset(obj),
renameKeys({
asset_id: 'id',
asset_name: 'name',
issue_height: 'height',
issue_timestamp: 'timestamp',
total_quantity: 'quantity',
decimals: 'precision',
}),
reject(isNil)
);
module.exports = transformAsset;
const { compose } = require('ramda');
const { renameKeys } = require('ramda-adjunct');
const { transformTxInfo } = require('../_common/transformTxInfo');
module.exports = compose(
transformTxInfo,
renameKeys({ lease_id: 'leaseId' })
);
export const transformDbResponse = (raw: AssetDbResponse): Asset =>
compose(
(obj: any) => new Asset(obj),
renameKeys({
asset_id: 'id',
asset_name: 'name',
issue_height: 'height',
issue_timestamp: 'timestamp',
total_quantity: 'quantity',
decimals: 'precision',
has_script: 'hasScript',
min_sponsored_asset_fee: 'minSponsoredFee',
})
)(raw);