ETH Price: $3,403.06 (+4.66%)

Contract

0xfc9E7c1a7AF6a585755b079b1BeA7667DcBdB9E0
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Create NFT Vault209339512024-10-10 8:15:35101 days ago1728548135IN
0xfc9E7c1a...7DcBdB9E0
0 ETH0.0087084711.07565264

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
209339512024-10-10 8:15:35101 days ago1728548135
0xfc9E7c1a...7DcBdB9E0
 Contract Creation0 ETH
209335972024-10-10 7:04:47101 days ago1728543887  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CommunityVaultsRegistry

Compiler Version
v0.8.25+commit.b61c2a91

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 27 : CommunityVaultsRegistry.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "@openzeppelin/contracts/utils/Create2.sol";

import "../Traits/interfaces/IRandomNumberProvider.sol";
import "./interfaces/ICommunityVaultsRegistry.sol";
import "./interfaces/ICoinsVault.sol";
import "./interfaces/INFTVault.sol";

import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
import "../@galaxis/registries/contracts/CommunityList.sol";
import "../@galaxis/registries/contracts/CommunityRegistry.sol";

contract CommunityVaultsRegistry is ICommunityVaultsRegistry, UsesGalaxisRegistry {
    string public constant NFT_VAULT_IMPL_KEY = "GOLDEN_NFT_VAULT";
    string public constant COINS_VAULT_IMPL_KEY = "GOLDEN_COINS_VAULT";

    bytes32 public constant VAULTS_REGISTRY_ADMIN =
        keccak256("VAULTS_REGISTRY_ADMIN");

    bytes32 public constant RANDOM_CONSUMER = keccak256("RANDOM_CONSUMER");

    CommunityRegistry public communityRegistry;

    uint32 public communityId;
    uint256 public totalVaultsCount;

    mapping(uint8 => uint256) public vaultTypeNonces;

    // vault id => vault info
    mapping(uint256 => BaseVaultInfo) internal _vaultsInfo;

    modifier onlyVaultsRegistryAdmin() {
        _onlyVaultsRegistryAdmin();
        _;
    }

    constructor(address galaxisRegistry_, uint32 communityId_) UsesGalaxisRegistry(galaxisRegistry_) {
        CommunityList communityList_ = CommunityList(galaxisRegistry.getRegistryAddress("COMMUNITY_LIST"));
        (, address crAddr_, ) = communityList_.communities(communityId_);

        if (crAddr_ == address(0)) {
            revert CommunityVaultsRegistryInvalidCommunityId(communityId_);
        }

        communityRegistry = CommunityRegistry(crAddr_);
        communityId = communityId_;
    }

    function version() public pure virtual override returns (uint256) {
        return 2024040401;
    }

    function createNFTVault(
        string calldata vaultName_,
        IGenericVault.GenericVaultInitParams calldata initParams_
    ) external override onlyVaultsRegistryAdmin returns (address) {
        INFTVault newNFTVault_ = INFTVault(
            _deployVault(
                galaxisRegistry.getRegistryAddress(NFT_VAULT_IMPL_KEY),
                VaultTypes.NFTVault,
                vaultName_
            )
        );

        newNFTVault_.__NFTVault_init(
            communityRegistry,
            initParams_
        );

        return address(newNFTVault_);
    }

    function createCoinsVault(
        string calldata vaultName_,
        IGenericVault.GenericVaultInitParams calldata initParams_
    ) external override onlyVaultsRegistryAdmin returns (address) {
        ICoinsVault newCoinsVault_ = ICoinsVault(
            _deployVault(
                galaxisRegistry.getRegistryAddress(COINS_VAULT_IMPL_KEY),
                VaultTypes.CoinsVault,
                vaultName_
            )
        );

        newCoinsVault_.__CoinsVault_init(
            communityRegistry,
            initParams_
        );

        return address(newCoinsVault_);
    }

    function getVaultAddress(
        VaultTypes vaultType_,
        uint256 vaultTypeNonce_
    ) external view override returns (address) {
        address communityVaultsImpl_ = vaultType_ == VaultTypes.NFTVault
            ? galaxisRegistry.getRegistryAddress(NFT_VAULT_IMPL_KEY)
            : galaxisRegistry.getRegistryAddress(COINS_VAULT_IMPL_KEY);

        return getVaultAddress(communityVaultsImpl_, vaultType_, vaultTypeNonce_);
    }

    function getVaultAddress(
        address implementation_,
        VaultTypes vaultType_,
        uint256 vaultTypeNonce_
    ) public view override returns (address) {
        bytes32 bytecodeHash_ = keccak256(
            _creationCode(implementation_, vaultType_, vaultTypeNonce_)
        );

        return Create2.computeAddress(bytes32(0), bytecodeHash_);
    }

    function getVaultAddressById(
        uint256 vaultId_
    ) external view override returns (address) {
        return _vaultsInfo[vaultId_].vaultAddr;
    }

    function getVaultsInfo(
        uint256[] calldata vaultIds_
    ) external view override returns (VaultInfo[] memory resultArr_) {
        resultArr_ = new VaultInfo[](vaultIds_.length);

        for (uint256 i = 0; i < vaultIds_.length; i++) {
            resultArr_[i] = VaultInfo(
                _vaultsInfo[vaultIds_[i]],
                IGenericVault(_vaultsInfo[vaultIds_[i]].vaultAddr).getBuySettingsInfo(_getExistingBuyTypes())
            );
        }
    }

    function hasVaultsRegistryAdminRole(
        address userAddr_
    ) public view override returns (bool) {
        return _hasRole(VAULTS_REGISTRY_ADMIN, userAddr_);
    }

    function _deployVault(
        address implementation_,
        VaultTypes vaultType_,
        string calldata vaultName_
    ) internal returns (address) {
        if (implementation_ == address(0)) {
            revert CommunityVaultsRegistryZeroVaultsGolden();
        }

        if (bytes(vaultName_).length == 0) {
            revert CommunityVaultsRegistryInvalidVaultName();
        }

        uint256 currentVaultTypeNonce_ = vaultTypeNonces[uint8(vaultType_)]++;

        bytes memory creationCode_ = _creationCode(
            implementation_,
            vaultType_,
            currentVaultTypeNonce_
        );

        address vaultAddr_ = Create2.deploy(0, 0, creationCode_);

        if (vaultAddr_ == address(0)) {
            revert CommunityVaultsRegistryVaultCreationFailed();
        }

        uint256 vaultId_ = totalVaultsCount++;

        _vaultsInfo[vaultId_] = BaseVaultInfo(
            vaultAddr_,
            vaultType_,
            currentVaultTypeNonce_,
            vaultName_
        );

        communityRegistry.grantRole(RANDOM_CONSUMER, vaultAddr_);

        emit VaultCreated(
            vaultId_,
            vaultAddr_,
            vaultType_,
            currentVaultTypeNonce_
        );

        return vaultAddr_;
    }

    function _hasRole(
        bytes32 roleKey_,
        address userAddr_
    ) internal view returns (bool) {
        return communityRegistry.hasRole(roleKey_, userAddr_);
    }

    function _onlyVaultsRegistryAdmin() internal view {
        if (!hasVaultsRegistryAdminRole(msg.sender)) {
            revert CommunityVaultsRegistryUnauthorized();
        }
    }

    function _creationCode(
        address implementation_,
        VaultTypes vaultType_,
        uint256 vaultTypeNonce_
    ) internal view returns (bytes memory) {
        return
            abi.encodePacked(
                hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73",
                implementation_,
                hex"5af43d82803e903d91602b57fd5bf3",
                abi.encode(communityId, vaultType_, vaultTypeNonce_)
            );
    }

    function _getExistingBuyTypes()
        internal
        pure
        returns (IGenericVault.BuyTypes[] memory existingBuyTypesArr_)
    {
        existingBuyTypesArr_ = new IGenericVault.BuyTypes[](3);
        existingBuyTypesArr_[0] = IGenericVault.BuyTypes.NATIVE;
        existingBuyTypesArr_[1] = IGenericVault.BuyTypes.VAULT_ERC20_PAYMENT_TOKEN;
        existingBuyTypesArr_[2] = IGenericVault.BuyTypes.ERC1155;
    }

    function updateVaultName(
        uint256 vaultId_,
        string calldata newVaultName_
    ) external override onlyVaultsRegistryAdmin {
        _vaultsInfo[vaultId_].vaultName = newVaultName_;
        emit VaultNameUpdated(vaultId_);
    }
}

File 2 of 27 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 27 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
}

File 4 of 27 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 5 of 27 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 6 of 27 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 7 of 27 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 8 of 27 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 9 of 27 : Create2.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Create2.sol)

pragma solidity ^0.8.0;

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(
        uint256 amount,
        bytes32 salt,
        bytes memory bytecode
    ) internal returns (address) {
        address addr;
        require(address(this).balance >= amount, "Create2: insufficient balance");
        require(bytecode.length != 0, "Create2: bytecode length is zero");
        /// @solidity memory-safe-assembly
        assembly {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "Create2: Failed on deploy");
        return addr;
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(
        bytes32 salt,
        bytes32 bytecodeHash,
        address deployer
    ) internal pure returns (address) {
        bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
        return address(uint160(uint256(_data)));
    }
}

File 10 of 27 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 11 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 12 of 27 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 13 of 27 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 14 of 27 : CommunityList.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "./Versionable/IVersionable.sol";

contract CommunityList is AccessControlEnumerable, IVersionable { 

    function version() external pure returns (uint256) {
        return 2024040301;
    }

    bytes32 public constant CONTRACT_ADMIN = keccak256("CONTRACT_ADMIN");


    uint256                              public numberOfEntries;

    struct community_entry {
        string      name;
        address     registry;
        uint32      id;
    }
    
    mapping(uint32 => community_entry)  public communities;   // community_id => record
    mapping(uint256 => uint32)           public index;         // entryNumber => community_id for enumeration

    event CommunityAdded(uint256 pos, string community_name, address community_registry, uint32 community_id);

    constructor() {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(CONTRACT_ADMIN,msg.sender);
    }

    function addCommunity(uint32 community_id, string memory community_name, address community_registry) external onlyRole(CONTRACT_ADMIN) {
        uint256 pos = numberOfEntries++;
        index[pos]  = community_id;
        communities[community_id] = community_entry(community_name, community_registry, community_id);
        emit CommunityAdded(pos, community_name, community_registry, community_id);
    }

}

File 15 of 27 : CommunityRegistry.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./Versionable/IVersionable.sol";
import "./UsesGalaxisRegistry.sol";

contract CommunityRegistry is AccessControlEnumerable, UsesGalaxisRegistry, IVersionable  {

    function version() virtual external pure returns(uint256) {
        return 2024040401;
    }

    bytes32 public constant COMMUNITY_REGISTRY_ADMIN = keccak256("COMMUNITY_REGISTRY_ADMIN");

    uint32                      public  community_id;
    string                      public  community_name;
    

    mapping(bytes32 => address)         addresses;
    mapping(bytes32 => uint256)         uints;
    mapping(bytes32 => bool)            booleans;
    mapping(bytes32 => string)          strings;

    mapping (uint => string)    public  addressEntries;
    mapping (uint => string)    public  uintEntries;
    mapping (uint => string)    public  boolEntries;
    mapping (uint => string)    public  stringEntries;
    uint                        public  numberOfAddresses;
    uint                        public  numberOfUINTs;
    uint                        public  numberOfBooleans;
    uint                        public  numberOfStrings;

    bool                                initialised;

    bool                        public  independant;

    event IndependanceDay(bool gain_independance);

    modifier onlyAdmin() {
        require(
            isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender)
            ,"CommunityRegistry : Unauthorised");
        _;
    }

    modifier onlyPropertyAdmin() {
        require(
            isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender) ||
            hasRole(COMMUNITY_REGISTRY_ADMIN,msg.sender)
            ,"CommunityRegistry : Unauthorised");
        _;
    }



    function isUserCommunityAdmin(bytes32 role, address user) public view returns (bool) {
        if (hasRole(DEFAULT_ADMIN_ROLE,user) ) return true; // community_admin can do anything
        if (independant){        
            return(
                hasRole(role,user)
            );
        } else { // for Factories
           return(roleManager().hasRole(role,user));
        }
    }

    function roleManager() internal view returns (IAccessControlEnumerable) {
        address addr = galaxisRegistry.getRegistryAddress("ROLE_MANAGER"); // universal
        if (addr != address(0)) return IAccessControlEnumerable(addr);
        addr = galaxisRegistry.getRegistryAddress("MAINNET_CHAIN_IMPLEMENTER"); // mainnet
        if (addr != address(0)) return IAccessControlEnumerable(addr);
        addr = galaxisRegistry.getRegistryAddress("L2_RECEIVER"); // mainnet
        require(addr != address(0),"CommunityRegistry : no higher authority found");
        return IAccessControlEnumerable(addr);
    }

    function grantRole(bytes32 key, address user) public override(AccessControl,IAccessControl) onlyAdmin {
        _grantRole(key,user); // need to be able to grant it
    }


 
    constructor (
        address _galaxisRegistry,
        uint32  _community_id, 
        address _community_admin, 
        string memory _community_name
    ) UsesGalaxisRegistry(_galaxisRegistry){
        _init(_community_id,_community_admin,_community_name);
    }

    
    function init(
        uint32  _community_id, 
        address _community_admin, 
        string memory _community_name
    ) external {
        _init(_community_id,_community_admin,_community_name);
    }

    function _init(
        uint32  _community_id, 
        address _community_admin, 
        string memory _community_name
    ) internal {
        require(!initialised,"This can only be called once");
        initialised = true;
        community_id = _community_id;
        community_name  = _community_name;
        _setupRole(DEFAULT_ADMIN_ROLE, _community_admin); // default admin = launchpad
    }



    event AdminUpdated(address user, bool isAdmin);
    event AppAdminChanged(address app,address user,bool state);
    //===
    event AddressChanged(string key, address value);
    event UintChanged(string key, uint256 value);
    event BooleanChanged(string key, bool value);
    event StringChanged(string key, string value);

    function setIndependant(bool gain_independance) external onlyAdmin {
        if (independant != gain_independance) {
                independant = gain_independance;
                emit IndependanceDay(gain_independance);
        }
    }


    function setAdmin(address user,bool status ) external onlyAdmin {
        if (status)
            _grantRole(COMMUNITY_REGISTRY_ADMIN,user);
        else
            _revokeRole(COMMUNITY_REGISTRY_ADMIN,user);
    }

    function hash(string memory field) internal pure returns (bytes32) {
        return keccak256(abi.encode(field));
    }

    function setRegistryAddress(string memory fn, address value) external onlyPropertyAdmin {
        bytes32 hf = hash(fn);
        addresses[hf] = value;
        addressEntries[numberOfAddresses++] = fn;
        emit AddressChanged(fn,value);
    }

    function setRegistryBool(string memory fn, bool value) external onlyPropertyAdmin {
        bytes32 hf = hash(fn);
        booleans[hf] = value;
        boolEntries[numberOfBooleans++] = fn;
        emit BooleanChanged(fn,value);
    }

    function setRegistryString(string memory fn, string memory value) external onlyPropertyAdmin {
        bytes32 hf = hash(fn);
        strings[hf] = value;
        stringEntries[numberOfStrings++] = fn;
        emit StringChanged(fn,value);
    }

    function setRegistryUINT(string memory fn, uint value) external onlyPropertyAdmin {
        bytes32 hf = hash(fn);
        uints[hf] = value;
        uintEntries[numberOfUINTs++] = fn;
        emit UintChanged(fn,value);
    }

    function getRegistryAddress(string memory key) external view returns (address) {
        return addresses[hash(key)];
    }

    function getRegistryBool(string memory key) external view returns (bool) {
        return booleans[hash(key)];
    }

    function getRegistryUINT(string memory key) external view returns (uint256) {
        return uints[hash(key)];
    }

    function getRegistryString(string memory key) external view returns (string memory) {
        return strings[hash(key)];
    }

}

File 16 of 27 : IRegistry.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

interface IRegistry {
    function setRegistryAddress(string memory fn, address value) external ;
    function setRegistryBool(string memory fn, bool value) external ;
    function setRegistryUINT(string memory key) external returns (uint256) ;
    function setRegistryString(string memory fn, string memory value) external ;
    function setAdmin(address user,bool status ) external;
    function setAppAdmin(address app, address user, bool state) external;

    function getRegistryAddress(string memory key) external view returns (address) ;
    function getRegistryBool(string memory key) external view returns (bool);
    function getRegistryUINT(string memory key) external view returns (uint256) ;
    function getRegistryString(string memory key) external view returns (string memory) ;
    function isAdmin(address user) external view returns (bool) ;
    function isAppAdmin(address app, address user) external view returns (bool);

    function numberOfAddresses() external view returns(uint256);
    function addressEntries(uint256) external view returns(string memory);
}

File 17 of 27 : UsesGalaxisRegistry.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import "./IRegistry.sol";

contract UsesGalaxisRegistry {

    IRegistry   immutable   public   galaxisRegistry;

    constructor(address _galaxisRegistry) {
        galaxisRegistry = IRegistry(_galaxisRegistry);
    }

}

File 18 of 27 : IGenericVersionable.sol
//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;

import "./IVersionable.sol";

/**
 * @title IGenericVersionable
 * @dev Interface for generic versionable contracts extending IVersionable.
 */
interface IGenericVersionable is IVersionable {
    /**
     * @notice Get the base version of the contract.
     * @return The base version.
     */
    function baseVersion() external pure returns (uint256);
}

File 19 of 27 : IVersionable.sol
//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;

/**
 * @title IVersionable
 * @dev Interface for versionable contracts.
 */
interface IVersionable {
    /**
     * @notice Get the current version of the contract.
     * @return The current version.
     */
    function version() external pure returns (uint256);
}

File 20 of 27 : IPaymentMatrix.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

interface IPaymentMatrix {
    function getDevIDAndAmountForTraitType(uint16 _traitType) external view returns(uint256 devId, uint256 amount);
    function getArtistIDAndAmountForCollection(uint32 _communityId, uint32 _collectionId) external view returns(uint256 artistId, uint256 amount);
}

File 21 of 27 : DigitalRedeem.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "../Generic/GenericTrait.sol";

contract DigitalRedeem is GenericTrait {

    uint256 public vaultID;
    uint256 public redeemMode;

    function version() public pure override returns (uint256) {
        return 2023082701;
    }

    function TRAIT_TYPE() public pure override returns (uint16) {
        return 6;
    }

    function APP() public pure override returns (bytes32) {
        return "digitalredeem";
    }

    constructor(address _galaxisRegistry) GenericTrait(_galaxisRegistry) {
        
    }


    function init() virtual override public {
        _initStandardProps();

        addStoredProperty(bytes32("vault_id"),                  FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("tokens_amount"),             FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("pseudo_random_interval"),    FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("coin_token_address"),        FieldTypes.STORED_ADDRESS);
        addStoredProperty(bytes32("luck"),                      FieldTypes.STORED_UINT_8);
        addStoredProperty(bytes32("redeem_mode"),               FieldTypes.STORED_UINT_8);

        afterInit();

        vaultID = uint256(bytes32(getProperty("vault_id", 0)));
        redeemMode = uint256(bytes32(getProperty("redeem_mode", 0)));
    }
    
}

File 22 of 27 : GenericTrait.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "../../../@galaxis/registries/contracts/CommunityRegistry.sol";
import "../../../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";

import "../../../PaymentMatrix/IPaymentMatrix.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IGTRegistry {
    function addressCanModifyTrait(address, uint16) external view returns (bool);
    function getTraitControllerAccessData(address) external view returns (uint8[] memory);
    function myCommunityRegistry() external view returns (CommunityRegistry);
    function tokenNumber() external view returns (uint32);
    function TOKEN_KEY() external view returns (string memory);
}

enum FieldTypes {
    NONE,
    STORED_BOOL,
    STORED_UINT_8,
    STORED_UINT_16,
    STORED_UINT_32,
    STORED_UINT_64,
    STORED_UINT_128,
    STORED_UINT_256,       
    STORED_BYTES_32,       // bytes32 fixed
    STORED_STRING,         // bytes array
    STORED_BYTES,          // bytes array
    STORED_ADDRESS,
    LOGIC_BOOL,
    LOGIC_UINT_8,
    LOGIC_UINT_32,
    LOGIC_UINT_64,
    LOGIC_UINT_128,
    LOGIC_UINT_256,
    LOGIC_BYTES_32,
    LOGIC_ADDRESS
}

struct traitProperty {
    bytes32     _name;
    FieldTypes  _type;
    bytes4      _selector;
    bytes       _default;
    bool        _limited;
    uint256     _min;
    uint256     _max;
    bool        _reset_on_owner_change;
}

struct traitInfo {
    uint16 _id;
    uint16 _type;
    address _registry;
    uint256 _baseVersion;
    uint256 _version;
    traitProperty[] _schema;
    uint8   _propertyCount;
    bytes32 _app;
    traitConfig _traitConfig; 
}

struct traitConfig {
    bool inverted;
}

enum BitType {
    NONE,
    EXISTS,
    INITIALIZED
}

enum TraitStatus {
    NONE,
    // NOT_INITIALIZED,
    ACTIVE,
    DORMANT,
    SPENT
}

enum MovementPermission {
    NONE,
    OPEN,
    LOCKED,
    SOULBOUND,
    SOULBURN
}

enum ModifierMode {
    NONE,
    ADD,
    SET
}


contract GenericTrait is UsesGalaxisRegistry  {

    uint16      public     traitId;
    IGTRegistry public     GTRegistry;
    event tokenTraitChangeEvent(uint32 indexed _tokenId);

    function baseVersion() public pure returns (uint256) {
        return 2024052201;
    }

    function version() public pure virtual returns (uint256) {
        return baseVersion();
    }
    
    function TRAIT_TYPE() public pure virtual returns (uint16) {
        return 0;   // Physical redemption
    }

    function APP() public pure virtual returns (bytes32) {
        return "generic-trait";   // Physical redemption
    }

    constructor(address _galaxisRegistry) UsesGalaxisRegistry(_galaxisRegistry) {
        
    }


    function tellEverything() external view returns(traitInfo memory) {
        return traitInfo(
            traitId,
            TRAIT_TYPE(),
            address(GTRegistry),
            baseVersion(),
            version(),
            getSchema(),
            propertyCount,
            APP(),
            thisTraitConfig
        );
    }

    // constructor(
    //     address _registry,
    //     uint16 _traitId,
    //     bytes[] memory _defaultPropValues
    // ) {
    //     traitId = _traitId;
    //     GTRegistry = IGTRegistry(_registry);
    //     for(uint8 i = 0; i < _defaultPropValues.length; i++) {
    //         defaultPropValues[i] = _defaultPropValues[i];
    //     }
    // }

    // cannot store as bytes unless we only allow simple types, no string / array 

    /*
        Set Properties
        Name	            type	defaults	description
        Expiration  date	date	-	        Trait can't be used after expiration date passes
        Counter	            int	    -	        Trait can only be used this many times
        Cooldown	        int	    -	        current date + cooldonw = Activation Date
        Activation Date	    date	-	        If set, trait can't be used before this date
        Modifier Lock	    bool	FALSE	    if True, Value Modifier Traits can't modify limiters
        Burn If Spent	    bool	FALSE	    If trait's status ever becomes "spent", it gets burned.
        Movement Permission	status	OPEN	    See "movement permission"
        Royalty ID	        ID	    -	        ID of the entity who is entitled to the Usage Royalty
        Royalty Amount	    int	    0	        Royalty amount in GLX


        Discount Trait Properties
        Name	        type	defaults	    Description
        Discount Type	status	PERCENTAGE	    It can be either PERCENTAGE or a fix GLX AMOUNT
        Discount Amount	int	    -	            Either 0-100 or a GLX amount
        Acceptor Type	status	MARKETPLACE	    Acceptor Type, can't be blank. Check Discounts for list.
        Max	            int	    -	            max value possible (value modifier can't go beyond)
        Modifier Lock	bool	FALSE	        If true, Value Modifier Traits have no effect


        Digital Redeemable Trait Properties
        Name	        Type	defaults	description
        Vault	        ID	    -	        The target vault of the redeemable. Can not be empty.
        Luck	        0-100	0	        If greater than zero, the Luck Process is invoked.
        Redeem Mode	    ID	    RR	        See "Redeem Modes" in the Vault page.
        Modifier Lock	bool	FALSE	    If True, Value Modifiers can't apply to this trait.


        Physical Redeemable Trait Properties
        name	    type	description
        item name	ID	    name of the item that can be redeemed


        Value Modifier Trait Properties
        name	    type	defaults	description
        Trait Type	ID	    -	        What type of trait to modify (Digital Redeemable, etc)
        Property	ID	    -	        What property of that trait to modify
        Mode	    ID	    ADD	        ADD or SET
        Value	    int	    -	        By how much

    */

    bool public initialized = false;
    traitConfig thisTraitConfig;

    mapping(uint8 => traitProperty) property;
    uint8 propertyCount = 0;
    mapping(bytes32 => uint8) propertyNameToId;
    mapping(uint8 => uint8) propertyStorageMap;

    //      propId  => tokenId => ( index => value )
    mapping(uint8 => mapping( uint32 => bytes ) ) storageMapArray;
    //      tokenId => data ( except bytes / string which go into storageMapArray )
    mapping(uint32 => bytes ) storageData;

    //      propId  => tokenId => ( index => value )
    mapping(uint8 => bytes ) storageMapArrayDEFAULT;
    //      tokenId => data ( except bytes / string which go into storageMapArrayDEFAULT )

    bytes tokenDataDEFAULT;
    mapping(uint8 => bytes ) defaultPropValues;

    // we need an efficient way to activate traits at mint or by using dropper
    // to achieve this we set 1 bit per tokenId
    // 

    mapping(uint32 => uint8 )    public existsData;
    mapping(uint32 => uint8 )    initializedData;

    // indexed props
    bool    public modifier_lock;
    uint8   public movement_permission;

    bytes32 constant constant_royalty_id_key = hex"726f79616c74795f696400000000000000000000000000000000000000000000";
    bytes32 constant constant_royalty_amount_key = hex"726f79616c74795f616d6f756e74000000000000000000000000000000000000";
    bytes32 constant constant_owner_stored_key = hex"6f776e65725f73746f7265640000000000000000000000000000000000000000";

    // constructor() {
    //     init();
    // }

    function isLogicFieldType(FieldTypes _type) internal pure returns (bool) {
        if(_type == FieldTypes.LOGIC_BOOL) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_UINT_8) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_UINT_32) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_UINT_64) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_UINT_128) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_UINT_256) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_BYTES_32) {
            return true;
        }
        if(_type == FieldTypes.LOGIC_ADDRESS) {
            return true;
        }
        return false;
    }

    function _addProperty(bytes32 _name, FieldTypes _type, bytes4 _selector) internal {
        uint8 thisId = propertyCount;

        if(propertyNameToId[_name] > 0) {
            // no duplicates
            revert();
        } else {
            propertyNameToId[_name]     = thisId;
            traitProperty storage prop = property[thisId];
            prop._name = _name;
            prop._type = _type;
            prop._selector = _selector;
            prop._default = defaultPropValues[thisId]; // _default;
            propertyCount++;
        }
    }

    function addStoredProperty(bytes32 _name, FieldTypes _type) internal {
        _addProperty(_name, _type, bytes4(0));
    }

    function addLogicProperty(bytes32 _name, FieldTypes _type, bytes4 _selector) internal {
        _addProperty(_name, _type, _selector);
    }

    function addPropertyLimits(bytes32 _name, uint256 _min, uint256 _max) internal {
        uint8 _id = propertyNameToId[_name];
        traitProperty storage thisProp = property[_id];
        require(thisProp._selector == bytes4(hex"00000000"), "Trait: Cannot set limits on Logic property");
        thisProp._limited = true;
        thisProp._min = _min;
        thisProp._max = _max;
    }

    function setPropertyResetOnOwnerChange(bytes32 _name) internal {
        uint8 _id = propertyNameToId[_name];
        traitProperty storage thisProp = property[_id];
        thisProp._reset_on_owner_change = true;
    }

    function _initStandardProps() internal {
        require(!initialized, "Trait: already initialized!");

        addLogicProperty( bytes32("exists"),              FieldTypes.LOGIC_BOOL,        bytes4(keccak256("hasTrait(uint32)")));
        addLogicProperty( bytes32("initialized"),         FieldTypes.LOGIC_BOOL,        bytes4(keccak256("isInitialized(uint32)")));

        // required for soulbound
        addStoredProperty(bytes32("owner_stored"),        FieldTypes.STORED_ADDRESS);
        addLogicProperty( bytes32("owner_current"),       FieldTypes.LOGIC_ADDRESS,     bytes4(keccak256("currentTokenOwnerAddress(uint32)")));


        // if true, Value Modifier Traits can't modify limiters
        addStoredProperty(bytes32("modifier_lock"),       FieldTypes.STORED_BOOL);
        addStoredProperty(bytes32("movement_permission"), FieldTypes.STORED_UINT_8);
        addStoredProperty(bytes32("activation"),          FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("cooldown"),            FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("expiration"),          FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("counter"),             FieldTypes.STORED_UINT_8);

        addStoredProperty(bytes32("royalty_id"),          FieldTypes.STORED_UINT_256);
        addStoredProperty(bytes32("royalty_amount"),      FieldTypes.STORED_UINT_256);

        addLogicProperty( bytes32("status"),              FieldTypes.LOGIC_UINT_8,      bytes4(keccak256("status(uint32)")));



        // setPropertySoulbound()
            // owner_stored
            // if(_name == hex"6f776e65725f73746f7265640000000000000000000000000000000000000000") {
            //     prop._soulbound = true;
            // }


        // status change on owner_current change
        // if movement_permission == MovementPermission.SOULBOUND
        // on addTrait / setProperty / setData set owner_stored
        // 
        

        // prop reset on owner_stored
        // _reset_on_owner_change
        // addStoredProperty(bytes32("points"),              FieldTypes.STORED_UINT_256);
        // setPropertyResetOnOwnerChange(bytes32("points"));
        // addStoredProperty(bytes32("points"),              FieldTypes.STORED_UINT_256);

        // addPropertyLimits(bytes32("cooldown"),      0,      3600 * 24);
        // addPropertyLimits(bytes32("counter"),       0,      100);
    }

    function setup(
        address _registry,
        uint16 _traitId,
        traitConfig memory _traitConfig,
        bytes[] memory _defaultPropValues
    ) virtual public {
        require(!initialized, "Trait: already initialized!");
        GTRegistry = IGTRegistry(_registry);
        traitId = _traitId;
        thisTraitConfig = _traitConfig;
        for(uint8 i = 0; i < _defaultPropValues.length; i++) {
            defaultPropValues[i] = _defaultPropValues[i];
        }        
    }

    

    function init() virtual public {
        _initStandardProps();
        // custom props
        afterInit();
    }

    function getRoyaltiesForThisTraitType() internal view returns (uint256, uint256) {
        IPaymentMatrix PaymentMatrix = IPaymentMatrix(
            galaxisRegistry.getRegistryAddress("PAYMENT_MATRIX")
        ); 
        
        require(address(PaymentMatrix) != address(0), "Trait: PAYMENT_MATRIX address cannot be 0");

        // if(initialized){} 
        return PaymentMatrix.getDevIDAndAmountForTraitType(TRAIT_TYPE());
    }

    function afterInit() internal {

        // overwrite royalty_id / royalty_amount
        (uint256 royalty_id, uint256 royalty_amount) = getRoyaltiesForThisTraitType();
        for(uint8 _id = 0; _id < propertyCount; _id++) {
            traitProperty memory thisProp = property[_id];
            if(thisProp._name == constant_royalty_id_key || thisProp._name == constant_royalty_amount_key) {
                bytes memory value;
                if(thisProp._name == constant_royalty_id_key) {
                    value = abi.encode(royalty_id);
                } else if(thisProp._name == constant_royalty_amount_key) {
                    value = abi.encode(royalty_amount);
                }
                defaultPropValues[_id] = value;
                property[_id]._default = value;
            } 

            // reset default owner in case deployer wrote a different address here
            if(thisProp._name == constant_owner_stored_key ) {
                property[_id]._default = abi.encode(address(0));
            }
        }

        // index for cheaper internal logic
        modifier_lock = (uint256(bytes32(getProperty("modifier_lock", 0))) > 0 );
        movement_permission = abi.decode(getProperty("movement_permission", 0), (uint8));
        // set defaults
        tokenDataDEFAULT = getDefaultTokenDataOutput();

        initialized = true;
    }


    function getSchema() public view returns (traitProperty[] memory) {
        traitProperty[] memory myProps = new traitProperty[](propertyCount);
        for(uint8 i = 0; i < propertyCount; i++) {
            myProps[i] = property[i];
        }
        return myProps;
    }

    // function _getFieldTypeByteLenght(uint8 _id) public view returns (uint16) {
    //     traitProperty storage thisProp = property[_id];
    //     if(thisProp._type == FieldTypes.LOGIC_BOOL || thisProp._type == FieldTypes.STORED_BOOL) {
    //         return 1;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_8) {
    //         return 1;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_16) {
    //         return 2;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_32) {
    //         return 4;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_64) {
    //         return 8;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_128) {
    //         return 16;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_UINT_256) {
    //         return 32;
    //     }
    //     else if(thisProp._type == FieldTypes.STORED_STRING || thisProp._type == FieldTypes.STORED_BYTES) {
    //         // array length for strings / bytes limited to uint16.
    //         return 2;
    //     }

    //     revert("Trait: FieldType Not Implemented");
    // }

    function getOutputBufferLength(uint32 _tokenId) public view returns(uint16, uint16) {
        // abi.encode style 32 byte blocks
        // with memory pointer at location for complex types
        // pointer to length followed by records
        uint16 propCount = propertyCount;
        uint16 _length = 32 * propCount;
        uint16 complexDataOutputPtr = _length;
        bytes memory tokenData = bytes(storageData[_tokenId]);
        
        for(uint8 _id = 0; _id < propertyCount; _id++) {
            FieldTypes thisPropType = property[_id]._type;
            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                uint16 offset = uint16(_id) * 32;
                // console.log("getOutputBufferLength", _id, offset);
                bytes memory arrayLenB = new bytes(2);
                if(tokenData.length > 0) {
                    arrayLenB[0] = bytes1(tokenData[offset + 30]);
                    arrayLenB[1] = bytes1(tokenData[offset + 31]);
                    // each complex type adds another 32 for length 
                    // and data 32 * ceil(length/32)
                    _length+= 32 + 32 + ( 32 * ( uint16(bytes2(arrayLenB)) / 32 ) );

                } else {
                    arrayLenB[0] = 0;
                    arrayLenB[1] = 0;
                    _length+= 32;
                }
            }
        }
        return (_length, complexDataOutputPtr);
    }

    function getData(uint32[] memory _tokenIds) public view returns(bytes[] memory) {
        bytes[] memory outputs = new bytes[](_tokenIds.length);
        for(uint32 i = 0; i < _tokenIds.length; i++) {
            outputs[i] = getData(_tokenIds[i]);
        }
        return outputs;
    }

    function getDefaultTokenDataOutput() public view returns(bytes memory) {
        uint32 _tokenId = 0;
        ( uint16 _length, uint16 complexDataOutputPtr) = getOutputBufferLength(_tokenId);
        bytes memory outputBuffer = new bytes(_length);
        uint256 outputPtr;
        uint256 complexDataOutputRealPtr;
        uint256 _start = 0;

        assembly {
            // jump over length 32 byte block
            outputPtr := add(outputBuffer, 32)
            complexDataOutputRealPtr := add(outputPtr, complexDataOutputPtr)
        }

        for(uint8 _id = 0; _id < propertyCount; _id++) {
            _start+=32;

            FieldTypes thisPropType = property[_id]._type;
            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                bytes memory value = storageMapArrayDEFAULT[_id];
                assembly {
                    // let readptr := add(tokenData, _start)
                    // store location of data in place
                    mstore(outputPtr, complexDataOutputPtr)

                    complexDataOutputPtr := add(complexDataOutputPtr, 32)
                    let byteLength := mload(value)
                    let itemBlocks := div(byteLength, 32)
                    if lt(mul(itemBlocks, 32), byteLength ) {
                        itemBlocks := add(itemBlocks, 1)
                    }
                    // store array length
                    mstore(complexDataOutputRealPtr, byteLength)
                    complexDataOutputRealPtr:= add(complexDataOutputRealPtr, 32)
                    for { let n := 0 } lt(n, itemBlocks) { n := add(n, 1) } {
                        // store array 32 byte blocks
                        mstore(
                            complexDataOutputRealPtr, 
                            mload(
                                add(value, mul(add(n,1), 32) ) 
                            )
                        )
                        complexDataOutputRealPtr:= add(complexDataOutputRealPtr, 32)
                    }
                    complexDataOutputPtr := add(complexDataOutputPtr, mul(itemBlocks, 32))
                }

            }
            else {
                bytes32 value = bytes32(property[_id]._default);
                assembly {
                    // store empty value in place
                    mstore(outputPtr, value)
                }
            }

            assembly {
                outputPtr := add(outputPtr, 32)
            }
        }
        return outputBuffer;

    }

    function getData(uint32 _tokenId) public view returns(bytes memory) {
        uint16 _length = 0;
        uint16 complexDataOutputPtr;
        ( _length, complexDataOutputPtr) = getOutputBufferLength(_tokenId);
        bytes memory outputBuffer = new bytes(_length);
        bytes memory tokenData = storageData[_tokenId];

        if(!isInitialized(_tokenId)) {
            tokenData = tokenDataDEFAULT;
        }

        // 32 byte block contains bytes array size / length
        if(tokenData.length == 0) {
            // could simply return empty outputBuffer here..;
            tokenData = new bytes(
                uint16(propertyCount) * 32
            );
        }

        uint256 outputPtr;
        uint256 complexDataOutputRealPtr;
        uint256 _start = 0;

        assembly {
            // jump over length 32 byte block
            outputPtr := add(outputBuffer, 32)
            complexDataOutputRealPtr := add(outputPtr, complexDataOutputPtr)
        }

        for(uint8 _id = 0; _id < propertyCount; _id++) {
            _start+=32;

            FieldTypes thisPropType = property[_id]._type;
            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                bytes memory value = storageMapArray[_id][_tokenId];
                assembly {
                    // let readptr := add(tokenData, _start)
                    // store location of data in place
                    mstore(outputPtr, complexDataOutputPtr)

                    complexDataOutputPtr := add(complexDataOutputPtr, 32)
                    let byteLength := mload(value)
                    let itemBlocks := div(byteLength, 32)
                    if lt(mul(itemBlocks, 32), byteLength ) {
                        itemBlocks := add(itemBlocks, 1)
                    }
                    // store array length
                    mstore(complexDataOutputRealPtr, byteLength)
                    complexDataOutputRealPtr:= add(complexDataOutputRealPtr, 32)
                    for { let n := 0 } lt(n, itemBlocks) { n := add(n, 1) } {
                        // store array 32 byte blocks
                        mstore(
                            complexDataOutputRealPtr, 
                            mload(
                                add(value, mul(add(n,1), 32) ) 
                            )
                        )
                        complexDataOutputRealPtr:= add(complexDataOutputRealPtr, 32)
                    }
                    complexDataOutputPtr := add(complexDataOutputPtr, mul(itemBlocks, 32))
                }

            }
            else if(isLogicFieldType(thisPropType)) {

                callMethodAndCopyToOutputPointer(
                    property[_id]._selector, 
                    _tokenId,
                    outputPtr
                );

            } else {
                assembly {
                    // store value in place
                    mstore(outputPtr, mload(
                        add(tokenData, _start)
                    ))
                }
            }

            assembly {
                outputPtr := add(outputPtr, 32)
            }
        }
        return outputBuffer;
    }

    function callMethodAndCopyToOutputPointer(bytes4 _selector, uint32 _tokenId, uint256 outputPtr ) internal view {
        (bool success, bytes memory callResult) = address(this).staticcall(
            abi.encodeWithSelector(_selector, _tokenId)
        );
        require(success, "Trait: internal method call failed");
        // console.logBytes(callResult);
        assembly {
            // store value in place  // shift by 32 so we just get the value
            mstore(outputPtr, mload(add(callResult, 32)))
        }
    }

    /*
        should remove, gives too much power
    */
    function setData(uint32 _tokenId, bytes memory _bytesData) public onlyAllowed {
        _setData(_tokenId, _bytesData);
        
        //
        _updateCurrentOwnerInStorage(_tokenId);
    }

    function _setData(uint32 _tokenId, bytes memory _bytesData) internal {
        
        if(!hasTrait(_tokenId)) {
            // if the trait does not exist
            setTraitExistance(_tokenId, true);
        }

        if(!isInitialized(_tokenId)) {
            // if the trait is not initialized
            _tokenSetBit(_tokenId, BitType.INITIALIZED, true);
        }

        uint16 _length = uint16(propertyCount) * 32;
        if(_bytesData.length < _length) {
            revert("Trait: Message not long enough");
        }

        bytes memory newTokenData = new bytes(_length);
        uint256 newTokenDataPtr;
        uint256 readPtr;
        assembly {
            // jump over length 32 byte block
            newTokenDataPtr := add(newTokenData, 32)
            readPtr := add(_bytesData, 32)
        }

        for(uint8 _id = 0; _id < propertyCount; _id++) {
            FieldTypes thisPropType = property[_id]._type;
            bytes32 fieldValue;
            assembly {
                fieldValue:= mload(readPtr)
            }

            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                // read length from offset stored in fieldValue
                bytes32 byteLength;
                uint256 complexDataPtr;
                assembly {
                    complexDataPtr:= add(
                        add(_bytesData, 32),
                        fieldValue
                    )

                    byteLength:= mload(complexDataPtr)
                    // store length
                    mstore(newTokenDataPtr, byteLength)
                }

                bytes memory propValue = new bytes(uint256(byteLength));

                assembly {
                
                    let propValuePtr := add(propValue, 32)
                    let itemBlocks := div(byteLength, 32)
                    if lt(mul(itemBlocks, 32), byteLength ) {
                        itemBlocks := add(itemBlocks, 1)
                    }

                    // store array 32 byte blocks
                    for { let n := 0 } lt(n, itemBlocks) { n := add(n, 1) } {
                        complexDataPtr:= add(complexDataPtr, 32)
                        mstore(
                            propValuePtr, 
                            mload(complexDataPtr)
                        )                        
                        propValuePtr:= add(propValuePtr, 32)
                    }

                }
                storageMapArray[_id][_tokenId] = propValue;
            
            } else if(isLogicFieldType(thisPropType)) {
                // do nothing
            } else {
                // just store fieldValue in newTokenData
                assembly {
                    mstore(newTokenDataPtr, fieldValue)
                }
            }

            assembly {
                newTokenDataPtr := add(newTokenDataPtr, 32)
                readPtr := add(readPtr, 32)
            }
        }
        storageData[_tokenId] = newTokenData;
        emit tokenTraitChangeEvent(_tokenId);
    }

    // function getPropertyOutputBufferLength(uint8 _id, FieldTypes _thisPropType, uint32 _tokenId) public view returns(uint16) {
    //     uint16 _length = 32;
    //     bytes memory tokenData = bytes(storageData[_tokenId]);
    //     if(_thisPropType == FieldTypes.STORED_STRING || _thisPropType == FieldTypes.STORED_BYTES) {
    //         uint16 offset = _id * 32;
    //         bytes memory arrayLenB = new bytes(2);
    //         if(tokenData.length > 0) {
    //             arrayLenB[0] = bytes1(tokenData[offset + 30]);
    //             arrayLenB[1] = bytes1(tokenData[offset +31]);
    //             // each complex type adds another 32 for length 
    //             // and data 32 * ceil(length/32)
    //             _length+= 32 + 32 + ( 32 * ( uint16(bytes2(arrayLenB)) / 32 ) );
    //         } else {
    //             arrayLenB[0] = 0;
    //             arrayLenB[1] = 0;
    //         }
    //     }
        
    //     return _length;
    // }

    function getProperties(uint32 _tokenId, bytes32[] memory _names) public  view returns(bytes[] memory) {
        bytes[] memory outputs = new bytes[](_names.length);
        for(uint32 i = 0; i < _names.length; i++) {
            outputs[i] = getProperty(_names[i], _tokenId);
        }
        return outputs;
    }

    function getProperty(bytes32 _name, uint32 _tokenId) public view returns (bytes memory) {
        uint8 _id = propertyNameToId[_name];
        FieldTypes thisPropType = property[_id]._type;
        if(!isInitialized(_tokenId) && !isLogicFieldType(thisPropType)) {
            // if the trait has not been initialized, and is not a method return, we return default stored data
            return property[_id]._default;
        } else {
            return _getProperty(_id, _tokenId);
        }
    }

    function _getProperty(uint8 _id, uint32 _tokenId) internal view returns (bytes memory) {
        FieldTypes thisPropType = property[_id]._type;
        bytes memory output = new bytes(32);
        uint256 outputPtr;
        assembly {
            outputPtr := add(output, 32)
        }
        if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
            output = storageMapArray[_id][_tokenId];
        }
        else if(isLogicFieldType(thisPropType)) {
            callMethodAndCopyToOutputPointer(
                property[_id]._selector, 
                _tokenId,
                outputPtr
            );
        }
        else {
            bytes memory tokenData = bytes(storageData[_tokenId]);
            // first 32 is tokenData length
            uint256 _start = 32 + 32 * uint16(_id);
            assembly {
                outputPtr := add(output, 32)
                // store value in place
                mstore(outputPtr, mload(
                        add(tokenData, _start)
                    )
                )
            }
        }
        return output; 
    }

    // function canUpdateTo(bytes32 _name, bytes memory newValue) public view returns (bool) {
    //     return true;

    //     uint8 _id = propertyNameToId[_name];
    //     traitProperty memory thisProp = property[_id];
        
    //     thisProp._limited;

    //     if(modifier_lock) {
    //         // if()
    //         return false;
    //     }
    //     return false;
    //     // 
    // }

    function setProperties(uint32 _tokenId, bytes32[] memory _names, bytes[] memory inputs) public onlyAllowed {
        _updateCurrentOwnerInStorage(_tokenId);

        for(uint8 i = 0; i < _names.length; i++) {
            bytes32 name = _names[i];
            if(name == constant_owner_stored_key) {
                revert("Trait: dissalowed! Cannot set owner_stored value!");
            }
            _setProperty(name, _tokenId, inputs[i]);
        }
    }


    function setProperty(bytes32 _name, uint32 _tokenId, bytes memory input) public onlyAllowed {
        if(_name == constant_owner_stored_key) {
            revert("Trait: dissalowed! Cannot set owner_stored value!");
        }
        _updateCurrentOwnerInStorage(_tokenId);
        _setProperty(_name, _tokenId, input);
    }

    function _updateCurrentOwnerInStorage(uint32 _tokenId) internal {
        if(movement_permission == uint8(MovementPermission.SOULBOUND)) {
            // if default address 0 value, then do the update
            if(
                // decoded stored value
                abi.decode(getProperty(constant_owner_stored_key, _tokenId), (address)) 
                == address(0)
            ) {
                _setProperty(
                    constant_owner_stored_key,
                    _tokenId, 
                    // abi encodePacked left shifts everything, but ethers.js cannot decode that properly!
                    abi.encode(currentTokenOwnerAddress(_tokenId))
                );
            }
            // else do nothing
        } else {
            _setProperty(
                constant_owner_stored_key,
                _tokenId, 
                // abi encodePacked left shifts everything, but ethers.js cannot decode that properly!
                abi.encode(currentTokenOwnerAddress(_tokenId))
            );
        }

    }

    function _setProperty(bytes32 _name, uint32 _tokenId, bytes memory input) internal {
        // if(!canUpdateTo(_name, input)) {
        //     revert("Trait: Cannot update values because modifier lock is true");
        // }

        if(!hasTrait(_tokenId)) {
            // if the trait does not exist
            setTraitExistance(_tokenId, true);
        }

        if(!isInitialized(_tokenId)) {
            // if the trait is not initialized
            _tokenSetBit(_tokenId, BitType.INITIALIZED, true);
            _setData(_tokenId, tokenDataDEFAULT);
        }

        uint8 _id = propertyNameToId[_name];
        FieldTypes thisPropType = property[_id]._type;

        if(isLogicFieldType(thisPropType)) {
            revert("Trait: Cannot set logic value!");
        } else {

            uint16 _length = uint16(propertyCount) * 32;
            bytes memory tokenData = bytes(storageData[_tokenId]);
            if(tokenData.length == 0) {
                tokenData = new bytes(_length);
                // init default tokenData.. empty for now
            }

            uint256 valuePtr;
            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                assembly {
                    valuePtr := input
                }
                storageMapArray[_id][_tokenId] = input;

            } else {
                assembly {
                    // load from pointer location
                    valuePtr := add(input, 32)
                }
            }

            assembly {
                // store incomming length value into value slot
                mstore(
                    add(
                        add(tokenData, 32),
                        mul(_id, 32) 
                    ),
                    mload(valuePtr)
                )
            }
            storageData[_tokenId] = tokenData;
        }
        
        emit tokenTraitChangeEvent(_tokenId);
    }

    function getByteAndBit(uint32 _offset) public pure returns (uint32 _byte, uint8 _bit) {
        // find byte storig our bit
        _byte = uint32(_offset / 8);
        _bit = uint8(_offset - _byte * 8);
    }

    function hasTrait(uint32 _tokenId) public view returns (bool result) {
        bool _hasTrait = _tokenHasBit(_tokenId, BitType.EXISTS);
        if(thisTraitConfig.inverted) {
            return !_hasTrait;
        }
        return _hasTrait;
    }

    function isInitialized(uint32 _tokenId) public view returns (bool result) {
        return _tokenHasBit(_tokenId, BitType.INITIALIZED);
    }

    function _tokenHasBit(uint32 _tokenId, BitType _bitType) internal view returns (bool result) {
        uint8 bitType = uint8(_bitType);
        (uint32 byteNum, uint8 bitPos) = getByteAndBit(_tokenId);
        if(bitType == 1) {
            return existsData[byteNum] & (0x01 * 2**bitPos) != 0;
        } else if(bitType == 2) {
            return initializedData[byteNum] & (0x01 * 2**bitPos) != 0;
        }
    }

    function status(uint32 _tokenId) public view returns ( uint8 ) {
        TraitStatus statusValue = TraitStatus.NONE;
        if(hasTrait(_tokenId)) {
            uint256 activation  = uint256(bytes32(getProperty("activation", _tokenId)));
            uint256 expiration  = uint256(bytes32(getProperty("expiration", _tokenId)));
            uint256 counter     = uint256(bytes32(getProperty("counter",    _tokenId)));

            if(expiration == 0) {
                // expiration 0 means never
                expiration = block.timestamp + 3600;
            }

            if(counter > 0) {
                if(activation <= block.timestamp && block.timestamp <= expiration) {

                    // SOULBOUND Check
                    if(movement_permission == uint8(MovementPermission.SOULBOUND)) {

                        address storedOwnerValue = abi.decode(getProperty(constant_owner_stored_key, _tokenId), (address));
                        address currentOwnerValue = currentTokenOwnerAddress(_tokenId);
                        
                        if(storedOwnerValue == currentOwnerValue) {
                            statusValue = TraitStatus.ACTIVE;
                        } else {
                            statusValue = TraitStatus.DORMANT;
                        }

                    } else {
                        statusValue = TraitStatus.ACTIVE;
                    }

                } else {
                    statusValue = TraitStatus.DORMANT;
                }
            } else {
                statusValue = TraitStatus.SPENT;
            }
        }
        return uint8(statusValue);
    }

    // marks token as having the trait
    function addTrait(uint32[] memory _tokenIds) public onlyAllowed {
        for(uint16 _id = 0; _id < _tokenIds.length; _id++) {
            if(!hasTrait(_tokenIds[_id])) {
                // if trait is soulbound we have to initialize it.. 
                if(movement_permission == uint8(MovementPermission.SOULBOUND)) {
                    _updateCurrentOwnerInStorage(_tokenIds[_id]);     
                } else {
                    setTraitExistance(_tokenIds[_id], true);
                    emit tokenTraitChangeEvent(_tokenIds[_id]);
                }
            } else {
                revert("Trait: Token already has trait!");
            }
        }
    }

    function setTraitExistance(uint32 _tokenId, bool _value) internal {
        if(thisTraitConfig.inverted) {
            _value = !_value;
        }
        _tokenSetBit(_tokenId, BitType.EXISTS, _value);
    }

    // util, sets bit in item in map at position as true / false
    function _tokenSetBit(uint32 _tokenId, BitType _bitType, bool _value) internal {
        (uint32 byteNum, uint8 bitPos) = getByteAndBit(_tokenId);
        if(_bitType == BitType.EXISTS) {
            if(_value) {
                existsData[byteNum] = uint8(existsData[byteNum] | 2**bitPos);
            } else {
                existsData[byteNum] = uint8(existsData[byteNum] & ~(2**bitPos));
            }
        } else if(_bitType == BitType.INITIALIZED) {
            if(_value) {
                initializedData[byteNum] = uint8(initializedData[byteNum] | 2**bitPos);
            } else {
                initializedData[byteNum] = uint8(initializedData[byteNum] & ~(2**bitPos));
            }
        }
    }

    function _removeTrait(uint32 _tokenId) internal returns (bool) {
        require(hasTrait(_tokenId), "Trait: Token does not have trait!");

        delete storageData[_tokenId];
        for(uint8 _id = 0; _id < propertyCount; _id++) {
            FieldTypes thisPropType = property[_id]._type;
            if(thisPropType == FieldTypes.STORED_STRING || thisPropType == FieldTypes.STORED_BYTES) {
                delete storageMapArray[_id][_tokenId];
            }
        }

        setTraitExistance(_tokenId, false);
        _tokenSetBit(_tokenId, BitType.INITIALIZED, false);

        emit tokenTraitChangeEvent(_tokenId);
        return true;
    }

    function removeTrait(uint32[] memory _tokenIds) public onlyAllowed returns (bool) {
        for(uint8 i = 0; i < _tokenIds.length; i++) {
            _removeTrait(_tokenIds[i]);
        }
        return true;
    }

    function incrementCounter(uint32 _tokenId) public onlyAllowed {
        uint256 counter     = uint256(bytes32(getProperty("counter", _tokenId))) + 1;
        require(counter < 256, "GenericTrait: counter exceeds max (255)");
        setProperty("counter", _tokenId, abi.encodePacked(counter));
    }

    function decrementCounter(uint32 _tokenId) public onlyAllowed {
        uint256 counter     = uint256(bytes32(getProperty("counter", _tokenId)));
        require(counter > 0, "GenericTrait: attempt to decrement zero counter");
        uint256 cooldown    = uint256(bytes32(getProperty("cooldown", _tokenId)));
        setProperty("counter", _tokenId, abi.encodePacked(counter - 1));
        setProperty("activation", _tokenId, abi.encodePacked(block.timestamp + cooldown));
    }


    function currentTokenOwnerAddress(uint32 _tokenId) public view returns (address) {
        return IERC721(
            (GTRegistry.myCommunityRegistry()).getRegistryAddress(
                GTRegistry.TOKEN_KEY()
            )
        ).ownerOf(_tokenId);
    }

    modifier onlyAllowed() {
        require(
            GTRegistry.addressCanModifyTrait(msg.sender, traitId) ||
            galaxisRegistry.getRegistryAddress("ACTION_HUB") == msg.sender, "Trait: Not authorized.");
        _;
    }

}

File 23 of 27 : IRandomNumberProvider.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

interface IRandomNumberProvider {
    function requestRandomNumber() external returns (uint256 requestId);
    function requestRandomNumberWithCallback() external returns (uint256);
    function isRequestComplete(uint256 requestId) external view returns (bool isCompleted);
    function randomNumber(uint256 requestId) external view returns (uint256 randomNum);
    function setAuth(address user, bool grant) external;
    function setAdmin(address user, bool grant) external;
}

File 24 of 27 : ICoinsVault.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "../../@galaxis/registries/contracts/CommunityRegistry.sol";
import "./IGenericVault.sol";

interface ICoinsVault is IGenericVault {
    /**
     * @dev Error emitted when there's an attempt to redeem coins with invalid data
     * @param tokenAddr Address of coin token
     * @param value Amount of tokens
     */
    error CoinsVaultInvalidCoinsRedeemData(address tokenAddr, uint256 value);

    error CoinsVaultCallerNotABuyERC1155Addr(address callerAddr);

    /**
     * @dev Initializes the coins vault with the given parameters
     * @param communityRegistry_ An address of the community registry
     */
    function __CoinsVault_init(
        CommunityRegistry communityRegistry_,
        GenericVaultInitParams calldata initParams_
    ) external;
}

File 25 of 27 : ICommunityVaultsRegistry.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "../../@galaxis/registries/contracts/Versionable/IVersionable.sol";
import "./IGenericVault.sol";
import "./INFTVault.sol";

/**
 * @title ICommunityVaultsRegistry
 * @dev Interface that represents a registry for community vaults
 */
interface ICommunityVaultsRegistry is IVersionable {
    /**
     * @dev Enum representing the different types of vaults
     */
    enum VaultTypes {
        NFTVault,
        CoinsVault
    }

    /**
     * @dev Base structure for holding basic information about vaults
     */
    struct BaseVaultInfo {
        address vaultAddr;
        VaultTypes vaultType;
        uint256 vaultTypeNonce;
        string vaultName;
    }

    /**
     * @dev Structure for holding detailed information about vault including buy NFT settings
     */
    struct VaultInfo {
        BaseVaultInfo baseVaultInfo;
        IGenericVault.BuySettingsInfo buySettingsInfo;
    }

    /**
     * @dev Emitted when a new vault is created
     * @param vaultId The ID of the created vault
     * @param vaultAddr The address of the created vault
     * @param vaultType The type of the created vault
     * @param vaultTypeNonce The nonce of the vault
     */
    event VaultCreated(
        uint256 vaultId,
        address vaultAddr,
        VaultTypes vaultType,
        uint256 vaultTypeNonce
    );

    /**
     * @dev Emitted when a new vault is created
     * @param vaultId The ID of the created vault
     */
    event VaultNameUpdated(
        uint256 vaultId
    );

    /*
     * @dev Indicates that the provided vault name is empty
     */
    error CommunityVaultsRegistryInvalidVaultName();

    /*
     * @dev Indicates that the caller does not have the required permissions for the operation
     */
    error CommunityVaultsRegistryUnauthorized();

    /*
     * @dev Indicates that there are zero golden vaults
     */
    error CommunityVaultsRegistryZeroVaultsGolden();

    /*
     * @dev Indicates a failure during the creation of a vault
     */
    error CommunityVaultsRegistryVaultCreationFailed();

    /*
     * @dev Indicates a failure while getting random provider
     */
    error CommunityVaultsRegistryRandomProviderNotRegistred();

    /*
     * @dev Indicates that the provided community ID doesn't exists
     */
    error CommunityVaultsRegistryInvalidCommunityId(uint32 communityId);

    /*
     * @dev Indicates that the provided vault ID doesn't exists
     */
    error CommunityVaultsRegistryInvalidVaultId(uint256 vaultId);

    /*
     * @dev Indicates that the update message was not received from the vault
     */
    error CommunityVaultsRegistryInvalidMsgSender();


    /**
     * @dev Creates a new NFT vault
     * @param vaultName_ Name of the vault
     * @return Address of the newly created NFT vault
     */
    function createNFTVault(
        string calldata vaultName_,
        IGenericVault.GenericVaultInitParams calldata initParams_
    ) external returns (address);

    /**
     * @dev Creates a new coins vault
     * @param vaultName_ Name of the vault
     * @return Address of the newly created coins vault
     */
    function createCoinsVault(
        string calldata vaultName_,
        IGenericVault.GenericVaultInitParams calldata initParams_
    ) external returns (address);

    /**
     * @dev Retrieves the address of a vault by its type and nonce
     * @param vaultType_ Type of the vault
     * @param vaultTypeNonce_ Nonce of the vault
     * @return Address of the vault
     */
    function getVaultAddress(
        VaultTypes vaultType_,
        uint256 vaultTypeNonce_
    ) external view returns (address);

    /**
     * @dev Retrieves the address of a vault by its implementation, type, and nonce
     * @param implementation_ Address of the implementation
     * @param vaultType_ Type of the vault
     * @param vaultTypeNonce_ Nonce of the vault
     * @return Address of the vault
     */
    function getVaultAddress(
        address implementation_,
        VaultTypes vaultType_,
        uint256 vaultTypeNonce_
    ) external view returns (address);

    /**
     * @dev Retrieves the address of a vault by its ID
     * @param vaultId_ ID of the vault
     * @return Address of the vault
     */
    function getVaultAddressById(
        uint256 vaultId_
    ) external view returns (address);

    /**
     * @dev Retrieves detailed information about multiple vaults by their IDs.
     * @param vaultIds_ List of vault IDs
     * @return resultArr_ Array of vault information
     */
    function getVaultsInfo(
        uint256[] calldata vaultIds_
    ) external view returns (VaultInfo[] memory resultArr_);

    /**
     * @dev Checks if an address has admin permissions for the vaults registry
     * @param userAddr_ Address to check
     * @return True if the address has admin permissions, false otherwise
     */
    function hasVaultsRegistryAdminRole(
        address userAddr_
    ) external view returns (bool);

    /**
     * @dev Updates the name of an existing vault
     * @param vaultId_ Id of the vault
     * @param newVaultName_ New name of the vault
     */
    function updateVaultName(
        uint256 vaultId_,
        string calldata newVaultName_
    ) external;
}

File 26 of 27 : IGenericVault.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import {CommunityRegistry} from "../../@galaxis/registries/contracts/CommunityRegistry.sol";
import {DigitalRedeem} from "../../Traits/Implementers/DigitalRedeem/DigitalRedeem.sol";
import {ICommunityVaultsRegistry} from "./ICommunityVaultsRegistry.sol";
import {IGenericVersionable} from "../../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";

/**
 * @title IGenericVault
 * @dev Interface for generic vault operations
 */
interface IGenericVault is IGenericVersionable {
    /**
     * @dev Enum representing the different types of tokens supported by the vault
     */
    enum TokenTypes {
        ERC20,
        ERC721,
        ERC1155
    }

    /**
     * @dev Enum representing the different redeem modes supported by the vault
     */
    enum RedeemModes {
        RANDOM_REDEEM,
        SEQUENTIAL_REDEEM,
        DIRECT_SELECT,
        DET_PSEUDO_RANDOM,
        COINS_REDEEM
    }

    enum BuyTypes {
        NATIVE,
        VAULT_ERC20_PAYMENT_TOKEN,
        ERC1155
    }

    struct BuyTypeData {
        address tokenAddr;
        uint256 tokenId;
        uint256 tokensAmount;
        bool isBuyable;
    }

    struct BuySettings {
        BaseBuySettings baseBuySettings;
        mapping(BuyTypes => BuyTypeData) buyTypesData;
    }

    struct BaseBuySettings {
        RedeemModes redeemMode;
        bytes specialRedeemData;
    }

    struct BuyTypeInfo {
        BuyTypes buyType;
        BuyTypeData buyTypeData;
    }

    struct BuySettingsInfo {
        BaseBuySettings baseBuySettings;
        BuyTypeInfo[] buyTypeInfoArr;
    }

    /**
     * @dev Structure for whitelisting receivable tokens
     */
    struct ReceivablesWhitelistEntry {
        address tokenAddr;
        TokenTypes tokenType;
        bool isAdding;
    }

    /**
     * @dev Structure for updating supported redeem modes
     */
    struct RedeemModesUpdateEntry {
        RedeemModes redeemMode;
        bool isAdding;
    }

    /**
     * @dev Structure holding info about whitelisted tokens
     */
    struct WhitelistedTokenInfo {
        address tokenAddr;
        TokenTypes tokenType;
    }

    struct GenericVaultInitParams {
        ReceivablesWhitelistEntry[] whitelistEntries;
        RedeemModesUpdateEntry[] redeemModesUpdateEntries;
        BuySettingsInfo buySettingsInfo;
        bool initialState;
    }

    /**
     * @dev Parameters required for withdrawal of tokens
     */
    struct WithdrawParams {
        address tokenAddr;
        address tokenRecipient;
        uint256 tokenId;
        uint256 tokensAmount;
        TokenTypes tokenType;
    }

    /**
     * @dev Parameters required for withdrawal of traits
     */
    struct TraitWithdrawParams {
        DigitalRedeem trait;
        uint32 tokenId;
        bytes redeemData;
    }

    error GenericVaultInvalidNativeCurrencyAmount();

    error GenericVaultFailedToTransferNativeCurrency(
        address recipient,
        uint256 transferAmount
    );

    error GenericVaultUnsupportedBuyType(BuyTypes buyType);

    error GenericVaultUnableToBuyNFTs(BuyTypes buyType);

    error GenericVaultNotEnoughTokensToBuy(
        BuyTypes buyType,
        uint256 userBalance,
        uint256 nftPrice
    );

    /**
     * @dev Thrown when the special redeem data is not valid for the redeem mode
     */
    error GenericVaultInvalidSpecialRedeemData(RedeemModes, bytes);

    /**
     * @dev Raised when provided token is not valid for receivables whitelist
     */
    error GenericVaultInvalidReceivablesWhitelistToken(address tokenAddr);

    /**
     * @dev Raised when a provided redeem mode is unsupported
     */
    error GenericVaultUnsupportedRedeemMode(RedeemModes redeemMode);

    /**
     * @dev Raised when a trait is inactive
     */
    error GenericVaultInactiveTrait(address trait, uint32 tokenId);

    /**
     * @dev Raised when an invalid type is used for withdrawal
     */
    error GenericVaultInvalidWithdrawType();

    /**
     * @dev Raised when a token is not present in the receivables whitelist
     */
    error GenericVaultNotInAReceivablesWhitelist(address tokenAddr);

    /**
     * @dev Raised when provided token type is invalid for the vault type
     */
    error GenericVaultInvalidTokenType(
        ICommunityVaultsRegistry.VaultTypes vaultType,
        TokenTypes tokenType
    );

    /**
     * @dev Raised when an unsupported interface is used
     */
    error GenericVaultUnsupportedInterface(
        bytes4 interfaceId,
        address tokenAddr
    );

    /**
     * @dev Raised when a user is unauthorized for a particular role
     */
    error GenericVaultUnauthorized(bytes32 role, address userAddr);

    /**
     * @dev Raised when a vault is disabled
     */
    error GenericVaultDisabled();

    /**
     * @notice Updates the whitelist for receivable tokens
     * @param entriesToUpdate_ List of tokens to be updated
     */
    function updateReceivablesWhitelist(
        ReceivablesWhitelistEntry[] calldata entriesToUpdate_
    ) external;

    /**
     * @notice Updates the supported redeem modes for the vault
     * @param entriesToUpdate_ List of redeem modes to be updated
     */
    function updateSupportedRedeemModes(
        RedeemModesUpdateEntry[] calldata entriesToUpdate_
    ) external;

    function updateBuySettings(
        BuySettingsInfo calldata newBuySettingsInfo_
    ) external;

    function updateBaseBuySettings(
        BaseBuySettings calldata newBaseBuySettings_
    ) external;

    function updateBuyTypesData(
        BuyTypeInfo[] calldata buyTypeInfoArr_
    ) external;

    /**
     * @notice Allows the withdrawal of tokens from the vault
     * @param withdrawParams_ Parameters required for withdrawal
     */
    function withdraw(WithdrawParams memory withdrawParams_) external;

    /**
     * @notice Allows batch withdrawal of tokens from the vault
     * @param withdrawParamsArr_ Array of parameters required for withdrawals
     */
    function withdrawBatch(WithdrawParams[] memory withdrawParamsArr_) external;

    /**
     * @notice Allows withdrawal by traits from the vault
     * @param traitWithdrawParams_ Parameters required for trait withdrawal
     */
    function traitWithdraw(
        TraitWithdrawParams memory traitWithdrawParams_
    ) external;

    function buyFromVault(
        BuyTypes buyType_,
        bytes calldata userData_
    ) external payable;

    function VAULT_NATIVE_BUYING_FLAG() external view returns (string memory);

    /**
     * @notice Fetches information about the vault
     * @return communityId_ ID of the community associated with the vault
     * @return vaultType_ Type of the vault
     * @return vaultTypeNonce_ Nonce of the vault
     * @return state Vault state
     */
    function getVaultInfo()
        external
        view
        returns (
            uint32 communityId_,
            uint8 vaultType_,
            uint256 vaultTypeNonce_,
            bool state
        );

    /**
     * @notice Fetches the whitelist of receivable tokens
     * @return An array of addresses representing the whitelist
     */
    function getReceivablesWhitelist() external view returns (address[] memory);

    /**
     * @notice Fetches the supported redeem modes
     * @return An array of supported redeem modes
     */
    function getSupportedRedeemModes()
        external
        view
        returns (RedeemModes[] memory);

    /**
     * @notice Fetches information about whitelisted tokens
     * @return An array of WhitelistedTokenInfo structures
     */
    function getReceivablesWhitelistInfo()
        external
        view
        returns (WhitelistedTokenInfo[] memory);

    /**
     * @notice Fetches the type of a whitelisted token
     * @param whitelistedToken_ The address of the whitelisted token
     * @return The type of the whitelisted token
     */
    function getWhitelistedTokenType(
        address whitelistedToken_
    ) external view returns (TokenTypes);

    function getBaseBuySettings()
        external
        view
        returns (BaseBuySettings memory);

    function getBuySettingsInfo(
        BuyTypes[] calldata buyTypesArr_
    ) external view returns (BuySettingsInfo memory);

    function getBuyTypeInfo(
        BuyTypes[] calldata buyTypesArr_
    ) external view returns (BuyTypeInfo[] memory);

    function getBuyTypeData(
        BuyTypes buyType_
    ) external view returns (BuyTypeData memory buyTypeData_);

    /**
     * @notice Checks if a token is in the receivables whitelist
     * @param tokenAddr_ The address of the token to check
     * @return True if the token is in the whitelist, false otherwise
     */
    function isInReceivablesWhitelist(
        address tokenAddr_
    ) external view returns (bool);

    /**
     * @notice Checks if a redeem mode is supported by the vault
     * @param redeemMode_ The redeem mode to check
     * @return True if the redeem mode is supported, false otherwise
     */
    function isRedeemModeSupported(
        RedeemModes redeemMode_
    ) external view returns (bool);

    function isBuyable(BuyTypes buyType_) external view returns (bool);

    /**
     * @notice Enable or disable a vault
     * @param newState_ The new state
     */
    function updateVaultState(bool newState_) external;
}

File 27 of 27 : INFTVault.sol
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;

import "../../@galaxis/registries/contracts/CommunityRegistry.sol";
import "../../Traits/Implementers/Generic/GenericTrait.sol";
import "./IGenericVault.sol";

/**
 * @title INFTVault
 * @dev Interface defining operations and data structures for the NFTVault
 */
interface INFTVault is IGenericVault {
    /**
     * @dev Contains details about a token
     */
    struct TokenInfo {
        address tokenAddr; // Address of the token
        uint256 tokenId; // ID of the token
        TokenTypes tokenType; // Type of the token
    }

    /**
     * @dev Contains data for random redeem
     */
    struct RandomRedeemData {
        address recipientAddr; // Recipient address
        TokenInfo tokenInfo; // Information about the token
        uint256 randomNumber; // Generated random number
        uint8 luck; // Luck metric in persent
    }

    /**
     * @dev Contains data for direct selection of tokens
     */
    struct DirectSelectData {
        address recipient; // Recipient address
        TokenInfo tokenInfo; // Information about the token is wanted to be selected
    }

    /**
     * @dev Thrown when provided NFT buy data is invalid
     */
    error NFTVaultInvalidNFTBuyData(address nftAddr, uint256 tokenId);

    /**
     * @dev Thrown when either the payment token address is invalid or the sender address is zero
     */
    error NFTVaultInvalidPaymentTokenOrSender(address tokenAddr);

    error NFTVaultCallerNotABuyERC1155Addr(address tokenAddr);

    /**
     * @dev Thrown when the user balance is lower than NFT price
     */
    error NFTVaultNotEnoughTokensToBuy(uint256 userBalance, uint256 tokenPrice);

    /**
     * @dev Thrown when the request ID is not exists
     */
    error NFTVaultInvalidRequestId(uint256 requestId);

    /**
     * @dev Thrown when the request ID has already been processed
     */
    error NFTVaultRequestIdHasAlreadyBeenProcessed(uint256 requestId);

    /**
     * @dev Triggered when the total NFT supply amount is not enough
     */
    error NFTVaultInvalidTotalNFTSupplyAmount();

    /**
     * @dev Triggered when NFTs is not buyable
     */
    error NFTVaultUnableToBuyNFTs();

    /**
     * @dev Triggered when an address used is the zero address
     */
    error NFTVaultZeroAddress();

    /**
     * @dev Triggered when the pseudo-random equals to 0
     */
    error NFTVaultInvalidPseudoRandomInterval();

    /**
     * @dev Triggered when there's an issue with the sequential data used
     */
    error NFTVaultInvalidSequentialData();

    /**
     * @dev Emitted when an NFT has been successfully sold
     */
    event NFTSold(
        address nftRecipient,
        address indexed nftAddr,
        uint256 tokenId,
        uint256 paymentTokensAmount
    );

    /**
     * @dev Initializes the NFTVault with necessary settings and configurations
     * @param communityRegistry_ The address of the community registry
     */
    function __NFTVault_init(
        CommunityRegistry communityRegistry_,
        GenericVaultInitParams calldata initParams_
    ) external;

    /**
     * @dev Returns the total supply amount of the NFTVault
     * @return Total NFT supply amount
     */
    function totalNFTVaultSupplyAmount() external view returns (uint256);

    /**
     * @dev Gets the number of pending NFTs (for random withdraw)
     * @return Amount of pending NFTs
     */
    function pendingNFTsAmount() external view returns (uint256);

    /**
     * @dev Retrieves the random redeem data associated with a specific request ID
     * @param requestId_ The ID of the request to fetch data for
     * @return RandomRedeemData structure containing details of the redeem request associated with the given ID
     */
    function getRandomRedeemData(
        uint256 requestId_
    ) external view returns (RandomRedeemData memory);

    /**
     * @dev Fetches the last random request ID for a specific trait and token ID
     * @param trait_ Address of the given trait
     * @param tokenId_ The community token ID
     * @return Last random request ID
     */
    function getLastRandomRequestIdForTrait(
        GenericTrait trait_,
        uint32 tokenId_
    ) external view returns (uint256);

    /**
     * @dev Fetches the last random request ID associated with a user address (for buy)
     * @param userAddr_ Address of the user
     * @return Last random request ID
     */
    function getLastRandomRequestIdForUser(
        address userAddr_
    ) external view returns (uint256);

    /**
     * @dev Fetches all random request IDs associated with a specific trait and community token ID
     * @param trait_ The given trait
     * @param tokenId_ The token ID
     * @return Array containing all random request IDs for the trait and community token ID
     */
    function getAllRandomRequestIdsForTrait(
        GenericTrait trait_,
        uint32 tokenId_
    ) external view returns (uint256[] memory);

    /**
     * @dev Retrieves all random request IDs associated with a user address
     * @param userAddr_ Address of the user
     * @return Array containing all random request IDs for the user address
     */
    function getAllRandomRequestIdsForUser(
        address userAddr_
    ) external view returns (uint256[] memory);

    /**
     * @dev Obtains token information for a pseudo-random process based on a trait and token ID
     * @param trait_ The given trait
     * @param tokenId_ Specific token ID
     * @return TokenInfo structure containing details of the token for the trait and token ID
     */
    function getTokenInfoForPseudoRandomForTrait(
        GenericTrait trait_,
        uint32 tokenId_
    ) external view returns (TokenInfo memory);

    /**
     * @dev Retrieves token information for a pseudo-random process based on a buyer's address
     * @param buyer_ Address of the buyer
     * @return TokenInfo structure containing details of the token for the buyer
     */
    function getTokenInfoForPseudoRandomForBuy(
        address buyer_
    ) external view returns (TokenInfo memory);

    /**
     * @dev Obtains token information based on a given random number
     * @param randomNumber_ The random number to search by
     * @return tokenInfo_ TokenInfo structure related to the provided random number
     */
    function getTokenInfoByRandomNumber(
        uint256 randomNumber_
    ) external view returns (TokenInfo memory tokenInfo_);

    /**
     * @dev Determines the amount of NFTs that are available (without pending one)
     * @return Amount of free NFTs available
     */
    function getFreeNFTSupplyAmount() external view returns (uint256);

    /**
     * @dev Determines the account key based on a trait and token ID
     * @param trait_ Address of the given trait
     * @param tokenId_ Specific token ID
     * @return Account key derived from trait and token ID
     */
    function getTraitAccountKey(
        address trait_,
        uint32 tokenId_
    ) external view returns (bytes32);

    /**
     * @dev Determines the account key for a specific user address
     * @param userAddr_ Address of the user
     * @return Account key for the user
     */
    function getAccountKey(address userAddr_) external view returns (bytes32);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"galaxisRegistry_","type":"address"},{"internalType":"uint32","name":"communityId_","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint32","name":"communityId","type":"uint32"}],"name":"CommunityVaultsRegistryInvalidCommunityId","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryInvalidMsgSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"CommunityVaultsRegistryInvalidVaultId","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryInvalidVaultName","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryRandomProviderNotRegistred","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryUnauthorized","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryVaultCreationFailed","type":"error"},{"inputs":[],"name":"CommunityVaultsRegistryZeroVaultsGolden","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"address","name":"vaultAddr","type":"address"},{"indexed":false,"internalType":"enum ICommunityVaultsRegistry.VaultTypes","name":"vaultType","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"vaultTypeNonce","type":"uint256"}],"name":"VaultCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"VaultNameUpdated","type":"event"},{"inputs":[],"name":"COINS_VAULT_IMPL_KEY","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NFT_VAULT_IMPL_KEY","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RANDOM_CONSUMER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VAULTS_REGISTRY_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"communityId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"communityRegistry","outputs":[{"internalType":"contract CommunityRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"vaultName_","type":"string"},{"components":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"enum IGenericVault.TokenTypes","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"isAdding","type":"bool"}],"internalType":"struct IGenericVault.ReceivablesWhitelistEntry[]","name":"whitelistEntries","type":"tuple[]"},{"components":[{"internalType":"enum IGenericVault.RedeemModes","name":"redeemMode","type":"uint8"},{"internalType":"bool","name":"isAdding","type":"bool"}],"internalType":"struct IGenericVault.RedeemModesUpdateEntry[]","name":"redeemModesUpdateEntries","type":"tuple[]"},{"components":[{"components":[{"internalType":"enum IGenericVault.RedeemModes","name":"redeemMode","type":"uint8"},{"internalType":"bytes","name":"specialRedeemData","type":"bytes"}],"internalType":"struct IGenericVault.BaseBuySettings","name":"baseBuySettings","type":"tuple"},{"components":[{"internalType":"enum IGenericVault.BuyTypes","name":"buyType","type":"uint8"},{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"tokensAmount","type":"uint256"},{"internalType":"bool","name":"isBuyable","type":"bool"}],"internalType":"struct IGenericVault.BuyTypeData","name":"buyTypeData","type":"tuple"}],"internalType":"struct IGenericVault.BuyTypeInfo[]","name":"buyTypeInfoArr","type":"tuple[]"}],"internalType":"struct IGenericVault.BuySettingsInfo","name":"buySettingsInfo","type":"tuple"},{"internalType":"bool","name":"initialState","type":"bool"}],"internalType":"struct IGenericVault.GenericVaultInitParams","name":"initParams_","type":"tuple"}],"name":"createCoinsVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"vaultName_","type":"string"},{"components":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"enum IGenericVault.TokenTypes","name":"tokenType","type":"uint8"},{"internalType":"bool","name":"isAdding","type":"bool"}],"internalType":"struct IGenericVault.ReceivablesWhitelistEntry[]","name":"whitelistEntries","type":"tuple[]"},{"components":[{"internalType":"enum IGenericVault.RedeemModes","name":"redeemMode","type":"uint8"},{"internalType":"bool","name":"isAdding","type":"bool"}],"internalType":"struct IGenericVault.RedeemModesUpdateEntry[]","name":"redeemModesUpdateEntries","type":"tuple[]"},{"components":[{"components":[{"internalType":"enum IGenericVault.RedeemModes","name":"redeemMode","type":"uint8"},{"internalType":"bytes","name":"specialRedeemData","type":"bytes"}],"internalType":"struct IGenericVault.BaseBuySettings","name":"baseBuySettings","type":"tuple"},{"components":[{"internalType":"enum IGenericVault.BuyTypes","name":"buyType","type":"uint8"},{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"tokensAmount","type":"uint256"},{"internalType":"bool","name":"isBuyable","type":"bool"}],"internalType":"struct IGenericVault.BuyTypeData","name":"buyTypeData","type":"tuple"}],"internalType":"struct IGenericVault.BuyTypeInfo[]","name":"buyTypeInfoArr","type":"tuple[]"}],"internalType":"struct IGenericVault.BuySettingsInfo","name":"buySettingsInfo","type":"tuple"},{"internalType":"bool","name":"initialState","type":"bool"}],"internalType":"struct IGenericVault.GenericVaultInitParams","name":"initParams_","type":"tuple"}],"name":"createNFTVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"galaxisRegistry","outputs":[{"internalType":"contract IRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"implementation_","type":"address"},{"internalType":"enum ICommunityVaultsRegistry.VaultTypes","name":"vaultType_","type":"uint8"},{"internalType":"uint256","name":"vaultTypeNonce_","type":"uint256"}],"name":"getVaultAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ICommunityVaultsRegistry.VaultTypes","name":"vaultType_","type":"uint8"},{"internalType":"uint256","name":"vaultTypeNonce_","type":"uint256"}],"name":"getVaultAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultId_","type":"uint256"}],"name":"getVaultAddressById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"vaultIds_","type":"uint256[]"}],"name":"getVaultsInfo","outputs":[{"components":[{"components":[{"internalType":"address","name":"vaultAddr","type":"address"},{"internalType":"enum ICommunityVaultsRegistry.VaultTypes","name":"vaultType","type":"uint8"},{"internalType":"uint256","name":"vaultTypeNonce","type":"uint256"},{"internalType":"string","name":"vaultName","type":"string"}],"internalType":"struct ICommunityVaultsRegistry.BaseVaultInfo","name":"baseVaultInfo","type":"tuple"},{"components":[{"components":[{"internalType":"enum IGenericVault.RedeemModes","name":"redeemMode","type":"uint8"},{"internalType":"bytes","name":"specialRedeemData","type":"bytes"}],"internalType":"struct IGenericVault.BaseBuySettings","name":"baseBuySettings","type":"tuple"},{"components":[{"internalType":"enum IGenericVault.BuyTypes","name":"buyType","type":"uint8"},{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"tokensAmount","type":"uint256"},{"internalType":"bool","name":"isBuyable","type":"bool"}],"internalType":"struct IGenericVault.BuyTypeData","name":"buyTypeData","type":"tuple"}],"internalType":"struct IGenericVault.BuyTypeInfo[]","name":"buyTypeInfoArr","type":"tuple[]"}],"internalType":"struct IGenericVault.BuySettingsInfo","name":"buySettingsInfo","type":"tuple"}],"internalType":"struct ICommunityVaultsRegistry.VaultInfo[]","name":"resultArr_","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddr_","type":"address"}],"name":"hasVaultsRegistryAdminRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVaultsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vaultId_","type":"uint256"},{"internalType":"string","name":"newVaultName_","type":"string"}],"name":"updateVaultName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"vaultTypeNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

60a060405234801561001057600080fd5b506040516122f63803806122f683398101604081905261002f916101d9565b6001600160a01b0382166080819052604051631d2e660b60e21b815260206004820152600e60248201526d10d3d353555392551657d31254d560921b6044820152600091906374b9982c90606401602060405180830381865afa15801561009a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100be919061020c565b60405163d0f4a53760e01b815263ffffffff841660048201529091506000906001600160a01b0383169063d0f4a53790602401600060405180830381865afa15801561010e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101369190810190610244565b509150506001600160a01b03811661016d57604051631af56e0960e21b815263ffffffff8416600482015260240160405180910390fd5b6000805463ffffffff909416600160a01b026001600160c01b03199094166001600160a01b0390921691909117929092179091555061032e9050565b80516001600160a01b03811681146101c057600080fd5b919050565b805163ffffffff811681146101c057600080fd5b600080604083850312156101ec57600080fd5b6101f5836101a9565b9150610203602084016101c5565b90509250929050565b60006020828403121561021e57600080fd5b610227826101a9565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561025957600080fd5b83516001600160401b038082111561027057600080fd5b818601915086601f83011261028457600080fd5b8151818111156102965761029661022e565b604051601f8201601f19908116603f011681019083821181831017156102be576102be61022e565b816040528281526020935089848487010111156102da57600080fd5b600091505b828210156102fc57848201840151818301850152908301906102df565b60008484830101528097505050506103158187016101a9565b93505050610325604085016101c5565b90509250925092565b608051611f91610365600039600081816102760152818161061e01528181610759015281816108ee01526109a40152611f916000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063753a4d35116100a2578063a200ac8611610071578063a200ac86146102d9578063bfb6b5d0146102ec578063df61ed33146102ff578063e2fe2d7b1461031f578063f6e4d7261461034257600080fd5b8063753a4d351461025e5780637671114d146102715780637685aab4146102985780637f50861a146102ad57600080fd5b806352aeec22116100e957806352aeec22146101c457806354fd4d50146101eb5780635ad6234f146101f55780635f7b1ac21461021c5780636657e80b1461022f57600080fd5b806303f66daa1461011b5780630972d8d9146101445780631ca4a4a3146101825780633c2a61f1146101ad575b600080fd5b61012e6101293660046110d7565b61036b565b60405161013b91906111e8565b60405180910390f35b6101756040518060400160405280601281526020017111d3d311115397d0d3d25394d7d59055531560721b81525081565b60405161013b9190611341565b61019561019036600461139c565b6105cf565b6040516001600160a01b03909116815260200161013b565b6101b660015481565b60405190815260200161013b565b6101b67fb55ee8fa278d4d711a66e8ddff0365a4333380c8c6dbcdf8c74675b71e0e765981565b6378a467d16101b6565b6101b67fad916ab32ddd97c2dbac9528e0ea47783da7ea69f1c0d8f2cfec8f642034d8ba81565b61019561022a36600461139c565b61070c565b6101756040518060400160405280601081526020016f11d3d311115397d3919517d59055531560821b81525081565b61019561026c366004611434565b61080c565b6101957f000000000000000000000000000000000000000000000000000000000000000081565b6102ab6102a6366004611472565b610838565b005b6000546102c490600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161013b565b600054610195906001600160a01b031681565b6101956102fa3660046114bd565b610895565b6101b661030d3660046114e7565b60026020526000908152604090205481565b61033261032d36600461150a565b610a2e565b604051901515815260200161013b565b610195610350366004611527565b6000908152600360205260409020546001600160a01b031690565b6060816001600160401b0381111561038557610385611540565b6040519080825280602002602001820160405280156103be57816020015b6103ab61105c565b8152602001906001900390816103a35790505b50905060005b828110156105c8576040518060400160405280600360008787868181106103ed576103ed611556565b6020908102929092013583525081810192909252604090810160002081516080810190925280546001600160a01b03811683529192909190830190600160a01b900460ff1660018111156104435761044361114b565b60018111156104545761045461114b565b8152602001600182015481526020016002820180546104729061156c565b80601f016020809104026020016040519081016040528092919081815260200182805461049e9061156c565b80156104eb5780601f106104c0576101008083540402835291602001916104eb565b820191906000526020600020905b8154815290600101906020018083116104ce57829003601f168201915b50505050508152505081526020016003600087878681811061050f5761050f611556565b60209081029290920135835250810191909152604001600020546001600160a01b0316637b977a7d61053f610a60565b6040518263ffffffff1660e01b815260040161055b91906115a6565b600060405180830381865afa158015610578573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105a09190810190611797565b8152508282815181106105b5576105b5611556565b60209081029190910101526001016103c4565b5092915050565b60006105d9610b53565b604080518082018252601281527111d3d311115397d0d3d25394d7d59055531560721b60208201529051631d2e660b60e21b815260009161069c916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916374b9982c916106529190600401611341565b602060405180830381865afa15801561066f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069391906118b6565b60018787610b7b565b6000546040516350f0546760e01b81529192506001600160a01b03808416926350f05467926106d19216908790600401611ba2565b600060405180830381600087803b1580156106eb57600080fd5b505af11580156106ff573d6000803e3d6000fd5b5092979650505050505050565b6000610716610b53565b604080518082018252601081526f11d3d311115397d3919517d59055531560821b60208201529051631d2e660b60e21b81526000916107d7916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916374b9982c9161078d9190600401611341565b602060405180830381865afa1580156107aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ce91906118b6565b60008787610b7b565b60005460405163180293c760e21b81529192506001600160a01b038084169263600a4f1c926106d19216908790600401611ba2565b60008061081a858585610e1e565b8051602090910120905061082f600082610e7d565b95945050505050565b610840610b53565b600083815260036020526040902060020161085c828483611ccf565b506040518381527f6782e4d62cf874ac43dab58dffd78f3248e6ecd5aa2f7ac67f0838fbef1aff5b9060200160405180910390a1505050565b600080808460018111156108ab576108ab61114b565b1461096857604080518082018252601281527111d3d311115397d0d3d25394d7d59055531560721b60208201529051631d2e660b60e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916374b9982c916109229190600401611341565b602060405180830381865afa15801561093f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096391906118b6565b610a19565b604080518082018252601081526f11d3d311115397d3919517d59055531560821b60208201529051631d2e660b60e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916374b9982c916109d89190600401611341565b602060405180830381865afa1580156109f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1991906118b6565b9050610a2681858561080c565b949350505050565b6000610a5a7fad916ab32ddd97c2dbac9528e0ea47783da7ea69f1c0d8f2cfec8f642034d8ba83610edc565b92915050565b60408051600380825260808201909252606091602082018380368337019050509050600081600081518110610a9757610a97611556565b60200260200101906002811115610ab057610ab061114b565b90816002811115610ac357610ac361114b565b81525050600181600181518110610adc57610adc611556565b60200260200101906002811115610af557610af561114b565b90816002811115610b0857610b0861114b565b81525050600281600281518110610b2157610b21611556565b60200260200101906002811115610b3a57610b3a61114b565b90816002811115610b4d57610b4d61114b565b90525090565b610b5c33610a2e565b610b7957604051631cde339560e21b815260040160405180910390fd5b565b60006001600160a01b038516610ba4576040516363d4af3960e01b815260040160405180910390fd5b6000829003610bc657604051630f570aad60e21b815260040160405180910390fd5b600060026000866001811115610bde57610bde61114b565b60ff16815260208101919091526040016000908120805491610bff83611d8f565b9190505590506000610c12878784610e1e565b90506000610c21818084610f52565b90506001600160a01b038116610c4a57604051637896550360e11b815260040160405180910390fd5b6001805460009182610c5b83611d8f565b9190505590506040518060800160405280836001600160a01b03168152602001896001811115610c8d57610c8d61114b565b815260200185815260200188888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152600360209081526040909120835181546001600160a01b039091166001600160a01b031982168117835592850151919350909183916001600160a81b03191617600160a01b836001811115610d2a57610d2a61114b565b02179055506040820151600182015560608201516002820190610d4d9082611db6565b5050600054604051632f2ff15d60e01b81527fb55ee8fa278d4d711a66e8ddff0365a4333380c8c6dbcdf8c74675b71e0e765960048201526001600160a01b0385811660248301529091169150632f2ff15d90604401600060405180830381600087803b158015610dbd57600080fd5b505af1158015610dd1573d6000803e3d6000fd5b505050507ff05b5cfff5f684799218b8134d5d0c1cbeb310e8fc7d26e0ef92e2c792b02ec681838a87604051610e0a9493929190611e75565b60405180910390a150979650505050505050565b6000546040516060918591610e4791600160a01b900463ffffffff169086908690602001611ea7565b60408051601f1981840301815290829052610e659291602001611ecf565b60405160208183030381529060405290509392505050565b604080516001600160f81b03196020808301919091526bffffffffffffffffffffffff193060601b16602183015260358201859052605580830185905283518084039091018152607590920190925280519101206000905b9392505050565b60008054604051632474521560e21b8152600481018590526001600160a01b038481166024830152909116906391d1485490604401602060405180830381865afa158015610f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed59190611f3e565b60008084471015610faa5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b8251600003610ffb5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610fa1565b8383516020850187f590506001600160a01b038116610a265760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610fa1565b6040518060400160405280611093604080516080810190915260008082526020820190815260200160008152602001606081525090565b81526020016110a06110a5565b905290565b60405180604001604052806110b86110c5565b8152602001606081525090565b604080518082019091528060006110b8565b600080602083850312156110ea57600080fd5b82356001600160401b038082111561110157600080fd5b818501915085601f83011261111557600080fd5b81358181111561112457600080fd5b8660208260051b850101111561113957600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052602160045260246000fd5b600281106111715761117161114b565b9052565b60005b83811015611190578181015183820152602001611178565b50506000910152565b600081518084526111b1816020860160208601611175565b601f01601f19169290920160200192915050565b600581106111715761117161114b565b600381106111e5576111e561114b565b50565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561133357888303603f190185528151805187855280516001600160a01b039081168987015289820151606061124a81890183611161565b8a8401519150608082818a01528185015194508060a08a015261127060c08a0186611199565b94508c86015195508885038d8a0152855192508b85526112938c860184516111c5565b8c83015192508b828601526112aa81860184611199565b958d0151858703958e01959095528451808752948d01958d0194600093505b8084101561131a57865180516112de816111d5565b87528e0151805186168f880152808f01518e8801528d81015184880152830151151582870152958d019560a090950194600193909301926112c9565b505050978a01975090945050509086019060010161120f565b509098975050505050505050565b602081526000610ed56020830184611199565b60008083601f84011261136657600080fd5b5081356001600160401b0381111561137d57600080fd5b60208301915083602082850101111561139557600080fd5b9250929050565b6000806000604084860312156113b157600080fd5b83356001600160401b03808211156113c857600080fd5b6113d487838801611354565b909550935060208601359150808211156113ed57600080fd5b5084016080818703121561140057600080fd5b809150509250925092565b6001600160a01b03811681146111e557600080fd5b80356002811061142f57600080fd5b919050565b60008060006060848603121561144957600080fd5b83356114548161140b565b925061146260208501611420565b9150604084013590509250925092565b60008060006040848603121561148757600080fd5b8335925060208401356001600160401b038111156114a457600080fd5b6114b086828701611354565b9497909650939450505050565b600080604083850312156114d057600080fd5b6114d983611420565b946020939093013593505050565b6000602082840312156114f957600080fd5b813560ff81168114610ed557600080fd5b60006020828403121561151c57600080fd5b8135610ed58161140b565b60006020828403121561153957600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061158057607f821691505b6020821081036115a057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252825182820181905260009190848201906040850190845b818110156115e75783516115d5816111d5565b835292840192918401916001016115c2565b50909695505050505050565b604080519081016001600160401b038111828210171561161557611615611540565b60405290565b604051608081016001600160401b038111828210171561161557611615611540565b604051601f8201601f191681016001600160401b038111828210171561166557611665611540565b604052919050565b600581106111e557600080fd5b600381106111e557600080fd5b80151581146111e557600080fd5b600082601f8301126116a657600080fd5b815160206001600160401b038211156116c1576116c1611540565b6116cf818360051b0161163d565b82815260a092830285018201928282019190878511156116ee57600080fd5b8387015b8581101561178a578089038281121561170b5760008081fd5b6117136115f3565b825161171e8161167a565b81526080601f1983018113156117345760008081fd5b61173c61161b565b92508784015161174b8161140b565b83526040848101518985015260608086015182860152918501519161176f83611687565b840191909152508087019190915284529284019281016116f2565b5090979650505050505050565b600060208083850312156117aa57600080fd5b82516001600160401b03808211156117c157600080fd5b90840190604082870312156117d557600080fd5b6117dd6115f3565b8251828111156117ec57600080fd5b8301604081890312156117fe57600080fd5b6118066115f3565b81516118118161166d565b8152818601518481111561182457600080fd5b80830192505088601f83011261183957600080fd5b81518481111561184b5761184b611540565b61185d601f8201601f1916880161163d565b8181528a8883860101111561187157600080fd5b611880828983018a8701611175565b8288015250825250828401518281111561189957600080fd5b6118a588828601611695565b948201949094529695505050505050565b6000602082840312156118c857600080fd5b8151610ed58161140b565b803561142f81611687565b8183526000602080850194508260005b8581101561194e5781356119018161140b565b6001600160a01b03168752818301356119198161167a565b611922816111d5565b8784015260408281013561193581611687565b15159088015260609687019691909101906001016118ee565b509495945050505050565b6000808335601e1984360301811261197057600080fd5b83016020810192503590506001600160401b0381111561198f57600080fd5b8060061b360382131561139557600080fd5b8183526000602080850194508260005b8581101561194e5781356119c48161166d565b6119ce88826111c5565b50828201356119dc81611687565b15158784015260409687019691909101906001016119b1565b60008235603e19833603018112611a0b57600080fd5b90910192915050565b6000808335601e19843603018112611a2b57600080fd5b83016020810192503590506001600160401b03811115611a4a57600080fd5b60a08102360382131561139557600080fd5b8183526000602080850194508260005b8581101561194e578135611a7f8161167a565b611a88816111d5565b875281830135611a978161140b565b6001600160a01b0316878401526040828101359088015260608083013590880152608080830135611ac781611687565b15159088015260a0968701969190910190600101611a6c565b6000611aec82836119f5565b604084528035611afb8161166d565b611b0860408601826111c5565b506020810135601e19823603018112611b2057600080fd5b016020810190356001600160401b03811115611b3b57600080fd5b803603821315611b4a57600080fd5b60406060860152806080860152808260a0870137600085820160a00152601f01601f191684019050611b7f6020840184611a14565b60a0868403016020870152611b9860a084018284611a5c565b9695505050505050565b6001600160a01b0383168152604060208201526000823536849003601e19018112611bcc57600080fd5b83016020810190356001600160401b03811115611be857600080fd5b606081023603821315611bfa57600080fd5b60806040850152611c0f60c0850182846118de565b915050611c1f6020850185611959565b603f1980868503016060870152611c378483856119a1565b9350611c4660408801886119f5565b9250808685030160808701525050611c5e8282611ae0565b915050611c6d606085016118d3565b80151560a085015250949350505050565b601f821115611cca576000816000526020600020601f850160051c81016020861015611ca75750805b601f850160051c820191505b81811015611cc657828155600101611cb3565b5050505b505050565b6001600160401b03831115611ce657611ce6611540565b611cfa83611cf4835461156c565b83611c7e565b6000601f841160018114611d2e5760008515611d165750838201355b600019600387901b1c1916600186901b178355611d88565b600083815260209020601f19861690835b82811015611d5f5786850135825560209485019460019092019101611d3f565b5086821015611d7c5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b600060018201611daf57634e487b7160e01b600052601160045260246000fd5b5060010190565b81516001600160401b03811115611dcf57611dcf611540565b611de381611ddd845461156c565b84611c7e565b602080601f831160018114611e185760008415611e005750858301515b600019600386901b1c1916600185901b178555611cc6565b600085815260208120601f198616915b82811015611e4757888601518255948401946001909101908401611e28565b5085821015611e655787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8481526001600160a01b038416602082015260808101611e986040830185611161565b82606083015295945050505050565b63ffffffff8416815260608101611ec16020830185611161565b826040830152949350505050565b733d60ad80600a3d3981f3363d3d373d3d3d363d7360601b8152606083901b6bffffffffffffffffffffffff191660148201526e5af43d82803e903d91602b57fd5bf360881b60288201528151600090611f30816037850160208701611175565b919091016037019392505050565b600060208284031215611f5057600080fd5b8151610ed58161168756fea26469706673582212202d0d5cb7fbeeda18c66a6b05c9de7d1f68564807b4b8935237fd92b250d07cb964736f6c63430008190033000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae200000000000000000000000000000000000000000000000000000000000000c4

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063753a4d35116100a2578063a200ac8611610071578063a200ac86146102d9578063bfb6b5d0146102ec578063df61ed33146102ff578063e2fe2d7b1461031f578063f6e4d7261461034257600080fd5b8063753a4d351461025e5780637671114d146102715780637685aab4146102985780637f50861a146102ad57600080fd5b806352aeec22116100e957806352aeec22146101c457806354fd4d50146101eb5780635ad6234f146101f55780635f7b1ac21461021c5780636657e80b1461022f57600080fd5b806303f66daa1461011b5780630972d8d9146101445780631ca4a4a3146101825780633c2a61f1146101ad575b600080fd5b61012e6101293660046110d7565b61036b565b60405161013b91906111e8565b60405180910390f35b6101756040518060400160405280601281526020017111d3d311115397d0d3d25394d7d59055531560721b81525081565b60405161013b9190611341565b61019561019036600461139c565b6105cf565b6040516001600160a01b03909116815260200161013b565b6101b660015481565b60405190815260200161013b565b6101b67fb55ee8fa278d4d711a66e8ddff0365a4333380c8c6dbcdf8c74675b71e0e765981565b6378a467d16101b6565b6101b67fad916ab32ddd97c2dbac9528e0ea47783da7ea69f1c0d8f2cfec8f642034d8ba81565b61019561022a36600461139c565b61070c565b6101756040518060400160405280601081526020016f11d3d311115397d3919517d59055531560821b81525081565b61019561026c366004611434565b61080c565b6101957f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae281565b6102ab6102a6366004611472565b610838565b005b6000546102c490600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161013b565b600054610195906001600160a01b031681565b6101956102fa3660046114bd565b610895565b6101b661030d3660046114e7565b60026020526000908152604090205481565b61033261032d36600461150a565b610a2e565b604051901515815260200161013b565b610195610350366004611527565b6000908152600360205260409020546001600160a01b031690565b6060816001600160401b0381111561038557610385611540565b6040519080825280602002602001820160405280156103be57816020015b6103ab61105c565b8152602001906001900390816103a35790505b50905060005b828110156105c8576040518060400160405280600360008787868181106103ed576103ed611556565b6020908102929092013583525081810192909252604090810160002081516080810190925280546001600160a01b03811683529192909190830190600160a01b900460ff1660018111156104435761044361114b565b60018111156104545761045461114b565b8152602001600182015481526020016002820180546104729061156c565b80601f016020809104026020016040519081016040528092919081815260200182805461049e9061156c565b80156104eb5780601f106104c0576101008083540402835291602001916104eb565b820191906000526020600020905b8154815290600101906020018083116104ce57829003601f168201915b50505050508152505081526020016003600087878681811061050f5761050f611556565b60209081029290920135835250810191909152604001600020546001600160a01b0316637b977a7d61053f610a60565b6040518263ffffffff1660e01b815260040161055b91906115a6565b600060405180830381865afa158015610578573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105a09190810190611797565b8152508282815181106105b5576105b5611556565b60209081029190910101526001016103c4565b5092915050565b60006105d9610b53565b604080518082018252601281527111d3d311115397d0d3d25394d7d59055531560721b60208201529051631d2e660b60e21b815260009161069c916001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216916374b9982c916106529190600401611341565b602060405180830381865afa15801561066f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069391906118b6565b60018787610b7b565b6000546040516350f0546760e01b81529192506001600160a01b03808416926350f05467926106d19216908790600401611ba2565b600060405180830381600087803b1580156106eb57600080fd5b505af11580156106ff573d6000803e3d6000fd5b5092979650505050505050565b6000610716610b53565b604080518082018252601081526f11d3d311115397d3919517d59055531560821b60208201529051631d2e660b60e21b81526000916107d7916001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216916374b9982c9161078d9190600401611341565b602060405180830381865afa1580156107aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ce91906118b6565b60008787610b7b565b60005460405163180293c760e21b81529192506001600160a01b038084169263600a4f1c926106d19216908790600401611ba2565b60008061081a858585610e1e565b8051602090910120905061082f600082610e7d565b95945050505050565b610840610b53565b600083815260036020526040902060020161085c828483611ccf565b506040518381527f6782e4d62cf874ac43dab58dffd78f3248e6ecd5aa2f7ac67f0838fbef1aff5b9060200160405180910390a1505050565b600080808460018111156108ab576108ab61114b565b1461096857604080518082018252601281527111d3d311115397d0d3d25394d7d59055531560721b60208201529051631d2e660b60e21b81526001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216916374b9982c916109229190600401611341565b602060405180830381865afa15801561093f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096391906118b6565b610a19565b604080518082018252601081526f11d3d311115397d3919517d59055531560821b60208201529051631d2e660b60e21b81526001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216916374b9982c916109d89190600401611341565b602060405180830381865afa1580156109f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1991906118b6565b9050610a2681858561080c565b949350505050565b6000610a5a7fad916ab32ddd97c2dbac9528e0ea47783da7ea69f1c0d8f2cfec8f642034d8ba83610edc565b92915050565b60408051600380825260808201909252606091602082018380368337019050509050600081600081518110610a9757610a97611556565b60200260200101906002811115610ab057610ab061114b565b90816002811115610ac357610ac361114b565b81525050600181600181518110610adc57610adc611556565b60200260200101906002811115610af557610af561114b565b90816002811115610b0857610b0861114b565b81525050600281600281518110610b2157610b21611556565b60200260200101906002811115610b3a57610b3a61114b565b90816002811115610b4d57610b4d61114b565b90525090565b610b5c33610a2e565b610b7957604051631cde339560e21b815260040160405180910390fd5b565b60006001600160a01b038516610ba4576040516363d4af3960e01b815260040160405180910390fd5b6000829003610bc657604051630f570aad60e21b815260040160405180910390fd5b600060026000866001811115610bde57610bde61114b565b60ff16815260208101919091526040016000908120805491610bff83611d8f565b9190505590506000610c12878784610e1e565b90506000610c21818084610f52565b90506001600160a01b038116610c4a57604051637896550360e11b815260040160405180910390fd5b6001805460009182610c5b83611d8f565b9190505590506040518060800160405280836001600160a01b03168152602001896001811115610c8d57610c8d61114b565b815260200185815260200188888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152600360209081526040909120835181546001600160a01b039091166001600160a01b031982168117835592850151919350909183916001600160a81b03191617600160a01b836001811115610d2a57610d2a61114b565b02179055506040820151600182015560608201516002820190610d4d9082611db6565b5050600054604051632f2ff15d60e01b81527fb55ee8fa278d4d711a66e8ddff0365a4333380c8c6dbcdf8c74675b71e0e765960048201526001600160a01b0385811660248301529091169150632f2ff15d90604401600060405180830381600087803b158015610dbd57600080fd5b505af1158015610dd1573d6000803e3d6000fd5b505050507ff05b5cfff5f684799218b8134d5d0c1cbeb310e8fc7d26e0ef92e2c792b02ec681838a87604051610e0a9493929190611e75565b60405180910390a150979650505050505050565b6000546040516060918591610e4791600160a01b900463ffffffff169086908690602001611ea7565b60408051601f1981840301815290829052610e659291602001611ecf565b60405160208183030381529060405290509392505050565b604080516001600160f81b03196020808301919091526bffffffffffffffffffffffff193060601b16602183015260358201859052605580830185905283518084039091018152607590920190925280519101206000905b9392505050565b60008054604051632474521560e21b8152600481018590526001600160a01b038481166024830152909116906391d1485490604401602060405180830381865afa158015610f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed59190611f3e565b60008084471015610faa5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b8251600003610ffb5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610fa1565b8383516020850187f590506001600160a01b038116610a265760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610fa1565b6040518060400160405280611093604080516080810190915260008082526020820190815260200160008152602001606081525090565b81526020016110a06110a5565b905290565b60405180604001604052806110b86110c5565b8152602001606081525090565b604080518082019091528060006110b8565b600080602083850312156110ea57600080fd5b82356001600160401b038082111561110157600080fd5b818501915085601f83011261111557600080fd5b81358181111561112457600080fd5b8660208260051b850101111561113957600080fd5b60209290920196919550909350505050565b634e487b7160e01b600052602160045260246000fd5b600281106111715761117161114b565b9052565b60005b83811015611190578181015183820152602001611178565b50506000910152565b600081518084526111b1816020860160208601611175565b601f01601f19169290920160200192915050565b600581106111715761117161114b565b600381106111e5576111e561114b565b50565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561133357888303603f190185528151805187855280516001600160a01b039081168987015289820151606061124a81890183611161565b8a8401519150608082818a01528185015194508060a08a015261127060c08a0186611199565b94508c86015195508885038d8a0152855192508b85526112938c860184516111c5565b8c83015192508b828601526112aa81860184611199565b958d0151858703958e01959095528451808752948d01958d0194600093505b8084101561131a57865180516112de816111d5565b87528e0151805186168f880152808f01518e8801528d81015184880152830151151582870152958d019560a090950194600193909301926112c9565b505050978a01975090945050509086019060010161120f565b509098975050505050505050565b602081526000610ed56020830184611199565b60008083601f84011261136657600080fd5b5081356001600160401b0381111561137d57600080fd5b60208301915083602082850101111561139557600080fd5b9250929050565b6000806000604084860312156113b157600080fd5b83356001600160401b03808211156113c857600080fd5b6113d487838801611354565b909550935060208601359150808211156113ed57600080fd5b5084016080818703121561140057600080fd5b809150509250925092565b6001600160a01b03811681146111e557600080fd5b80356002811061142f57600080fd5b919050565b60008060006060848603121561144957600080fd5b83356114548161140b565b925061146260208501611420565b9150604084013590509250925092565b60008060006040848603121561148757600080fd5b8335925060208401356001600160401b038111156114a457600080fd5b6114b086828701611354565b9497909650939450505050565b600080604083850312156114d057600080fd5b6114d983611420565b946020939093013593505050565b6000602082840312156114f957600080fd5b813560ff81168114610ed557600080fd5b60006020828403121561151c57600080fd5b8135610ed58161140b565b60006020828403121561153957600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061158057607f821691505b6020821081036115a057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252825182820181905260009190848201906040850190845b818110156115e75783516115d5816111d5565b835292840192918401916001016115c2565b50909695505050505050565b604080519081016001600160401b038111828210171561161557611615611540565b60405290565b604051608081016001600160401b038111828210171561161557611615611540565b604051601f8201601f191681016001600160401b038111828210171561166557611665611540565b604052919050565b600581106111e557600080fd5b600381106111e557600080fd5b80151581146111e557600080fd5b600082601f8301126116a657600080fd5b815160206001600160401b038211156116c1576116c1611540565b6116cf818360051b0161163d565b82815260a092830285018201928282019190878511156116ee57600080fd5b8387015b8581101561178a578089038281121561170b5760008081fd5b6117136115f3565b825161171e8161167a565b81526080601f1983018113156117345760008081fd5b61173c61161b565b92508784015161174b8161140b565b83526040848101518985015260608086015182860152918501519161176f83611687565b840191909152508087019190915284529284019281016116f2565b5090979650505050505050565b600060208083850312156117aa57600080fd5b82516001600160401b03808211156117c157600080fd5b90840190604082870312156117d557600080fd5b6117dd6115f3565b8251828111156117ec57600080fd5b8301604081890312156117fe57600080fd5b6118066115f3565b81516118118161166d565b8152818601518481111561182457600080fd5b80830192505088601f83011261183957600080fd5b81518481111561184b5761184b611540565b61185d601f8201601f1916880161163d565b8181528a8883860101111561187157600080fd5b611880828983018a8701611175565b8288015250825250828401518281111561189957600080fd5b6118a588828601611695565b948201949094529695505050505050565b6000602082840312156118c857600080fd5b8151610ed58161140b565b803561142f81611687565b8183526000602080850194508260005b8581101561194e5781356119018161140b565b6001600160a01b03168752818301356119198161167a565b611922816111d5565b8784015260408281013561193581611687565b15159088015260609687019691909101906001016118ee565b509495945050505050565b6000808335601e1984360301811261197057600080fd5b83016020810192503590506001600160401b0381111561198f57600080fd5b8060061b360382131561139557600080fd5b8183526000602080850194508260005b8581101561194e5781356119c48161166d565b6119ce88826111c5565b50828201356119dc81611687565b15158784015260409687019691909101906001016119b1565b60008235603e19833603018112611a0b57600080fd5b90910192915050565b6000808335601e19843603018112611a2b57600080fd5b83016020810192503590506001600160401b03811115611a4a57600080fd5b60a08102360382131561139557600080fd5b8183526000602080850194508260005b8581101561194e578135611a7f8161167a565b611a88816111d5565b875281830135611a978161140b565b6001600160a01b0316878401526040828101359088015260608083013590880152608080830135611ac781611687565b15159088015260a0968701969190910190600101611a6c565b6000611aec82836119f5565b604084528035611afb8161166d565b611b0860408601826111c5565b506020810135601e19823603018112611b2057600080fd5b016020810190356001600160401b03811115611b3b57600080fd5b803603821315611b4a57600080fd5b60406060860152806080860152808260a0870137600085820160a00152601f01601f191684019050611b7f6020840184611a14565b60a0868403016020870152611b9860a084018284611a5c565b9695505050505050565b6001600160a01b0383168152604060208201526000823536849003601e19018112611bcc57600080fd5b83016020810190356001600160401b03811115611be857600080fd5b606081023603821315611bfa57600080fd5b60806040850152611c0f60c0850182846118de565b915050611c1f6020850185611959565b603f1980868503016060870152611c378483856119a1565b9350611c4660408801886119f5565b9250808685030160808701525050611c5e8282611ae0565b915050611c6d606085016118d3565b80151560a085015250949350505050565b601f821115611cca576000816000526020600020601f850160051c81016020861015611ca75750805b601f850160051c820191505b81811015611cc657828155600101611cb3565b5050505b505050565b6001600160401b03831115611ce657611ce6611540565b611cfa83611cf4835461156c565b83611c7e565b6000601f841160018114611d2e5760008515611d165750838201355b600019600387901b1c1916600186901b178355611d88565b600083815260209020601f19861690835b82811015611d5f5786850135825560209485019460019092019101611d3f565b5086821015611d7c5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b600060018201611daf57634e487b7160e01b600052601160045260246000fd5b5060010190565b81516001600160401b03811115611dcf57611dcf611540565b611de381611ddd845461156c565b84611c7e565b602080601f831160018114611e185760008415611e005750858301515b600019600386901b1c1916600185901b178555611cc6565b600085815260208120601f198616915b82811015611e4757888601518255948401946001909101908401611e28565b5085821015611e655787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8481526001600160a01b038416602082015260808101611e986040830185611161565b82606083015295945050505050565b63ffffffff8416815260608101611ec16020830185611161565b826040830152949350505050565b733d60ad80600a3d3981f3363d3d373d3d3d363d7360601b8152606083901b6bffffffffffffffffffffffff191660148201526e5af43d82803e903d91602b57fd5bf360881b60288201528151600090611f30816037850160208701611175565b919091016037019392505050565b600060208284031215611f5057600080fd5b8151610ed58161168756fea26469706673582212202d0d5cb7fbeeda18c66a6b05c9de7d1f68564807b4b8935237fd92b250d07cb964736f6c63430008190033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae200000000000000000000000000000000000000000000000000000000000000c4

-----Decoded View---------------
Arg [0] : galaxisRegistry_ (address): 0xdBD9608fBcA959828C1615d29AEb3dc872d40Ae2
Arg [1] : communityId_ (uint32): 196

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae2
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000c4


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ 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.