Solidity unrecognized selector

112 views Asked by At

I am trying to build a cloud storage dapp, I uploaded the files to Pinata, taken the ipfs hash and then this is my solidity code, add and display works, what I want is to allow multiple users have access but on calling the allow function I am getting

  Contract call:       Upload#<unrecognized-selector>
  From:                0xf39f...........6f4ce6ab8827279cfffb92266
  To:                  0x5f.............cb367f032d93f642f64180aa3

  Error: Transaction reverted: function selector was not recognized and there's no fallback function

My Upload.sol

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Upload {
    struct Access {
        address user;
        bool access; //true or false
    }
    mapping(address => string[]) value;
    mapping(address => mapping(address => bool)) ownership;
    mapping(address => Access[]) accessList;
    mapping(address => mapping(address => bool)) previousData;
    mapping(address => string) public messages;

    function add(address _user, string memory url) external payable {
        value[_user].push(url);
    }

    function allow(address user) external {
        ownership[msg.sender][user] = true;
        if (previousData[msg.sender][user]) {
            for (uint i = 0; i < accessList[msg.sender].length; i++) {
                if (accessList[msg.sender][i].user == user) {
                    accessList[msg.sender][i].access = true;
                }
            }
        } else {
            accessList[msg.sender].push(Access(user, true));
            previousData[msg.sender][user] = true;
        }
    }

    function disallow(address user) public {
        ownership[msg.sender][user] = false;
        for (uint i = 0; i < accessList[msg.sender].length; i++) {
            if (accessList[msg.sender][i].user == user) {
                accessList[msg.sender][i].access = false;
            }
        }
    }

    function display(address _user) external view returns (string[] memory) {
        require(
            _user == msg.sender || ownership[_user][msg.sender],
            "You don't have access"
        );
        return value[_user];
    }

    function shareAccess() public view returns (Access[] memory) {
        return accessList[msg.sender];
    }
}

I am calling the functions from a React App using ethers.

0

There are 0 answers