Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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)
}
cmd: (data) => () => {
return chainClient().bytomCli.request(data)
}
}
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
constructor(props) {
super(props)
this.connection = chainClient().connection
this.submitWithErrors = this.submitWithErrors.bind(this)
}
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
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
const clientApi = () => options.clientApi ? options.clientApi() : chainClient()[`${type}s`]
listAddresses: (accountId) => {
return chainClient().accounts.listAddresses({accountId})
}
}
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 {}
}
))
}
})