From 296166fea82a3e964b948f02e1d33dca3918c4eb Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 May 2018 18:05:10 +0200 Subject: [PATCH 1/3] Update txHelper.js --- remix-lib/src/execution/txHelper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/remix-lib/src/execution/txHelper.js b/remix-lib/src/execution/txHelper.js index d65c580819..28a8804aa2 100644 --- a/remix-lib/src/execution/txHelper.js +++ b/remix-lib/src/execution/txHelper.js @@ -21,6 +21,7 @@ module.exports = { }, encodeFunctionId: function (funABI) { + if (funABI.type === 'fallback') return '' var abi = new ethers.Interface([funABI]) abi = abi.functions[funABI.name] return abi.sighash From ce64772df71452ffeae4a27316a05d40c03d443c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 May 2018 18:25:38 +0200 Subject: [PATCH 2/3] better return --- remix-lib/src/execution/txHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remix-lib/src/execution/txHelper.js b/remix-lib/src/execution/txHelper.js index 28a8804aa2..41478fabd9 100644 --- a/remix-lib/src/execution/txHelper.js +++ b/remix-lib/src/execution/txHelper.js @@ -21,7 +21,7 @@ module.exports = { }, encodeFunctionId: function (funABI) { - if (funABI.type === 'fallback') return '' + if (funABI.type === 'fallback') return '0x' var abi = new ethers.Interface([funABI]) abi = abi.functions[funABI.name] return abi.sighash From e5250839dc4296a85591c700beffb7eb426d12f8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 May 2018 18:25:41 +0200 Subject: [PATCH 3/3] add test --- remix-lib/test/txFormat.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/remix-lib/test/txFormat.js b/remix-lib/test/txFormat.js index b6a908f124..3935ec8db1 100644 --- a/remix-lib/test/txFormat.js +++ b/remix-lib/test/txFormat.js @@ -1,6 +1,7 @@ 'use strict' var tape = require('tape') var txFormat = require('../src/execution/txFormat') +var txHelper = require('../src/execution/txHelper') var compiler = require('solc') var compilerInput = require('../src/helpers/compilerHelper').compilerInput var executionContext = require('../src/execution/execution-context') @@ -149,6 +150,17 @@ function encodeFunctionCallTest (st) { /* *********************************************************** */ +tape('test fallback function', function (t) { + t.test('(fallback)', function (st) { + st.plan(2) + var output = compiler.compileStandardWrapper(compilerInput(fallbackFunction)) + output = JSON.parse(output) + var contract = output.contracts['test.sol']['fallbackFunctionContract'] + st.equal(txHelper.encodeFunctionId(contract.abi[0]), '0x805da4ad') + st.equal(txHelper.encodeFunctionId(contract.abi[1]), '0x') + }) +}) + var uintContract = `contract uintContractTest { uint _tp; address _ap; @@ -186,3 +198,13 @@ contract testContractLinkLibrary { } }` + +var fallbackFunction = `pragma solidity ^0.4.4; + +contract fallbackFunctionContract { + function get (uint _p, string _o) { + + } + + function () {} + }`