MATIC Price: $0.717224 (-0.49%)
Gas: 38 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040392877422023-02-14 16:03:10464 days ago1676390590IN
 Create: JoinRequestsFacet
0 MATIC0.578108951,143.57680695

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JoinRequestsFacet

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion
File 1 of 3 : JoinRequestsFacet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {AppStorage, Modifiers, Announcement} from "../libraries/LibAppStorage.sol";

/// "User has already requested to join"
error AlreadyRequested();
/// "User join request is already accepted"
error RequestAlreadyAccepted();
/// "User join request is not found"
error RequestNotFound();

/**
 * @title JoinRequestsFacet
 * @author PartyFinance
 * @notice Facet that lets read, create, update and delete join requests.
 */
contract JoinRequestsFacet is Modifiers {
    /**
     * @notice Emitted when a user requests to join a private party
     * @param member Address of the user requesting to join
     */
    event JoinRequest(address member);

    /**
     * @notice Emitted when a join requests gets accepted or rejected
     * @param member Address of the user that requested to join
     * @param accepted Whether the request was accepted or rejected
     */
    event HandleJoinRequest(address member, bool accepted);

    /**
     * @notice Gets the party pending join requests
     * @return Array of join requests that are pending
     */
    function getJoinRequests() external view returns (address[] memory) {
        return s.joinRequests;
    }

    /**
     * @notice Checks if the pending join request was accepted
     * @return Whether if a given user has an accepted join request
     */
    function isAcceptedRequest(address user) external view returns (bool) {
        return s.acceptedRequests[user];
    }

    /**
     * @notice Requests to join a party
     * @dev Only non Party Members are the only allowed to request to join
     */
    function createJoinRequest() external notMember isAlive {
        if (s.acceptedRequests[msg.sender]) revert RequestAlreadyAccepted();
        for (uint256 i = 0; i < s.joinRequests.length; ) {
            if (s.joinRequests[i] == msg.sender) {
                revert AlreadyRequested();
            }
            unchecked {
                i++;
            }
        }
        s.joinRequests.push(msg.sender);
        emit JoinRequest(msg.sender);
    }

    /**
     * @notice Handles a join request to party
     * @dev Only Party Managers are the only allowed to handle requests
     * @param accepted True if request should be accepted. Otherwise, it's discarted
     * @param user Accound address of the request
     */
    function handleJoinRequest(
        bool accepted,
        address user
    ) external onlyManager isAlive {
        if (s.acceptedRequests[user]) revert RequestAlreadyAccepted();
        // Search for the request
        bool found;
        for (uint256 i = 0; i < s.joinRequests.length; ) {
            if (s.joinRequests[i] == user) {
                found = true;
                if (accepted) {
                    s.acceptedRequests[user] = true;
                }
                if (i < s.joinRequests.length - 1) {
                    s.joinRequests[i] = s.joinRequests[
                        s.joinRequests.length - 1
                    ];
                }
                s.joinRequests.pop();
                emit HandleJoinRequest(user, accepted);
            }
            unchecked {
                i++;
            }
        }
        if (!found) revert RequestNotFound();
    }
}

File 2 of 3 : LibAppStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {LibMeta} from "./LibMeta.sol";

/**
 * @notice A struct containing the Party info tracked in storage.
 * @param name Name of the Party
 * @param bio Description of the Party
 * @param img Image URL of the Party (path to storage without protocol/domain)
 * @param model Model of the Party: "Democracy", "Monarchy", "WeightedDemocracy", "Republic"
 * @param purpose Purpose of the Party: "Trading", "YieldFarming", "LiquidityProviding", "NFT"
 * @param isPublic Visibility of the Party. (Private parties requires an accepted join request)
 * @param minDeposit Minimum deposit allowed in denomination asset
 * @param maxDeposit Maximum deposit allowed in denomination asset
 */
struct PartyInfo {
    string name;
    string bio;
    string img;
    string model;
    string purpose;
    bool isPublic;
    uint256 minDeposit;
    uint256 maxDeposit;
}

/**
 * @notice A struct containing the Announcement info tracked in storage.
 * @param title Title of the Announcement
 * @param bio Content of the Announcement
 * @param img Any external URL to include in the Announcement
 * @param model Model of the Party: "Democracy", "Monarchy", "WeightedDemocracy", "Republic"
 * @param created Block timestamp date of the Announcement creation
 * @param updated Block timestamp date of any Announcement edition
 */
struct Announcement {
    string title;
    string content;
    string url;
    string img;
    uint256 created;
    uint256 updated;
}

/**
 * @notice A struct containing the TokenGate info tracked in storage.
 * @param token Address of the asset
 * @param amount Required amount to hold
 */
struct TokenGate {
    address token;
    uint256 amount;
}

struct AppStorage {
    //
    // Party vault token
    //
    string name;
    string symbol;
    uint256 totalSupply;
    mapping(address => uint256) balances;
    mapping(address => mapping(address => uint256)) allowances;
    //
    // Denomination token asset for deposit/withdraws
    //
    address denominationAsset;
    //
    // Party info
    //
    PartyInfo partyInfo;
    bool closed; // Party life status
    //
    // Party access
    //
    mapping(address => bool) managers; // Maping to get if address is a manager
    mapping(address => bool) members; // Maping to get if address is a member
    //
    // Party ERC-20 holdings
    //
    address[] tokens; // Array of current party tokens holdings
    //
    // Party Announcements
    //
    Announcement[] announcements;
    //
    // Party Join Requests
    //
    address[] joinRequests; // Array of users that requested to join the party
    mapping(address => bool) acceptedRequests; // Mapping of requests accepted by a manager
    //
    // PLATFORM
    //
    uint256 platformFee; // Platform fee (in bps, 50 bps -> 0.5%)
    address platformFeeCollector; // Platform fee collector
    address platformSentinel; // Platform sentinel
    address platformFactory; // Platform factory
    //
    // Extended Party access
    //
    address creator; // Creator of the Party
    //
    // Token gating
    //
    TokenGate[] tokenGates;
}

library LibAppStorage {
    function diamondStorage() internal pure returns (AppStorage storage ds) {
        assembly {
            ds.slot := 0
        }
    }
}

contract Modifiers {
    AppStorage internal s;

    modifier onlyCreator() {
        require(s.creator == LibMeta.msgSender(), "Only Party Creator allowed");
        _;
    }

    modifier onlyManager() {
        require(s.managers[LibMeta.msgSender()], "Only Party Managers allowed");
        _;
    }

    modifier onlyMember() {
        require(s.members[LibMeta.msgSender()], "Only Party Members allowed");
        _;
    }

    modifier notMember() {
        require(
            !s.members[LibMeta.msgSender()],
            "Only non Party Members allowed"
        );
        _;
    }

    modifier onlyFactory() {
        require(
            LibMeta.msgSender() == s.platformFactory,
            "Only Factory allowed"
        );
        _;
    }

    modifier isAlive() {
        require(!s.closed, "Party is closed");
        _;
    }
}

File 2 of 3 : LibMeta.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library LibMeta {
    function getChainID() internal view returns (uint256 id) {
        assembly {
            id := chainid()
        }
    }

    function msgSender() internal view returns (address sender_) {
        if (msg.sender == address(this)) {
            bytes memory array = msg.data;
            uint256 index = msg.data.length;
            assembly {
                // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
                sender_ := and(
                    mload(add(array, index)),
                    0xffffffffffffffffffffffffffffffffffffffff
                )
            }
        } else {
            sender_ = msg.sender;
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 2000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"AlreadyRequested","type":"error"},{"inputs":[],"name":"RequestAlreadyAccepted","type":"error"},{"inputs":[],"name":"RequestNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"bool","name":"accepted","type":"bool"}],"name":"HandleJoinRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"member","type":"address"}],"name":"JoinRequest","type":"event"},{"inputs":[],"name":"createJoinRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getJoinRequests","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"accepted","type":"bool"},{"internalType":"address","name":"user","type":"address"}],"name":"handleJoinRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isAcceptedRequest","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610839806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806311bd8a76146100515780635a150cb71461006f5780636839c88614610079578063ae830b1d1461008c575b600080fd5b6100596100c8565b60405161006691906106eb565b60405180910390f35b61007761012d565b005b610077610087366004610754565b610350565b6100b861009a36600461078e565b6001600160a01b031660009081526014602052604090205460ff1690565b6040519015158152602001610066565b6060600060130180548060200260200160405190810160405280929190818152602001828054801561012357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610105575b5050505050905090565b6010600061013961068f565b6001600160a01b0316815260208101919091526040016000205460ff16156101a85760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206e6f6e205061727479204d656d6265727320616c6c6f776564000060448201526064015b60405180910390fd5b600e5460ff16156101fb5760405162461bcd60e51b815260206004820152600f60248201527f506172747920697320636c6f7365640000000000000000000000000000000000604482015260640161019f565b3360009081526014602052604090205460ff1615610245576040517f9f80515700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b6013548110156102bd576013805433919083908110610269576102696107b0565b6000918252602090912001546001600160a01b0316036102b5576040517f5303ed8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600101610248565b50601380546001810182556000919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900180547fffffffffffffffffffffffff000000000000000000000000000000000000000016339081179091556040519081527f88780427a45a71c800327bb3d61949a1761c6dc3961b6f7194fc5c4456da14de9060200160405180910390a1565b600f600061035c61068f565b6001600160a01b0316815260208101919091526040016000205460ff166103c55760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f7765640000000000604482015260640161019f565b600e5460ff16156104185760405162461bcd60e51b815260206004820152600f60248201527f506172747920697320636c6f7365640000000000000000000000000000000000604482015260640161019f565b6001600160a01b03811660009081526014602052604090205460ff161561046b576040517f9f80515700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b60135481101561065257826001600160a01b031660006013018281548110610499576104996107b0565b6000918252602090912001546001600160a01b03160361064a576001915083156104ff576001600160a01b038316600090815260146020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790555b60135461050e906001906107c6565b8110156105905760138054610525906001906107c6565b81548110610535576105356107b0565b600091825260209091200154601380546001600160a01b039092169183908110610561576105616107b0565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60138054806105a1576105a16107ed565b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690550190556040517f73f86856c3635f33c15b8186946fcd30e65484e50deea216e0d3dde24281c9519061064190859087906001600160a01b039290921682521515602082015260400190565b60405180910390a15b60010161046f565b508061068a576040517f4b13b31e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b60003033036106e557600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b031691506106e89050565b50335b90565b6020808252825182820181905260009190848201906040850190845b8181101561072c5783516001600160a01b031683529284019291840191600101610707565b50909695505050505050565b80356001600160a01b038116811461074f57600080fd5b919050565b6000806040838503121561076757600080fd5b8235801515811461077757600080fd5b915061078560208401610738565b90509250929050565b6000602082840312156107a057600080fd5b6107a982610738565b9392505050565b634e487b7160e01b600052603260045260246000fd5b818103818111156107e757634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603160045260246000fdfea26469706673582212203eacdc6cd03c19a9ab2e4ef767e45c0c41baad95f784d0a46c319e5e31815b3064736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806311bd8a76146100515780635a150cb71461006f5780636839c88614610079578063ae830b1d1461008c575b600080fd5b6100596100c8565b60405161006691906106eb565b60405180910390f35b61007761012d565b005b610077610087366004610754565b610350565b6100b861009a36600461078e565b6001600160a01b031660009081526014602052604090205460ff1690565b6040519015158152602001610066565b6060600060130180548060200260200160405190810160405280929190818152602001828054801561012357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610105575b5050505050905090565b6010600061013961068f565b6001600160a01b0316815260208101919091526040016000205460ff16156101a85760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206e6f6e205061727479204d656d6265727320616c6c6f776564000060448201526064015b60405180910390fd5b600e5460ff16156101fb5760405162461bcd60e51b815260206004820152600f60248201527f506172747920697320636c6f7365640000000000000000000000000000000000604482015260640161019f565b3360009081526014602052604090205460ff1615610245576040517f9f80515700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b6013548110156102bd576013805433919083908110610269576102696107b0565b6000918252602090912001546001600160a01b0316036102b5576040517f5303ed8200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600101610248565b50601380546001810182556000919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900180547fffffffffffffffffffffffff000000000000000000000000000000000000000016339081179091556040519081527f88780427a45a71c800327bb3d61949a1761c6dc3961b6f7194fc5c4456da14de9060200160405180910390a1565b600f600061035c61068f565b6001600160a01b0316815260208101919091526040016000205460ff166103c55760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f7765640000000000604482015260640161019f565b600e5460ff16156104185760405162461bcd60e51b815260206004820152600f60248201527f506172747920697320636c6f7365640000000000000000000000000000000000604482015260640161019f565b6001600160a01b03811660009081526014602052604090205460ff161561046b576040517f9f80515700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b60135481101561065257826001600160a01b031660006013018281548110610499576104996107b0565b6000918252602090912001546001600160a01b03160361064a576001915083156104ff576001600160a01b038316600090815260146020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790555b60135461050e906001906107c6565b8110156105905760138054610525906001906107c6565b81548110610535576105356107b0565b600091825260209091200154601380546001600160a01b039092169183908110610561576105616107b0565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60138054806105a1576105a16107ed565b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690550190556040517f73f86856c3635f33c15b8186946fcd30e65484e50deea216e0d3dde24281c9519061064190859087906001600160a01b039290921682521515602082015260400190565b60405180910390a15b60010161046f565b508061068a576040517f4b13b31e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b60003033036106e557600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b031691506106e89050565b50335b90565b6020808252825182820181905260009190848201906040850190845b8181101561072c5783516001600160a01b031683529284019291840191600101610707565b50909695505050505050565b80356001600160a01b038116811461074f57600080fd5b919050565b6000806040838503121561076757600080fd5b8235801515811461077757600080fd5b915061078560208401610738565b90509250929050565b6000602082840312156107a057600080fd5b6107a982610738565b9392505050565b634e487b7160e01b600052603260045260246000fd5b818103818111156107e757634e487b7160e01b600052601160045260246000fd5b92915050565b634e487b7160e01b600052603160045260246000fdfea26469706673582212203eacdc6cd03c19a9ab2e4ef767e45c0c41baad95f784d0a46c319e5e31815b3064736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.