Fix issue when Solidity method collises with JavaScript prototype (#1432, #2054, #2120).

This commit is contained in:
Richard Moore 2021-10-15 21:32:48 -04:00
parent 6582ede1ce
commit 0a8be37b08
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

View File

@ -728,8 +728,8 @@ export class BaseContract {
// are ambiguous
{
const name = fragment.name;
if (!uniqueNames[name]) { uniqueNames[name] = [ ]; }
uniqueNames[name].push(signature);
if (!uniqueNames[`%${ name }`]) { uniqueNames[`%${ name }`] = [ ]; }
uniqueNames[`%${ name }`].push(signature);
}
if ((<Contract>this)[signature] == null) {
@ -757,11 +757,13 @@ export class BaseContract {
});
Object.keys(uniqueNames).forEach((name) => {
// Ambiguous names to not get attached as bare names
const signatures = uniqueNames[name];
if (signatures.length > 1) { return; }
// Strip off the leading "%" used for prototype protection
name = name.substring(1);
const signature = signatures[0];
// If overwriting a member property that is null, swallow the error