Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Optimize signature for fallback function. (#4780)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Mar 6, 2017
1 parent c585985 commit a76fa7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion js/src/abi/util/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ export function eventSignature (eventName, params) {
const { strName, name } = parseName(eventName);
const types = (params || []).map(fromParamType).join(',');
const id = `${strName}(${types})`;
const signature = strName ? keccak_256(id) : '';

return { id, name, signature: keccak_256(id) };
return { id, name, signature };
}

export function methodSignature (methodName, params) {
Expand Down
8 changes: 4 additions & 4 deletions js/src/abi/util/signature.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ describe('abi/util/signature', () => {
expect(eventSignature(undefined, [])).to.deep.equal({
id: '()',
name: undefined,
signature: '861731d50c3880a2ca1994d5ec287b94b2f4bd832a67d3e41c08177bdd5674fe'
signature: ''
});
});

it('encodes no-params signature correctly as ()', () => {
expect(eventSignature(undefined, undefined)).to.deep.equal({
id: '()',
name: undefined,
signature: '861731d50c3880a2ca1994d5ec287b94b2f4bd832a67d3e41c08177bdd5674fe'
signature: ''
});
});
});
Expand Down Expand Up @@ -96,15 +96,15 @@ describe('abi/util/signature', () => {
expect(methodSignature(undefined, [])).to.deep.equal({
id: '()',
name: undefined,
signature: '861731d5'
signature: ''
});
});

it('encodes no-params signature correctly as ()', () => {
expect(methodSignature(undefined, undefined)).to.deep.equal({
id: '()',
name: undefined,
signature: '861731d5'
signature: ''
});
});
});
Expand Down

0 comments on commit a76fa7a

Please sign in to comment.