|
@ -2,6 +2,8 @@ import { END, eventChannel } from 'redux-saga' |
|
|
import { call, put, select, take, takeEvery } from 'redux-saga/effects' |
|
|
import { call, put, select, take, takeEvery } from 'redux-saga/effects' |
|
|
import * as ContractActions from './constants' |
|
|
import * as ContractActions from './constants' |
|
|
import * as TransactionsActions from '../transactions/transactionsActions' |
|
|
import * as TransactionsActions from '../transactions/transactionsActions' |
|
|
|
|
|
import { ACCOUNTS_FAILED, ACCOUNTS_FETCHED, ACCOUNTS_FETCHING } from '../accounts/accountsActions' |
|
|
|
|
|
import { getNetworkId } from '../web3/web3Saga' |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* Events |
|
|
* Events |
|
@ -199,7 +201,7 @@ function * callCallContractFn ({ |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error(error) |
|
|
console.error(error) |
|
|
|
|
|
|
|
|
var errorArgs = { |
|
|
const errorArgs = { |
|
|
name: contract.contractName, |
|
|
name: contract.contractName, |
|
|
variable: contract.abi[fnIndex].name, |
|
|
variable: contract.abi[fnIndex].name, |
|
|
argsHash: argsHash, |
|
|
argsHash: argsHash, |
|
@ -230,8 +232,8 @@ function * callSyncContract (action) { |
|
|
delete contractFnsState.events |
|
|
delete contractFnsState.events |
|
|
|
|
|
|
|
|
// Iterate over functions and hashes
|
|
|
// Iterate over functions and hashes
|
|
|
for (var fnName in contractFnsState) { |
|
|
for (let fnName in contractFnsState) { |
|
|
for (var argsHash in contractFnsState[fnName]) { |
|
|
for (let argsHash in contractFnsState[fnName]) { |
|
|
const fnIndex = contractFnsState[fnName][argsHash].fnIndex |
|
|
const fnIndex = contractFnsState[fnName][argsHash].fnIndex |
|
|
const args = contractFnsState[fnName][argsHash].args |
|
|
const args = contractFnsState[fnName][argsHash].args |
|
|
|
|
|
|
|
@ -271,6 +273,18 @@ function isSendOrCallOptions (options) { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function * isContractDeployed ({ web3, contractConfig }) { |
|
|
|
|
|
const networkId = yield call(getNetworkId, { web3 }) |
|
|
|
|
|
if(contractConfig.networks[networkId]){ |
|
|
|
|
|
const contractAddress = contractConfig.networks[networkId].address; |
|
|
|
|
|
|
|
|
|
|
|
const fetchedByteCode = yield call(web3.eth.getCode, contractAddress); |
|
|
|
|
|
if(fetchedByteCode === contractConfig.deployedBytecode) |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function * contractsSaga () { |
|
|
function * contractsSaga () { |
|
|
yield takeEvery(ContractActions.SEND_CONTRACT_TX, callSendContractTx) |
|
|
yield takeEvery(ContractActions.SEND_CONTRACT_TX, callSendContractTx) |
|
|
yield takeEvery(ContractActions.CALL_CONTRACT_FN, callCallContractFn) |
|
|
yield takeEvery(ContractActions.CALL_CONTRACT_FN, callCallContractFn) |
|
|