Skip to content

Commit 0a8be37

Browse files
committed
Fix issue when Solidity method collises with JavaScript prototype (#1432, #2054, #2120).
1 parent 6582ede commit 0a8be37

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/contracts/src.ts/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ export class BaseContract {
728728
// are ambiguous
729729
{
730730
const name = fragment.name;
731-
if (!uniqueNames[name]) { uniqueNames[name] = [ ]; }
732-
uniqueNames[name].push(signature);
731+
if (!uniqueNames[`%${ name }`]) { uniqueNames[`%${ name }`] = [ ]; }
732+
uniqueNames[`%${ name }`].push(signature);
733733
}
734734

735735
if ((<Contract>this)[signature] == null) {
@@ -757,11 +757,13 @@ export class BaseContract {
757757
});
758758

759759
Object.keys(uniqueNames).forEach((name) => {
760-
761760
// Ambiguous names to not get attached as bare names
762761
const signatures = uniqueNames[name];
763762
if (signatures.length > 1) { return; }
764763

764+
// Strip off the leading "%" used for prototype protection
765+
name = name.substring(1);
766+
765767
const signature = signatures[0];
766768

767769
// If overwriting a member property that is null, swallow the error

0 commit comments

Comments
 (0)