Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Dec 17, 2023
1 parent fba6062 commit e0e363b
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
.project
.settings
private
solidity_files/
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Lightweigh tool to manage your approvals for ERC-20, ERC-721 and ERC-1155 contra

To be run from GitHub pages at [https://bokkypoobah.github.io/ApprovalTool/](https://bokkypoobah.github.io/ApprovalTool/), or locally by cloning this repo and running e.g. [anywhere](https://www.npmjs.com/package/anywhere) in the ./docs folder

### Sample Screens

WIP

<kbd><img src="images/SampleScreen_20231217.png" /></kbd>

<br />

<br />
Expand Down
12 changes: 9 additions & 3 deletions docs/customNames.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const CUSTOMNAMES = {
"0x0000000000000000000000000000000000000000": "Dead:0x0000...0000",
"0x0000000000000000000000000000000000000000": ["eoa", "Dead", "Dead:0x0000...0000"],
"0x1E0049783F008A0085193E00003D00cd54003c71": ["nftexchange", "OS:Conduit", "OpenSea: Conduit"],
"0x495f947276749Ce646f68AC8c248420045cb7b5e": ["erc1155", "OSSSF", "OpenSea Shared StoreFront"],
"0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85": ["erc721", "ENS", "Ethereum Name Service"],
};

const CUSTOMNAMESOLD = {
// "0x0000000000000000000000000000000000000000": "Dead:0x0000...0000",
"0x0000000000000000000000000000000000000001": "Dead:0x0000...0001",
"0x0000000000000000000000000000000000000003": "Dead:0x0000...0003",
"0x000000000000000000000000000000000000dEaD": "Dead:0x0000...dEaD",
"0x000000000000000000000000000000000000dEaD": "Dead:0x0000...dEaD",
"0x00000000000000000000005cda7eC9514b4f5959": "Dead:IncorrectAddress3808",
"0x000000000060C4Ca14CfC4325359062ace33Fe3D": "LR:TransferManager1",
"0x0000000000A39bb272e79075ade125fd351887Ac": "Blur:WETH",
"0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC": "Seaport",
"0x18dDD8E16B0B0fB7679397c6e8F4Ec06Ea3F0a95": "SwapKiwi",
"0x1E0049783F008A0085193E00003D00cd54003c71": "OS:Conduit",
// "0x1E0049783F008A0085193E00003D00cd54003c71": "OS:Conduit",
"0x282BDD42f4eb70e7A9D9F40c8fEA0825B7f68C5D": "PunkV1Wrapper",
"0x29469395eAf6f95920E59F858042f0e28D98a20B": "Blur:Blend",
"0x2f18F339620a63e43f0839Eeb18D7de1e1Be4DfB": "Blur:Delegate",
Expand Down
85 changes: 72 additions & 13 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -916,32 +916,91 @@ <h4>Welcome</h4>
const owners = Object.keys(ownersMap);
const contracts = Object.keys(contractsMap);
const spenders = Object.keys(spendersMap);
console.log("owners.length: " + owners.length);
console.log("contracts.length: " + contracts.length);
console.log("spenders.length: " + spenders.length);
// console.log("owners: " + JSON.stringify(owners));
// console.log("contracts: " + JSON.stringify(contracts));
// console.log("spenders: " + JSON.stringify(spenders));

const accounts = {};
for (const account of owners) {
accounts[account] = { source: "owner" };
}
for (const account of contracts) {
if (!(account in accounts)) {
accounts[account] = { source: "contracts" };
}
}
for (const account of spenders) {
if (!(account in accounts)) {
accounts[account] = { source: "spenders" };
}
}
console.log("accounts: " + JSON.stringify(accounts));

const erc721Helper = new ethers.Contract(ERC721HELPERADDRESS, ERC721HELPERABI, provider);
const accountsToCheck = [...owners, ...contracts, ...spenders];
console.log("accountsToCheck: " + JSON.stringify(accountsToCheck));
for (const account of accountsToCheck) {
try {
const tokenInfos = await erc721Helper.tokenInfo([account], { gasLimit: 1000000 });
for (let i = 0; i < tokenInfos[0].length; i++) {
const mask = tokenInfos[0][i].toNumber();
const symbol = tokenInfos[1][i];
const name = tokenInfos[2][i];
console.log(" " + account + " " + symbol + " " + name + " " + mask);
if (account in CUSTOMNAMES) {
accounts[account].type = CUSTOMNAMES[account][0];
accounts[account].symbol = CUSTOMNAMES[account][1];
accounts[account].name = CUSTOMNAMES[account][2];
} else {
try {
const tokenInfos = await erc721Helper.tokenInfo([account], { gasLimit: 1000000 });
for (let i = 0; i < tokenInfos[0].length; i++) {
const mask = tokenInfos[0][i].toNumber();
const symbol = tokenInfos[1][i];
const name = tokenInfos[2][i];
if ((mask & MASK_ISEOA) == MASK_ISERC721) {
accounts[account].type = "eoa";
// accounts[account] = { type: "eoa", symbol: null, name: null };
} else if ((mask & MASK_ISERC20) == MASK_ISERC20) {
accounts[account].type = "erc20";
accounts[account].symbol = symbol;
accounts[account].name = name;
// accounts[account] = { type: "erc20", symbol, name };
} else if ((mask & MASK_ISERC721) == MASK_ISERC721) {
accounts[account].type = "erc721";
accounts[account].symbol = symbol;
accounts[account].name = name;
// accounts[account] = { type: "erc721", symbol, name };
} else {
const erc165Abi = [ "function supportsInterface(bytes4 interfaceID) external view returns (bool)" ];
const erc165Contract = new ethers.Contract(account, erc165Abi, provider);
try {
const result = await erc165Contract.supportsInterface(ERC1155_INTERFACE);
console.log(account + " " + result);
if (result) {
accounts[account].type = "erc1155";
// accounts[account].symbol = TODO
// accounts[account].name = TODO
// accounts[account] = { type: "erc1155", symbol, name };
} else {
accounts[account].type = "unknown2";
// accounts[account] = { type: "unknown2", symbol, name };
}
} catch (e1) {
accounts[account].type = "unknown1";
// accounts[account] = { type: "unknown1", symbol, name };
}
// console.log(" " + account + " " + symbol + " " + name + " " + mask);
}
}
} catch (e) {
console.log("syncNames erc721Helper - ERROR: " + account + ", message: " + e.message);
// results.mask = 0;
// results.symbol = null;
// results.name = null;
accounts[account].type = "unknown0";
}
} catch (e) {
console.log("syncNames erc721Helper - ERROR: " + account + ", message: " + e.message);
// results.mask = 0;
// results.symbol = null;
// results.name = null;
}
}



console.log("accounts: " + JSON.stringify(accounts, null, 2));
},

// TODO: Refresh sync
Expand Down
Binary file added images/SampleScreen_20231217.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0e363b

Please sign in to comment.