Skip to content

Commit dd6874c

Browse files
committed
Do not translate constant functions from <0.4.0 as payable
1 parent caa550a commit dd6874c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

abi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function update (compilerVersion, abi) {
1919
}
2020

2121
if (item.type !== 'event') {
22-
// add 'payable' to everything
23-
if (semver.lt(compilerVersion, '0.4.0')) {
22+
// add 'payable' to everything, except constant functions
23+
if (!item.constant && semver.lt(compilerVersion, '0.4.0')) {
2424
item.payable = true;
2525
}
2626

test/abi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tape('ABI translator', function (t) {
2222
});
2323
t.test('0.3.6 (constant function)', function (st) {
2424
var input = [ { inputs: [], type: 'function', constant: true } ];
25-
st.deepEqual(abi.update('0.3.6', input), [ { inputs: [], payable: true, constant: true, stateMutability: 'payable', type: 'function' }, { payable: true, stateMutability: 'payable', type: 'fallback' } ]);
25+
st.deepEqual(abi.update('0.3.6', input), [ { inputs: [], constant: true, stateMutability: 'view', type: 'function' }, { payable: true, stateMutability: 'payable', type: 'fallback' } ]);
2626
st.end();
2727
});
2828
t.test('0.3.6 (event)', function (st) {

0 commit comments

Comments
 (0)