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

[beta] Optimize signature for fallback function. (#4780) #4784

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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