Update ERC721 to latest 1.11.0 from OpenZeppelin-solidity (#11)
* Update ERC721 to latest 1.11.0 from OpenZeppelin-solidity * Hardcode supported interfaces instead of using lookup table. This avoids shifting storage when extending supports interface. * Update build artifacts * Fix linter errors
This commit is contained in:
committed by
GitHub
parent
8f4610e007
commit
c46f0353d1
21
test/helpers/makeInterfaceId.js
Normal file
21
test/helpers/makeInterfaceId.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { soliditySha3 } from 'web3-utils';
|
||||
|
||||
const INTERFACE_ID_LENGTH = 4;
|
||||
|
||||
export default (interfaces = []) => {
|
||||
const interfaceIdBuffer = interfaces
|
||||
.map(methodSignature => soliditySha3(methodSignature)) // keccak256
|
||||
.map(h =>
|
||||
Buffer
|
||||
.from(h.substring(2), 'hex')
|
||||
.slice(0, 4) // bytes4()
|
||||
)
|
||||
.reduce((memo, bytes) => {
|
||||
for (let i = 0; i < INTERFACE_ID_LENGTH; i++) {
|
||||
memo[i] = memo[i] ^ bytes[i]; // xor
|
||||
}
|
||||
return memo;
|
||||
}, Buffer.alloc(INTERFACE_ID_LENGTH));
|
||||
|
||||
return `0x${interfaceIdBuffer.toString('hex')}`;
|
||||
};
|
||||
Reference in New Issue
Block a user