当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript decentraland-commons.env类代码示例

本文整理汇总了TypeScript中decentraland-commons.env的典型用法代码示例。如果您正苦于以下问题:TypeScript env类的具体用法?TypeScript env怎么用?TypeScript env使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了env类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: main

export async function main() {
  log.info('Connecting database')
  await db.connect()

  const tokens = await Token.find<TokenAttributes>()

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

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

  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()
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:31,代码来源:monitorBalances.ts

示例2: migrate

export function migrate(
  commandArguments: string[],
  migrationsDir: string = __dirname
) {
  let CONNECTION_STRING = process.env.CONNECTION_STRING

  if (!CONNECTION_STRING) {
    loadEnv()

    CONNECTION_STRING = env.get('CONNECTION_STRING')
    if (!CONNECTION_STRING) {
      throw new Error(
        'Please set a CONNECTION_STRING env variable before running migrations'
      )
    }
  }

  const spawnArgs = [
    '--database-url-var',
    'CONNECTION_STRING',
    '--migration-file-language',
    'ts',
    '--migrations-dir',
    migrationsDir,
    '--ignore-pattern',
    '\\..*|.*migrate',
    ...commandArguments
  ]
  const child = spawn(resolvePath(__dirname + '/node-pg-migrate'), spawnArgs, {
    env: { ...process.env, CONNECTION_STRING }
  })

  console.log('Running command:')
  console.dir(`node-pg-migrate ${spawnArgs.join(' ')}`)

  child.on('error', function(error) {
    console.log(error.message)
  })

  child.stdout.on('data', function(data) {
    process.stdout.write(data.toString())
  })

  child.stderr.on('data', function(data) {
    process.stdout.write(data.toString())
  })

  return child
}
开发者ID:decentraland,项目名称:agora,代码行数:49,代码来源:migrate.ts

示例3: seed

async function seed() {
  const tokenAddress = env.get('MANA_TOKEN_CONTRACT_ADDRESS', '')

  console.log('Connecting database')
  await db.connect()

  console.log('Inserting tokens')
  await Promise.all([
    Token.create({
      address: tokenAddress.toLowerCase(),
      name: 'MANAToken',
      symbol: 'MANA'
    })
  ])

  console.log('Inserting account balances')
  await Promise.all([
    AccountBalance.create({
      address: '0x66788F71Bf33EcBd263a57E5F371cCDCaFfc519e',
      balance: '10',
      token_address: tokenAddress
    }),
    AccountBalance.create({
      address: '0x38b5ca83896C7C6Bf4C6178b7458cAAD5412A37A',
      balance: '25',
      token_address: tokenAddress
    }),
    AccountBalance.create({
      address: '0x1d9aa2025b67f0f21d1603ce521bda7869098f8a',
      balance: '15',
      token_address: tokenAddress
    })
  ])

  console.log('Inserting polls')
  await Promise.all([
    Poll.create({
      title: 'Should we support an auction model natively in the Marketplace?',
      balance: '50',
      submitter: '0x66788f71bf33ecbd263a57e5f371ccdcaffc519e',
      closes_at: '1537897526681',
      token_address: tokenAddress
    })
  ])
  const poll = (await Poll.find())[0]

  console.log('Inserting options')
  await Promise.all([
    Option.create({ value: 'YES', poll_id: poll.id }),
    Option.create({ value: 'NO', poll_id: poll.id })
  ])

  const options = await Option.find()

  console.log('Inserting votes')
  await Promise.all([
    Vote.create({
      account_address: '0x66788f71bf33ecbd263a57e5f371ccdcaffc519e',
      account_balance: '10',
      poll_id: poll.id,
      option_id: options[0].id,
      timestamp: Date.now(),
      message: 'signed1',
      signature: 'signature1'
    }),
    Vote.create({
      account_address: '0x38b5ca83896c7c6bf4c6178b7458caad5412a37a',
      account_balance: '25',
      poll_id: poll.id,
      option_id: options[1].id,
      timestamp: Date.now(),
      message: 'signed2',
      signature: 'signature2'
    }),
    Vote.create({
      account_address: '0x1d9aa2025b67f0f21d1603ce521bda7869098f8a',
      account_balance: '15',
      poll_id: poll.id,
      option_id: options[1].id,
      timestamp: Date.now(),
      message: 'signed3',
      signature: 'signature3'
    })
  ])

  process.exit()
}
开发者ID:decentraland,项目名称:agora,代码行数:87,代码来源:seed.ts

示例4: createWalletSaga

import {
  ConnectWalletSuccessAction,
  CONNECT_WALLET_SUCCESS
} from '@dapps/modules/wallet/actions'
import {
  COMPUTE_BALANCES_REQUEST,
  computeBalancesSuccess,
  computeBalancesFailure
} from 'modules/wallet/actions'
import { fetchAccountBalancesRequest } from 'modules/accountBalance/actions'
import { fetchTokensRequest } from 'modules/token/actions'
import { getContractTokens } from 'modules/token/selectors'
import { MANAToken } from 'contracts'

const baseWalletSaga = createWalletSaga({
  provider: env.get('REACT_APP_PROVIDER_URL'),
  contracts: [MANAToken],
  eth
})

export function* walletSaga() {
  yield all([baseWalletSaga(), walletBalanceSaga()])
}

function* walletBalanceSaga() {
  yield takeEvery(CONNECT_WALLET_SUCCESS, handleConnectWalletSuccess)
  yield takeEvery(COMPUTE_BALANCES_REQUEST, handleComputeBalancesRequest)
}

function* handleComputeBalancesRequest() {
  try {
开发者ID:decentraland,项目名称:agora,代码行数:31,代码来源:sagas.ts

示例5: fetchTokens

import { env } from 'decentraland-commons'
import { BaseAPI } from '@dapps/lib/api'
import { PollsRequestFilters } from 'modules/poll/types'

const URL = env.get('REACT_APP_API_URL', '')

export class API extends BaseAPI {
  fetchTokens() {
    return this.request('get', '/tokens', {})
  }

  fetchPolls(filters: PollsRequestFilters) {
    return this.request('get', '/polls', filters)
  }

  fetchPoll(id: string) {
    return this.request('get', `/polls/${id}`, {})
  }

  fetchPollOptions(id: string) {
    return this.request('get', `/polls/${id}/options`, {})
  }

  fetchPollVotes(id: string) {
    return this.request('get', `/polls/${id}/votes`, {})
  }

  fetchTranslations(locale: string) {
    return this.request('get', `/translations/${locale}`, {})
  }
开发者ID:decentraland,项目名称:agora,代码行数:30,代码来源:api.ts

示例6: loadEnv

export function loadEnv(envFilePath: string = '../src/.env') {
  env.load({ path: resolvePath(envFilePath) })
}
开发者ID:decentraland,项目名称:agora,代码行数:3,代码来源:utils.ts

示例7:

 predicate: (_: any, action) =>
   env.isDevelopment() || action.type.includes('Failure')
开发者ID:decentraland,项目名称:agora,代码行数:2,代码来源:store.ts

示例8: createHistory

import { rootSaga } from './sagas'

const composeEnhancers =
  (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const history = createHistory()

const historyMiddleware = routerMiddleware(history)
const sagasMiddleware = createSagasMiddleware()
const loggerMiddleware = createLogger({
  collapsed: () => true,
  predicate: (_: any, action) =>
    env.isDevelopment() || action.type.includes('Failure')
})
const analyticsMiddleware = createAnalyticsMiddleware(
  env.get('REACT_APP_SEGMENT_API_KEY')
)
const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({
  storageKey: env.get('REACT_APP_LOCAL_STORAGE_KEY', 'decentraland-agora')
})

const middleware = applyMiddleware(
  historyMiddleware,
  sagasMiddleware,
  loggerMiddleware,
  analyticsMiddleware,
  storageMiddleware
)
const enhancer = composeEnhancers(middleware)
const store = createStore(rootReducer, enhancer)
开发者ID:decentraland,项目名称:agora,代码行数:30,代码来源:store.ts

示例9: Assertion

import * as chai from 'chai'
import { env } from 'decentraland-commons'
import { omitProps } from './utils'

const Assertion = (chai as any).Assertion // necessary because @types/chai doesn't export chai.Assertion yet

chai.use(require('chai-as-promised'))

env.load({ path: './specs/.env' })

Assertion.addChainableMethod('equalRow', function(expectedRow: any) {
  const omittedProps = ['created_at', 'updated_at']

  if (!expectedRow.id) {
    omittedProps.push('id')
  }
  const actualRow = omitProps(this._obj, omittedProps)

  return new Assertion(expectedRow).to.deep.equal(actualRow)
})

Assertion.addChainableMethod('equalRows', function(expectedRows: any[]) {
  const omittedProps = ['created_at', 'updated_at']

  if (expectedRows.every(row => !row.id)) {
    omittedProps.push('id')
  }

  const actualRows = this._obj.map(_obj => omitProps(_obj, omittedProps))

  return new Assertion(expectedRows).to.deep.equal(actualRows)
开发者ID:decentraland,项目名称:agora,代码行数:31,代码来源:specs_setup.ts

示例10:

import { env } from 'decentraland-commons'
import { contracts } from 'decentraland-eth'
const MANAToken = new contracts.MANAToken(
  env.get('REACT_APP_MANA_TOKEN_CONTRACT_ADDRESS')
)
export { MANAToken }
开发者ID:decentraland,项目名称:agora,代码行数:6,代码来源:contracts.ts


注:本文中的decentraland-commons.env类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。