{
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "$id": "https://raw.githubusercontent.com/merokudao/dapp-store-registry/main/src/schemas/merokuDappStore.dAppSchema.json",
    "title": "dApp Schema",
    "description": "A schema for dapps for dApp Registry",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "description": "The name of the dApp. This is what is shown on listing",
            "maxLength": 100
        },
        "description": {
            "type": "string",
            "description": "A detailed description of the dApp"
        },
        "external_url": {
            "type": "string",
            "description": "The URL of the dApp. This is used by OpenSea. This should be set to Meroku Protocol Explorer.",
            "format": "uri",
            "pattern": "^(https?|http?|ipfs?)://",
            "minLength": 1
        },
        "image": {
            "type": "string",
            "format": "uri",
            "pattern": "^(https?|http?|ipfs?)://",
            "minLength": 1,
            "description": "A URL to the logo of the dApp. Should be square and 512x512 in PNG format. Used by OpenSea. This should automatically be set to the app logo from images field."
        },
        "attributes": {
            "type": "array",
            "items": {
                "type": "object",
                "required": ["trait_type", "value"],
                "properties": {
                    "display_type": {
                        "type": "string",
                        "description": "The display type of the trait"
                    },
                    "trait_type": {
                        "type": "string",
                        "description": "The trait type of the trait"
                    },
                    "value": {
                        "type": "string",
                        "description": "The value of the trait type"
                    }
                }
            }
        },
        "appUrl": {
            "type": "string",
            "description": "The URL of the dApp",
            "format": "uri",
            "pattern": "^(https?|http?|ipfs?)://",
            "minLength": 1
        },
        "downloadBaseUrls": {
            "$ref": "merokuDappStore.dAppDownloadBaseUrlsSchema.json"
        },
        "contracts": {
            "type": "array",
            "items": {
                "type": "object",
                "required": ["address", "chainId"],
                "properties": {
                    "address": {
                        "type": "string",
                        "description": "The address of the contract"
                    },
                    "chainId": {
                        "type": "string",
                        "description": "The chainId of the contract"
                    }
                }
            }
        },
        "images": { "$ref": "merokuDappStore.dAppImagesSchema.json" },
        "repoUrl": {
            "type": "string",
            "description": "If this is in OpenSource, the URL of the repository",
            "format": "uri",
            "pattern": "^(https?|http?|ipfs?)://",
            "minLength": 1
        },
        "dappId": {
            "type": "string",
            "description": "A Unique ID for each dApp."
        },
        "minAge": {
            "type": "integer",
            "description": "The min age of user who should access this dApp",
            "exclusiveMinimum": 3
        },
        "isForMatureAudience": {
            "type": "boolean",
            "description": "Boolean to signify if the dApp is for mature audience"
        },
        "isSelfModerated": {
            "type": "boolean",
            "description": "Boolean to signify if the dApp developers have a moderation in place for the content posted/generated by the dApp or it's users"
        },
        "language": {
            "type": "array",
            "items": {
                "type": "string"
            },
            "minItems": 1,
            "description": "A string in ISO-639-1 which signifies the language of the dApp"
        },
        "version": {
            "type": "string",
            "description": "The version of the dApp that is available on the dApp store"
        },
        "versionCode": {
            "type": "string",
            "description": "The version code of the dapp that is available on dApp store",
            "minLength": 1
        },
        "isListed": {
            "type": "boolean",
            "description": "Boolean to signify if the dApp is listed on the dApp store"
        },
        "listDate": {
            "type": "string",
            "format": "date",
            "description": "The date on which this dApp is listed on dApp store. This date can be a future date as well. This can not be in past."
        },
        "expiryDate": {
            "type": "string",
            "format": "date",
            "description": "The date on which this dApp name will expiry. This date will be calculate based on dapp name registation date with addition of purchased time."
        },
        "availableOnPlatform": {
            "type": "array",
            "items": {
                "type": "string",
                "enum": ["ios", "web", "android"]
            },
            "minItems": 1,
            "description": "A string signifying if the dApp is available on which platform - web, iOS, android"
        },
        "geoRestrictions": {
            "type": "object",
            "description": "A list of countries where the dApp is available or unavailable. If this is not present, the dApp is available everywhere. If this is present, then one of either allowedCountries or blockedCountries should be present. If both are present, then the dApp is available in allowedCountries and unavailable in blockedCountries. The name of countries should be in ISO-3661-1 Alpha-2 Code.",
            "properties": {
                "allowedCountries": {
                    "type": "array",
                    "description": "A list of countries where the dApp is available",
                    "items": {
                        "type": "string"
                    }
                },
                "blockedCountries": {
                    "type": "array",
                    "description": "A list of countries where the dApp is unavailable",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "developer": { "$ref": "merokuDappStore.developerSchema.json" },
        "tags": {
            "type": "array",
            "items": {
                "type": "string"
            },
            "minItems": 1,
            "uniqueItems": true
        },
        "chains": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
                "type": "integer"
            }
        },
        "category": {
            "type": "string",
            "description": "The category of the dApp. You can assign one category to your dApp. The category you select is particularly important for your app’s discoverability on the dApp Store. This will be the category in which the app appears when users browse the dApp Store or filter search results, and it determines placement on the dApps tab or Games",
            "enum": [
                "books",
                "business",
                "finance",
                "developer-tools",
                "education",
                "entertainment",
                "food-and-drink",
                "games",
                "gambling",
                "health-and-fitness",
                "kids",
                "lifestyle",
                "news",
                "nft",
                "personalization",
                "photography",
                "productivity",
                "shopping",
                "social-networking",
                "sports",
                "travel",
                "utilities",
                "ai"
            ]
        },
        "subCategory": {
            "type": "string",
            "description": "The sub-category of the dapp. You can assign one sub-category to your dApp. The category you select is particularly important for your app's discoverability on the dApp Store. This will be the category in which the app appears when users browse the dApp Store or filter search results, and it determines placement on the dApps tab or Games"
        },
        "packageId": {
            "type": "string",
            "description": "The package id of the dapp",
            "minLength": 3,
            "maxLength": 100
        },
        "walletApiVersion": {
            "type": "array",
            "description": "The wallet api version supported by the dapp",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "minted": {
            "type": "boolean",
            "description": "The minted status will be used to denote if a dapp is claimed by owner or not.",
            "default": false
        },
        "referredBy": {
            "type": "object",
            "description": "The details of a vendor, who have referred this dapp to dapp registry",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "The name of the vendor."
                },
                "url": {
                    "type": "string",
                    "description": "The website link of the vendor."
                }
            }
        },
        "privacyPolicyUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^(https?|http?|ipfs?)://",
            "minLength": 1
        },
        "support": {
            "type": "object",
            "properties": {
                "url": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                },
                "email": {
                    "type": "string",
                    "format": "email"
                }
            }
        },
        "social": {
            "type": "object",
            "properties": {
                "twitterUrl": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                },
                "discordUrl": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                },
                "instagramUrl": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                },
                "facebookUrl": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                },
                "other": {
                    "type": "string",
                    "format": "uri",
                    "pattern": "^(https?|http?|ipfs?)://",
                    "minLength": 1
                }
            }
        },
        "cdn": {
            "images": { "$ref": "merokuDappStore.dAppImagesSchema.json" },
            "downloadBaseUrls": {
                "$ref": "merokuDappStore.dAppDownloadBaseUrlsSchema.json"
            }
        },
        "whitelistedForStores": {
            "type": "array",
            "items": {
                "type": "string"
            },
            "minItems": 1,
            "uniqueItems": true
        },
        "tokens": {
            "type": "array",
            "items": {
                "type": "object",
                "required": ["name", "symbol", "address", "chains"],
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "The name of the token"
                    },
                    "symbol": {
                        "type": "string",
                        "description": "The symbol of the token"
                    },
                    "address": {
                        "type": "string",
                        "description": "The address of the token"
                    },
                    "chains": {
                        "type": "array",
                        "minItems": 1,
                        "uniqueItems": true,
                        "items": {
                            "type": "integer"
                        }
                    }
                }
            }
        }
    },
    "allOf": [
        {
            "if": {
                "properties": {
                    "category": { "const": "books" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["audiobooks", "document-readers", "ebooks"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "business" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "communication",
                            "decentralized-business-tools",
                            "human-resources",
                            "project-management"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "developer tools" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "analytics",
                            "block-explorer",
                            "bridges",
                            "developer-infra",
                            "discovery-tool",
                            "front-ends",
                            "identity",
                            "indexer",
                            "monitoring",
                            "node-infra",
                            "oracle",
                            "security",
                            "storage"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "education" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["language-learning", "learning-tools", "reference", "stem"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "entertainment" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "live-events",
                            "music",
                            "music-streaming",
                            "video",
                            "video-streaming"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "finance" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "airdrop-tool",
                            "banking",
                            "exchanges",
                            "farming",
                            "defi",
                            "insurance",
                            "lending-and-borrowing",
                            "liquid-staking",
                            "others",
                            "payments",
                            "prediction-markets",
                            "price-aggregator",
                            "ramp",
                            "stablecoins",
                            "tooling",
                            "tokenization",
                            "trading"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "food and drink" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["cooking", "recipes", "restaurant-finding"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "games" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "action",
                            "adventure",
                            "board",
                            "metaverse",
                            "puzzle",
                            "racing",
                            "role-playing",
                            "simulation",
                            "strategy",
                            "studios",
                            "word"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "health and fitness" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "medical",
                            "meditation",
                            "nutrition",
                            "sleep-trackers",
                            "workout-apps"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "lifestyle" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["dating", "fashion", "home-automation"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "news" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "decentralized-news-platforms",
                            "live-news",
                            "magazines",
                            "newspapers",
                            "sports-news"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "photography" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["camera-apps", "photo-editing", "photo-sharing"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "productivity" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "calendar",
                            "decentralized-collaboration-tools",
                            "decentralized-collaboration-tools-investing",
                            "decentralized-collaboration-tools-misc",
                            "decentralized-collaboration-tools-tools",
                            "graphics-and-design",
                            "note-taking",
                            "task-management",
                            "time-management"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "shopping" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["ecommerce"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "social-networking" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "decentralized-social-networks",
                            "messaging",
                            "social-media",
                            "social-graph"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "sports" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["live-scores", "team-management"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "travel" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "accommodation-booking",
                            "navigation",
                            "transportation",
                            "trip-planning"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "utilities" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "browsers",
                            "file-management",
                            "security-and-privacy",
                            "wallets",
                            "weather"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "personalization" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": ["customization-tools", "themes", "wallpapers"]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": { "const": "nft" }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "art",
                            "domain-names",
                            "nft-marketplaces",
                            "pfps",
                            "tooling"
                        ]
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "category": {
                        "const": "ai"
                    }
                }
            },
            "then": {
                "properties": {
                    "subCategory": {
                        "enum": [
                            "text",
                            "image",
                            "audio",
                            "video",
                            "business",
                            "code",
                            "others"
                        ]
                    }
                }
            }
        }
    ],
    "required": [
        "name",
        "description",
        "dappId",
        "minAge",
        "isForMatureAudience",
        "isSelfModerated",
        "language",
        "availableOnPlatform",
        "listDate",
        "isListed",
        "category"
    ]
}
