How to use the ramda-adjunct.renameKeys function in ramda-adjunct

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

github wavesplatform / data-service / src / services / transactions / transfer / resolver / transformResult / common.js View on Github external
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 };
github fullstack-development / react-redux-starter-kit / src / features / usersSearch / view / containers / UsersSearchForm / UsersSearchForm.tsx View on Github external
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<string, string | number>;
    });
github wavesplatform / data-service / src / services / candles / transformResults.ts View on Github external
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);
};
github wavesplatform / data-service / src / services / transactions / invokeScript / transformTxInfo.js View on Github external
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)
);
github wavesplatform / data-service / src / services / transactions / issue / transformTxInfo.ts View on Github external
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',
  })
);
github wavesplatform / data-service / src / services / transactions / burn / transformTxInfo.ts View on Github external
import { compose } from 'ramda';
import { renameKeys } from 'ramda-adjunct';

import { transformTxInfo } from '../_common/transformTxInfo';

export default compose(
  transformTxInfo,
  renameKeys({
    asset_id: 'assetId',
  })
);
github wavesplatform / data-service / src / services / transactions / sponsorship / transformTxInfo.js View on Github external
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',
  })
);
github wavesplatform / data-service / src / services / assets / transformAsset.js View on Github external
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;
github wavesplatform / data-service / src / services / transactions / leaseCancel / transformTxInfo.js View on Github external
const { compose } = require('ramda');
const { renameKeys } = require('ramda-adjunct');

const { transformTxInfo } = require('../_common/transformTxInfo');

module.exports = compose(
  transformTxInfo,
  renameKeys({ lease_id: 'leaseId' })
);
github wavesplatform / data-service / src / services / assets / transformAsset.ts View on Github external
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);