This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Import contract factory generated from `hardhat compile` with typechain | |
| import { IERC165__factory, IERC2981__factory } from '@custom-types/contracts' | |
| import { ethers } from 'hardhat' | |
| import { utils } from 'ethers' | |
| const getInterfaceID = (contractInterface: utils.Interface) => { | |
| let interfaceID = ethers.constants.Zero; | |
| const functions: string[] = Object.keys(contractInterface.functions); | |
| for (let i = 0; i < functions.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // EIP-712 v4 Encoding Arrays | |
| function hash(string[] calldata array) internal pure returns (bytes32 result) { | |
| bytes32[] memory _array = new bytes32[](array.length); | |
| for (uint256 i = 0; i < array.length; ++i) { | |
| _array[i] = keccak256(bytes(array[i])); | |
| } | |
| result = keccak256(abi.encodePacked(_array)); | |
| } |