Merge pull request #791 from ethereum/yann300-patch-8

Fix encoding fallback function
pull/7/head
yann300 7 years ago committed by GitHub
commit 03d5a7c2f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      remix-lib/src/execution/txHelper.js
  2. 22
      remix-lib/test/txFormat.js

@ -21,6 +21,7 @@ module.exports = {
}, },
encodeFunctionId: function (funABI) { encodeFunctionId: function (funABI) {
if (funABI.type === 'fallback') return '0x'
var abi = new ethers.Interface([funABI]) var abi = new ethers.Interface([funABI])
abi = abi.functions[funABI.name] abi = abi.functions[funABI.name]
return abi.sighash return abi.sighash

@ -1,6 +1,7 @@
'use strict' 'use strict'
var tape = require('tape') var tape = require('tape')
var txFormat = require('../src/execution/txFormat') var txFormat = require('../src/execution/txFormat')
var txHelper = require('../src/execution/txHelper')
var compiler = require('solc') var compiler = require('solc')
var compilerInput = require('../src/helpers/compilerHelper').compilerInput var compilerInput = require('../src/helpers/compilerHelper').compilerInput
var executionContext = require('../src/execution/execution-context') 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 { var uintContract = `contract uintContractTest {
uint _tp; uint _tp;
address _ap; address _ap;
@ -186,3 +198,13 @@ contract testContractLinkLibrary {
} }
}` }`
var fallbackFunction = `pragma solidity ^0.4.4;
contract fallbackFunctionContract {
function get (uint _p, string _o) {
}
function () {}
}`

Loading…
Cancel
Save