How to use the decentraland-commons.env.get function in decentraland-commons

To help you get started, we’ve selected a few decentraland-commons 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 decentraland / builder / src / modules / analytics / delighted.ts View on Github external
import { delay, call, select } from 'redux-saga/effects'
import { env } from 'decentraland-commons'
import { getAnalytics } from 'decentraland-dapps/dist/modules/analytics/utils'
import { getEmail } from 'modules/auth/selectors'

const DELIGHTED_DELAY = 180 * 1000
const DELIGHTED_API_KEY = env.get('REACT_APP_DELIGHTED_API_KEY', '')
const isEnabled = !!DELIGHTED_API_KEY

if (isEnabled) {
  // prettier-ignore
  // @ts-ignore
  // tslint:disable-next-line
  window.initDelighted=function(b,c,a,g,e){if(!b[e]){var d=b[e]=[];for(b=0;b
github decentraland / agora / src / Translation / Translation.ts View on Github external
constructor() {
    this.localesPath = env.get(
      'LOCALES_PATH',
      path.resolve(__dirname, './locales')
    )
    this.cache = {} // {locale: translations}
  }
github decentraland / agora / src / Receipt / Receipt.model.ts View on Github external
static canSign() {
    const serverKey = env.get('SERVER_SIGNING_KEY', '')
    if (!serverKey) {
      console.warn(
        '[WARN] SERVER_SIGNING_KEY env var is undefined. Receipts are disabled'
      )
    }
    return !!serverKey
  }
github decentraland / agora / scripts / monitorBalances.ts View on Github external
for (const token of tokens) {
    if (DistrictToken.isValid(token)) continue

    const tokenContract = new contracts.ERC20Token(token.address)
    tokenContract.getContractName = () => token.name
    tokenContracts[token.address] = tokenContract as any
  }

  try {
    log.info(`Connecting to Ethereum Node with ${tokens.map(t => t.name)}`)
    await eth.connect({
      contracts: Object.values(tokenContracts),
      provider: env.get('RPC_URL')
    })

    const delay = env.get('MONITOR_BALANCES_DELAY', '10000')
    log.info(`Using ${delay}ms as delay between updates`)
    await monitorBalances(Number(delay))
  } catch (error) {
    log.info('Whoops, something went wrong')
    log.info(error)

    process.exit()
  }
}
github decentraland / agora / scripts / translate.ts View on Github external
"en"
  ] */

  const result = await axios.get(
    `https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=${lang}&dt=t&q=${encodeURIComponent(
      text
    )}`
  )
  const translation: string = result.data[0][0][0]
  return translation
}

if (require.main === module) {
  loadEnv()

  BATCH_SIZE = parseInt(env.get('BATCH_SIZE', '10'), 10)
  log.info(`Using ${BATCH_SIZE} as batch size, configurable via BATCH_SIZE`)

  main().catch(error => console.error(error))
}
github decentraland / agora / scripts / monitorBalances.ts View on Github external
const tokens = await Token.find()

  for (const token of tokens) {
    if (DistrictToken.isValid(token)) continue

    const tokenContract = new contracts.ERC20Token(token.address)
    tokenContract.getContractName = () => token.name
    tokenContracts[token.address] = tokenContract as any
  }

  try {
    log.info(`Connecting to Ethereum Node with ${tokens.map(t => t.name)}`)
    await eth.connect({
      contracts: Object.values(tokenContracts),
      provider: env.get('RPC_URL')
    })

    const delay = env.get('MONITOR_BALANCES_DELAY', '10000')
    log.info(`Using ${delay}ms as delay between updates`)
    await monitorBalances(Number(delay))
  } catch (error) {
    log.info('Whoops, something went wrong')
    log.info(error)

    process.exit()
  }
}
github decentraland / builder / src / components / Modals / ShareModal / ShareModal.tsx View on Github external
import * as React from 'react'
import { env } from 'decentraland-commons'
import { Loader, ModalNavigation } from 'decentraland-ui'

import Modal from 'decentraland-dapps/dist/containers/Modal'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'

import { locations } from 'routing/locations'
import Icon from 'components/Icon'
import { ShareTarget } from 'modules/ui/share/types'
import LoginModal from '../LoginModal'
import { Props, ShareModalType, State } from './ShareModal.types'

import './ShareModal.css'

const SHARE_SCENE_URL = env.get('REACT_APP_SHARE_SCENE_URL', '')

export default class ShareModal extends React.PureComponent {
  state: State = {
    copied: false,
    type: ShareModalType.PROJECT,
    id: null
  }

  input = React.createRef()

  componentDidMount() {
    const { metadata, onUpdate, isLoggedIn } = this.props
    if (metadata) {
      this.setState({
        type: metadata.type,
        id: metadata.id
github decentraland / agora / webapp / src / components / Navbar / Navbar.container.tsx View on Github external
const mapState = (state: RootState): any => {
  const wallet = getWallet(state) as Wallet
  const isWalletConnected = isConnected(state)
  const manaAddress = env.get('REACT_APP_MANA_TOKEN_CONTRACT_ADDRESS', '')

  let mana: string | null = null

  if (isWalletConnected) {
    const balance: number | undefined = wallet.balances[manaAddress]

    if (balance) {
      mana = balance.toLocaleString()
    }
  }

  return {
    mana,
    address: wallet.address,
    isConnected: isWalletConnected,
    isConnecting: isConnecting(state),
github decentraland / builder / src / lib / api / avatars.ts View on Github external
import { env } from 'decentraland-commons'
import { BaseAPI } from 'decentraland-dapps/dist/lib/api'
import { User } from 'modules/auth/types'
import { authorize } from './auth'

export const AVATARS_API_URL = env.get('REACT_APP_AVATARS_API_URL', '')

export class AvatarsAPI extends BaseAPI {
  fetchUser = async (accessToken?: string) => {
    const user: User = await this.request('get', `/profile`, null, authorize(accessToken))
    return user
  }
}

export const avatars = new AvatarsAPI(AVATARS_API_URL)
github decentraland / builder / src / lib / api / profile.ts View on Github external
import { env } from 'decentraland-commons'
import { User, RemoteUser } from 'modules/auth/types'
import { authorize } from './auth'

export const PROFILE_API_URL = env.get('REACT_APP_PROFILE_API_URL', '')

export class ProfileAPI {
  constructor(public url: string) { }

  async request(method: string, path: string, params: any | null = null, options: RequestInit) {
    const res = await fetch(this.getUrl(path), {
      method,
      ...options,
      body: params
    })

    if (!res.ok) {
      throw new Error(`Status: ${res.status} - ${res.statusText}`)
    }

    return res.json()

decentraland-commons

Set of common functionality accross Decentraland projects.

ISC
Latest version published 4 years ago

Package Health Score

46 / 100
Full package analysis

Popular decentraland-commons functions