Optimize signature for fallback function. (#4780)
This commit is contained in:
parent
0de8771007
commit
4f934cf2c2
@ -21,8 +21,9 @@ export function eventSignature (eventName, params) {
|
|||||||
const { strName, name } = parseName(eventName);
|
const { strName, name } = parseName(eventName);
|
||||||
const types = (params || []).map(fromParamType).join(',');
|
const types = (params || []).map(fromParamType).join(',');
|
||||||
const id = `${strName}(${types})`;
|
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) {
|
export function methodSignature (methodName, params) {
|
||||||
|
@ -46,7 +46,7 @@ describe('abi/util/signature', () => {
|
|||||||
expect(eventSignature(undefined, [])).to.deep.equal({
|
expect(eventSignature(undefined, [])).to.deep.equal({
|
||||||
id: '()',
|
id: '()',
|
||||||
name: undefined,
|
name: undefined,
|
||||||
signature: '861731d50c3880a2ca1994d5ec287b94b2f4bd832a67d3e41c08177bdd5674fe'
|
signature: ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe('abi/util/signature', () => {
|
|||||||
expect(eventSignature(undefined, undefined)).to.deep.equal({
|
expect(eventSignature(undefined, undefined)).to.deep.equal({
|
||||||
id: '()',
|
id: '()',
|
||||||
name: undefined,
|
name: undefined,
|
||||||
signature: '861731d50c3880a2ca1994d5ec287b94b2f4bd832a67d3e41c08177bdd5674fe'
|
signature: ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -96,7 +96,7 @@ describe('abi/util/signature', () => {
|
|||||||
expect(methodSignature(undefined, [])).to.deep.equal({
|
expect(methodSignature(undefined, [])).to.deep.equal({
|
||||||
id: '()',
|
id: '()',
|
||||||
name: undefined,
|
name: undefined,
|
||||||
signature: '861731d5'
|
signature: ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ describe('abi/util/signature', () => {
|
|||||||
expect(methodSignature(undefined, undefined)).to.deep.equal({
|
expect(methodSignature(undefined, undefined)).to.deep.equal({
|
||||||
id: '()',
|
id: '()',
|
||||||
name: undefined,
|
name: undefined,
|
||||||
signature: '861731d5'
|
signature: ''
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,5 @@ export function abiEncode (methodName, inputTypes, data) {
|
|||||||
})
|
})
|
||||||
}, data);
|
}, data);
|
||||||
|
|
||||||
return methodName === null
|
return result;
|
||||||
? `0x${result.substr(10)}`
|
|
||||||
: result;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user