How to use the nahmii-sdk/lib/utils.hash function in nahmii-sdk

To help you get started, we’ve selected a few nahmii-sdk 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 hubiinetwork / hubii-core / src / containers / NahmiiAirdriipRegistration / saga.js View on Github external
import { makeSelectCurrentWalletWithInfo } from 'containers/WalletHoc/selectors';
import { SET_CURRENT_WALLET } from 'containers/WalletHoc/constants';
import { LOAD_IDENTITY_SERVICE_TOKEN_SUCCESS } from 'containers/HubiiApiHoc/constants';
import { makeSelectCurrentNetwork } from 'containers/App/selectors';

import { REGISTER } from './constants';
import {
  registerationSuccess,
  registerationFailed,
  register as registerAction,
  checkAddressRegistrationSuccess,
} from './actions';
import { makeSelectNahmiiAirdriipRegistration } from './selectors';

const MESSAGE = 'I agree to the terms and conditions for signing up for the nahmii airdriip.';
const MESSAGE_HASH = utils.hash(MESSAGE);
const API_PATH = 'airdriips/registrations';

export function* checkRegistrationStatus({ address }) {
  try {
    // this saga is special, as it may be called before the JWT token for the hubii
    // API has been loaded. do a quick check here and ensure the JWT is loaded
    let network = yield select(makeSelectCurrentNetwork());
    if (!network.identityServiceToken) {
      yield take(LOAD_IDENTITY_SERVICE_TOKEN_SUCCESS);
      network = yield select(makeSelectCurrentNetwork());
    }

    const addressStatus = (yield select(makeSelectNahmiiAirdriipRegistration()))
                            .getIn(['addressStatuses', address]);

    if (addressStatus === 'registered') return;