Skip to content

Commit

Permalink
Fix issue when Solidity method collises with JavaScript prototype (#1432
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 16, 2021
1 parent 6582ede commit 0a8be37
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/contracts/src.ts/index.ts
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a8be37

Please sign in to comment.