badger icon indicating copy to clipboard operation
badger copied to clipboard

Account bound functionality

Open masonchain opened this issue 2 years ago • 1 comments

ISSUES

  • Hit an issue with the Hook objects in the database being overwritten. If token_id 0 had an account bound hook, and token_id 1 is then configured to be account bound as well, then the indexer overwrites that existing Hook object with the new config that contains the token ID.
    • The execute() function in BadgerTransferBound.sol shows how token IDs are packed in the same hook
/**
     * See {ERC1155._beforeTokenTransfer}
     * @dev Enables the ability to have modules such as Account Bound, etc.
     */
    function _beforeTokenTransfer(
        address _operator,
        address _from,
        address _to,
        uint256[] memory _ids,
        uint256[] memory _amounts,
        bytes memory _data
    ) internal virtual override {
        /// @dev Before transferring, process any Organization hooks.
        _hook(
            BEFORE_TRANSFER,
            abi.encode(_operator, _from, _to, _ids, _amounts, _data)
        );

        /// @dev Do not call the super as it is an empty function.
    }

So this fat list of args gets passed to _hook, and then _execute, as the data param.

BadgerTransferBound decodes is as:

    /**
     * See {IBadgerHook-execute}.
     */
    function execute(bytes calldata _data) public virtual override {
        /// @dev Decode the transfer data forwarded from the Organization.
        (
            address _operator,
            address _from,
            address _to,
            uint256[] memory _ids,
            ,

        ) = abi.decode(
                _data,
                (address, address, address, uint256[], uint256[], bytes)
            );

masonchain avatar Oct 04 '23 22:10 masonchain

Deploy Preview for badger-frontend ready!

Name Link
Latest commit 529ab1a8257c1c53f5fb5a5ce45b493f0658e4fb
Latest deploy log https://app.netlify.com/sites/badger-frontend/deploys/651deac6dd9c770008602a8a
Deploy Preview https://deploy-preview-254--badger-frontend.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Oct 04 '23 22:10 netlify[bot]