diff --git a/src/components/CommonPage/DetailPage.js b/src/components/CommonPage/DetailPage.js index ac0db567..20f1b4f2 100644 --- a/src/components/CommonPage/DetailPage.js +++ b/src/components/CommonPage/DetailPage.js @@ -103,8 +103,6 @@ class DetailPage extends Component { const { loading, error, pending } = this.props const isNotFoundPage = !loading && error !== '' && !isHxAddress(error) && !pending - console.log("Detail Page", this.state) - const Content = () => { if (pending) { return diff --git a/src/components/ContractsPage/ContractDetailPage/ContractTabs/ContractComponent.js b/src/components/ContractsPage/ContractDetailPage/ContractTabs/ContractComponent.js index 35d80c66..a95bcdae 100644 --- a/src/components/ContractsPage/ContractDetailPage/ContractTabs/ContractComponent.js +++ b/src/components/ContractsPage/ContractDetailPage/ContractTabs/ContractComponent.js @@ -52,12 +52,24 @@ function ContractComponent({ alert('Please connect to wallet first') } else { const paramsData = makeParams(params, method, inputs) + let value = null; + if (paramsData.hasOwnProperty("value")) { + value = paramsData.value; + const valueInput = inputs.find(f => f.name === 'value' && f.type === "icx"); + if (valueInput) { + value = parseFloat(value); + } + delete paramsData.value; + } + + const rawMethodCall = await customMethod( walletAddress, address, method, paramsData, - nid + nid, + value ) icxSendTransaction({ params: { ...rawMethodCall }, diff --git a/src/components/ContractsPage/contractUtils.js b/src/components/ContractsPage/contractUtils.js index 42dc19ef..99aa6f48 100644 --- a/src/components/ContractsPage/contractUtils.js +++ b/src/components/ContractsPage/contractUtils.js @@ -67,11 +67,22 @@ export function createContractMethodsState(contractReadWriteInfo) { result.writeMethodsNameArray.push(funcName) const inputs = { ...func } + + if (inputs.payable === "0x1") { + if (!inputs.inputs.find(f => f.name === 'value')) { + inputs.inputs.push({ name: 'value', type: 'icx' }) + } + } + + + const outputs = writeFuncOutputs[index] result[funcName] = { inputs, outputs, } + + }) return result diff --git a/src/redux/api/jsProvider/icx.js b/src/redux/api/jsProvider/icx.js index a0afc01c..01114dd8 100644 --- a/src/redux/api/jsProvider/icx.js +++ b/src/redux/api/jsProvider/icx.js @@ -3,6 +3,7 @@ import { requestJsonRpc } from '../../../utils/connect' export async function icxSendTransaction(payload) { console.log('icxSendTransaction payload:', payload) + // payload will always have an 'index' field const { index } = payload const result = { @@ -18,6 +19,8 @@ export async function icxSendTransaction(payload) { if (rawTx == null) { throw new Error('Invalid payload for icxSendTransaction') } + + result.data = await requestJsonRpc(rawTx.params) console.log('result success') } catch (e) { @@ -28,8 +31,8 @@ export async function icxSendTransaction(payload) { typeof e === 'string' ? e : e.message != null && typeof e.message === 'string' - ? e.message - : JSON.stringify(e) + ? e.message + : JSON.stringify(e) } return result } diff --git a/src/utils/rawTxMaker/api/custom.js b/src/utils/rawTxMaker/api/custom.js index d1377fb7..3c55162f 100644 --- a/src/utils/rawTxMaker/api/custom.js +++ b/src/utils/rawTxMaker/api/custom.js @@ -7,8 +7,8 @@ import { makeTxCallRPCObj } from './helpers' /* * */ -async function customMethod(from, to, methodName, methodParams, nid) { - const RPCObj = await makeTxCallRPCObj(from, to, methodName, methodParams, nid) +async function customMethod(from, to, methodName, methodParams, nid, value = null) { + const RPCObj = await makeTxCallRPCObj(from, to, methodName, methodParams, nid, null, value) return RPCObj } diff --git a/src/utils/rawTxMaker/api/helpers.js b/src/utils/rawTxMaker/api/helpers.js index 8f3bf1b2..05da693c 100644 --- a/src/utils/rawTxMaker/api/helpers.js +++ b/src/utils/rawTxMaker/api/helpers.js @@ -26,9 +26,14 @@ async function makeTxCallRPCObj( method, paramsObj = null, nid, - stepLimit = 2000000, + stepLimit, value = null ) { + + if (!stepLimit) { + stepLimit = 2000000 + } + const params = { from: from, to: to,