mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 14:26:34 +00:00
25b0641cc2
This does a few things: - It integrates with the latest `CommunityTokensMetadata` to access community specific ERC721 token - It changes `ChatLayout` such that it conditionally loads either `ChatView` or `JoinCommunityView`. `JoinCommunityView` has been specifically designed for token-gated communities Here's what works (in terms of token permissions): 1. If a community has token permissions and the the current users is not a member of that community, we show `JoinCommunityView` instead of `ChatView` 2. Any community token permissions of type "Become member" are listed in the `JoinCommunityView` 3. There are different types of token critera a permission can have: ERC20 token, ERC721 token, or ENS (which is also ERC721 but we have a type for that nonetheless) Only ERC20 token balances are checked for the known wallet accounts. This happens every time the known token list has been updated (every 10 min atm). We still need to add balance checks for any ERC721 tokens and ENS. 4. If token permissions are created, updated or deleted by the community owner, the `JoinCommunityView` will update in real-time. You'll also notice that the `Reveal my address and request access` button will be enabled if any of the token permissions are fulfilled (only ERC20 at the time being). Clicking that button will not yet send a request. This will be done in the next step as part of https://github.com/status-im/status-desktop/issues/9761
53 lines
1.6 KiB
QML
53 lines
1.6 KiB
QML
import QtQml 2.15
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
required property string activeSectionId
|
|
required property var chatCommunitySectionModuleInst
|
|
|
|
readonly property var permissionsModel:
|
|
chatCommunitySectionModuleInst.permissionsModel
|
|
|
|
readonly property bool isOwner: false
|
|
|
|
readonly property bool allTokenRequirementsMet: chatCommunitySectionModuleInst.allTokenRequirementsMet
|
|
|
|
readonly property QtObject _d: QtObject {
|
|
id: d
|
|
|
|
function createPermissionEntry(holdings, permissionType, isPrivate,
|
|
channels) {
|
|
return {
|
|
holdingsListModel: holdings,
|
|
channelsListModel: channels,
|
|
permissionType,
|
|
isPrivate
|
|
}
|
|
}
|
|
|
|
function createOrEdit(key, holdings, permissionType, isPrivate,
|
|
channels) {
|
|
|
|
root.chatCommunitySectionModuleInst.createOrEditCommunityTokenPermission(
|
|
root.activeSectionId, key,
|
|
permissionType,
|
|
JSON.stringify(holdings),
|
|
isPrivate)
|
|
}
|
|
}
|
|
|
|
function createPermission(holdings, permissionType, isPrivate, channels) {
|
|
d.createOrEdit("", holdings, permissionType, isPrivate, channels)
|
|
}
|
|
|
|
function editPermission(key, holdings, permissionType, channels, isPrivate) {
|
|
d.createOrEdit(key, holdings, permissionType, isPrivate, channels)
|
|
}
|
|
|
|
function removePermission(key) {
|
|
root.chatCommunitySectionModuleInst.deleteCommunityTokenPermission(
|
|
root.activeSectionId, key)
|
|
}
|
|
}
|