How to use the utility/environment.chainClient function in utility

To help you get started, we’ve selected a few utility 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 Bytom / bytom-dashboard / src / features / backup / actions.js View on Github external
return function(dispatch) {
      return chainClient().backUp.backup()
        .then(resp => {
          if (resp.status === 'fail') {
            throw resp
          }
          const date = new Date()
          const dateStr = date.toLocaleDateString().split(' ')[0]
          const timestamp = date.getTime()
          const fileName = ['bytom-wallet-backup-', dateStr, timestamp].join('-')

          let element = document.createElement('a')
          element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(resp.data)))
          element.setAttribute('download', fileName)
          element.style.display = 'none'
          document.body.appendChild(element)
          element.click()
github Bytom / bytom-dashboard / src / features / transactions / components / New / Vote.jsx View on Github external
constructor(props) {
    super(props)
    this.connection = chainClient().connection
    this.state = {
      estimateGas:1000000,
      address:null,
      displayGas: true
    }

    this.submitWithValidation = this.submitWithValidation.bind(this)
    this.disableSubmit = this.disableSubmit.bind(this)
  }
github Bytom / bytom-dashboard / src / features / app / actions.js View on Github external
cmd: (data) => () => {
    return chainClient().bytomCli.request(data)
  }
}
github Bytom / bytom-dashboard / src / features / shared / actions / update.js View on Github external
submitUpdateForm: (data, id) => {
      const clientApi = options.clientApi ? options.clientApi() : chainClient()[`${type}s`]
      let promise = Promise.resolve()

      return function(dispatch) {
        return promise.then(() => clientApi.updateAlias({
          id: id,
          alias: data.alias,
        }).then((resp) => {
          if (resp.status === 'fail') {
            throw resp
          }
          dispatch(updated(resp))

          dispatch(push({
            pathname: `/${type}s/${id}`,
            state: {
              preserveFlash: true
github Bytom / bytom-dashboard / src / features / app / components / Register / Register.jsx View on Github external
constructor(props) {
    super(props)
    this.connection = chainClient().connection

    this.submitWithErrors = this.submitWithErrors.bind(this)
  }
github Bytom / bytom-dashboard / src / features / transactions / actions.js View on Github external
form.submitForm = (formParams) => function (dispatch) {
  const client = chainClient()

  const builderFunction = ( builder ) => {
    const processed = preprocessTransaction(formParams)

    builder.actions = processed.actions
    if (processed.baseTransaction) {
      builder.baseTransaction = processed.baseTransaction
    }
  }

  const submitSucceeded = () => {
    dispatch(form.created())
    dispatch(push({
      pathname: '/transactions',
      state: {
        preserveFlash: true
github Bytom / bytom-dashboard / src / features / initialization / actions.js View on Github external
return (dispatch) => {
    if (typeof data.keyAlias == 'string')  data.keyAlias = data.keyAlias.trim()
    if (typeof data.mnemonic == 'string') data.mnemonic = data.mnemonic.trim()

    const keyData = {
      'alias': data.keyAlias,
      'password': data.password,
      'mnemonic': data.mnemonic
    }

    return chainClient().mockHsm.keys.create(keyData)
      .then((resp) => {
        if (resp.status === 'fail') {
          throw resp
        }else{
          return chainClient().backUp.recovery({
            xpubs: [resp.data.xpub]
          })
            .then((resp) => {
              if (resp.status === 'fail') {
                throw resp
              }

              dispatch(success)
            })
            .catch((err) => {
              throw err
github Bytom / bytom-dashboard / src / features / shared / actions / list.js View on Github external
  const clientApi = () => options.clientApi ? options.clientApi() : chainClient()[`${type}s`]
github Bytom / bytom-dashboard / src / features / accounts / actions.js View on Github external
listAddresses: (accountId) => {
    return chainClient().accounts.listAddresses({accountId})
  }
}
github Bytom / bytom-dashboard / src / features / transactions / components / New / NormalTransactionForm.jsx View on Github external
values.receivers.forEach((receiver, idx) => {
    const address = values.receivers[idx].address
    if ( !address || address.length === 0)
      promises.push(Promise.resolve())
    else{
      promises.push(
        chainClient().accounts.validateAddresses(address)
          .then(
            (resp) => {
              if (!resp.data.valid) {
                errors[idx] = {address: props.t('errorMessage.addressError')}
              }
              return {}
            }
          ))
    }
  })