How to use the nahmii-sdk.NahmiiProvider 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 / config / constants.js View on Github external
export const MAINNET_IDENTITY_SERVICE_SECRET = stringFromEnv('MAINNET_IDENTITY_SERVICE_SECRET');
export const ROPSTEN_IDENTITY_SERVICE_APPID = stringFromEnv('ROPSTEN_IDENTITY_SERVICE_APPID');
export const MAINNET_IDENTITY_SERVICE_APPID = stringFromEnv('MAINNET_IDENTITY_SERVICE_APPID');

const trimmableWalletApiEndpoint = (endpoint) => (trimmed) => {
  if (trimmed) return endpoint.split('//')[1].split('/')[0]; // trim https:// prefix and / suffix
  return endpoint;
};

const ROPSTEN_URL = 'https://api2.dev.hubii.net/';
const MAINNET_URL = 'https://api.nahmii.io/';

export const SUPPORTED_NETWORKS = {
  mainnet: {
    provider: getDefaultProvider('mainnet'),
    nahmiiProvider: new nahmii.NahmiiProvider(
      trimmableWalletApiEndpoint(MAINNET_URL)(true),
      MAINNET_IDENTITY_SERVICE_APPID,
      MAINNET_IDENTITY_SERVICE_SECRET
    ),
    walletApiEndpoint: trimmableWalletApiEndpoint(MAINNET_URL),
    identityServiceSecret: process.env.NODE_ENV === 'test' ? 'secret' : MAINNET_IDENTITY_SERVICE_SECRET,
    identityServiceAppId: process.env.NODE_ENV === 'test' ? 'appid' : MAINNET_IDENTITY_SERVICE_APPID,
  },
  ropsten: {
    provider: getDefaultProvider('ropsten'),
    nahmiiProvider: new nahmii.NahmiiProvider(
      trimmableWalletApiEndpoint(ROPSTEN_URL)(true),
      ROPSTEN_IDENTITY_SERVICE_APPID,
      ROPSTEN_IDENTITY_SERVICE_SECRET
      ),
    walletApiEndpoint: trimmableWalletApiEndpoint(ROPSTEN_URL),
github hubiinetwork / hubii-core / src / containers / HubiiApiHoc / saga.js View on Github external
export function* requestToken() {
  while (true) { // eslint-disable-line no-constant-condition
    let nahmiiProvider;
    try {
      const network = yield select(makeSelectCurrentNetwork());
      nahmiiProvider = new nahmii.NahmiiProvider(
        network.walletApiEndpoint(true),
        network.identityServiceAppId,
        network.identityServiceSecret
      );
      const token = yield call([nahmiiProvider, 'getApiAccessToken']);
      yield put(loadIdentityServiceTokenSuccess(token));
      return;
    } catch (e) {
      // try again in 2sec
      const TWO_SEC_IN_MS = 2 * 1000;
      yield delay(TWO_SEC_IN_MS);
    } finally {
      nahmiiProvider.stopUpdate();
    }
  }
}
github hubiinetwork / hubii-core / src / containers / HubiiApiHoc / saga.js View on Github external
export function* getNahmiiProvider() {
  const network = yield select(makeSelectCurrentNetwork());
  const nahmiiProvider = new nahmii.NahmiiProvider(
    network.walletApiEndpoint(true),
    network.identityServiceAppId,
    network.identityServiceSecret
  );
  return nahmiiProvider;
}
github hubiinetwork / hubii-core / src / config / constants.js View on Github external
export const SUPPORTED_NETWORKS = {
  mainnet: {
    provider: getDefaultProvider('mainnet'),
    nahmiiProvider: new nahmii.NahmiiProvider(
      trimmableWalletApiEndpoint(MAINNET_URL)(true),
      MAINNET_IDENTITY_SERVICE_APPID,
      MAINNET_IDENTITY_SERVICE_SECRET
    ),
    walletApiEndpoint: trimmableWalletApiEndpoint(MAINNET_URL),
    identityServiceSecret: process.env.NODE_ENV === 'test' ? 'secret' : MAINNET_IDENTITY_SERVICE_SECRET,
    identityServiceAppId: process.env.NODE_ENV === 'test' ? 'appid' : MAINNET_IDENTITY_SERVICE_APPID,
  },
  ropsten: {
    provider: getDefaultProvider('ropsten'),
    nahmiiProvider: new nahmii.NahmiiProvider(
      trimmableWalletApiEndpoint(ROPSTEN_URL)(true),
      ROPSTEN_IDENTITY_SERVICE_APPID,
      ROPSTEN_IDENTITY_SERVICE_SECRET
      ),
    walletApiEndpoint: trimmableWalletApiEndpoint(ROPSTEN_URL),
    identityServiceSecret: process.env.NODE_ENV === 'test' ? 'secret' : ROPSTEN_IDENTITY_SERVICE_SECRET,
    identityServiceAppId: process.env.NODE_ENV === 'test' ? 'appid' : ROPSTEN_IDENTITY_SERVICE_APPID,
  },
};