Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
ab932e18
Commit
ab932e18
authored
Oct 18, 2018
by
Nicolás Venturo
Committed by
Leo Arias
Oct 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added leading underscore to internal functions, renamed supportsInterfaces. (#1435)
(cherry picked from commit
0231fac5
)
parent
43941076
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
30 deletions
+30
-30
ERC165Checker.sol
contracts/introspection/ERC165Checker.sol
+12
-12
ERC165CheckerMock.sol
contracts/mocks/ERC165CheckerMock.sol
+4
-4
ERC165Checker.test.js
test/introspection/ERC165Checker.test.js
+14
-14
No files found.
contracts/introspection/ERC165Checker.sol
View file @
ab932e18
...
...
@@ -20,15 +20,15 @@ library ERC165Checker {
* @param account The address of the contract to query for support of ERC165
* @return true if the contract at account implements ERC165
*/
function supportsERC165(address account)
function
_
supportsERC165(address account)
internal
view
returns (bool)
{
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return supportsERC165Interface(account, _InterfaceId_ERC165) &&
!supportsERC165Interface(account, _InterfaceId_Invalid);
return
_
supportsERC165Interface(account, _InterfaceId_ERC165) &&
!
_
supportsERC165Interface(account, _InterfaceId_Invalid);
}
/**
...
...
@@ -39,14 +39,14 @@ library ERC165Checker {
* identifier interfaceId, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function supportsInterface(address account, bytes4 interfaceId)
function
_
supportsInterface(address account, bytes4 interfaceId)
internal
view
returns (bool)
{
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) &&
supportsERC165Interface(account, interfaceId);
return
_
supportsERC165(account) &&
_
supportsERC165Interface(account, interfaceId);
}
/**
...
...
@@ -57,19 +57,19 @@ library ERC165Checker {
* interfaceIds list, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function
supports
Interfaces(address account, bytes4[] interfaceIds)
function
_supportsAll
Interfaces(address account, bytes4[] interfaceIds)
internal
view
returns (bool)
{
// query support of ERC165 itself
if (!supportsERC165(account)) {
if (!
_
supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!supportsERC165Interface(account, interfaceIds[i])) {
if (!
_
supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
...
...
@@ -89,14 +89,14 @@ library ERC165Checker {
* with the `supportsERC165` method in this library.
* Interface identification is specified in ERC-165.
*/
function supportsERC165Interface(address account, bytes4 interfaceId)
function
_
supportsERC165Interface(address account, bytes4 interfaceId)
private
view
returns (bool)
{
// success determines whether the staticcall succeeded and result determines
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = callERC165SupportsInterface(
(bool success, bool result) =
_
callERC165SupportsInterface(
account, interfaceId);
return (success && result);
...
...
@@ -110,7 +110,7 @@ library ERC165Checker {
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function callERC165SupportsInterface(
function
_
callERC165SupportsInterface(
address account,
bytes4 interfaceId
)
...
...
contracts/mocks/ERC165CheckerMock.sol
View file @
ab932e18
...
...
@@ -10,7 +10,7 @@ contract ERC165CheckerMock {
view
returns (bool)
{
return account.supportsERC165();
return account.
_
supportsERC165();
}
function supportsInterface(address account, bytes4 interfaceId)
...
...
@@ -18,14 +18,14 @@ contract ERC165CheckerMock {
view
returns (bool)
{
return account.supportsInterface(interfaceId);
return account.
_
supportsInterface(interfaceId);
}
function supportsInterfaces(address account, bytes4[] interfaceIds)
function supports
All
Interfaces(address account, bytes4[] interfaceIds)
public
view
returns (bool)
{
return account.
supports
Interfaces(interfaceIds);
return account.
_supportsAll
Interfaces(interfaceIds);
}
}
test/introspection/ERC165Checker.test.js
View file @
ab932e18
...
...
@@ -32,8 +32,8 @@ contract('ERC165Checker', function () {
supported
.
should
.
equal
(
false
);
});
it
(
'does not support mock interface via supportsInterfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
it
(
'does not support mock interface via supports
All
Interfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
supported
.
should
.
equal
(
false
);
});
});
...
...
@@ -53,8 +53,8 @@ contract('ERC165Checker', function () {
supported
.
should
.
equal
(
false
);
});
it
(
'does not support mock interface via supportsInterfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
it
(
'does not support mock interface via supports
All
Interfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
supported
.
should
.
equal
(
false
);
});
});
...
...
@@ -74,8 +74,8 @@ contract('ERC165Checker', function () {
supported
.
should
.
equal
(
true
);
});
it
(
'supports mock interface via supportsInterfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
it
(
'supports mock interface via supports
All
Interfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
[
DUMMY_ID
]);
supported
.
should
.
equal
(
true
);
});
});
...
...
@@ -98,22 +98,22 @@ contract('ERC165Checker', function () {
};
});
it
(
'supports all interfaceIds via supportsInterfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
this
.
supportedInterfaces
);
it
(
'supports all interfaceIds via supports
All
Interfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
this
.
supportedInterfaces
);
supported
.
should
.
equal
(
true
);
});
it
(
'supports none of the interfaces queried via supportsInterfaces'
,
async
function
()
{
it
(
'supports none of the interfaces queried via supports
All
Interfaces'
,
async
function
()
{
const
interfaceIdsToTest
=
[
DUMMY_UNSUPPORTED_ID
,
DUMMY_UNSUPPORTED_ID_2
];
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
interfaceIdsToTest
);
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
interfaceIdsToTest
);
supported
.
should
.
equal
(
false
);
});
it
(
'supports not all of the interfaces queried via supportsInterfaces'
,
async
function
()
{
it
(
'supports not all of the interfaces queried via supports
All
Interfaces'
,
async
function
()
{
const
interfaceIdsToTest
=
[...
this
.
supportedInterfaces
,
DUMMY_UNSUPPORTED_ID
];
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
this
.
target
.
address
,
interfaceIdsToTest
);
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
this
.
target
.
address
,
interfaceIdsToTest
);
supported
.
should
.
equal
(
false
);
});
});
...
...
@@ -129,8 +129,8 @@ contract('ERC165Checker', function () {
supported
.
should
.
equal
(
false
);
});
it
(
'does not support mock interface via supportsInterfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supportsInterfaces
(
DUMMY_ACCOUNT
,
[
DUMMY_ID
]);
it
(
'does not support mock interface via supports
All
Interfaces'
,
async
function
()
{
const
supported
=
await
this
.
mock
.
supports
All
Interfaces
(
DUMMY_ACCOUNT
,
[
DUMMY_ID
]);
supported
.
should
.
equal
(
false
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment