RohanNero / block3d

An open-source authentication toolkit designed to streamline access control within Nextjs dapps.
https://block3d.gitbook.io/block3d
GNU General Public License v3.0
1 stars 0 forks source link

Add support for ERC-1155 (ENS specifically) #7

Open RohanNero opened 3 weeks ago

RohanNero commented 3 weeks ago

Overview

We use a shared abi for balanceOf(address) when making ERC-20 and ERC-721 function calls. However, ERC-1155 uses a slightly different: balanceOf(address, unit), making our current code incompatible.

The solution won't be straightforward since we don't know what id to pass as the uint when calling balanceOf, so we will have to research a method for querying whether an address owns an ENS or not. (Might make this issue specifically geared towards ENS as the solution could be totally different. i.e. for standard 1155 tokens, we could make looped balanceOfBatch() calls.)

Solution

To support ERC-1155 we will need to add a new utility function and type field to our block3d.config file.

Example

const block3dConfig: Block3dConfig = {
  publicRoutes: ["/public-route"],
  strict: false,
  rules: [
    {
      type: "multi", 
      title: "ENS",
      contracts: [
        {
          address: "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401", 
          chainId: 1,
          minimumBal: "1",
        },
      ],
    },
  ],
};

export default block3dConfig;