Skip to content

Commit

Permalink
WIP: Adding interfaces we might care about
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Sep 11, 2023
1 parent f630281 commit d8bcb42
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/__tests__/interfaces.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect } from '@jest/globals';

import { selectorsToInterfaces } from '../interfaces';

import { test } from "./env";


test('selectors to interfaces', async ({}) => {
// Given a set of interfaces, get the interfaces that it implements
const selectors = ['0x02751cec', '0x054d50d4', '0x18cbafe5', '0x1f00ca74', '0x2195995c', '0x38ed1739', '0x4a25d94a', '0x5b0d5984', '0x5c11d795', '0x791ac947', '0x7ff36ab5', '0x85f8c259', '0x8803dbee', '0xad5c4648', '0xad615dec', '0xaf2979eb', '0xb6f9de95', '0xbaa2abde', '0xc45a0155', '0xd06ca61f', '0xded9382a', '0xe8e33700', '0xf305d719', '0xfb3bdb41'];

const got = selectorsToInterfaces(selectors);

});

58 changes: 58 additions & 0 deletions src/embedded/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const interfaces = {
"ERC-20": [
"function totalSupply() view returns (uint256)",
"function balanceOf(address) view returns (uint256)",
"function transfer(address, uint256) returns (bool)",
"function allowance(address, address) returns (uint256)",
"function approve(address, uint256) returns (bool)",
"function transferFrom(address, address, uint256) returns (bool)",
],
"ERC-165": [
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
],
"ERC-721": [
"function balanceOf(address owner) view returns (uint256 balance)",
"function ownerOf(uint256 tokenId) view returns (address owner)",
"function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data)",
"function safeTransferFrom(address from, address to, uint256 tokenId)",
"function transferFrom(address from, address to, uint256 tokenId)",
"function approve(address to, uint256 tokenId)",
"function setApprovalForAll(address operator, bool _approved)",
"function getApproved(uint256 tokenId) view returns (address operator)",
"function isApprovedForAll(address owner, address operator) view returns (bool)",
],
"ERC-777": [
"function name() view returns (string memory)",
"function symbol() view returns (string memory)",
"function granularity() view returns (uint256)",
"function totalSupply() view returns (uint256)",
"function balanceOf(address owner) view returns (uint256)",
"function send(address recipient, uint256 amount, bytes calldata data)",
"function burn(uint256 amount, bytes calldata data)",
"function isOperatorFor(address operator, address tokenHolder) view returns (bool)",
"function authorizeOperator(address operator)",
"function revokeOperator(address operator)",
"function defaultOperators() view returns (address[] memory)",
"function operatorSend(address sender, address recipient, uint256 amount, bytes calldata data, bytes calldata operatorData)",
"function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData)",
],
"ERC-1155": [
"function balanceOf(address account, uint256 id) view returns (uint256)",
"function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) view returns (uint256[] memory)",
"function setApprovalForAll(address operator, bool approved)",
"function isApprovedForAll(address account, address operator) view returns (bool)",
"function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data)",
"function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data)",
],
"ERC-4626": [
],
"Ownable": [
"function owner() view returns (address)",
"function renounceOwnership()",
"function transferOwnership(address)",
],
"Multicall": [
"function multicall(bytes[]) returns (bytes[] memory)",
],
}

5 changes: 5 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Given a list of selectors, return a mapping of interfaces it implements to a list of present function signatures that belong to it.
export function selectorsToInterfaces(selectors: string[], index?: any): Record<string, string[]> {
// XXX
return {}
}

0 comments on commit d8bcb42

Please sign in to comment.