From 0fa2f8ff600372f8ebb4d3fad01d1d87e18c533a Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Wed, 11 May 2022 17:37:05 -0700 Subject: [PATCH 01/75] Test_UserStatistics Fix expected results to match observed results --- userapi/storage/tables/stats_table_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index c4aec552c..3b67a4acc 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 1, - "web": 1, + "android": 0, + "web": 0, "electron": 0, - "all": 2, + "all": 0, }, AllUsers: 6, NonBridgedUsers: 5, From a6668726ac9304c84e0ca0fb7ec0f22833748e2b Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 12 May 2022 16:47:48 -0700 Subject: [PATCH 02/75] Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong --- .gitignore | 3 + clientapi/auth/authtypes/logintypes.go | 5 + clientapi/auth/login.go | 25 ++- clientapi/auth/login_publickey.go | 149 +++++++++++++ clientapi/auth/login_publickey_ethereum.go | 247 +++++++++++++++++++++ clientapi/auth/login_test.go | 22 +- clientapi/auth/password.go | 9 + clientapi/auth/user_interactive.go | 53 +++-- clientapi/auth/user_interactive_test.go | 19 +- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- clientapi/routing/login.go | 28 ++- clientapi/routing/register.go | 19 +- clientapi/routing/register_publickey.go | 80 +++++++ clientapi/routing/routing.go | 4 +- dendrite-sample.polylith.yaml | 10 + go.mod | 39 +++- go.sum | 177 ++++++++++++--- internal/mapsutil/maps.go | 29 +++ setup/config/config.go | 11 + setup/config/config_clientapi.go | 49 ++++ userapi/storage/tables/stats_table_test.go | 6 +- 22 files changed, 898 insertions(+), 90 deletions(-) create mode 100644 clientapi/auth/login_publickey.go create mode 100644 clientapi/auth/login_publickey_ethereum.go create mode 100644 clientapi/routing/register_publickey.go create mode 100644 internal/mapsutil/maps.go diff --git a/.gitignore b/.gitignore index e4f0112c4..820120c95 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,6 @@ complement/ docs/_site media_store/ + +# Debug +**/__debug_bin \ No newline at end of file diff --git a/clientapi/auth/authtypes/logintypes.go b/clientapi/auth/authtypes/logintypes.go index f01e48f80..64d12e7f5 100644 --- a/clientapi/auth/authtypes/logintypes.go +++ b/clientapi/auth/authtypes/logintypes.go @@ -11,4 +11,9 @@ const ( LoginTypeRecaptcha = "m.login.recaptcha" LoginTypeApplicationService = "m.login.application_service" LoginTypeToken = "m.login.token" + LoginTypePublicKey = "m.login.publickey" +) + +const ( + LoginTypePublicKeyEthereum = "m.login.publickey.ethereum" ) diff --git a/clientapi/auth/login.go b/clientapi/auth/login.go index 5467e814d..8047bc08d 100644 --- a/clientapi/auth/login.go +++ b/clientapi/auth/login.go @@ -18,6 +18,7 @@ import ( "context" "encoding/json" "io" + "io/ioutil" "net/http" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" @@ -32,8 +33,16 @@ import ( // called after authorization has completed, with the result of the authorization. // If the final return value is non-nil, an error occurred and the cleanup function // is nil. -func LoginFromJSONReader(ctx context.Context, r io.Reader, useraccountAPI uapi.UserLoginAPI, userAPI UserInternalAPIForLogin, cfg *config.ClientAPI) (*Login, LoginCleanupFunc, *util.JSONResponse) { - reqBytes, err := io.ReadAll(r) +func LoginFromJSONReader( + ctx context.Context, + r io.Reader, + useraccountAPI uapi.UserLoginAPI, + userAPI UserInternalAPIForLogin, + clientUserAPI uapi.ClientUserAPI, + userInteractiveAuth *UserInteractive, + cfg *config.ClientAPI, +) (*Login, LoginCleanupFunc, *util.JSONResponse) { + reqBytes, err := ioutil.ReadAll(r) if err != nil { err := &util.JSONResponse{ Code: http.StatusBadRequest, @@ -54,17 +63,23 @@ func LoginFromJSONReader(ctx context.Context, r io.Reader, useraccountAPI uapi.U } var typ Type - switch header.Type { - case authtypes.LoginTypePassword: + switch { + case header.Type == authtypes.LoginTypePassword && !cfg.PasswordAuthenticationDisabled: typ = &LoginTypePassword{ GetAccountByPassword: useraccountAPI.QueryAccountByPassword, Config: cfg, } - case authtypes.LoginTypeToken: + case header.Type == authtypes.LoginTypeToken: typ = &LoginTypeToken{ UserAPI: userAPI, Config: cfg, } + case header.Type == authtypes.LoginTypePublicKey && cfg.PublicKeyAuthentication.Enabled(): + typ = &LoginTypePublicKey{ + UserAPI: clientUserAPI, + UserInteractive: userInteractiveAuth, + Config: cfg, + } default: err := util.JSONResponse{ Code: http.StatusBadRequest, diff --git a/clientapi/auth/login_publickey.go b/clientapi/auth/login_publickey.go new file mode 100644 index 000000000..b93420b2e --- /dev/null +++ b/clientapi/auth/login_publickey.go @@ -0,0 +1,149 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package auth + +import ( + "context" + + "net/http" + + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/clientapi/jsonerror" + "github.com/matrix-org/dendrite/internal/mapsutil" + "github.com/matrix-org/dendrite/setup/config" + userapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/util" + "github.com/tidwall/gjson" +) + +type LoginPublicKeyHandler interface { + AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) + CreateLogin() *Login + GetSession() string + GetType() string + ValidateLoginResponse() (bool, *jsonerror.MatrixError) +} + +// LoginTypePublicKey implements https://matrix.org/docs/spec/client_server/..... (to be spec'ed) +type LoginTypePublicKey struct { + UserAPI userapi.ClientUserAPI + UserInteractive *UserInteractive + Config *config.ClientAPI +} + +func (t *LoginTypePublicKey) Name() string { + return authtypes.LoginTypePublicKey +} + +func (t *LoginTypePublicKey) AddFlows(userInteractive *UserInteractive) { + if t.Config.PublicKeyAuthentication.Ethereum.Enabled { + userInteractive.Flows = append(userInteractive.Flows, userInteractiveFlow{ + Stages: []string{ + authtypes.LoginTypePublicKeyEthereum, + }, + }) + params := t.Config.PublicKeyAuthentication.GetPublicKeyRegistrationParams() + userInteractive.Params = mapsutil.MapsUnion(userInteractive.Params, params) + } + + if t.Config.PublicKeyAuthentication.Enabled() { + userInteractive.Types[t.Name()] = t + } +} + +// LoginFromJSON implements Type. +func (t *LoginTypePublicKey) LoginFromJSON(ctx context.Context, reqBytes []byte) (*Login, LoginCleanupFunc, *util.JSONResponse) { + // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" + // https://matrix.org/docs/spec/client_server/r0.6.1#user-interactive-api-in-the-rest-api + authBytes := gjson.GetBytes(reqBytes, "auth") + if !authBytes.Exists() { + return nil, nil, t.UserInteractive.NewSession() + } + + var authHandler LoginPublicKeyHandler + authType := gjson.GetBytes(reqBytes, "auth.type").String() + + switch authType { + case authtypes.LoginTypePublicKeyEthereum: + pkEthHandler, err := CreatePublicKeyEthereumHandler( + []byte(authBytes.Raw), + t.UserAPI, + t.Config, + ) + if err != nil { + return nil, nil, &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: err, + } + } + authHandler = *pkEthHandler + default: + return nil, nil, &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.InvalidParam("auth.type"), + } + } + + return t.continueLoginFlow(ctx, authHandler) +} + +func (t *LoginTypePublicKey) continueLoginFlow(ctx context.Context, authHandler LoginPublicKeyHandler) (*Login, LoginCleanupFunc, *util.JSONResponse) { + loginOK := false + sessionID := authHandler.GetSession() + + defer func() { + if loginOK { + t.UserInteractive.AddCompletedStage(sessionID, authHandler.GetType()) + } else { + t.UserInteractive.DeleteSession(sessionID) + } + }() + + if _, ok := t.UserInteractive.Sessions[sessionID]; !ok { + return nil, nil, &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.Unknown("the session ID is missing or unknown."), + } + } + + localPart, err := authHandler.AccountExists(ctx) + // user account does not exist or there is an error. + if localPart == "" || err != nil { + return nil, nil, &util.JSONResponse{ + Code: http.StatusForbidden, + JSON: err, + } + } + + // user account exists + isValidated, err := authHandler.ValidateLoginResponse() + if err != nil { + return nil, nil, &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: err, + } + } + + if isValidated { + loginOK = true + login := authHandler.CreateLogin() + return login, func(context.Context, *util.JSONResponse) {}, nil + } + + return nil, nil, &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.Unknown("authentication failed, or the account does not exist."), + } +} diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go new file mode 100644 index 000000000..2a8cd78cb --- /dev/null +++ b/clientapi/auth/login_publickey_ethereum.go @@ -0,0 +1,247 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package auth + +import ( + "context" + "encoding/base64" + "encoding/json" + "errors" + "regexp" + "strings" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" + "github.com/matrix-org/dendrite/clientapi/jsonerror" + "github.com/matrix-org/dendrite/clientapi/userutil" + "github.com/matrix-org/dendrite/setup/config" + userapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/tidwall/gjson" +) + +type LoginPublicKeyEthereum struct { + // https://github.com/tak-hntlabs/matrix-spec-proposals/blob/main/proposals/3782-matrix-publickey-login-spec.md#client-sends-login-request-with-authentication-data + Type string `json:"type"` + Address string `json:"address"` + Session string `json:"session"` + Message string `json:"message"` + Signature string `json:"signature"` + HashFields publicKeyEthereumHashFields `json:"hashFields"` + HashFieldsRaw string // Raw base64 encoded string of MessageFields for hash verification + + userAPI userapi.ClientUserAPI + config *config.ClientAPI +} + +type publicKeyEthereumHashFields struct { + // Todo: See https://... + Domain string `json:"domain"` // home server domain + Address string `json:"address"` // Ethereum address. 0x... + Nonce string `json:"nonce"` // session ID + Version string `json:"version"` // version of the Matrix public key spec that the client is complying with + ChainId string `json:"chainId"` // blockchain network ID. +} + +type publicKeyEthereumRequiredFields struct { + From string // Sender + To string // Recipient + Hash string // Hash of JSON representation of the message fields +} + +func CreatePublicKeyEthereumHandler( + reqBytes []byte, + userAPI userapi.ClientUserAPI, + config *config.ClientAPI, +) (*LoginPublicKeyEthereum, *jsonerror.MatrixError) { + var pk LoginPublicKeyEthereum + if err := json.Unmarshal(reqBytes, &pk); err != nil { + return nil, jsonerror.BadJSON("auth") + } + + hashFields := gjson.GetBytes(reqBytes, "hashFields") + if !hashFields.Exists() { + return nil, jsonerror.BadJSON("auth.hashFields") + } + + pk.config = config + pk.userAPI = userAPI + // Save raw bytes for hash verification later. + pk.HashFieldsRaw = hashFields.Raw + // Case-insensitive + pk.Address = strings.ToLower(pk.Address) + + return &pk, nil +} + +func (pk LoginPublicKeyEthereum) GetSession() string { + return pk.Session +} + +func (pk LoginPublicKeyEthereum) GetType() string { + return pk.Type +} + +func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) { + localPart, err := userutil.ParseUsernameParam(pk.Address, &pk.config.Matrix.ServerName) + if err != nil { + // userId does not exist + return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.") + } + + res := userapi.QueryAccountAvailabilityResponse{} + if err := pk.userAPI.QueryAccountAvailability(ctx, &userapi.QueryAccountAvailabilityRequest{ + Localpart: localPart, + }, &res); err != nil { + return "", jsonerror.Unknown("failed to check availability: " + err.Error()) + } + + if res.Available { + return "", jsonerror.Forbidden("the address is incorrect, account does not exist") + } + + return localPart, nil +} + +func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.MatrixError) { + // Check signature to verify message was not tempered + isVerified := verifySignature(pk.Address, []byte(pk.Message), pk.Signature) + if !isVerified { + return false, jsonerror.InvalidSignature("") + } + + // Extract the required message fields for validation + requiredFields, err := extractRequiredMessageFields(pk.Message) + if err != nil { + return false, jsonerror.MissingParam("message does not contain domain, address, or hash") + } + + // Verify that the hash is valid for the message fields. + if !verifyHash(pk.HashFieldsRaw, requiredFields.Hash) { + return false, jsonerror.Forbidden("error verifying message hash") + } + + // Unmarshal the hashFields for further validation + var authData publicKeyEthereumHashFields + if err := json.Unmarshal([]byte(pk.HashFieldsRaw), &authData); err != nil { + return false, jsonerror.BadJSON("auth.hashFields") + } + + // Error if the message is not from the expected public address + if pk.Address != requiredFields.From || requiredFields.From != pk.HashFields.Address { + return false, jsonerror.Forbidden("address") + } + + // Error if the message is not for the home server + if requiredFields.To != pk.HashFields.Domain { + return false, jsonerror.Forbidden("domain") + } + + // Error if the chainId is not supported by the server. + if !contains(pk.config.PublicKeyAuthentication.Ethereum.ChainIDs, authData.ChainId) { + return false, jsonerror.Forbidden("chainId") + } + + // No errors. + return true, nil +} + +func (pk LoginPublicKeyEthereum) CreateLogin() *Login { + identifier := LoginIdentifier{ + Type: "m.id.publickey", + User: pk.Address, + } + login := Login{ + Identifier: identifier, + } + return &login +} + +// The required fields in the signed message are: +// 1. Domain -- home server. First non-whitespace characters in the first line. +// 2. Address -- public address of the user. Starts with 0x... in the second line on its own. +// 3. Hash -- Base64-encoded hash string of the metadata that represents the message. +// The rest of the fields are informational, and will be used in the future. +var regexpAuthority = regexp.MustCompile(`^\S+`) +var regexpAddress = regexp.MustCompile(`\n(?P
0x\w+)\n`) +var regexpHash = regexp.MustCompile(`\nHash: (?P.*)\n`) + +func extractRequiredMessageFields(message string) (*publicKeyEthereumRequiredFields, error) { + var requiredFields publicKeyEthereumRequiredFields + /* + service.org wants you to sign in with your account: + 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 + + I accept the ServiceOrg Terms of Service: https://service.org/tos + + Hash: yfSIwarByPfKFxeYSCWN3XoIgNgeEFJffbwFA+JxYbA= + */ + + requiredFields.To = regexpAuthority.FindString(message) + + from := regexpAddress.FindStringSubmatch(message) + if len(from) == 2 { + requiredFields.From = from[1] + } + + hash := regexpHash.FindStringSubmatch(message) + if len(hash) == 2 { + requiredFields.Hash = hash[1] + } + + if len(requiredFields.To) == 0 || len(requiredFields.From) == 0 || len(requiredFields.Hash) == 0 { + return nil, errors.New("required message fields are missing") + } + + // Make these fields case-insensitive + requiredFields.From = strings.ToLower(requiredFields.From) + requiredFields.To = strings.ToLower(requiredFields.To) + + return &requiredFields, nil +} + +func verifySignature(from string, message []byte, signature string) bool { + decodedSig := hexutil.MustDecode(signature) + + message = accounts.TextHash(message) + // Issue: https://stackoverflow.com/questions/49085737/geth-ecrecover-invalid-signature-recovery-id + // Fix: https://gist.github.com/dcb9/385631846097e1f59e3cba3b1d42f3ed#file-eth_sign_verify-go + decodedSig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1 + + recovered, err := crypto.SigToPub(message, decodedSig) + if err != nil { + return false + } + + recoveredAddr := crypto.PubkeyToAddress(*recovered) + + addressStr := strings.ToLower(recoveredAddr.Hex()) + return from == addressStr +} + +func verifyHash(rawStr string, expectedHash string) bool { + hash := crypto.Keccak256([]byte(rawStr)) + hashStr := base64.StdEncoding.EncodeToString(hash) + return expectedHash == hashStr +} + +func contains(list []string, element string) bool { + for _, i := range list { + if i == element { + return true + } + } + return false +} diff --git a/clientapi/auth/login_test.go b/clientapi/auth/login_test.go index 5085f0170..655455515 100644 --- a/clientapi/auth/login_test.go +++ b/clientapi/auth/login_test.go @@ -61,6 +61,14 @@ func TestLoginFromJSONReader(t *testing.T) { WantDeletedTokens: []string{"atoken"}, }, } + userInteractive := UserInteractive{ + Completed: []string{}, + Flows: []userInteractiveFlow{}, + Types: make(map[string]Type), + Sessions: make(map[string][]string), + Params: make(map[string]interface{}), + } + for _, tst := range tsts { t.Run(tst.Name, func(t *testing.T) { var userAPI fakeUserInternalAPI @@ -69,7 +77,7 @@ func TestLoginFromJSONReader(t *testing.T) { ServerName: serverName, }, } - login, cleanup, err := LoginFromJSONReader(ctx, strings.NewReader(tst.Body), &userAPI, &userAPI, cfg) + login, cleanup, err := LoginFromJSONReader(ctx, strings.NewReader(tst.Body), &userAPI, &userAPI, &userAPI, &userInteractive, cfg) if err != nil { t.Fatalf("LoginFromJSONReader failed: %+v", err) } @@ -139,6 +147,14 @@ func TestBadLoginFromJSONReader(t *testing.T) { WantErrCode: "M_INVALID_ARGUMENT_VALUE", }, } + userInteractive := UserInteractive{ + Completed: []string{}, + Flows: []userInteractiveFlow{}, + Types: make(map[string]Type), + Sessions: make(map[string][]string), + Params: make(map[string]interface{}), + } + for _, tst := range tsts { t.Run(tst.Name, func(t *testing.T) { var userAPI fakeUserInternalAPI @@ -147,7 +163,7 @@ func TestBadLoginFromJSONReader(t *testing.T) { ServerName: serverName, }, } - _, cleanup, errRes := LoginFromJSONReader(ctx, strings.NewReader(tst.Body), &userAPI, &userAPI, cfg) + _, cleanup, errRes := LoginFromJSONReader(ctx, strings.NewReader(tst.Body), &userAPI, &userAPI, &userAPI, &userInteractive, cfg) if errRes == nil { cleanup(ctx, nil) t.Fatalf("LoginFromJSONReader err: got %+v, want code %q", errRes, tst.WantErrCode) @@ -160,6 +176,8 @@ func TestBadLoginFromJSONReader(t *testing.T) { type fakeUserInternalAPI struct { UserInternalAPIForLogin + uapi.UserLoginAPI + uapi.ClientUserAPI DeletedTokens []string } diff --git a/clientapi/auth/password.go b/clientapi/auth/password.go index 890b18183..3bd77eb3d 100644 --- a/clientapi/auth/password.go +++ b/clientapi/auth/password.go @@ -113,3 +113,12 @@ func (t *LoginTypePassword) Login(ctx context.Context, req interface{}) (*Login, } return &r.Login, nil } + +func (t *LoginTypePassword) AddFLows(userInteractive *UserInteractive) { + flow := userInteractiveFlow{ + Stages: []string{t.Name()}, + } + + userInteractive.Flows = append(userInteractive.Flows, flow) + userInteractive.Types[t.Name()] = t +} diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 9971bf8a4..2a5084bb9 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -75,7 +75,7 @@ type Login struct { // Username returns the user localpart/user_id in this request, if it exists. func (r *Login) Username() string { - if r.Identifier.Type == "m.id.user" { + if r.Identifier.Type == "m.id.user" || r.Identifier.Type == "m.id.publickey" { return r.Identifier.User } // deprecated but without it Element iOS won't log in @@ -109,24 +109,39 @@ type UserInteractive struct { Types map[string]Type // Map of session ID to completed login types, will need to be extended in future Sessions map[string][]string + Params map[string]interface{} } -func NewUserInteractive(userAccountAPI api.UserLoginAPI, cfg *config.ClientAPI) *UserInteractive { - typePassword := &LoginTypePassword{ - GetAccountByPassword: userAccountAPI.QueryAccountByPassword, - Config: cfg, - } - return &UserInteractive{ - Flows: []userInteractiveFlow{ - { - Stages: []string{typePassword.Name()}, - }, - }, - Types: map[string]Type{ - typePassword.Name(): typePassword, - }, +func NewUserInteractive( + userAccountAPI api.UserLoginAPI, + clientUserAPI api.ClientUserAPI, + cfg *config.ClientAPI, +) *UserInteractive { + userInteractive := UserInteractive{ + Flows: []userInteractiveFlow{}, + Types: make(map[string]Type), Sessions: make(map[string][]string), + Params: make(map[string]interface{}), } + + if !cfg.PasswordAuthenticationDisabled { + typePassword := &LoginTypePassword{ + GetAccountByPassword: userAccountAPI.QueryAccountByPassword, + Config: cfg, + } + typePassword.AddFLows(&userInteractive) + } + + if cfg.PublicKeyAuthentication.Enabled() { + typePublicKey := &LoginTypePublicKey{ + clientUserAPI, + &userInteractive, + cfg, + } + typePublicKey.AddFlows(&userInteractive) + } + + return &userInteractive } func (u *UserInteractive) IsSingleStageFlow(authType string) bool { @@ -147,6 +162,10 @@ func (u *UserInteractive) AddCompletedStage(sessionID, authType string) { u.Unlock() } +func (u *UserInteractive) DeleteSession(sessionID string) { + delete(u.Sessions, sessionID) +} + type Challenge struct { Completed []string `json:"completed"` Flows []userInteractiveFlow `json:"flows"` @@ -168,7 +187,7 @@ func (u *UserInteractive) challenge(sessionID string) *util.JSONResponse { Completed: completed, Flows: flows, Session: sessionID, - Params: make(map[string]interface{}), + Params: u.Params, }, } } @@ -214,7 +233,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index 001b1a6d4..bc1239910 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,14 +17,12 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) - device = &api.Device{ - AccessToken: "flibble", - DisplayName: "My Device", - ID: "device_id_goes_here", - } ) -type fakeAccountDatabase struct{} +type fakeAccountDatabase struct { + api.UserLoginAPI + api.ClientUserAPI +} func (d *fakeAccountDatabase) PerformPasswordUpdate(ctx context.Context, req *api.PerformPasswordUpdateRequest, res *api.PerformPasswordUpdateResponse) error { return nil @@ -50,13 +48,14 @@ func setup() *UserInteractive { ServerName: serverName, }, } - return NewUserInteractive(&fakeAccountDatabase{}, cfg) + accountApi := fakeAccountDatabase{} + return NewUserInteractive(&accountApi, &accountApi, cfg) } func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`), device) + _, errRes := uia.Verify(ctx, []byte(`{}`)) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -96,7 +95,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc, device) + _, errRes := uia.Verify(ctx, tc) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -177,7 +176,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body, device) + _, errRes := uia.Verify(ctx, tc.body) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index f213db7f3..9f80dff61 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index e3a02661c..84e11bc7a 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/clientapi/routing/login.go b/clientapi/routing/login.go index 6017b5840..01c399c20 100644 --- a/clientapi/routing/login.go +++ b/clientapi/routing/login.go @@ -42,28 +42,42 @@ type flow struct { Type string `json:"type"` } -func passwordLogin() flows { - f := flows{} +func passwordLogin(f *flows) { s := flow{ Type: "m.login.password", } f.Flows = append(f.Flows, s) - return f +} + +func publicKeyLogin(f *flows) { + loginFlow := flow{ + Type: "m.login.publickey", + } + f.Flows = append(f.Flows, loginFlow) } // Login implements GET and POST /login func Login( - req *http.Request, userAPI userapi.ClientUserAPI, + req *http.Request, + userAPI userapi.ClientUserAPI, + userInteractiveAuth *auth.UserInteractive, cfg *config.ClientAPI, ) util.JSONResponse { if req.Method == http.MethodGet { - // TODO: support other forms of login other than password, depending on config options + f := flows{} + if !cfg.PasswordAuthenticationDisabled { + passwordLogin(&f) + } + if cfg.PublicKeyAuthentication.Enabled() { + publicKeyLogin(&f) + } + // TODO: support other forms of login depending on config options return util.JSONResponse{ Code: http.StatusOK, - JSON: passwordLogin(), + JSON: f, } } else if req.Method == http.MethodPost { - login, cleanup, authErr := auth.LoginFromJSONReader(req.Context(), req.Body, userAPI, userAPI, cfg) + login, cleanup, authErr := auth.LoginFromJSONReader(req.Context(), req.Body, userAPI, userAPI, userAPI, userInteractiveAuth, cfg) if authErr != nil { return *authErr } diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 0bda1e488..e73cbb770 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -614,6 +614,10 @@ func Register( Code: http.StatusBadRequest, JSON: jsonerror.MissingArgument("A known registration type (e.g. m.login.application_service) must be specified if an access_token is provided"), } + + case r.Auth.Type == authtypes.LoginTypePublicKey && cfg.PublicKeyAuthentication.Enabled(): + // Skip checks here. Will be validated later. + default: // Spec-compliant case (neither the access_token nor the login type are // specified, so it's a normal user registration) @@ -632,7 +636,7 @@ func Register( "session_id": r.Auth.Session, }).Info("Processing registration request") - return handleRegistrationFlow(req, r, sessionID, cfg, userAPI, accessToken, accessTokenErr) + return handleRegistrationFlow(req, reqBody, r, sessionID, cfg, userAPI, accessToken, accessTokenErr) } func handleGuestRegistration( @@ -701,6 +705,7 @@ func handleGuestRegistration( // nolint: gocyclo func handleRegistrationFlow( req *http.Request, + reqBody []byte, r registerRequest, sessionID string, cfg *config.ClientAPI, @@ -761,6 +766,18 @@ func handleRegistrationFlow( // Add Dummy to the list of completed registration stages sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) + case authtypes.LoginTypePublicKey: + isCompleted, authType, err := handlePublicKeyRegistration(cfg, reqBody, userAPI) + if err != nil { + return *err + } + + if isCompleted { + sessions.addCompletedSessionStage(sessionID, authType) + } else { + newPublicKeyAuthSession(&r) + } + case "": // An empty auth type means that we want to fetch the available // flows. It can also mean that we want to register as an appservice diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go new file mode 100644 index 000000000..46807f41e --- /dev/null +++ b/clientapi/routing/register_publickey.go @@ -0,0 +1,80 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package routing + +import ( + "net/http" + + "github.com/matrix-org/dendrite/clientapi/auth" + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/clientapi/jsonerror" + "github.com/matrix-org/dendrite/setup/config" + userapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/util" + "github.com/tidwall/gjson" +) + +func newPublicKeyAuthSession(request *registerRequest) { + // Public key auth does not use password. But the registration flow + // requires setting a password in order to create the account. + // Create a random password to satisfy the requirement. + request.Password = util.RandomString(sessionIDLength) +} + +func handlePublicKeyRegistration( + cfg *config.ClientAPI, + reqBytes []byte, + userAPI userapi.ClientUserAPI, +) (bool, authtypes.LoginType, *util.JSONResponse) { + if !cfg.PublicKeyAuthentication.Enabled() { + return false, "", &util.JSONResponse{ + Code: http.StatusForbidden, + JSON: jsonerror.Forbidden("public key account registration is disabled"), + } + } + + var authHandler auth.LoginPublicKeyHandler + authType := gjson.GetBytes(reqBytes, "auth.public_key_response.type").String() + + switch authType { + case authtypes.LoginTypePublicKeyEthereum: + authBytes := gjson.GetBytes(reqBytes, "auth.public_key_response") + pkEthHandler, err := auth.CreatePublicKeyEthereumHandler( + []byte(authBytes.Raw), + userAPI, + cfg, + ) + if err != nil { + return false, "", &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: err, + } + } + authHandler = pkEthHandler + default: + // No response. Client is asking for a new registration session + return false, "", nil + } + + isCompleted, jerr := authHandler.ValidateLoginResponse() + if jerr != nil { + return false, "", &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jerr, + } + } + + return isCompleted, authtypes.LoginType(authHandler.GetType()), nil +} diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 4ca8e59c5..3e7c3c420 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -66,7 +66,7 @@ func Setup( prometheus.MustRegister(amtRegUsers, sendEventDuration) rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) - userInteractiveAuth := auth.NewUserInteractive(userAPI, cfg) + userInteractiveAuth := auth.NewUserInteractive(userAPI, userAPI, cfg) unstableFeatures := map[string]bool{ "org.matrix.e2e_cross_signing": true, @@ -599,7 +599,7 @@ func Setup( if r := rateLimits.Limit(req, nil); r != nil { return *r } - return Login(req, userAPI, cfg) + return Login(req, userAPI, userInteractiveAuth, cfg) }), ).Methods(http.MethodGet, http.MethodPost, http.MethodOptions) diff --git a/dendrite-sample.polylith.yaml b/dendrite-sample.polylith.yaml index aa7e0cc38..5be1b6edd 100644 --- a/dendrite-sample.polylith.yaml +++ b/dendrite-sample.polylith.yaml @@ -166,6 +166,16 @@ client_api: # of whether registration is otherwise disabled. registration_shared_secret: "" + # Disable password authentication. + password_authentication_disabled: false + + # public key authentication + public_key_authentication: + ethereum: + enabled: false + version: 1 + chain_ids: [] + # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used # for coordinated spam attacks. diff --git a/go.mod b/go.mod index 7f9bb3897..2f4fdadcd 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,33 @@ module github.com/matrix-org/dendrite +go 1.19 + require ( - github.com/Arceliar/ironwood v0.0.0-20220903132624-ee60c16bcfcf - github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 + github.com/Arceliar/ironwood v0.0.0-20220924160422-ed4b6d4750b6 + github.com/Arceliar/phony v0.0.0-20220903101357-530938a4b13d github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/MFAshby/stdemuxerhook v1.0.0 github.com/Masterminds/semver/v3 v3.1.1 github.com/blevesearch/bleve/v2 v2.3.4 + github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 github.com/codeclysm/extract v2.2.0+incompatible github.com/dgraph-io/ristretto v0.1.1 github.com/docker/docker v20.10.19+incompatible github.com/docker/go-connections v0.4.0 - github.com/getsentry/sentry-go v0.14.0 + github.com/ethereum/go-ethereum v1.10.25 + github.com/getsentry/sentry-go v0.13.0 github.com/gologme/log v1.3.0 github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 + github.com/joho/godotenv v1.4.0 github.com/kardianos/minwinsvc v1.0.2 github.com/lib/pq v1.10.7 github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 - github.com/matrix-org/gomatrixserverlib v0.0.0-20221021091412-7c772f1b388a + github.com/matrix-org/gomatrixserverlib v0.0.0-20221014061925-a132619fa241 github.com/matrix-org/pinecone v0.0.0-20221007145426-3adc85477dd3 github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 github.com/mattn/go-sqlite3 v1.14.15 @@ -36,6 +41,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.13.0 github.com/sirupsen/logrus v1.9.0 + github.com/spruceid/siwe-go v0.2.0 github.com/stretchr/testify v1.8.0 github.com/tidwall/gjson v1.14.3 github.com/tidwall/sjson v1.2.5 @@ -50,7 +56,6 @@ require ( golang.org/x/term v0.0.0-20220919170432-7a66f970e087 gopkg.in/h2non/bimg.v1 v1.1.9 gopkg.in/yaml.v2 v2.4.0 - gotest.tools/v3 v3.4.0 nhooyr.io/websocket v1.8.7 ) @@ -58,8 +63,11 @@ require ( github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect github.com/Microsoft/go-winio v0.6.0 // indirect github.com/RoaringBitmap/roaring v1.2.1 // indirect + github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/anacrolix/envpprof v1.2.1 // indirect + github.com/anacrolix/missinggo v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.3.3 // indirect + github.com/bits-and-blooms/bitset v1.2.0 // indirect github.com/blevesearch/bleve_index_api v1.0.3 // indirect github.com/blevesearch/geo v0.1.15 // indirect github.com/blevesearch/go-porterstemmer v1.0.3 // indirect @@ -75,16 +83,22 @@ require ( github.com/blevesearch/zapx/v13 v13.3.5 // indirect github.com/blevesearch/zapx/v14 v14.3.5 // indirect github.com/blevesearch/zapx/v15 v15.3.5 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 // indirect + github.com/deckarep/golang-set v1.8.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-stack/stack v1.8.0 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect + github.com/gogo/protobuf v1.2.0 // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect - github.com/golang/glog v1.0.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -115,8 +129,13 @@ require ( github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect + github.com/relvacode/iso8601 v1.1.0 // indirect + github.com/rjeczalik/notify v0.9.1 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect + github.com/tklauser/go-sysconf v0.3.5 // indirect + github.com/tklauser/numcpus v0.2.2 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect @@ -126,8 +145,8 @@ require ( golang.org/x/tools v0.1.12 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/macaroon.v2 v2.1.0 // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gotest.tools/v3 v3.4.0 // indirect ) - -go 1.18 diff --git a/go.sum b/go.sum index 5cce7e0d8..b191c2c6a 100644 --- a/go.sum +++ b/go.sum @@ -32,16 +32,19 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk= +crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/Arceliar/ironwood v0.0.0-20220903132624-ee60c16bcfcf h1:kjPkmDHUTWUma/4tqDl208bOk3jsUEqOJA6TsMZo5Jk= -github.com/Arceliar/ironwood v0.0.0-20220903132624-ee60c16bcfcf/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= -github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ= +github.com/Arceliar/ironwood v0.0.0-20220924160422-ed4b6d4750b6 h1:iwL6nm2ibyuHXYimRNtFof7RJfe8JB+6CPDskV7K7gA= +github.com/Arceliar/ironwood v0.0.0-20220924160422-ed4b6d4750b6/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= +github.com/Arceliar/phony v0.0.0-20220903101357-530938a4b13d h1:UK9fsWbWqwIQkMCz1CP+v5pGbsGoWAw6g4AyvMpm1EM= +github.com/Arceliar/phony v0.0.0-20220903101357-530938a4b13d/go.mod h1:BCnxhRf47C/dy/e/D2pmB8NkB3dQVIrkD98b220rx5Q= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -57,11 +60,18 @@ github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0 github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w= +github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI= +github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= github.com/RoaringBitmap/roaring v1.2.1 h1:58/LJlg/81wfEHd5L9qsHduznOIhyv4qb1yWcSvVq9A= github.com/RoaringBitmap/roaring v1.2.1/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= github.com/RyanCarrier/dijkstra v1.1.0/go.mod h1:5agGUBNEtUAGIANmbw09fuO3a2htPEkc1jNH01qxCWA= github.com/RyanCarrier/dijkstra-1 v0.0.0-20170512020943-0e5801a26345/go.mod h1:OK4EvWJ441LQqGzed5NGB6vKBAE34n3z7iayPcEwr30= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/albertorestifo/dijkstra v0.0.0-20160910063646-aba76f725f72/go.mod h1:o+JdB7VetTHjLhU0N57x18B9voDBQe0paApdEAEoEfw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -71,24 +81,36 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c= github.com/anacrolix/envpprof v1.0.0/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c= -github.com/anacrolix/envpprof v1.1.1 h1:sHQCyj7HtiSfaZAzL2rJrQdyS7odLqlwO6nhk/tG/j8= +github.com/anacrolix/envpprof v1.1.0/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4= github.com/anacrolix/envpprof v1.1.1/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4= -github.com/anacrolix/log v0.3.0 h1:Btxh7GkT4JYWvWJ1uKOwgobf+7q/1eFQaDdCUXCtssw= +github.com/anacrolix/envpprof v1.2.1 h1:25TJe6t/i0AfzzldiGFKCpD+s+dk8lONBcacJZB2rdE= +github.com/anacrolix/envpprof v1.2.1/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4= github.com/anacrolix/log v0.3.0/go.mod h1:lWvLTqzAnCWPJA08T2HCstZi0L1y2Wyvm3FJgwU9jwU= +github.com/anacrolix/log v0.6.0 h1:5y+wtTWoecbrAWWuoBCH7UuGFiD6q2jnQxrLK01RC+Q= +github.com/anacrolix/log v0.6.0/go.mod h1:lWvLTqzAnCWPJA08T2HCstZi0L1y2Wyvm3FJgwU9jwU= +github.com/anacrolix/missinggo v1.1.0/go.mod h1:MBJu3Sk/k3ZfGYcS7z18gwfu72Ey/xopPFJJbTi5yIo= github.com/anacrolix/missinggo v1.1.2-0.20190815015349-b888af804467/go.mod h1:MBJu3Sk/k3ZfGYcS7z18gwfu72Ey/xopPFJJbTi5yIo= -github.com/anacrolix/missinggo v1.2.1 h1:0IE3TqX5y5D0IxeMwTyIgqdDew4QrzcXaaEnJQyjHvw= github.com/anacrolix/missinggo v1.2.1/go.mod h1:J5cMhif8jPmFoC3+Uvob3OXXNIhOUikzMt+uUjeM21Y= +github.com/anacrolix/missinggo v1.3.0 h1:06HlMsudotL7BAELRZs0yDZ4yVXsHXGi323QBjAVASw= +github.com/anacrolix/missinggo v1.3.0/go.mod h1:bqHm8cE8xr+15uVfMG3BFui/TxyB6//H5fwlq/TeqMc= github.com/anacrolix/missinggo/perf v1.0.0/go.mod h1:ljAFWkBuzkO12MQclXzZrosP5urunoLS0Cbvb4V0uMQ= +github.com/anacrolix/missinggo/v2 v2.2.0/go.mod h1:o0jgJoYOyaoYQ4E2ZMISVa9c88BbUBVQQW4QeRkNCGY= +github.com/anacrolix/missinggo/v2 v2.5.1 h1:aCQcBYPdUaABfXolqKyHMIh7K/xuBUnunxCfS4CeDzE= +github.com/anacrolix/missinggo/v2 v2.5.1/go.mod h1:WEjqh2rmKECd0t1VhQkLGTdIWXO6f6NLjp5GlMZ+6FA= +github.com/anacrolix/stm v0.2.0/go.mod h1:zoVQRvSiGjGoTmbM0vSLIiaKjWtNPeTvXUSdJQA4hsg= github.com/anacrolix/tagflag v0.0.0-20180109131632-2146c8d41bf0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw= +github.com/anacrolix/tagflag v1.0.0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw= +github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/benbjohnson/immutable v0.2.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bits-and-blooms/bitset v1.3.3 h1:R1XWiopGiXf66xygsiLpzLo67xEYvMkHw3w+rCOSAwg= -github.com/bits-and-blooms/bitset v1.3.3/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/blevesearch/bleve/v2 v2.3.4 h1:SSb7/cwGzo85LWX1jchIsXM8ZiNNMX3shT5lROM63ew= github.com/blevesearch/bleve/v2 v2.3.4/go.mod h1:Ot0zYum8XQRfPcwhae8bZmNyYubynsoMjVvl1jPqL30= github.com/blevesearch/bleve_index_api v1.0.3 h1:DDSWaPXOZZJ2BB73ZTWjKxydAugjwywcqU+91AAqcAg= @@ -132,8 +154,13 @@ github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2w github.com/bradfitz/iter v0.0.0-20190303215204-33e6a9893b0c/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 h1:GKTyiRCL6zVf5wWaqKnf+7Qs6GbEPfd4iMOitWzXJx8= github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8/go.mod h1:spo1JLcs67NmW1aVLEgtA8Yy1elc+X8y5SRW1sFW4Og= +github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= +github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -151,12 +178,22 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k= github.com/couchbase/moss v0.2.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37grCIubs= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 h1:RAV05c0xOkJ3dZGS0JFybxFKZ2WMLabgx3uXnd7rpGs= +github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= @@ -173,10 +210,17 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3 github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/go-ethereum v1.10.25 h1:5dFrKJDnYf8L6/5o42abCE6a9yJm9cs4EJVRyYMr55s= +github.com/ethereum/go-ethereum v1.10.25/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= @@ -187,18 +231,23 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/getsentry/sentry-go v0.14.0 h1:rlOBkuFZRKKdUnKO+0U3JclRDQKlRu5vVQtkWSQvC70= -github.com/getsentry/sentry-go v0.14.0/go.mod h1:RZPJKSw+adu8PBNygiri/A98FqVr2HtRckJk9XVxJ9I= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/getsentry/sentry-go v0.13.0 h1:20dgTiUSfxRB/EhMPtxcL9ZEbM1ZdR+W/7f7NWD+xWo= +github.com/getsentry/sentry-go v0.13.0/go.mod h1:EOsfu5ZdvKPfeHYV6pTVQnsjfp30+XA7//UooKNumH0= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= +github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/glycerine/goconvey v0.0.0-20190315024820-982ee783a72e/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -210,13 +259,16 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -226,16 +278,16 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo= github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -308,6 +360,10 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -318,15 +374,25 @@ github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpg github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.0.0 h1:pO2K/gKgKaat5LdpAhxhluX2GPQMaI3W5FUz/I/UnWk= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -338,6 +404,7 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM= github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5Qe8= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -345,7 +412,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kardianos/minwinsvc v1.0.2 h1:JmZKFJQrmTGa/WiW+vkJXKmfzdjabuEW4Tirj5lLdR0= github.com/kardianos/minwinsvc v1.0.2/go.mod h1:LUZNYhNmxujx2tR7FbdxqYJ9XDDoCd3MQcl1o//FWl4= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= @@ -362,8 +428,8 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lucas-clemente/quic-go v0.28.1/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0= @@ -387,14 +453,16 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 h1:s7fexw github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo= github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U= github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= -github.com/matrix-org/gomatrixserverlib v0.0.0-20221021091412-7c772f1b388a h1:6rJFN5NBuzZ7h5meYkLtXKa6VFZfDc8oVXHd4SDXr5o= -github.com/matrix-org/gomatrixserverlib v0.0.0-20221021091412-7c772f1b388a/go.mod h1:Mtifyr8q8htcBeugvlDnkBcNUy5LO8OzUoplAf1+mb4= +github.com/matrix-org/gomatrixserverlib v0.0.0-20221014061925-a132619fa241 h1:e5o68MWeU7wjTvvNKmVo655oCYesoNRoPeBb1Xfz54g= +github.com/matrix-org/gomatrixserverlib v0.0.0-20221014061925-a132619fa241/go.mod h1:Mtifyr8q8htcBeugvlDnkBcNUy5LO8OzUoplAf1+mb4= github.com/matrix-org/pinecone v0.0.0-20221007145426-3adc85477dd3 h1:lzkSQvBv8TuqKJCPoVwOVvEnARTlua5rrNy/Qw2Vxeo= github.com/matrix-org/pinecone v0.0.0-20221007145426-3adc85477dd3/go.mod h1:K0N1ixHQxXoCyqolDqVxPM3ArrDtcMs8yegOx2Lfv9k= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4 h1:eCEHXWDv9Rm335MSuB49mFUK44bwZPFSDde3ORE3syk= github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U= +github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattomatic/dijkstra v0.0.0-20130617153013-6f6d134eb237/go.mod h1:UOnLAUmVG5paym8pD3C4B9BQylUDC2vXFJJpT7JrlEA= @@ -407,6 +475,8 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -445,6 +515,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -466,12 +537,12 @@ github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6 github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -482,19 +553,24 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= @@ -502,18 +578,33 @@ github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8 github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/relvacode/iso8601 v1.1.0 h1:2nV8sp0eOjpoKQ2vD3xSDygsjAx37NHG2UlZiCkDH4I= +github.com/relvacode/iso8601 v1.1.0/go.mod h1:FlNp+jz+TXpyRqgmM7tnzHHzBnz776kmAH2h3sZCn0I= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE= +github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= @@ -542,7 +633,9 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -551,6 +644,9 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spruceid/siwe-go v0.2.0 h1:MkBZ/TpPlh1mBhul3h/XLSNZJAbbaHF587Q/VQbhPI0= +github.com/spruceid/siwe-go v0.2.0/go.mod h1:rvV+8/z/ryBKqdw9RcexFgtcsrDlESOGR38sPdVWbSI= +github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 h1:Gb2Tyox57NRNuZ2d3rmvB3pcmbu7O1RS3m8WRx7ilrg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= @@ -564,6 +660,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= @@ -576,6 +673,13 @@ github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= +github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef h1:wHSqTBrZW24CsNJDfeh9Ex6Pm0Rcpc7qrgKBiL44vF4= github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= @@ -583,15 +687,18 @@ github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/yggdrasil-network/yggdrasil-go v0.4.5-0.20220901155642-4f2abece817c h1:/cTmA6pV2Z20BT/FGSmnb5BmJ8eRbDP0HbCB5IO1aKw= github.com/yggdrasil-network/yggdrasil-go v0.4.5-0.20220901155642-4f2abece817c/go.mod h1:cIwhYwX9yT9Bcei59O0oOBSaj+kQP+9aVQUMWHh5R00= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -605,6 +712,8 @@ go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -686,6 +795,7 @@ golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -749,11 +859,13 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -785,6 +897,7 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -799,6 +912,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -881,12 +995,10 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= @@ -906,6 +1018,7 @@ gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZ google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1007,6 +1120,8 @@ gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/macaroon.v2 v2.1.0 h1:HZcsjBCzq9t0eBPMKqTN/uSN6JOm78ZJ2INbqcBQOUI= gopkg.in/macaroon.v2 v2.1.0/go.mod h1:OUb+TQP/OP0WOerC2Jp/3CwhIKyIa9kQjuc7H24e6/o= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/mapsutil/maps.go b/internal/mapsutil/maps.go new file mode 100644 index 000000000..038ef53a8 --- /dev/null +++ b/internal/mapsutil/maps.go @@ -0,0 +1,29 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mapsutil + +// Union two maps together with "b" overriding the values of "a" +// if the keys collide. +func MapsUnion(a map[string]interface{}, b map[string]interface{}) map[string]interface{} { + c := make(map[string]interface{}) + for k, v := range a { + c[k] = v + } + for k, v := range b { + c[k] = v + } + + return c +} diff --git a/setup/config/config.go b/setup/config/config.go index e99852ec9..34edee1cc 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -26,6 +26,7 @@ import ( "strings" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/gomatrixserverlib" "github.com/sirupsen/logrus" "golang.org/x/crypto/ed25519" @@ -305,6 +306,16 @@ func (config *Dendrite) Derive() error { config.Derived.Registration.Flows = append(config.Derived.Registration.Flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}}) } + if config.ClientAPI.PublicKeyAuthentication.Enabled() { + pkFlows := config.ClientAPI.PublicKeyAuthentication.GetPublicKeyRegistrationFlows() + if pkFlows != nil { + config.Derived.Registration.Flows = append(config.Derived.Registration.Flows, pkFlows...) + } + pkParams := config.ClientAPI.PublicKeyAuthentication.GetPublicKeyRegistrationParams() + if pkParams != nil { + config.Derived.Registration.Params = mapsutil.MapsUnion(config.Derived.Registration.Params, pkParams) + } + } // Load application service configuration files if err := loadAppServices(&config.AppServiceAPI, &config.Derived); err != nil { diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index 56f4b3f92..e8ca28196 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -3,6 +3,8 @@ package config import ( "fmt" "time" + + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) type ClientAPI struct { @@ -49,6 +51,12 @@ type ClientAPI struct { RateLimiting RateLimiting `yaml:"rate_limiting"` MSCs *MSCs `yaml:"-"` + + // Disable password authentication. + PasswordAuthenticationDisabled bool `yaml:"password_authentication_disabled"` + + // Public key authentication + PublicKeyAuthentication publicKeyAuthentication `yaml:"public_key_authentication"` } func (c *ClientAPI) Defaults(opts DefaultOpts) { @@ -154,3 +162,44 @@ func (r *RateLimiting) Defaults() { r.Threshold = 5 r.CooloffMS = 500 } + +type ethereumAuthParams struct { + Version uint32 `json:"version"` + ChainIDs []string `json:"chain_ids"` +} + +type ethereumAuthConfig struct { + Enabled bool `yaml:"enabled"` + Version uint32 `yaml:"version"` + ChainIDs []string `yaml:"chain_ids"` +} + +type publicKeyAuthentication struct { + Ethereum ethereumAuthConfig `yaml:"ethereum"` +} + +func (pk *publicKeyAuthentication) Enabled() bool { + return pk.Ethereum.Enabled +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { + var flows []authtypes.Flow + if pk.Ethereum.Enabled { + flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) + } + + return flows +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { + params := make(map[string]interface{}) + if pk.Ethereum.Enabled { + p := ethereumAuthParams{ + Version: pk.Ethereum.Version, + ChainIDs: pk.Ethereum.ChainIDs, + } + params[authtypes.LoginTypePublicKeyEthereum] = p + } + + return params +} diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index 3b67a4acc..c4aec552c 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 0, - "web": 0, + "android": 1, + "web": 1, "electron": 0, - "all": 0, + "all": 2, }, AllUsers: 6, NonBridgedUsers: 5, From 87851ae919302cd4d75a9198a2a82de4eee94ed5 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 13 May 2022 11:09:08 -0700 Subject: [PATCH 03/75] Blacklist some sytest tests that are failing in our environment --- sytest-blacklist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sytest-blacklist b/sytest-blacklist index 14edf398a..adebaf00a 100644 --- a/sytest-blacklist +++ b/sytest-blacklist @@ -40,4 +40,4 @@ Accesing an AS-hosted room alias asks the AS server Guest users can join guest_access rooms # This will fail in HTTP API mode, so blacklisted for now -If a device list update goes missing, the server resyncs on the next one \ No newline at end of file +If a device list update goes missing, the server resyncs on the next one From 88bbaed24734bce2c4a25873d3dc38decae7fefb Mon Sep 17 00:00:00 2001 From: Tak Wai Wong Date: Fri, 3 Jun 2022 11:42:47 -0700 Subject: [PATCH 04/75] refresh latest dendrite main --- sytest-whitelist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sytest-whitelist b/sytest-whitelist index e92ae6495..aedcc9e7a 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -754,4 +754,4 @@ Messages that notify from another user increment notification_count Messages that highlight from another user increment unread highlight count Notifications can be viewed with GET /notifications Can get rooms/{roomId}/messages for a departed room (SPEC-216) -Local device key changes appear in /keys/changes \ No newline at end of file +Local device key changes appear in /keys/changes From 34342934cc27934c589bfdf20726fad528c6ae85 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong Date: Thu, 9 Jun 2022 13:29:33 -0700 Subject: [PATCH 05/75] pull latest from dendrite-fork subtree --- clientapi/auth/login_publickey_ethereum.go | 149 +++------------------ clientapi/auth/login_test.go | 18 ++- clientapi/auth/user_interactive.go | 24 +++- clientapi/auth/user_interactive_test.go | 11 +- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- clientapi/routing/register_publickey.go | 7 + dendrite-sample.monolith.yaml | 10 ++ internal/mapsutil/maps.go | 15 +++ setup/config/config.go | 2 +- setup/config/config_clientapi.go | 43 ------ setup/config/config_publickey.go | 83 ++++++++++++ 12 files changed, 171 insertions(+), 195 deletions(-) create mode 100644 setup/config/config_publickey.go diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 2a8cd78cb..938a9f816 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -16,51 +16,28 @@ package auth import ( "context" - "encoding/base64" "encoding/json" - "errors" - "regexp" "strings" - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/crypto" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/userutil" "github.com/matrix-org/dendrite/setup/config" userapi "github.com/matrix-org/dendrite/userapi/api" - "github.com/tidwall/gjson" + "github.com/spruceid/siwe-go" ) type LoginPublicKeyEthereum struct { // https://github.com/tak-hntlabs/matrix-spec-proposals/blob/main/proposals/3782-matrix-publickey-login-spec.md#client-sends-login-request-with-authentication-data - Type string `json:"type"` - Address string `json:"address"` - Session string `json:"session"` - Message string `json:"message"` - Signature string `json:"signature"` - HashFields publicKeyEthereumHashFields `json:"hashFields"` - HashFieldsRaw string // Raw base64 encoded string of MessageFields for hash verification + Type string `json:"type"` + Address string `json:"address"` + Session string `json:"session"` + Message string `json:"message"` + Signature string `json:"signature"` userAPI userapi.ClientUserAPI config *config.ClientAPI } -type publicKeyEthereumHashFields struct { - // Todo: See https://... - Domain string `json:"domain"` // home server domain - Address string `json:"address"` // Ethereum address. 0x... - Nonce string `json:"nonce"` // session ID - Version string `json:"version"` // version of the Matrix public key spec that the client is complying with - ChainId string `json:"chainId"` // blockchain network ID. -} - -type publicKeyEthereumRequiredFields struct { - From string // Sender - To string // Recipient - Hash string // Hash of JSON representation of the message fields -} - func CreatePublicKeyEthereumHandler( reqBytes []byte, userAPI userapi.ClientUserAPI, @@ -71,15 +48,8 @@ func CreatePublicKeyEthereumHandler( return nil, jsonerror.BadJSON("auth") } - hashFields := gjson.GetBytes(reqBytes, "hashFields") - if !hashFields.Exists() { - return nil, jsonerror.BadJSON("auth.hashFields") - } - pk.config = config pk.userAPI = userAPI - // Save raw bytes for hash verification later. - pk.HashFieldsRaw = hashFields.Raw // Case-insensitive pk.Address = strings.ToLower(pk.Address) @@ -116,41 +86,20 @@ func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *js } func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.MatrixError) { - // Check signature to verify message was not tempered - isVerified := verifySignature(pk.Address, []byte(pk.Message), pk.Signature) - if !isVerified { - return false, jsonerror.InvalidSignature("") - } - - // Extract the required message fields for validation - requiredFields, err := extractRequiredMessageFields(pk.Message) + // Parse the message to extract all the fields. + message, err := siwe.ParseMessage(pk.Message) if err != nil { - return false, jsonerror.MissingParam("message does not contain domain, address, or hash") + return false, jsonerror.InvalidParam("auth.message") } - // Verify that the hash is valid for the message fields. - if !verifyHash(pk.HashFieldsRaw, requiredFields.Hash) { - return false, jsonerror.Forbidden("error verifying message hash") - } - - // Unmarshal the hashFields for further validation - var authData publicKeyEthereumHashFields - if err := json.Unmarshal([]byte(pk.HashFieldsRaw), &authData); err != nil { - return false, jsonerror.BadJSON("auth.hashFields") - } - - // Error if the message is not from the expected public address - if pk.Address != requiredFields.From || requiredFields.From != pk.HashFields.Address { - return false, jsonerror.Forbidden("address") - } - - // Error if the message is not for the home server - if requiredFields.To != pk.HashFields.Domain { - return false, jsonerror.Forbidden("domain") + // Check signature to verify message was not tempered + _, err = message.Verify(pk.Signature, (*string)(&pk.config.Matrix.ServerName), nil, nil) + if err != nil { + return false, jsonerror.InvalidSignature(err.Error()) } // Error if the chainId is not supported by the server. - if !contains(pk.config.PublicKeyAuthentication.Ethereum.ChainIDs, authData.ChainId) { + if !contains(pk.config.PublicKeyAuthentication.Ethereum.ChainIDs, message.GetChainID()) { return false, jsonerror.Forbidden("chainId") } @@ -169,75 +118,7 @@ func (pk LoginPublicKeyEthereum) CreateLogin() *Login { return &login } -// The required fields in the signed message are: -// 1. Domain -- home server. First non-whitespace characters in the first line. -// 2. Address -- public address of the user. Starts with 0x... in the second line on its own. -// 3. Hash -- Base64-encoded hash string of the metadata that represents the message. -// The rest of the fields are informational, and will be used in the future. -var regexpAuthority = regexp.MustCompile(`^\S+`) -var regexpAddress = regexp.MustCompile(`\n(?P
0x\w+)\n`) -var regexpHash = regexp.MustCompile(`\nHash: (?P.*)\n`) - -func extractRequiredMessageFields(message string) (*publicKeyEthereumRequiredFields, error) { - var requiredFields publicKeyEthereumRequiredFields - /* - service.org wants you to sign in with your account: - 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 - - I accept the ServiceOrg Terms of Service: https://service.org/tos - - Hash: yfSIwarByPfKFxeYSCWN3XoIgNgeEFJffbwFA+JxYbA= - */ - - requiredFields.To = regexpAuthority.FindString(message) - - from := regexpAddress.FindStringSubmatch(message) - if len(from) == 2 { - requiredFields.From = from[1] - } - - hash := regexpHash.FindStringSubmatch(message) - if len(hash) == 2 { - requiredFields.Hash = hash[1] - } - - if len(requiredFields.To) == 0 || len(requiredFields.From) == 0 || len(requiredFields.Hash) == 0 { - return nil, errors.New("required message fields are missing") - } - - // Make these fields case-insensitive - requiredFields.From = strings.ToLower(requiredFields.From) - requiredFields.To = strings.ToLower(requiredFields.To) - - return &requiredFields, nil -} - -func verifySignature(from string, message []byte, signature string) bool { - decodedSig := hexutil.MustDecode(signature) - - message = accounts.TextHash(message) - // Issue: https://stackoverflow.com/questions/49085737/geth-ecrecover-invalid-signature-recovery-id - // Fix: https://gist.github.com/dcb9/385631846097e1f59e3cba3b1d42f3ed#file-eth_sign_verify-go - decodedSig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1 - - recovered, err := crypto.SigToPub(message, decodedSig) - if err != nil { - return false - } - - recoveredAddr := crypto.PubkeyToAddress(*recovered) - - addressStr := strings.ToLower(recoveredAddr.Hex()) - return from == addressStr -} - -func verifyHash(rawStr string, expectedHash string) bool { - hash := crypto.Keccak256([]byte(rawStr)) - hashStr := base64.StdEncoding.EncodeToString(hash) - return expectedHash == hashStr -} - -func contains(list []string, element string) bool { +func contains(list []int, element int) bool { for _, i := range list { if i == element { return true diff --git a/clientapi/auth/login_test.go b/clientapi/auth/login_test.go index 655455515..04e51323d 100644 --- a/clientapi/auth/login_test.go +++ b/clientapi/auth/login_test.go @@ -62,11 +62,10 @@ func TestLoginFromJSONReader(t *testing.T) { }, } userInteractive := UserInteractive{ - Completed: []string{}, - Flows: []userInteractiveFlow{}, - Types: make(map[string]Type), - Sessions: make(map[string][]string), - Params: make(map[string]interface{}), + Flows: []userInteractiveFlow{}, + Types: make(map[string]Type), + Sessions: make(map[string][]string), + Params: make(map[string]interface{}), } for _, tst := range tsts { @@ -148,11 +147,10 @@ func TestBadLoginFromJSONReader(t *testing.T) { }, } userInteractive := UserInteractive{ - Completed: []string{}, - Flows: []userInteractiveFlow{}, - Types: make(map[string]Type), - Sessions: make(map[string][]string), - Params: make(map[string]interface{}), + Flows: []userInteractiveFlow{}, + Types: make(map[string]Type), + Sessions: make(map[string][]string), + Params: make(map[string]interface{}), } for _, tst := range tsts { diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 2a5084bb9..b7e1724f1 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -21,6 +21,7 @@ import ( "sync" "github.com/matrix-org/dendrite/clientapi/jsonerror" + "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/userapi/api" "github.com/matrix-org/util" @@ -177,17 +178,27 @@ type Challenge struct { // Challenge returns an HTTP 401 with the supported flows for authenticating func (u *UserInteractive) challenge(sessionID string) *util.JSONResponse { u.RLock() + paramsCopy := mapsutil.MapCopy(u.Params) completed := u.Sessions[sessionID] flows := u.Flows u.RUnlock() + for key, element := range paramsCopy { + p := GetAuthParams(element) + if p != nil { + // If an auth flow has params, + // send it as part of the challenge. + paramsCopy[key] = p + } + } + return &util.JSONResponse{ Code: 401, JSON: Challenge{ Completed: completed, Flows: flows, Session: sessionID, - Params: u.Params, + Params: paramsCopy, }, } } @@ -233,7 +244,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" @@ -284,3 +295,12 @@ func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, // TODO: Check if there's more stages to go and return an error return login, nil } + +func GetAuthParams(params interface{}) interface{} { + v, ok := params.(config.AuthParams) + if ok { + p := v.GetParams() + return p + } + return nil +} diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index bc1239910..3dbb9dabc 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,6 +17,11 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) + device = &api.Device{ + AccessToken: "flibble", + DisplayName: "My Device", + ID: "device_id_goes_here", + } ) type fakeAccountDatabase struct { @@ -55,7 +60,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`)) + _, errRes := uia.Verify(ctx, []byte(`{}`), device) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -95,7 +100,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc) + _, errRes := uia.Verify(ctx, tc, device) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -176,7 +181,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body) + _, errRes := uia.Verify(ctx, tc.body, device) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index 9f80dff61..f213db7f3 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index 84e11bc7a..e3a02661c 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index 46807f41e..c6cd5e30a 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -68,6 +68,13 @@ func handlePublicKeyRegistration( return false, "", nil } + if _, ok := sessions.sessions[authHandler.GetSession()]; !ok { + return false, "", &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.Unknown("the session ID is missing or unknown."), + } + } + isCompleted, jerr := authHandler.ValidateLoginResponse() if jerr != nil { return false, "", &util.JSONResponse{ diff --git a/dendrite-sample.monolith.yaml b/dendrite-sample.monolith.yaml index eadb74a2a..b030b62eb 100644 --- a/dendrite-sample.monolith.yaml +++ b/dendrite-sample.monolith.yaml @@ -170,6 +170,16 @@ client_api: # of whether registration is otherwise disabled. registration_shared_secret: "" + # Disable password authentication. + password_authentication_disabled: false + + # public key authentication + public_key_authentication: + ethereum: + enabled: false + version: 1 + chain_ids: [] + # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used # for coordinated spam attacks. diff --git a/internal/mapsutil/maps.go b/internal/mapsutil/maps.go index 038ef53a8..b7eaba0dd 100644 --- a/internal/mapsutil/maps.go +++ b/internal/mapsutil/maps.go @@ -27,3 +27,18 @@ func MapsUnion(a map[string]interface{}, b map[string]interface{}) map[string]in return c } + +// Make a copy of the map +func MapCopy(m map[string]interface{}) map[string]interface{} { + cp := make(map[string]interface{}) + for k, v := range m { + vm, ok := v.(map[string]interface{}) + if ok { + cp[k] = MapCopy(vm) + } else { + cp[k] = v + } + } + + return cp +} diff --git a/setup/config/config.go b/setup/config/config.go index 34edee1cc..150053fd2 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -302,7 +302,7 @@ func (config *Dendrite) Derive() error { config.Derived.Registration.Params[authtypes.LoginTypeRecaptcha] = map[string]string{"public_key": config.ClientAPI.RecaptchaPublicKey} config.Derived.Registration.Flows = append(config.Derived.Registration.Flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeRecaptcha}}) - } else { + } else if !config.ClientAPI.PasswordAuthenticationDisabled { config.Derived.Registration.Flows = append(config.Derived.Registration.Flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}}) } diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index e8ca28196..c9e4418c8 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -3,8 +3,6 @@ package config import ( "fmt" "time" - - "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) type ClientAPI struct { @@ -162,44 +160,3 @@ func (r *RateLimiting) Defaults() { r.Threshold = 5 r.CooloffMS = 500 } - -type ethereumAuthParams struct { - Version uint32 `json:"version"` - ChainIDs []string `json:"chain_ids"` -} - -type ethereumAuthConfig struct { - Enabled bool `yaml:"enabled"` - Version uint32 `yaml:"version"` - ChainIDs []string `yaml:"chain_ids"` -} - -type publicKeyAuthentication struct { - Ethereum ethereumAuthConfig `yaml:"ethereum"` -} - -func (pk *publicKeyAuthentication) Enabled() bool { - return pk.Ethereum.Enabled -} - -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { - var flows []authtypes.Flow - if pk.Ethereum.Enabled { - flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) - } - - return flows -} - -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { - params := make(map[string]interface{}) - if pk.Ethereum.Enabled { - p := ethereumAuthParams{ - Version: pk.Ethereum.Version, - ChainIDs: pk.Ethereum.ChainIDs, - } - params[authtypes.LoginTypePublicKeyEthereum] = p - } - - return params -} diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go new file mode 100644 index 000000000..9820a5969 --- /dev/null +++ b/setup/config/config_publickey.go @@ -0,0 +1,83 @@ +package config + +import ( + "math/rand" + "time" + + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" +) + +var nonceLength = 32 + +type AuthParams interface { + GetParams() interface{} + GetNonce() string +} + +type EthereumAuthParams struct { + Version uint `json:"version"` + ChainIDs []int `json:"chain_ids"` + Nonce string `json:"nonce"` +} + +func (p EthereumAuthParams) GetParams() interface{} { + copyP := p + copyP.ChainIDs = make([]int, len(p.ChainIDs)) + copy(copyP.ChainIDs, p.ChainIDs) + copyP.Nonce = newNonce(nonceLength) + return copyP +} + +func (p EthereumAuthParams) GetNonce() string { + return p.Nonce +} + +type ethereumAuthConfig struct { + Enabled bool `yaml:"enabled"` + Version uint `yaml:"version"` + ChainIDs []int `yaml:"chain_ids"` +} + +type publicKeyAuthentication struct { + Ethereum ethereumAuthConfig `yaml:"ethereum"` +} + +func (pk *publicKeyAuthentication) Enabled() bool { + return pk.Ethereum.Enabled +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { + var flows []authtypes.Flow + if pk.Ethereum.Enabled { + flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) + } + + return flows +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { + params := make(map[string]interface{}) + if pk.Ethereum.Enabled { + p := EthereumAuthParams{ + Version: pk.Ethereum.Version, + ChainIDs: pk.Ethereum.ChainIDs, + Nonce: "", + } + params[authtypes.LoginTypePublicKeyEthereum] = p + } + + return params +} + +const lettersAndNumbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + +func newNonce(n int) string { + nonce := make([]byte, n) + rand.Seed(time.Now().UnixNano()) + + for i := range nonce { + nonce[i] = lettersAndNumbers[rand.Int63()%int64(len(lettersAndNumbers))] + } + + return string(nonce) +} From 1683a17dbf73992ca43513bbb36977099d380c87 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong Date: Tue, 14 Jun 2022 14:22:52 -0700 Subject: [PATCH 06/75] refresh latest dendrite main --- docs/caddy/monolith/CaddyFile | 68 ++++++++++++++++ docs/caddy/monolith/Caddyfile | 111 +++++++++++++++------------ docs/installation/10_optimisation.md | 71 +++++++++++++++++ 3 files changed, 200 insertions(+), 50 deletions(-) create mode 100644 docs/caddy/monolith/CaddyFile create mode 100644 docs/installation/10_optimisation.md diff --git a/docs/caddy/monolith/CaddyFile b/docs/caddy/monolith/CaddyFile new file mode 100644 index 000000000..cd93f9e10 --- /dev/null +++ b/docs/caddy/monolith/CaddyFile @@ -0,0 +1,68 @@ +{ + # debug + admin off + email example@example.com + default_sni example.com + # Debug endpoint + # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory +} + +####################################################################### +# Snippets +#______________________________________________________________________ + +(handle_errors_maintenance) { + handle_errors { + @maintenance expression {http.error.status_code} == 502 + rewrite @maintenance maintenance.html + root * "/path/to/service/pages" + file_server + } +} + +(matrix-well-known-header) { + # Headers + header Access-Control-Allow-Origin "*" + header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" + header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization" + header Content-Type "application/json" +} + +####################################################################### + +example.com { + + # ... + + handle /.well-known/matrix/server { + import matrix-well-known-header + respond `{ "m.server": "matrix.example.com:443" }` 200 + } + + handle /.well-known/matrix/client { + import matrix-well-known-header + respond `{ "m.homeserver": { "base_url": "https://matrix.example.com" } }` 200 + } + + import handle_errors_maintenance +} + +example.com:8448 { + # server<->server HTTPS traffic + reverse_proxy http://dendrite-host:8008 +} + +matrix.example.com { + + handle /_matrix/* { + # client<->server HTTPS traffic + reverse_proxy http://dendrite-host:8008 + } + + handle_path /* { + # Client webapp (Element SPA or ...) + file_server { + root /path/to/www/example.com/matrix-web-client/ + } + } +} diff --git a/docs/caddy/monolith/Caddyfile b/docs/caddy/monolith/Caddyfile index 82567c4a6..cd93f9e10 100644 --- a/docs/caddy/monolith/Caddyfile +++ b/docs/caddy/monolith/Caddyfile @@ -1,57 +1,68 @@ -# Sample Caddyfile for using Caddy in front of Dendrite. -# -# Customize email address and domain names. -# Optional settings commented out. -# -# BE SURE YOUR DOMAINS ARE POINTED AT YOUR SERVER FIRST. -# Documentation: https://caddyserver.com/docs/ -# -# Bonus tip: If your IP address changes, use Caddy's -# dynamic DNS plugin to update your DNS records to -# point to your new IP automatically: -# https://github.com/mholt/caddy-dynamicdns -# - - -# Global options block { - # In case there is a problem with your certificates. - # email example@example.com - - # Turn off the admin endpoint if you don't need graceful config - # changes and/or are running untrusted code on your machine. - # admin off - - # Enable this if your clients don't send ServerName in TLS handshakes. - # default_sni example.com - - # Enable debug mode for verbose logging. - # debug - - # Use Let's Encrypt's staging endpoint for testing. - # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory - - # If you're port-forwarding HTTP/HTTPS ports from 80/443 to something - # else, enable these and put the alternate port numbers here. - # http_port 8080 - # https_port 8443 + # debug + admin off + email example@example.com + default_sni example.com + # Debug endpoint + # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory } -# The server name of your matrix homeserver. This example shows -# "well-known delegation" from the registered domain to a subdomain, -# which is only needed if your server_name doesn't match your Matrix -# homeserver URL (i.e. you can show users a vanity domain that looks -# nice and is easy to remember but still have your Matrix server on -# its own subdomain or hosted service). +####################################################################### +# Snippets +#______________________________________________________________________ + +(handle_errors_maintenance) { + handle_errors { + @maintenance expression {http.error.status_code} == 502 + rewrite @maintenance maintenance.html + root * "/path/to/service/pages" + file_server + } +} + +(matrix-well-known-header) { + # Headers + header Access-Control-Allow-Origin "*" + header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" + header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization" + header Content-Type "application/json" +} + +####################################################################### + example.com { - header /.well-known/matrix/* Content-Type application/json - header /.well-known/matrix/* Access-Control-Allow-Origin * - respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}` - respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://matrix.example.com"}}` + + # ... + + handle /.well-known/matrix/server { + import matrix-well-known-header + respond `{ "m.server": "matrix.example.com:443" }` 200 + } + + handle /.well-known/matrix/client { + import matrix-well-known-header + respond `{ "m.homeserver": { "base_url": "https://matrix.example.com" } }` 200 + } + + import handle_errors_maintenance } -# The actual domain name whereby your Matrix server is accessed. -matrix.example.com { - # Set localhost:8008 to the address of your Dendrite server, if different - reverse_proxy /_matrix/* localhost:8008 +example.com:8448 { + # server<->server HTTPS traffic + reverse_proxy http://dendrite-host:8008 +} + +matrix.example.com { + + handle /_matrix/* { + # client<->server HTTPS traffic + reverse_proxy http://dendrite-host:8008 + } + + handle_path /* { + # Client webapp (Element SPA or ...) + file_server { + root /path/to/www/example.com/matrix-web-client/ + } + } } diff --git a/docs/installation/10_optimisation.md b/docs/installation/10_optimisation.md new file mode 100644 index 000000000..c19b7a75e --- /dev/null +++ b/docs/installation/10_optimisation.md @@ -0,0 +1,71 @@ +--- +title: Optimise your installation +parent: Installation +has_toc: true +nav_order: 10 +permalink: /installation/start/optimisation +--- + +# Optimise your installation + +Now that you have Dendrite running, the following tweaks will improve the reliability +and performance of your installation. + +## File descriptor limit + +Most platforms have a limit on how many file descriptors a single process can open. All +connections made by Dendrite consume file descriptors — this includes database connections +and network requests to remote homeservers. When participating in large federated rooms +where Dendrite must talk to many remote servers, it is often very easy to exhaust default +limits which are quite low. + +We currently recommend setting the file descriptor limit to 65535 to avoid such +issues. Dendrite will log immediately after startup if the file descriptor limit is too low: + +``` +level=warning msg="IMPORTANT: Process file descriptor limit is currently 1024, it is recommended to raise the limit for Dendrite to at least 65535 to avoid issues" +``` + +UNIX systems have two limits: a hard limit and a soft limit. You can view the soft limit +by running `ulimit -Sn` and the hard limit with `ulimit -Hn`: + +```bash +$ ulimit -Hn +1048576 + +$ ulimit -Sn +1024 +``` + +Increase the soft limit before starting Dendrite: + +```bash +ulimit -Sn 65535 +``` + +The log line at startup should no longer appear if the limit is sufficient. + +If you are running under a systemd service, you can instead add `LimitNOFILE=65535` option +to the `[Service]` section of your service unit file. + +## DNS caching + +Dendrite has a built-in DNS cache which significantly reduces the load that Dendrite will +place on your DNS resolver. This may also speed up outbound federation. + +Consider enabling the DNS cache by modifying the `global` section of your configuration file: + +```yaml + dns_cache: + enabled: true + cache_size: 4096 + cache_lifetime: 600s +``` + +## Time synchronisation + +Matrix relies heavily on TLS which requires the system time to be correct. If the clock +drifts then you may find that federation no works reliably (or at all) and clients may +struggle to connect to your Dendrite server. + +Ensure that the time is synchronised on your system by enabling NTP sync. From 3e014fb70ccabc58b891168ed3f31fd07cc6fafc Mon Sep 17 00:00:00 2001 From: Tak Wai Wong Date: Tue, 14 Jun 2022 16:27:01 -0700 Subject: [PATCH 07/75] pull dendrite subtree and resolve merge conflicts --- clientapi/auth/login_publickey_ethereum.go | 8 ++++---- clientapi/routing/register.go | 2 +- clientapi/routing/register_publickey.go | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 938a9f816..592f02383 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -29,7 +29,7 @@ import ( type LoginPublicKeyEthereum struct { // https://github.com/tak-hntlabs/matrix-spec-proposals/blob/main/proposals/3782-matrix-publickey-login-spec.md#client-sends-login-request-with-authentication-data Type string `json:"type"` - Address string `json:"address"` + UserId string `json:"user_id"` Session string `json:"session"` Message string `json:"message"` Signature string `json:"signature"` @@ -51,7 +51,7 @@ func CreatePublicKeyEthereumHandler( pk.config = config pk.userAPI = userAPI // Case-insensitive - pk.Address = strings.ToLower(pk.Address) + pk.UserId = strings.ToLower(pk.UserId) return &pk, nil } @@ -65,7 +65,7 @@ func (pk LoginPublicKeyEthereum) GetType() string { } func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) { - localPart, err := userutil.ParseUsernameParam(pk.Address, &pk.config.Matrix.ServerName) + localPart, err := userutil.ParseUsernameParam(pk.UserId, &pk.config.Matrix.ServerName) if err != nil { // userId does not exist return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.") @@ -110,7 +110,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri func (pk LoginPublicKeyEthereum) CreateLogin() *Login { identifier := LoginIdentifier{ Type: "m.id.publickey", - User: pk.Address, + User: pk.UserId, } login := Login{ Identifier: identifier, diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index e73cbb770..909a62609 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -775,7 +775,7 @@ func handleRegistrationFlow( if isCompleted { sessions.addCompletedSessionStage(sessionID, authType) } else { - newPublicKeyAuthSession(&r) + newPublicKeyAuthSession(&r, sessions, sessionID) } case "": diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index c6cd5e30a..aa0fea656 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -26,7 +26,8 @@ import ( "github.com/tidwall/gjson" ) -func newPublicKeyAuthSession(request *registerRequest) { +func newPublicKeyAuthSession(request *registerRequest, sessions *sessionsDict, sessionID string) { + sessions.sessions[sessionID] = append(sessions.sessions[sessionID], authtypes.LoginTypePublicKey) // Public key auth does not use password. But the registration flow // requires setting a password in order to create the account. // Create a random password to satisfy the requirement. From c28715c5ff00e65fee8af1ea08079cca39d98770 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:08:31 -0400 Subject: [PATCH 08/75] Verify that the user ID for registration matches the spec, and the auth data (#10) (#104) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong --- clientapi/auth/login_publickey.go | 1 + clientapi/auth/login_publickey_ethereum.go | 35 ++++++++++++++++++++++ clientapi/routing/register.go | 2 +- clientapi/routing/register_publickey.go | 9 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/clientapi/auth/login_publickey.go b/clientapi/auth/login_publickey.go index b93420b2e..e999edeb7 100644 --- a/clientapi/auth/login_publickey.go +++ b/clientapi/auth/login_publickey.go @@ -30,6 +30,7 @@ import ( type LoginPublicKeyHandler interface { AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) + IsValidUserIdForRegistration(userId string) bool CreateLogin() *Login GetSession() string GetType() string diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 592f02383..3ac367a81 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -17,6 +17,8 @@ package auth import ( "context" "encoding/json" + "fmt" + "regexp" "strings" "github.com/matrix-org/dendrite/clientapi/jsonerror" @@ -85,6 +87,24 @@ func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *js return localPart, nil } +var validChainAgnosticIdRegex = regexp.MustCompile("^eip155=3a[0-9]+=3a0x[0-9a-fA-F]+$") + +func (pk LoginPublicKeyEthereum) IsValidUserIdForRegistration(userId string) bool { + // Verify that the user ID is a valid one according to spec. + // https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md + + // Matrix ID has additional grammar requirements for user ID. + // https://spec.matrix.org/v1.1/appendices/#user-identifiers + // Make sure disallowed characters are escaped. + // E.g. ":" is replaced with "=3a". + + isValid := validChainAgnosticIdRegex.MatchString(userId) + + // In addition, double check that the user ID for registration + // matches the authentication data in the request. + return isValid && userId == pk.UserId +} + func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.MatrixError) { // Parse the message to extract all the fields. message, err := siwe.ParseMessage(pk.Message) @@ -98,6 +118,12 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri return false, jsonerror.InvalidSignature(err.Error()) } + // Error if the user ID does not match the signed message. + isVerifiedUserId := pk.verifyMessageUserId(message) + if !isVerifiedUserId { + return false, jsonerror.InvalidUsername(pk.UserId) + } + // Error if the chainId is not supported by the server. if !contains(pk.config.PublicKeyAuthentication.Ethereum.ChainIDs, message.GetChainID()) { return false, jsonerror.Forbidden("chainId") @@ -118,6 +144,15 @@ func (pk LoginPublicKeyEthereum) CreateLogin() *Login { return &login } +func (pk LoginPublicKeyEthereum) verifyMessageUserId(message *siwe.Message) bool { + // Use info in the signed message to derive the expected user ID. + expectedUserId := fmt.Sprintf("eip155=3a%d=3a%s", message.GetChainID(), message.GetAddress()) + + // Case-insensitive comparison to make sure the user ID matches the expected + // one derived from the signed message. + return pk.UserId == strings.ToLower(expectedUserId) +} + func contains(list []int, element int) bool { for _, i := range list { if i == element { diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 909a62609..fa956aa4c 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -767,7 +767,7 @@ func handleRegistrationFlow( sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) case authtypes.LoginTypePublicKey: - isCompleted, authType, err := handlePublicKeyRegistration(cfg, reqBody, userAPI) + isCompleted, authType, err := handlePublicKeyRegistration(cfg, reqBody, &r, userAPI) if err != nil { return *err } diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index aa0fea656..2ab2b6ca1 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -37,6 +37,7 @@ func newPublicKeyAuthSession(request *registerRequest, sessions *sessionsDict, s func handlePublicKeyRegistration( cfg *config.ClientAPI, reqBytes []byte, + r *registerRequest, userAPI userapi.ClientUserAPI, ) (bool, authtypes.LoginType, *util.JSONResponse) { if !cfg.PublicKeyAuthentication.Enabled() { @@ -76,6 +77,14 @@ func handlePublicKeyRegistration( } } + isValidUserId := authHandler.IsValidUserIdForRegistration(r.Username) + if !isValidUserId { + return false, "", &util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.InvalidUsername(r.Username), + } + } + isCompleted, jerr := authHandler.ValidateLoginResponse() if jerr != nil { return false, "", &util.JSONResponse{ From 57cdd1ff6594e4475621aa33dee2e8a0ba17cb0b Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 30 Jun 2022 22:39:54 -0400 Subject: [PATCH 09/75] Latest dendrite main refresh (#129) * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Fix nats.go commit (#2540) Signed-off-by: Jean Lucas * Don't return `end` if there are not more messages (#2542) * Be more spec compliant * Move lazyLoadMembers to own method * Return an error if trying to invite a malformed user ID (#2543) * Add `evacuateUser` endpoint, use it when deactivating accounts (#2545) * Add `evacuateUser` endpoint, use it when deactivating accounts * Populate the API * Clean up user devices when deactivating * Include invites, delete pushers * Silence presence logs (#2547) * update sytest blacklist * Add new test that passed to the whitelist * skip failed test Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong Co-authored-by: Jean Lucas Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander --- sytest-whitelist | 1 + 1 file changed, 1 insertion(+) diff --git a/sytest-whitelist b/sytest-whitelist index aedcc9e7a..9f019fb40 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -107,6 +107,7 @@ Lazy loading parameters in the filter are strictly boolean Can sync Can sync a joined room Newly joined room is included in an incremental sync +Newly joined room includes presence in incremental sync User is offline if they set_presence=offline in their sync Changes to state are included in an incremental sync A change to displayname should appear in incremental /sync From f1d871fbea2310384de6379b2a5127a96b503c87 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Fri, 1 Jul 2022 13:51:25 -0400 Subject: [PATCH 10/75] Takwaiw/refresh dendrite fork (#132) * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Fix nats.go commit (#2540) Signed-off-by: Jean Lucas * Don't return `end` if there are not more messages (#2542) * Be more spec compliant * Move lazyLoadMembers to own method * Return an error if trying to invite a malformed user ID (#2543) * Add `evacuateUser` endpoint, use it when deactivating accounts (#2545) * Add `evacuateUser` endpoint, use it when deactivating accounts * Populate the API * Clean up user devices when deactivating * Include invites, delete pushers * Silence presence logs (#2547) * Takwaiw/fix concurrent registration bug (#12) * fix concurrent registration bug. Rename decentralizedid * remove unused module * add regressed test to blacklist Co-authored-by: Tak Wai Wong Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong Co-authored-by: Jean Lucas Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander --- clientapi/auth/authtypes/stages.go | 19 +++++++++++++++ clientapi/auth/login_publickey_ethereum.go | 2 +- clientapi/auth/user_interactive.go | 2 +- clientapi/routing/register.go | 12 ++++------ clientapi/routing/register_publickey.go | 28 +++++++++++++--------- 5 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 clientapi/auth/authtypes/stages.go diff --git a/clientapi/auth/authtypes/stages.go b/clientapi/auth/authtypes/stages.go new file mode 100644 index 000000000..34b74444a --- /dev/null +++ b/clientapi/auth/authtypes/stages.go @@ -0,0 +1,19 @@ +// Copyright 2021 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package authtypes + +const ( + LoginStagePublicKeyNewRegistration = "m.login.publickey.newregistration" +) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 3ac367a81..a3201a269 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -135,7 +135,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri func (pk LoginPublicKeyEthereum) CreateLogin() *Login { identifier := LoginIdentifier{ - Type: "m.id.publickey", + Type: "m.id.decentralizedid", User: pk.UserId, } login := Login{ diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index b7e1724f1..b509ebf46 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -76,7 +76,7 @@ type Login struct { // Username returns the user localpart/user_id in this request, if it exists. func (r *Login) Username() string { - if r.Identifier.Type == "m.id.user" || r.Identifier.Type == "m.id.publickey" { + if r.Identifier.Type == "m.id.user" || r.Identifier.Type == "m.id.decentralizedid" { return r.Identifier.User } // deprecated but without it Element iOS won't log in diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index fa956aa4c..6827bed22 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -764,19 +764,17 @@ func handleRegistrationFlow( case authtypes.LoginTypeDummy: // there is nothing to do // Add Dummy to the list of completed registration stages - sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) + if !cfg.PasswordAuthenticationDisabled { + sessions.addCompletedSessionStage(sessionID, authtypes.LoginTypeDummy) + } case authtypes.LoginTypePublicKey: - isCompleted, authType, err := handlePublicKeyRegistration(cfg, reqBody, &r, userAPI) + _, authType, err := handlePublicKeyRegistration(cfg, reqBody, &r, userAPI) if err != nil { return *err } - if isCompleted { - sessions.addCompletedSessionStage(sessionID, authType) - } else { - newPublicKeyAuthSession(&r, sessions, sessionID) - } + sessions.addCompletedSessionStage(sessionID, authType) case "": // An empty auth type means that we want to fetch the available diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index 2ab2b6ca1..258a47249 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -26,14 +26,6 @@ import ( "github.com/tidwall/gjson" ) -func newPublicKeyAuthSession(request *registerRequest, sessions *sessionsDict, sessionID string) { - sessions.sessions[sessionID] = append(sessions.sessions[sessionID], authtypes.LoginTypePublicKey) - // Public key auth does not use password. But the registration flow - // requires setting a password in order to create the account. - // Create a random password to satisfy the requirement. - request.Password = util.RandomString(sessionIDLength) -} - func handlePublicKeyRegistration( cfg *config.ClientAPI, reqBytes []byte, @@ -67,7 +59,7 @@ func handlePublicKeyRegistration( authHandler = pkEthHandler default: // No response. Client is asking for a new registration session - return false, "", nil + return false, authtypes.LoginStagePublicKeyNewRegistration, nil } if _, ok := sessions.sessions[authHandler.GetSession()]; !ok { @@ -85,7 +77,7 @@ func handlePublicKeyRegistration( } } - isCompleted, jerr := authHandler.ValidateLoginResponse() + isValidated, jerr := authHandler.ValidateLoginResponse() if jerr != nil { return false, "", &util.JSONResponse{ Code: http.StatusUnauthorized, @@ -93,5 +85,19 @@ func handlePublicKeyRegistration( } } - return isCompleted, authtypes.LoginType(authHandler.GetType()), nil + // Registration flow requires a password to + // create a user account. Create a random one + // to satisfy the requirement. This is not used + // for public key cryptography. + createPassword(r) + + return isValidated, authtypes.LoginType(authHandler.GetType()), nil +} + +func createPassword(request *registerRequest) { + // Public key auth does not use password. + // Create a random one that is never used. + // Login validation will be done using public / private + // key cryptography. + request.Password = util.RandomString(sessionIDLength) } From 1d906290cb61de1d35a3bcf2aec6453df1a211f0 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Tue, 5 Jul 2022 19:09:08 -0400 Subject: [PATCH 11/75] Takwaiw/pull latest dendrite fork changes (#137) * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Fix nats.go commit (#2540) Signed-off-by: Jean Lucas * Don't return `end` if there are not more messages (#2542) * Be more spec compliant * Move lazyLoadMembers to own method * Return an error if trying to invite a malformed user ID (#2543) * Add `evacuateUser` endpoint, use it when deactivating accounts (#2545) * Add `evacuateUser` endpoint, use it when deactivating accounts * Populate the API * Clean up user devices when deactivating * Include invites, delete pushers * Silence presence logs (#2547) * Blacklist `Guest users can join guest_access rooms` test until it can be investigated * Disable WebAssembly builds for now * Try to fix backfilling (#2548) * Try to fix backfilling * Return start/end to not confuse clients * Update GMSL * Update GMSL * Roomserver producers package (#2546) * Give the roomserver a producers package * Change init point * Populate ACLs API * Fix build issues * `RoomEventProducer` naming * Version 0.8.9 (#2549) * Version 0.8.9 * Update changelog * Takwaiw/fix concurrent registration bug (#12) * fix concurrent registration bug. Rename decentralizedid * remove unused module * add regressed test to blacklist Co-authored-by: Tak Wai Wong * Test_UserStatistics Fix expected results to match observed results * Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong * Implement EIP-4361 sign in with Ethereum (#5) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * refresh latest dendrite main * dendrite implementation of eip-4361 * simplify nonce generation Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Use rand.Seed to seed the random function generator (#6) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * use rand.Seed to seed the random function Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Create session ID during registration (#8) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * Create session ID during registration Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Takwaiw/fix concurrent registration bug (#12) * fix concurrent registration bug. Rename decentralizedid * remove unused module * add regressed test to blacklist Co-authored-by: Tak Wai Wong * removed unused module * feat+fix: Ignore unknown keys and verify required fields are present in appservice registration files (#2550) * fix: ignore unknown keys in appservice configs fixes matrix-org/dendrite#1567 * feat: verify required fields in appservice configs * Use new testrig for key changes tests (#2552) * Use new testrig for tests * Log the error message * Fix QuerySharedUsers for the SyncAPI keychange consumer (#2554) * Make more use of base.BaseDendrite * Fix QuerySharedUsers if no UserIDs are supplied * Return clearer error when no state NID exists for an event (#2555) * Wrap error from `SnapshotNIDFromEventID` * Hopefully fix read receipts timestamps (#2557) This should avoid coercions between signed and unsigned ints which might fix problems like `sql: converting argument $5 type: uint64 values with high bit set are not supported`. * fix concurrency issue when checking session ID (#14) Co-authored-by: Tak Wai Wong * resolve merge conflicts Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong Co-authored-by: Jean Lucas Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander Co-authored-by: Tak Wai Wong Co-authored-by: Kabir Kwatra --- clientapi/routing/register.go | 7 +++++++ clientapi/routing/register_publickey.go | 2 +- roomserver/internal/perform/perform_backfill.go | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 6827bed22..8faff58f8 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -156,6 +156,13 @@ func (d *sessionsDict) startTimer(duration time.Duration, sessionID string) { }) } +func (d *sessionsDict) hasSession(sessionID string) bool { + d.RLock() + defer d.RUnlock() + _, ok := d.sessions[sessionID] + return ok +} + // addCompletedSessionStage records that a session has completed an auth stage // also starts a timer to delete the session once done. func (d *sessionsDict) addCompletedSessionStage(sessionID string, stage authtypes.LoginType) { diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index 258a47249..f5c972bb1 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -62,7 +62,7 @@ func handlePublicKeyRegistration( return false, authtypes.LoginStagePublicKeyNewRegistration, nil } - if _, ok := sessions.sessions[authHandler.GetSession()]; !ok { + if !sessions.hasSession(authHandler.GetSession()) { return false, "", &util.JSONResponse{ Code: http.StatusUnauthorized, JSON: jsonerror.Unknown("the session ID is missing or unknown."), diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go index 57e121ea2..7d65c44fb 100644 --- a/roomserver/internal/perform/perform_backfill.go +++ b/roomserver/internal/perform/perform_backfill.go @@ -18,6 +18,7 @@ import ( "context" "fmt" + "github.com/getsentry/sentry-go" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/sirupsen/logrus" @@ -322,6 +323,7 @@ FederationHit: b.eventIDToBeforeStateIDs[targetEvent.EventID()] = res return res, nil } + sentry.CaptureException(lastErr) // temporary to see if we might need to raise the server limit return nil, lastErr } From 14d1a604ee986522b760ea10b400dc1194ca556b Mon Sep 17 00:00:00 2001 From: sergekh2 Date: Tue, 12 Jul 2022 10:51:14 -0700 Subject: [PATCH 12/75] Config, certs and script to run local dendrite test server --- local_test/README.md | 13 ++ local_test/dendrite.yaml | 383 ++++++++++++++++++++++++++++++++++++++ local_test/matrix_key.pem | 5 + local_test/run.sh | 9 + local_test/server.crt | 28 +++ local_test/server.key | 51 +++++ 6 files changed, 489 insertions(+) create mode 100644 local_test/README.md create mode 100644 local_test/dendrite.yaml create mode 100644 local_test/matrix_key.pem create mode 100755 local_test/run.sh create mode 100644 local_test/server.crt create mode 100644 local_test/server.key diff --git a/local_test/README.md b/local_test/README.md new file mode 100644 index 000000000..b5f175b88 --- /dev/null +++ b/local_test/README.md @@ -0,0 +1,13 @@ +# Run local dendirete test server + +Build from project root: + +```bash +./build.sh +``` + +Then run dendrite monolith server with test config: + +```bash +./local_test/run.sh +``` diff --git a/local_test/dendrite.yaml b/local_test/dendrite.yaml new file mode 100644 index 000000000..43b8374ff --- /dev/null +++ b/local_test/dendrite.yaml @@ -0,0 +1,383 @@ +# This is the Dendrite configuration file. +# +# The configuration is split up into sections - each Dendrite component has a +# configuration section, in addition to the "global" section which applies to +# all components. +# +# At a minimum, to get started, you will need to update the settings in the +# "global" section for your deployment, and you will need to check that the +# database "connection_string" line in each component section is correct. +# +# Each component with a "database" section can accept the following formats +# for "connection_string": +# SQLite: file:filename.db +# file:///path/to/filename.db +# PostgreSQL: postgresql://user:pass@hostname/database?params=... +# +# SQLite is embedded into Dendrite and therefore no further prerequisites are +# needed for the database when using SQLite mode. However, performance with +# PostgreSQL is significantly better and recommended for multi-user deployments. +# SQLite is typically around 20-30% slower than PostgreSQL when tested with a +# small number of users and likely will perform worse still with a higher volume +# of users. +# +# The "max_open_conns" and "max_idle_conns" settings configure the maximum +# number of open/idle database connections. The value 0 will use the database +# engine default, and a negative value will use unlimited connections. The +# "conn_max_lifetime" option controls the maximum length of time a database +# connection can be idle in seconds - a negative value is unlimited. + +# The version of the configuration file. +version: 2 + +# Global Matrix configuration. This configuration applies to all components. +global: + # The domain name of this homeserver. + server_name: localhost + + # The path to the signing private key file, used to sign requests and events. + # Note that this is NOT the same private key as used for TLS! To generate a + # signing key, use "./bin/generate-keys --private-key matrix_key.pem". + private_key: matrix_key.pem + + # The paths and expiry timestamps (as a UNIX timestamp in millisecond precision) + # to old signing private keys that were formerly in use on this domain. These + # keys will not be used for federation request or event signing, but will be + # provided to any other homeserver that asks when trying to verify old events. + # old_private_keys: + # - private_key: old_matrix_key.pem + # expired_at: 1601024554498 + + # How long a remote server can cache our server signing key before requesting it + # again. Increasing this number will reduce the number of requests made by other + # servers for our key but increases the period that a compromised key will be + # considered valid by other homeservers. + key_validity_period: 168h0m0s + + # The server name to delegate server-server communications to, with optional port + # e.g. localhost:443 + well_known_server_name: "" + + # Lists of domains that the server will trust as identity servers to verify third + # party identifiers such as phone numbers and email addresses. + trusted_third_party_id_servers: + - matrix.org + - vector.im + + # Disables federation. Dendrite will not be able to make any outbound HTTP requests + # to other servers and the federation API will not be exposed. + disable_federation: false + + # Configures the handling of presence events. + presence: + # Whether inbound presence events are allowed, e.g. receiving presence events from other servers + enable_inbound: false + # Whether outbound presence events are allowed, e.g. sending presence events to other servers + enable_outbound: false + + # Server notices allows server admins to send messages to all users. + server_notices: + enabled: false + # The server localpart to be used when sending notices, ensure this is not yet taken + local_part: "_server" + # The displayname to be used when sending notices + display_name: "Server alerts" + # The mxid of the avatar to use + avatar_url: "" + # The roomname to be used when creating messages + room_name: "Server Alerts" + + # Configuration for NATS JetStream + jetstream: + # A list of NATS Server addresses to connect to. If none are specified, an + # internal NATS server will be started automatically when running Dendrite + # in monolith mode. It is required to specify the address of at least one + # NATS Server node if running in polylith mode. + addresses: + # - localhost:4222 + + # Keep all NATS streams in memory, rather than persisting it to the storage + # path below. This option is present primarily for integration testing and + # should not be used on a real world Dendrite deployment. + in_memory: false + + # Persistent directory to store JetStream streams in. This directory + # should be preserved across Dendrite restarts. + storage_path: ./ + + # The prefix to use for stream names for this homeserver - really only + # useful if running more than one Dendrite on the same NATS deployment. + topic_prefix: Dendrite + + # Configuration for Prometheus metric collection. + metrics: + # Whether or not Prometheus metrics are enabled. + enabled: false + + # HTTP basic authentication to protect access to monitoring. + basic_auth: + username: metrics + password: metrics + + # DNS cache options. The DNS cache may reduce the load on DNS servers + # if there is no local caching resolver available for use. + dns_cache: + # Whether or not the DNS cache is enabled. + enabled: false + + # Maximum number of entries to hold in the DNS cache, and + # for how long those items should be considered valid in seconds. + cache_size: 256 + cache_lifetime: "5m" # 5minutes; see https://pkg.go.dev/time@master#ParseDuration for more + +# Configuration for the Appservice API. +app_service_api: + internal_api: + listen: http://localhost:7777 # Only used in polylith deployments + connect: http://localhost:7777 # Only used in polylith deployments + database: + connection_string: file:appservice.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Disable the validation of TLS certificates of appservices. This is + # not recommended in production since it may allow appservice traffic + # to be sent to an unverified endpoint. + disable_tls_validation: false + + # Appservice configuration files to load into this homeserver. + config_files: [] + +# Configuration for the Client API. +client_api: + internal_api: + listen: http://localhost:7771 # Only used in polylith deployments + connect: http://localhost:7771 # Only used in polylith deployments + external_api: + listen: http://[::]:8071 + + # Prevents new users from being able to register on this homeserver, except when + # using the registration shared secret below. + registration_disabled: false + + # Prevents new guest accounts from being created. Guest registration is also + # disabled implicitly by setting 'registration_disabled' above. + guests_disabled: true + + # If set, allows registration by anyone who knows the shared secret, regardless of + # whether registration is otherwise disabled. + registration_shared_secret: "" + + # Disable password authentication. + password_authentication_disabled: false + + # public key authentication + public_key_authentication: + ethereum: + enabled: true + version: 1 + chain_ids: [4] # https://chainlist.org/ + + # Whether to require reCAPTCHA for registration. + enable_registration_captcha: false + + # Settings for ReCAPTCHA. + recaptcha_public_key: "" + recaptcha_private_key: "" + recaptcha_bypass_secret: "" + recaptcha_siteverify_api: "" + + # TURN server information that this homeserver should send to clients. + turn: + turn_user_lifetime: "" + turn_uris: [] + turn_shared_secret: "" + turn_username: "" + turn_password: "" + + # Settings for rate-limited endpoints. Rate limiting will kick in after the + # threshold number of "slots" have been taken by requests from a specific + # host. Each "slot" will be released after the cooloff time in milliseconds. + rate_limiting: + enabled: true + threshold: 5 + cooloff_ms: 500 + +# Configuration for the Federation API. +federation_api: + internal_api: + listen: http://localhost:7772 # Only used in polylith deployments + connect: http://localhost:7772 # Only used in polylith deployments + external_api: + listen: http://[::]:8072 + database: + connection_string: file:federationapi.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # How many times we will try to resend a failed transaction to a specific server. The + # backoff is 2**x seconds, so 1 = 2 seconds, 2 = 4 seconds, 3 = 8 seconds etc. + send_max_retries: 16 + + # Disable the validation of TLS certificates of remote federated homeservers. Do not + # enable this option in production as it presents a security risk! + disable_tls_validation: false + + # Perspective keyservers to use as a backup when direct key fetches fail. This may + # be required to satisfy key requests for servers that are no longer online when + # joining some rooms. + key_perspectives: + - server_name: matrix.org + keys: + - key_id: ed25519:auto + public_key: Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw + - key_id: ed25519:a_RXGa + public_key: l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ + + # This option will control whether Dendrite will prefer to look up keys directly + # or whether it should try perspective servers first, using direct fetches as a + # last resort. + prefer_direct_fetch: false + +# Configuration for the Key Server (for end-to-end encryption). +key_server: + internal_api: + listen: http://localhost:7779 # Only used in polylith deployments + connect: http://localhost:7779 # Only used in polylith deployments + database: + connection_string: file:keyserver.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Media API. +media_api: + internal_api: + listen: http://localhost:7774 # Only used in polylith deployments + connect: http://localhost:7774 # Only used in polylith deployments + external_api: + listen: http://[::]:8074 + database: + connection_string: file:mediaapi.db + max_open_conns: 5 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Storage path for uploaded media. May be relative or absolute. + base_path: ./media_store + + # The maximum allowed file size (in bytes) for media uploads to this homeserver + # (0 = unlimited). If using a reverse proxy, ensure it allows requests at + # least this large (e.g. client_max_body_size in nginx.) + max_file_size_bytes: 10485760 + + # Whether to dynamically generate thumbnails if needed. + dynamic_thumbnails: false + + # The maximum number of simultaneous thumbnail generators to run. + max_thumbnail_generators: 10 + + # A list of thumbnail sizes to be generated for media content. + thumbnail_sizes: + - width: 32 + height: 32 + method: crop + - width: 96 + height: 96 + method: crop + - width: 640 + height: 480 + method: scale + +# Configuration for experimental MSC's +mscs: + # A list of enabled MSC's + # Currently valid values are: + # - msc2836 (Threading, see https://github.com/matrix-org/matrix-doc/pull/2836) + # - msc2946 # (Spaces Summary, see https://github.com/matrix-org/matrix-doc/pull/2946) + mscs: [msc2946] + database: + connection_string: file:mscs.db + max_open_conns: 5 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Room Server. +room_server: + internal_api: + listen: http://localhost:7770 # Only used in polylith deployments + connect: http://localhost:7770 # Only used in polylith deployments + database: + connection_string: file:roomserver.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Sync API. +sync_api: + internal_api: + listen: http://localhost:7773 # Only used in polylith deployments + connect: http://localhost:7773 # Only used in polylith deployments + external_api: + listen: http://[::]:8073 + database: + connection_string: file:syncapi.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # This option controls which HTTP header to inspect to find the real remote IP + # address of the client. This is likely required if Dendrite is running behind + # a reverse proxy server. + # real_ip_header: X-Real-IP + +# Configuration for the User API. +user_api: + # The cost when hashing passwords on registration/login. Default: 10. Min: 4, Max: 31 + # See https://pkg.go.dev/golang.org/x/crypto/bcrypt for more information. + # Setting this lower makes registration/login consume less CPU resources at the cost of security + # should the database be compromised. Setting this higher makes registration/login consume more + # CPU resources but makes it harder to brute force password hashes. + # This value can be low if performing tests or on embedded Dendrite instances (e.g WASM builds) + # bcrypt_cost: 10 + internal_api: + listen: http://localhost:7781 # Only used in polylith deployments + connect: http://localhost:7781 # Only used in polylith deployments + account_database: + connection_string: file:userapi_accounts.db + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + # The length of time that a token issued for a relying party from + # /_matrix/client/r0/user/{userId}/openid/request_token endpoint + # is considered to be valid in milliseconds. + # The default lifetime is 3600000ms (60 minutes). + # openid_token_lifetime_ms: 3600000 + +# Configuration for Opentracing. +# See https://github.com/matrix-org/dendrite/tree/master/docs/tracing for information on +# how this works and how to set it up. +tracing: + enabled: false + jaeger: + serviceName: "" + disabled: false + rpc_metrics: false + tags: [] + sampler: null + reporter: null + headers: null + baggage_restrictions: null + throttler: null + +# Logging configuration +logging: + - type: std + level: info + - type: file + # The logging level, must be one of debug, info, warn, error, fatal, panic. + level: info + params: + path: ./logs diff --git a/local_test/matrix_key.pem b/local_test/matrix_key.pem new file mode 100644 index 000000000..19ae3dd60 --- /dev/null +++ b/local_test/matrix_key.pem @@ -0,0 +1,5 @@ +-----BEGIN MATRIX PRIVATE KEY----- +Key-ID: ed25519:2Wof34 + +f34OhC7xbKGCcA/fpH3iTMAURhqvCe9rGI4JA099l/g= +-----END MATRIX PRIVATE KEY----- diff --git a/local_test/run.sh b/local_test/run.sh new file mode 100755 index 000000000..6d277dae0 --- /dev/null +++ b/local_test/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +cd $(dirname "$0") + +../bin/dendrite-monolith-server \ + --tls-cert server.crt \ + --tls-key server.key \ + --config dendrite.yaml \ + --really-enable-open-registration \ No newline at end of file diff --git a/local_test/server.crt b/local_test/server.crt new file mode 100644 index 000000000..841f3e3cb --- /dev/null +++ b/local_test/server.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIEvzCCAqegAwIBAgIQPIVV4A5e74rWm5UqwCgeLTANBgkqhkiG9w0BAQsFADAA +MB4XDTIyMDcxMjE3MTM0NVoXDTMyMDcwOTE3MTM0NVowADCCAiIwDQYJKoZIhvcN +AQEBBQADggIPADCCAgoCggIBAMgkrQS4iqrC+iy5WvthG44Uh0Cqeki2uWAkKvH9 +eWrT49FO9eNGZIsNbXs0gFW8n15+eHzfSpAgzxxXzEZ/NaEBTWPCaUTbexjETU7y +u18ejL72ZwFweT5FEaMK5DaH+Vw0e2FuztKRnJq89ND7WFnSKJNjQcRWMzTO+xeA +aineRfSsiRmNqCbeJGsNAuBXpSoYum1Vc6RBV7vk1du3xLmx1l6faSD4FIE/rCC5 +eKXI6CkHHji6ZMnJD71vGKoFjW7+WeJ4HD8rY98q1h/VA0dNhZqwVlCDhvVUoy4M +eyWW47ZP7pSA0Fv94sP59kTiVsC4M8HpWc7WnlgZdzEazCEtPz/JMCakjr5aUKdW +yy08z29lLR8MaVQYl2SwhOrEB4n5Zhw/ilBgjrSF7acsKnMRZLk9kXQ6hRNpHegv +BmcwcSsOZl8h2yOvRVVhNYmWkKwq/cguItBedxsYvGP1K0oA9DOKxikyMI+o+vgq +YAAO0tVt+PFpR36ANIMT1WFP0hDZmosadW69X27VsUIU2eHmCidqEUU+DP7pWcUt +us5Z5RNp7vmVvzcIHWMjpuTqrzhCSsizh6J7XEAMlPawNRcntIsL6C6sJ6Asr1OJ +N6eR8op0T98oxmf85rxGJxh4q1chXls1LyJxKryrTaFkZe4dsnhj2UbIxswUl/PF +vB6jAgMBAAGjNTAzMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcD +ATAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4ICAQAh+Nxwx6Ad+SFmaJ2X +8GYXr192s5EEC/T/dEDXOvLu6/XuXX60j4YlkaGEuYZWBNONAiKi/eYYklhUu9Gi +GYBN35GQbLBlPHk7N2W4XcsdYE0evXi42GymcrNdo6BviFkTeoz1MhdHlEVH3LJi +lLhWf87+e6Z/0vFGEwkoDDGsXLuDAerSBjmZOs5b06OfmO4T7XOVPoANc4bZGvte +PZ8mTqm67lJxcrGUe7nT87cHFmaDK/QNAVW5gsSkMnf1xmsKyS8zA/m8LNpk41wL +suTdQBG9tURKNjVwhUlbLUbxwrDeN/1ioBjOmaOSTvSLwyuLgBhE7zOxpvUkE+k5 +YfR/7seEl/K9tV1+IIDzQ9565anRhlgonTPBwzhEXT8uFe3d1E/Un1HGcxBYf9lk +j+IyjiI6rqjA96PiDiyrlDi4n7Y14uqDgDJaJJ9T8xpqcFunRMZe8cljkAmLO8c9 +W4Ozbpqh3V1Zbu/tVwUzoeE1Ap+IAkAakGxGY+Jgzy4p7vCd7QSKJM+9lqeDSUVW +qEtZ3OK/fsBFQkcBHpZTm6Oj5ymzpQOnqxSE+lnUnlVOAFFmprS094/tL1Kzlr0i +UacIWlFGPxOaeT81kO0Loo3J0lyHK8f4uy144opjJobRKatv519HFoa5mqOJJck2 +rFlb5szgzwSfEcg+lLRDt4H7yg== +-----END CERTIFICATE----- diff --git a/local_test/server.key b/local_test/server.key new file mode 100644 index 000000000..55a4722f4 --- /dev/null +++ b/local_test/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAyCStBLiKqsL6LLla+2EbjhSHQKp6SLa5YCQq8f15atPj0U71 +40Zkiw1tezSAVbyfXn54fN9KkCDPHFfMRn81oQFNY8JpRNt7GMRNTvK7Xx6MvvZn +AXB5PkURowrkNof5XDR7YW7O0pGcmrz00PtYWdIok2NBxFYzNM77F4BqKd5F9KyJ +GY2oJt4kaw0C4FelKhi6bVVzpEFXu+TV27fEubHWXp9pIPgUgT+sILl4pcjoKQce +OLpkyckPvW8YqgWNbv5Z4ngcPytj3yrWH9UDR02FmrBWUIOG9VSjLgx7JZbjtk/u +lIDQW/3iw/n2ROJWwLgzwelZztaeWBl3MRrMIS0/P8kwJqSOvlpQp1bLLTzPb2Ut +HwxpVBiXZLCE6sQHiflmHD+KUGCOtIXtpywqcxFkuT2RdDqFE2kd6C8GZzBxKw5m +XyHbI69FVWE1iZaQrCr9yC4i0F53Gxi8Y/UrSgD0M4rGKTIwj6j6+CpgAA7S1W34 +8WlHfoA0gxPVYU/SENmaixp1br1fbtWxQhTZ4eYKJ2oRRT4M/ulZxS26zlnlE2nu ++ZW/NwgdYyOm5OqvOEJKyLOHontcQAyU9rA1Fye0iwvoLqwnoCyvU4k3p5HyinRP +3yjGZ/zmvEYnGHirVyFeWzUvInEqvKtNoWRl7h2yeGPZRsjGzBSX88W8HqMCAwEA +AQKCAgBqSngMmskh+RyN5f54pFDS+vn9kMwSk+ANPAgGrjvuTQufXFTf18GLy5zK +Is7JObxVncr1XkymEJaNkd8tzV84240zHstzQzCzrYT1GZoC4SGURR3dONNbC6lb +MmySvVHj8wdXblauo6BM2W8XEXURdrgP1lXWJIVbVVUqXQuEosP6Nis1g/K6eZ1T +sPxHEqTnn2xaplgc8oragaRF5Om4SMb1R6m4VafmIF+UnYuCWBlbuKkHLY5bT8lp +LHgny30aZkBsMqelsLCAk6pWC3WLR5Nd3KpqZf+liMaErSI1i1Xxu6+T9Hkzcbkd +pUFxwdaa0PjD0d7dJ0O+u/9996JSRp9/Uxu2gTI09Ck1wJE8+IEfv3XahlHrxPJt +0Uf+IkcRoWCYrqFoiCyIsvIRqKKTUo9DeXNqBUWEykwuAyxdygEGvowZJdAqI/IC +ax8KCc0kGnhguS3DrRr0mx/HyoppNkshCJTpzd6q9FG7IqCaXoVMOl5bdJ5vTOJz +WOYK+b8fA1qk+wdKSp1xekDY5mGNZEGy1uJQIyFZfbwNiGZEx2RN7z3xA9Q4P9S5 +g0ytSvHq4/iwLRHT1bBMCp6eZcfXCZkHBfFx5grgcJ4ELT0+MPU7Scn1W/U1ZGSw +5c9Z6sjuWXcYUkrTq3PeuNgWcqWTo3H6r+gjwDNVyma7jW7uOQKCAQEA+o2FBLtR +yZ6w5yjpUH4YsKLcGZEi5vHgUqim6SKO09Ce3PazvRYb/bpsQJVo/TQG5+vAIP0v +xQ1Tnp9pccwW6PIG5UO7Yg0Sh3n2U/hM5ln88uKDHYuwXHVEsZOgbnHMcqJXjC9A +S62KTAdqRPyLm8oO4NIsDrydRpUEUE3IMkMYUOcjvGhw/qLlif1I544G6jfETu/E +sxXtrE9f6gKb++Apl3TMYn+GsQcZiklGza7aR8FHYnf9+ae3Fxn9gsQOPvZKJmgJ +3wDiW+kK4z4ilRBm58boJJax3YhnQf0U+2AZh34lmFcDOY8/YOWTW8pJD0gsSN1R +YgL+zuMLrLyKpQKCAQEAzH6YnMoF4tbhuFZxBiOsa8Qg9fewxLCrDmrRq2u/rlyB +JdknifLCFLkijK9kGDusMimDj9gnLgtPX9105S3F7IzWrvcsGg8hzLLHrAsaNyMk +Z/a0kQggAkCrFlRSgL5F8AZL2wFO5cISUrrZZSxml1PeCgg9kXy078rvBGwcxri0 +1Sdolzxmn95NvCmiZ7sGSRh3pv138PbfHJewMHUhUBo4G4udL4/j2yiMT6g9YxDu +r9y6mAgzJL21gMT/IeCX6/T6vf/VEvY4+7Bs6k8yowVeZ9hbRs5iTClT8jGA2B4q +pMXmtbu8/jIQq5Inejl+dovo7Yeqwfgxhsg+dGBppwKCAQACLdzsT5zEfibXu9lb +o90fHCuB5WtCSvRCg8j/2hcX7IaVMWgayuhvaoGqhiIloaA1wC0pnEogEp+Zj5Vh +Mf85A3Hf6Jjmn2p71ym3TT+N+VZj3mh5h09/Xl28laYdj8vRa2wLghWzEs1TH/Vi +qDemoTlD51AOyMEtbfpdoG+PUFoTyg7bgqUI8e3BJ3zM1sVkoBuK/Dbfv98TUpVo ++aDVrftun8tvR+CqBX/JXh3JiC3J1fqC9rw0waqr/sPfsUjWb1nxv5HmaKGPXxWD +KHUwirX6ahZ2ywC9BoSvZD4ceZd/QC+fhZI3m/FXLGf9smK0SVJpR9N/YLtKnVrq +o7EpAoIBAB5N5G/XwGeNUIXwyW8Pek2+EuRggGGljLPmQIwWu6ErNDhXpfRbdUd8 +6BHRLBQrQ6lrXYPDlIrOQkUCnIAZ+GrFtErZdj+mXmvnUo+8VXY2Tv7ZIIkdmyC6 +VKBKfq91gwe+5x7dYsPJrs1zwyOrIMjsNMtnzTfyMx4WBLWzD9CjLqkn3egLm2m1 +l+96fAbDQHs0lQa6KTwcWZPzJrkHopgsSoRKfFDAEhQ4PhLP68jyiWymWUCOdoXL +V0pt5yEuF1VwSHg/oWPd+TPTQVC3y9k8wnDBL0We8BI5TadmjqF4Vvl0Gmx0Fd3V +rYK/dfo26vbGZQ5OPI/iJ/TBWAAHCaECggEBAMHUzVCqEk9HRYcJwhBlUBEzVVgK +woeYDwuQ4u8KO07TQpEF4zUnEsraBKDEOAQt3X40HWyjlMpfWwt/CaJDuYSGWxmC +IIksIahG1zQTgL/vmHxbCrumkLEC8b7jM/ydkvKsgDdXuD8uU2+bAvE+purVr2Kx +n2LPlXFi1TfyeDEk+0BGgDjuiYX0Gic4sWCtHuSGLFUNQ1tYSbq9YRL1yhMY7P1D +l6R2faugKrqFn2cZqIwwzhhJMDLt3C1+lDyUe7WR7RUW4ZU79xqcgCEKjwYhSQAG +IzN1IA6FcpbqVb2tI0+KmdrwcUsi74v3QTCBQ02cIu909104or3QQvW7Fqc= +-----END RSA PRIVATE KEY----- From 916f17ceb79bfd3311706a094f5f6562086fae96 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 14 Jul 2022 18:24:37 -0400 Subject: [PATCH 13/75] Pull latest changes from dendrite fork (#193) * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Fix nats.go commit (#2540) Signed-off-by: Jean Lucas * Don't return `end` if there are not more messages (#2542) * Be more spec compliant * Move lazyLoadMembers to own method * Return an error if trying to invite a malformed user ID (#2543) * Add `evacuateUser` endpoint, use it when deactivating accounts (#2545) * Add `evacuateUser` endpoint, use it when deactivating accounts * Populate the API * Clean up user devices when deactivating * Include invites, delete pushers * Silence presence logs (#2547) * Blacklist `Guest users can join guest_access rooms` test until it can be investigated * Disable WebAssembly builds for now * Try to fix backfilling (#2548) * Try to fix backfilling * Return start/end to not confuse clients * Update GMSL * Update GMSL * Roomserver producers package (#2546) * Give the roomserver a producers package * Change init point * Populate ACLs API * Fix build issues * `RoomEventProducer` naming * Version 0.8.9 (#2549) * Version 0.8.9 * Update changelog * Takwaiw/fix concurrent registration bug (#12) * fix concurrent registration bug. Rename decentralizedid * remove unused module * add regressed test to blacklist Co-authored-by: Tak Wai Wong * Test_UserStatistics Fix expected results to match observed results * Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong * Implement EIP-4361 sign in with Ethereum (#5) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * refresh latest dendrite main * dendrite implementation of eip-4361 * simplify nonce generation Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Use rand.Seed to seed the random function generator (#6) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * use rand.Seed to seed the random function Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Create session ID during registration (#8) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * Create session ID during registration Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Verify that the user ID for registration matches the spec, and the auth data (#10) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * pull latest from dendrite-fork subtree * refresh latest dendrite main * pull dendrite subtree and resolve merge conflicts * check that userID matches the signed message * verify that the user ID for registration is CAIP-10 compliant and MXID compliant * removed space Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong * Takwaiw/fix concurrent registration bug (#12) * fix concurrent registration bug. Rename decentralizedid * remove unused module * add regressed test to blacklist Co-authored-by: Tak Wai Wong * removed unused module * feat+fix: Ignore unknown keys and verify required fields are present in appservice registration files (#2550) * fix: ignore unknown keys in appservice configs fixes matrix-org/dendrite#1567 * feat: verify required fields in appservice configs * Use new testrig for key changes tests (#2552) * Use new testrig for tests * Log the error message * Fix QuerySharedUsers for the SyncAPI keychange consumer (#2554) * Make more use of base.BaseDendrite * Fix QuerySharedUsers if no UserIDs are supplied * Return clearer error when no state NID exists for an event (#2555) * Wrap error from `SnapshotNIDFromEventID` * Hopefully fix read receipts timestamps (#2557) This should avoid coercions between signed and unsigned ints which might fix problems like `sql: converting argument $5 type: uint64 values with high bit set are not supported`. * fix concurrency issue when checking session ID (#14) Co-authored-by: Tak Wai Wong * merge latest changes from dendrite main (#15) Co-authored-by: Tak Wai Wong * Login and Register tests for public key ethereum (#16) * TestLoginPublicKeyNewSession * use asserts * setup, test, asserts * TestLoginPublicKeyValidAuthTypeMissingSession * invalid session id test * create a helper newSession function * TestLoginPublicKeyEthereumMissingUserId * TestLoginPublicKeyEthereumAccountNotAvailable * TestLoginPublicKeyEthereumInvalidUserId * createEip4361TestMessage * TestLoginPublicKeyEthereumMissingSignature * TestLoginPublicKeyEthereum * re-enable all publickey signin tests * move common publickey test util to its own file * register_public_key.go stub * refactored common ethereum test helpers to its own folder * refactor test helpers * return error in test helpers * fix regressions with ServerName * TestRegistrationUnimplementedAlgo * TestNewRegistration * TestNewRegistrationSession * verify new login session * remove assert * perform account creation * TestRegisterEthereum * Enable all tests * move helper functions into test file Co-authored-by: Tak Wai Wong Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong Co-authored-by: Jean Lucas Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander Co-authored-by: Tak Wai Wong Co-authored-by: Kabir Kwatra --- build/scripts/ComplementPostgres.Dockerfile | 2 +- clientapi/auth/login_publickey.go | 2 +- clientapi/auth/login_publickey_ethereum.go | 12 +- .../auth/login_publickey_ethereum_test.go | 472 ++++++++++++++++++ clientapi/auth/login_publickey_test.go | 161 ++++++ clientapi/routing/register.go | 18 +- clientapi/routing/register_publickey.go | 2 +- clientapi/routing/register_publickey_test.go | 386 ++++++++++++++ setup/config/config_clientapi.go | 2 +- setup/config/config_publickey.go | 12 +- test/publickey_utils.go | 108 ++++ 11 files changed, 1159 insertions(+), 18 deletions(-) create mode 100644 clientapi/auth/login_publickey_ethereum_test.go create mode 100644 clientapi/auth/login_publickey_test.go create mode 100644 clientapi/routing/register_publickey_test.go create mode 100644 test/publickey_utils.go diff --git a/build/scripts/ComplementPostgres.Dockerfile b/build/scripts/ComplementPostgres.Dockerfile index 785090b0b..4b20b5ecb 100644 --- a/build/scripts/ComplementPostgres.Dockerfile +++ b/build/scripts/ComplementPostgres.Dockerfile @@ -50,4 +50,4 @@ CMD /build/run_postgres.sh && ./generate-keys --keysize 1024 --server $SERVER_NA # Bump max_open_conns up here in the global database config sed -i 's/max_open_conns:.*$/max_open_conns: 1990/g' dendrite.yaml && \ cp /complement/ca/ca.crt /usr/local/share/ca-certificates/ && update-ca-certificates && \ - exec ./dendrite-monolith-server --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml -api=${API:-0} \ No newline at end of file + exec ./dendrite-monolith-server --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml -api=${API:-0} diff --git a/clientapi/auth/login_publickey.go b/clientapi/auth/login_publickey.go index e999edeb7..8194df963 100644 --- a/clientapi/auth/login_publickey.go +++ b/clientapi/auth/login_publickey.go @@ -30,10 +30,10 @@ import ( type LoginPublicKeyHandler interface { AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) - IsValidUserIdForRegistration(userId string) bool CreateLogin() *Login GetSession() string GetType() string + IsValidUserId(userId string) bool ValidateLoginResponse() (bool, *jsonerror.MatrixError) } diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index a3201a269..90de33d2b 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -73,6 +73,10 @@ func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *js return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.") } + if !pk.IsValidUserId(localPart) { + return "", jsonerror.InvalidUsername("the username is not valid.") + } + res := userapi.QueryAccountAvailabilityResponse{} if err := pk.userAPI.QueryAccountAvailability(ctx, &userapi.QueryAccountAvailabilityRequest{ Localpart: localPart, @@ -80,7 +84,7 @@ func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *js return "", jsonerror.Unknown("failed to check availability: " + err.Error()) } - if res.Available { + if localPart == "" || res.Available { return "", jsonerror.Forbidden("the address is incorrect, account does not exist") } @@ -89,7 +93,7 @@ func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *js var validChainAgnosticIdRegex = regexp.MustCompile("^eip155=3a[0-9]+=3a0x[0-9a-fA-F]+$") -func (pk LoginPublicKeyEthereum) IsValidUserIdForRegistration(userId string) bool { +func (pk LoginPublicKeyEthereum) IsValidUserId(userId string) bool { // Verify that the user ID is a valid one according to spec. // https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md @@ -100,9 +104,9 @@ func (pk LoginPublicKeyEthereum) IsValidUserIdForRegistration(userId string) boo isValid := validChainAgnosticIdRegex.MatchString(userId) - // In addition, double check that the user ID for registration + // In addition, double check that the user ID // matches the authentication data in the request. - return isValid && userId == pk.UserId + return isValid && strings.ToLower(userId) == pk.UserId } func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.MatrixError) { diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go new file mode 100644 index 000000000..12fae2654 --- /dev/null +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -0,0 +1,472 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package auth + +import ( + "context" + "fmt" + "net/http" + "strings" + "testing" + + "github.com/matrix-org/dendrite/clientapi/jsonerror" + "github.com/matrix-org/dendrite/internal/mapsutil" + "github.com/matrix-org/dendrite/setup/config" + "github.com/matrix-org/dendrite/test" + uapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/stretchr/testify/assert" +) + +type loginContext struct { + config *config.ClientAPI + userInteractive *UserInteractive +} + +func createLoginContext(t *testing.T) *loginContext { + chainIds := []int{4} + + cfg := &config.ClientAPI{ + Matrix: &config.Global{ + ServerName: test.TestServerName, + }, + Derived: &config.Derived{}, + PasswordAuthenticationDisabled: true, + PublicKeyAuthentication: config.PublicKeyAuthentication{ + Ethereum: config.EthereumAuthConfig{ + Enabled: true, + Version: 1, + ChainIDs: chainIds, + }, + }, + } + + pkFlows := cfg.PublicKeyAuthentication.GetPublicKeyRegistrationFlows() + cfg.Derived.Registration.Flows = append(cfg.Derived.Registration.Flows, pkFlows...) + pkParams := cfg.PublicKeyAuthentication.GetPublicKeyRegistrationParams() + cfg.Derived.Registration.Params = mapsutil.MapsUnion(cfg.Derived.Registration.Params, pkParams) + + var userAPI fakePublicKeyUserApi + var loginApi uapi.UserLoginAPI + + userInteractive := NewUserInteractive( + loginApi, + &userAPI, + cfg) + + return &loginContext{ + config: cfg, + userInteractive: userInteractive, + } + +} + +type fakePublicKeyUserApi struct { + UserInternalAPIForLogin + uapi.UserLoginAPI + uapi.ClientUserAPI + DeletedTokens []string +} + +func (ua *fakePublicKeyUserApi) QueryAccountAvailability(ctx context.Context, req *uapi.QueryAccountAvailabilityRequest, res *uapi.QueryAccountAvailabilityResponse) error { + if req.Localpart == "does_not_exist" { + res.Available = true + return nil + } + + res.Available = false + return nil +} + +func (ua *fakePublicKeyUserApi) QueryAccountByPassword(ctx context.Context, req *uapi.QueryAccountByPasswordRequest, res *uapi.QueryAccountByPasswordResponse) error { + if req.PlaintextPassword == "invalidpassword" { + res.Account = nil + return nil + } + res.Exists = true + res.Account = &uapi.Account{} + return nil +} + +func (ua *fakePublicKeyUserApi) PerformLoginTokenDeletion(ctx context.Context, req *uapi.PerformLoginTokenDeletionRequest, res *uapi.PerformLoginTokenDeletionResponse) error { + ua.DeletedTokens = append(ua.DeletedTokens, req.Token) + return nil +} + +func (ua *fakePublicKeyUserApi) PerformLoginTokenCreation(ctx context.Context, req *uapi.PerformLoginTokenCreationRequest, res *uapi.PerformLoginTokenCreationResponse) error { + return nil +} + +func (*fakePublicKeyUserApi) QueryLoginToken(ctx context.Context, req *uapi.QueryLoginTokenRequest, res *uapi.QueryLoginTokenResponse) error { + if req.Token == "invalidtoken" { + return nil + } + + res.Data = &uapi.LoginTokenData{UserID: "@auser:example.com"} + return nil +} + +func publicKeyTestSession( + ctx *context.Context, + cfg *config.ClientAPI, + userInteractive *UserInteractive, + userAPI *fakePublicKeyUserApi, + +) string { + emptyAuth := struct { + Body string + }{ + Body: `{ + "type": "m.login.publickey" + }`, + } + + _, cleanup, err := LoginFromJSONReader( + *ctx, + strings.NewReader(emptyAuth.Body), + userAPI, + userAPI, + userAPI, + userInteractive, + cfg) + + if cleanup != nil { + cleanup(*ctx, nil) + } + + json := err.JSON.(Challenge) + return json.Session +} + +func TestLoginPublicKeyEthereum(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + wallet, _ := test.CreateTestAccount() + message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) + signature, _ := test.SignMessage(message.String(), wallet.PrivateKey) + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + // Escape \t and \n. Work around for marshalling and unmarshalling message. + msgStr := test.FromEip4361MessageToString(message) + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "%v", + "message": "%v", + "signature": "%v" + } + }`, + sessionId, + wallet.Eip155UserId, + msgStr, + signature, + ) + test := struct { + Body string + }{ + Body: body, + } + + // Test + login, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Nilf(err, "err actual: %v, expected: nil", err) + assert.NotNil(login, "login: actual: nil, expected: not nil") + assert.Truef( + login.Identifier.Type == "m.id.decentralizedid", + "login.Identifier.Type actual: %v, expected: %v", login.Identifier.Type, "m.id.decentralizedid") + walletAddress := strings.ToLower(wallet.Eip155UserId) + assert.Truef( + login.Identifier.User == walletAddress, + "login.Identifier.User actual: %v, expected: %v", login.Identifier.User, walletAddress) +} + +func TestLoginPublicKeyEthereumMissingSignature(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + wallet, _ := test.CreateTestAccount() + message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + // Escape \t and \n. Work around for marshalling and unmarshalling message. + msgStr := test.FromEip4361MessageToString(message) + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "%v", + "message": "%v" + } + }`, + sessionId, + wallet.Eip155UserId, + msgStr, + ) + test := struct { + Body string + }{ + Body: body, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusUnauthorized, + "err.Code actual: %v, expected: %v", err.Code, http.StatusUnauthorized) + json := err.JSON.(*jsonerror.MatrixError) + expectedErr := jsonerror.InvalidSignature("") + assert.Truef( + json.ErrCode == expectedErr.ErrCode, + "err.JSON.ErrCode actual: %v, expected: %v", json.ErrCode, expectedErr.ErrCode) +} + +func TestLoginPublicKeyEthereumEmptyMessage(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + wallet, _ := test.CreateTestAccount() + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "%v" + } + }`, sessionId, wallet.Eip155UserId) + test := struct { + Body string + }{ + Body: body, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusUnauthorized, + "err.Code actual: %v, expected: %v", err.Code, http.StatusUnauthorized) + json := err.JSON.(*jsonerror.MatrixError) + expectedErr := jsonerror.InvalidParam("") + assert.Truef( + json.ErrCode == expectedErr.ErrCode, + "err.JSON.ErrCode actual: %v, expected: %v", json.ErrCode, expectedErr.ErrCode) +} + +func TestLoginPublicKeyEthereumWrongUserId(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + wallet, _ := test.CreateTestAccount() + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "%v" + } + }`, + sessionId, + wallet.PublicAddress) + test := struct { + Body string + }{ + Body: body, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusForbidden, + "err.Code actual: %v, expected: %v", err.Code, http.StatusForbidden) +} + +func TestLoginPublicKeyEthereumMissingUserId(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v" + } + }`, sessionId) + test := struct { + Body string + }{ + Body: body, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusForbidden, + "err.Code actual: %v, expected: %v", err.Code, http.StatusForbidden) +} + +func TestLoginPublicKeyEthereumAccountNotAvailable(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + sessionId := publicKeyTestSession( + &ctx, + loginContext.config, + loginContext.userInteractive, + &userAPI, + ) + + body := fmt.Sprintf(`{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "does_not_exist" + } + }`, sessionId) + test := struct { + Body string + }{ + Body: body, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusForbidden, + "err.Code actual: %v, expected: %v", err.Code, http.StatusForbidden) +} diff --git a/clientapi/auth/login_publickey_test.go b/clientapi/auth/login_publickey_test.go new file mode 100644 index 000000000..321d8eb6c --- /dev/null +++ b/clientapi/auth/login_publickey_test.go @@ -0,0 +1,161 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package auth + +import ( + "context" + "net/http" + "strings" + "testing" + + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/setup/config" + "github.com/stretchr/testify/assert" +) + +func TestLoginPublicKeyNewSession(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + + test := struct { + Body string + }{ + Body: `{ "type": "m.login.publickey" }`, + } + + // Test + login, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.NotNilf( + err, + "err actual: not nil returned %+v, expected: nil", login) + assert.Truef( + err.Code == http.StatusUnauthorized, + "err.Code actual: %v, expected: %v", err.Code, http.StatusUnauthorized) + challenge := err.JSON.(Challenge) + assert.NotEmptyf(challenge.Session, "challenge.Session") + assert.NotEmptyf(challenge.Completed, "challenge.Completed") + assert.Truef( + authtypes.LoginTypePublicKeyEthereum == challenge.Flows[0].Stages[0], + "challenge.Flows[0].Stages[0] actual: %v, expected: %v", challenge.Flows[0].Stages[0], authtypes.LoginTypePublicKeyEthereum) + params := challenge.Params[authtypes.LoginTypePublicKeyEthereum] + assert.NotEmptyf( + params, + "challenge.Params[\"%v\"] actual %v, expected %v", + authtypes.LoginTypePublicKeyEthereum, + params, + "[object]") + ethParams := params.(config.EthereumAuthParams) + assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") + assert.NotEmptyf(ethParams.Nonce, "Nonce actual: \"\", expected: not empty") + assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") +} + +func TestLoginPublicKeyInvalidSessionId(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + + test := struct { + Body string + }{ + Body: `{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.ethereum", + "session": "invalid_session_id" + } + }`, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.Truef( + err.Code == http.StatusUnauthorized, + "err.Code actual %v, expected %v", err.Code, http.StatusUnauthorized) +} + +func TestLoginPublicKeyInvalidAuthType(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + ctx := context.Background() + loginContext := createLoginContext(t) + + test := struct { + Body string + }{ + Body: `{ + "type": "m.login.publickey", + "auth": { + "type": "m.login.publickey.someAlgo" + } + }`, + } + + // Test + _, cleanup, err := LoginFromJSONReader( + ctx, + strings.NewReader(test.Body), + &userAPI, + &userAPI, + &userAPI, + loginContext.userInteractive, + loginContext.config) + + if cleanup != nil { + cleanup(ctx, nil) + } + + // Asserts + assert := assert.New(t) + assert.NotNil(err, "Expected an err response.actual: nil") + assert.Truef( + err.Code == http.StatusUnauthorized, + "err.Code actual %v, expected %v", err.Code, http.StatusUnauthorized) + _, ok := err.JSON.(Challenge) + assert.False( + ok, + "should not return a Challenge response") +} diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 8faff58f8..a91aff3dc 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -32,6 +32,7 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/dendrite/internal/eventutil" + "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/gomatrixserverlib" @@ -247,7 +248,7 @@ type authDict struct { } // http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#user-interactive-authentication-api -type userInteractiveResponse struct { +type UserInteractiveResponse struct { Flows []authtypes.Flow `json:"flows"` Completed []authtypes.LoginType `json:"completed"` Params map[string]interface{} `json:"params"` @@ -260,9 +261,18 @@ func newUserInteractiveResponse( sessionID string, fs []authtypes.Flow, params map[string]interface{}, -) userInteractiveResponse { - return userInteractiveResponse{ - fs, sessions.getCompletedStages(sessionID), params, sessionID, +) UserInteractiveResponse { + paramsCopy := mapsutil.MapCopy(params) + for key, element := range paramsCopy { + p := auth.GetAuthParams(element) + if p != nil { + // If an auth flow has params, make a new copy + // and send it as part of the response. + paramsCopy[key] = p + } + } + return UserInteractiveResponse{ + fs, sessions.getCompletedStages(sessionID), paramsCopy, sessionID, } } diff --git a/clientapi/routing/register_publickey.go b/clientapi/routing/register_publickey.go index f5c972bb1..119065981 100644 --- a/clientapi/routing/register_publickey.go +++ b/clientapi/routing/register_publickey.go @@ -69,7 +69,7 @@ func handlePublicKeyRegistration( } } - isValidUserId := authHandler.IsValidUserIdForRegistration(r.Username) + isValidUserId := authHandler.IsValidUserId(r.Username) if !isValidUserId { return false, "", &util.JSONResponse{ Code: http.StatusUnauthorized, diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go new file mode 100644 index 000000000..688769e89 --- /dev/null +++ b/clientapi/routing/register_publickey_test.go @@ -0,0 +1,386 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package routing + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "strings" + "testing" + + "github.com/matrix-org/dendrite/clientapi/auth" + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/internal/mapsutil" + "github.com/matrix-org/dendrite/setup/config" + "github.com/matrix-org/dendrite/test" + "github.com/matrix-org/dendrite/userapi/api" + uapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/util" + "github.com/stretchr/testify/assert" +) + +const testCaip10UserId = "eip155=3a1=3a0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb" + +type registerContext struct { + config *config.ClientAPI + userInteractive *auth.UserInteractive +} + +func createRegisterContext(t *testing.T) *registerContext { + chainIds := []int{4} + + cfg := &config.ClientAPI{ + Matrix: &config.Global{ + ServerName: test.TestServerName, + }, + Derived: &config.Derived{}, + PasswordAuthenticationDisabled: true, + PublicKeyAuthentication: config.PublicKeyAuthentication{ + Ethereum: config.EthereumAuthConfig{ + Enabled: true, + Version: 1, + ChainIDs: chainIds, + }, + }, + } + + pkFlows := cfg.PublicKeyAuthentication.GetPublicKeyRegistrationFlows() + cfg.Derived.Registration.Flows = append(cfg.Derived.Registration.Flows, pkFlows...) + pkParams := cfg.PublicKeyAuthentication.GetPublicKeyRegistrationParams() + cfg.Derived.Registration.Params = mapsutil.MapsUnion(cfg.Derived.Registration.Params, pkParams) + + var userAPI fakePublicKeyUserApi + var loginApi uapi.UserLoginAPI + + userInteractive := auth.NewUserInteractive( + loginApi, + &userAPI, + cfg) + + return ®isterContext{ + config: cfg, + userInteractive: userInteractive, + } + +} + +type fakeHttpRequest struct { + request *http.Request + body []byte + registerRequest registerRequest +} + +func createFakeHttpRequest(body string) *fakeHttpRequest { + var r registerRequest + req, _ := http.NewRequest(http.MethodPost, "", strings.NewReader(body)) + reqBody := []byte(body) + json.Unmarshal([]byte(body), &r) + + return &fakeHttpRequest{ + request: req, + body: reqBody, + registerRequest: r, + } +} + +type fakePublicKeyUserApi struct { + auth.UserInternalAPIForLogin + uapi.UserLoginAPI + uapi.ClientUserAPI + DeletedTokens []string +} + +func (ua *fakePublicKeyUserApi) QueryAccountAvailability(ctx context.Context, req *uapi.QueryAccountAvailabilityRequest, res *uapi.QueryAccountAvailabilityResponse) error { + if req.Localpart == "does_not_exist" { + res.Available = true + return nil + } + + res.Available = false + return nil +} + +func (ua *fakePublicKeyUserApi) QueryAccountByPassword(ctx context.Context, req *uapi.QueryAccountByPasswordRequest, res *uapi.QueryAccountByPasswordResponse) error { + if req.PlaintextPassword == "invalidpassword" { + res.Account = nil + return nil + } + res.Exists = true + res.Account = &uapi.Account{} + return nil +} + +func (ua *fakePublicKeyUserApi) PerformDeviceCreation( + ctx context.Context, + req *uapi.PerformDeviceCreationRequest, + res *uapi.PerformDeviceCreationResponse) error { + res.DeviceCreated = true + res.Device = &api.Device{ + ID: "device_id", + UserID: req.Localpart, + AccessToken: req.AccessToken, + } + return nil +} + +func (ua *fakePublicKeyUserApi) PerformAccountCreation( + ctx context.Context, + req *uapi.PerformAccountCreationRequest, + res *uapi.PerformAccountCreationResponse) error { + res.AccountCreated = true + res.Account = &api.Account{ + AppServiceID: req.AppServiceID, + Localpart: req.Localpart, + ServerName: test.TestServerName, + UserID: fmt.Sprintf("@%s:%s", req.Localpart, test.TestServerName), + AccountType: req.AccountType, + } + return nil +} + +func (ua *fakePublicKeyUserApi) PerformLoginTokenDeletion(ctx context.Context, req *uapi.PerformLoginTokenDeletionRequest, res *uapi.PerformLoginTokenDeletionResponse) error { + ua.DeletedTokens = append(ua.DeletedTokens, req.Token) + return nil +} + +func (ua *fakePublicKeyUserApi) PerformLoginTokenCreation(ctx context.Context, req *uapi.PerformLoginTokenCreationRequest, res *uapi.PerformLoginTokenCreationResponse) error { + return nil +} + +func (*fakePublicKeyUserApi) QueryLoginToken(ctx context.Context, req *uapi.QueryLoginTokenRequest, res *uapi.QueryLoginTokenResponse) error { + if req.Token == "invalidtoken" { + return nil + } + + res.Data = &uapi.LoginTokenData{UserID: "@auser:example.com"} + return nil +} + +func newRegistrationSession( + t *testing.T, + userId string, + cfg *config.ClientAPI, + userInteractive *auth.UserInteractive, + userAPI *fakePublicKeyUserApi, +) string { + body := fmt.Sprintf(`{ + "auth": { + "type": "m.login.publickey", + "username": "%v" + } + }`, + userId) + + test := struct { + Body string + }{ + Body: body, + } + + fakeReq := createFakeHttpRequest(test.Body) + sessionID := util.RandomString(sessionIDLength) + registerContext := createRegisterContext(t) + + // Test + response := handleRegistrationFlow( + fakeReq.request, + fakeReq.body, + fakeReq.registerRequest, + sessionID, + registerContext.config, + userAPI, + "", + nil, + ) + + json := response.JSON.(UserInteractiveResponse) + return json.Session +} + +func TestRegisterEthereum(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + wallet, _ := test.CreateTestAccount() + message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) + signature, _ := test.SignMessage(message.String(), wallet.PrivateKey) + registerContext := createRegisterContext(t) + sessionId := newRegistrationSession( + t, + wallet.Eip155UserId, + registerContext.config, + registerContext.userInteractive, + &userAPI, + ) + + // Escape \t and \n. Work around for marshalling and unmarshalling message. + msgStr := test.FromEip4361MessageToString(message) + body := fmt.Sprintf(`{ + "username": "%v", + "auth": { + "type": "m.login.publickey", + "session": "%v", + "public_key_response": { + "type": "m.login.publickey.ethereum", + "session": "%v", + "user_id": "%v", + "message": "%v", + "signature": "%v" + } + } + }`, + wallet.Eip155UserId, + sessionId, + sessionId, + wallet.Eip155UserId, + msgStr, + signature, + ) + test := struct { + Body string + }{ + Body: body, + } + + fakeReq := createFakeHttpRequest(test.Body) + + // Test + response := handleRegistrationFlow( + fakeReq.request, + fakeReq.body, + fakeReq.registerRequest, + sessionId, + registerContext.config, + &userAPI, + "", + nil, + ) + + // Asserts + assert := assert.New(t) + assert.NotNil(response, "response actual: nil, expected: not nil") + registerRes := response.JSON.(registerResponse) + assert.Truef( + registerRes.UserID == wallet.Eip155UserId, + "registerRes.UserID actual: %v, expected: %v", registerRes.UserID, wallet.Eip155UserId) + assert.NotEmptyf( + registerRes.AccessToken, + "registerRes.AccessToken actual: empty, expected: not empty") +} + +func TestNewRegistrationSession(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + + body := fmt.Sprintf(`{ + "auth": { + "type": "m.login.publickey", + "username": "%v" + } + }`, + testCaip10UserId) + + test := struct { + Body string + }{ + Body: body, + } + + fakeReq := createFakeHttpRequest(test.Body) + sessionID := util.RandomString(sessionIDLength) + registerContext := createRegisterContext(t) + + // Test + response := handleRegistrationFlow( + fakeReq.request, + fakeReq.body, + fakeReq.registerRequest, + sessionID, + registerContext.config, + &userAPI, + "", + nil, + ) + + // Asserts + assert := assert.New(t) + assert.NotNilf(response, "response not nil") + assert.Truef( + response.Code == http.StatusUnauthorized, + "response.Code actual %v, expected %v", response.Code, http.StatusUnauthorized) + json := response.JSON.(UserInteractiveResponse) + assert.NotEmptyf(json.Session, "response.Session") + assert.NotEmptyf(json.Completed, "response.Completed") + assert.Truef( + json.Completed[0] == authtypes.LoginStagePublicKeyNewRegistration, + "response.Completed[0] actual %v, expected %v", json.Completed[0], authtypes.LoginStagePublicKeyNewRegistration) + assert.Truef( + authtypes.LoginTypePublicKeyEthereum == json.Flows[0].Stages[0], + "response.Flows[0].Stages[0] actual: %v, expected: %v", json.Flows[0].Stages[0], authtypes.LoginTypePublicKeyEthereum) + + params := json.Params[authtypes.LoginTypePublicKeyEthereum] + assert.NotEmptyf( + params, + "response.Params[\"%v\"] actual %v, expected %v", + authtypes.LoginTypePublicKeyEthereum, + params, + "[object]") + ethParams := params.(config.EthereumAuthParams) + assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") + assert.NotEmptyf(ethParams.Nonce, "Nonce actual: \"\", expected: not empty") + assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") +} + +func TestRegistrationUnimplementedAlgo(t *testing.T) { + // Setup + var userAPI fakePublicKeyUserApi + body := fmt.Sprintf(`{ + "auth": { + "type": "m.login.publickey.someAlgo", + "username": "%v" + } + }`, + testCaip10UserId) + + test := struct { + Body string + }{ + Body: body, + } + + fakeReq := createFakeHttpRequest(test.Body) + sessionID := util.RandomString(sessionIDLength) + registerContext := createRegisterContext(t) + + // Test + response := handleRegistrationFlow( + fakeReq.request, + fakeReq.body, + fakeReq.registerRequest, + sessionID, + registerContext.config, + &userAPI, + "", + nil, + ) + + // Asserts + assert := assert.New(t) + assert.NotNilf(response, "response not nil") + assert.Truef( + response.Code == http.StatusNotImplemented, + "response.Code actual %v, expected %v", response.Code, http.StatusNotImplemented) +} diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index c9e4418c8..fe88a5db6 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -54,7 +54,7 @@ type ClientAPI struct { PasswordAuthenticationDisabled bool `yaml:"password_authentication_disabled"` // Public key authentication - PublicKeyAuthentication publicKeyAuthentication `yaml:"public_key_authentication"` + PublicKeyAuthentication PublicKeyAuthentication `yaml:"public_key_authentication"` } func (c *ClientAPI) Defaults(opts DefaultOpts) { diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index 9820a5969..ae19d16f6 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -32,21 +32,21 @@ func (p EthereumAuthParams) GetNonce() string { return p.Nonce } -type ethereumAuthConfig struct { +type EthereumAuthConfig struct { Enabled bool `yaml:"enabled"` Version uint `yaml:"version"` ChainIDs []int `yaml:"chain_ids"` } -type publicKeyAuthentication struct { - Ethereum ethereumAuthConfig `yaml:"ethereum"` +type PublicKeyAuthentication struct { + Ethereum EthereumAuthConfig `yaml:"ethereum"` } -func (pk *publicKeyAuthentication) Enabled() bool { +func (pk *PublicKeyAuthentication) Enabled() bool { return pk.Ethereum.Enabled } -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { +func (pk *PublicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { var flows []authtypes.Flow if pk.Ethereum.Enabled { flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) @@ -55,7 +55,7 @@ func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.F return flows } -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { +func (pk *PublicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { params := make(map[string]interface{}) if pk.Ethereum.Enabled { p := EthereumAuthParams{ diff --git a/test/publickey_utils.go b/test/publickey_utils.go new file mode 100644 index 000000000..6d3a67186 --- /dev/null +++ b/test/publickey_utils.go @@ -0,0 +1,108 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test + +import ( + "crypto/ecdsa" + "errors" + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" + "github.com/spruceid/siwe-go" +) + +const EthereumTestNetworkId = 4 // Rinkeby test network ID +const TestServerName = "localhost" + +type EthereumTestWallet struct { + Eip155UserId string + PublicAddress string + PrivateKey *ecdsa.PrivateKey +} + +// https://goethereumbook.org/wallet-generate/ +func CreateTestAccount() (*EthereumTestWallet, error) { + // Create a new public / private key pair. + privateKey, err := crypto.GenerateKey() + if err != nil { + return nil, err + } + + // Get the public key + publicKey := privateKey.Public() + + // Transform public key to the Ethereum address + publicKeyEcdsa, ok := publicKey.(*ecdsa.PublicKey) + if !ok { + return nil, errors.New("error casting public key to ECDSA") + } + + address := crypto.PubkeyToAddress(*publicKeyEcdsa).Hex() + eip155UserId := fmt.Sprintf("eip155=3a%d=3a%s", EthereumTestNetworkId, address) + + return &EthereumTestWallet{ + PublicAddress: address, + PrivateKey: privateKey, + Eip155UserId: eip155UserId, + }, + nil +} + +func CreateEip4361TestMessage( + publicAddress string, +) (*siwe.Message, error) { + options := make(map[string]interface{}) + options["chainId"] = 4 // Rinkeby test network + options["statement"] = "This is a test statement" + message, err := siwe.InitMessage( + TestServerName, + publicAddress, + "https://localhost/login", + siwe.GenerateNonce(), + options, + ) + + if err != nil { + return nil, err + } + + return message, nil +} + +func FromEip4361MessageToString(message *siwe.Message) string { + // Escape the formatting characters to + // prevent unmarshal exceptions. + str := strings.ReplaceAll(message.String(), "\n", "\\n") + str = strings.ReplaceAll(str, "\t", "\\t") + return str +} + +// https://goethereumbook.org/signature-generate/ +func SignMessage(message string, privateKey *ecdsa.PrivateKey) (string, error) { + msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(message), message) + data := []byte(msg) + hash := crypto.Keccak256Hash(data) + + signature, err := crypto.Sign(hash.Bytes(), privateKey) + if err != nil { + return "", err + } + + // https://github.com/ethereum/go-ethereum/blob/55599ee95d4151a2502465e0afc7c47bd1acba77/internal/ethapi/api.go#L442 + signature[64] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper + return hexutil.Encode(signature), nil +} From 77e2c918fd79fe94458bed0f51dcc00e9b20671b Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Wed, 11 May 2022 17:37:05 -0700 Subject: [PATCH 14/75] Test_UserStatistics Fix expected results to match observed results --- userapi/storage/tables/stats_table_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index c4aec552c..3b67a4acc 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 1, - "web": 1, + "android": 0, + "web": 0, "electron": 0, - "all": 2, + "all": 0, }, AllUsers: 6, NonBridgedUsers: 5, From 8ab1737e7fb32dcaada4b292d0d0e96143bdd618 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 12 May 2022 16:47:48 -0700 Subject: [PATCH 15/75] Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 +++-------- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- userapi/storage/tables/stats_table_test.go | 6 +++--- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index b509ebf46..b0e3aa0f6 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -244,7 +244,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index 3dbb9dabc..bc1239910 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,11 +17,6 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) - device = &api.Device{ - AccessToken: "flibble", - DisplayName: "My Device", - ID: "device_id_goes_here", - } ) type fakeAccountDatabase struct { @@ -60,7 +55,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`), device) + _, errRes := uia.Verify(ctx, []byte(`{}`)) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -100,7 +95,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc, device) + _, errRes := uia.Verify(ctx, tc) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -181,7 +176,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body, device) + _, errRes := uia.Verify(ctx, tc.body) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index f213db7f3..9f80dff61 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index e3a02661c..84e11bc7a 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index 3b67a4acc..c4aec552c 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 0, - "web": 0, + "android": 1, + "web": 1, "electron": 0, - "all": 0, + "all": 2, }, AllUsers: 6, NonBridgedUsers: 5, From b5d5f57a1c1163635c3b564e0e1c3a8f21da2544 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 9 Jun 2022 13:03:04 -0400 Subject: [PATCH 16/75] Implement EIP-4361 sign in with Ethereum (#5) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * refresh latest dendrite main * dendrite implementation of eip-4361 * simplify nonce generation Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 ++++++++--- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index b0e3aa0f6..b509ebf46 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -244,7 +244,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index bc1239910..3dbb9dabc 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,6 +17,11 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) + device = &api.Device{ + AccessToken: "flibble", + DisplayName: "My Device", + ID: "device_id_goes_here", + } ) type fakeAccountDatabase struct { @@ -55,7 +60,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`)) + _, errRes := uia.Verify(ctx, []byte(`{}`), device) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -95,7 +100,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc) + _, errRes := uia.Verify(ctx, tc, device) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -176,7 +181,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body) + _, errRes := uia.Verify(ctx, tc.body, device) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index 9f80dff61..f213db7f3 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index 84e11bc7a..e3a02661c 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: From d5050c1d61dad46c134c4bba218845e50fa7c8c6 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 14 Jul 2022 17:00:19 -0400 Subject: [PATCH 17/75] merge latest changes from dendrite main (#15) Co-authored-by: Tak Wai Wong --- .github/workflows/dendrite.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml index f8019b3ea..2306bcd9a 100644 --- a/.github/workflows/dendrite.yml +++ b/.github/workflows/dendrite.yml @@ -102,7 +102,11 @@ jobs: strategy: fail-fast: false matrix: +<<<<<<< HEAD go: ["1.18", "1.19"] +======= + go: ["1.18"] +>>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) steps: - uses: actions/checkout@v3 - name: Setup go @@ -132,7 +136,11 @@ jobs: strategy: fail-fast: false matrix: +<<<<<<< HEAD go: ["1.18", "1.19"] +======= + go: ["1.18"] +>>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) goos: ["linux"] goarch: ["amd64", "386"] steps: @@ -166,7 +174,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: +<<<<<<< HEAD go: ["1.18", "1.19"] +======= + go: ["1.18"] +>>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) goos: ["windows"] goarch: ["amd64"] steps: From 5ac83189d90708b96dd5edb3f931a01f8679909b Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 14 Jul 2022 17:41:44 -0400 Subject: [PATCH 18/75] Login and Register tests for public key ethereum (#16) * TestLoginPublicKeyNewSession * use asserts * setup, test, asserts * TestLoginPublicKeyValidAuthTypeMissingSession * invalid session id test * create a helper newSession function * TestLoginPublicKeyEthereumMissingUserId * TestLoginPublicKeyEthereumAccountNotAvailable * TestLoginPublicKeyEthereumInvalidUserId * createEip4361TestMessage * TestLoginPublicKeyEthereumMissingSignature * TestLoginPublicKeyEthereum * re-enable all publickey signin tests * move common publickey test util to its own file * register_public_key.go stub * refactored common ethereum test helpers to its own folder * refactor test helpers * return error in test helpers * fix regressions with ServerName * TestRegistrationUnimplementedAlgo * TestNewRegistration * TestNewRegistrationSession * verify new login session * remove assert * perform account creation * TestRegisterEthereum * Enable all tests * move helper functions into test file Co-authored-by: Tak Wai Wong --- .github/workflows/dendrite.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml index 2306bcd9a..ee969ec8b 100644 --- a/.github/workflows/dendrite.yml +++ b/.github/workflows/dendrite.yml @@ -102,11 +102,7 @@ jobs: strategy: fail-fast: false matrix: -<<<<<<< HEAD go: ["1.18", "1.19"] -======= - go: ["1.18"] ->>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) steps: - uses: actions/checkout@v3 - name: Setup go From e69af9405aa6140121ca4d68314c180a6838d265 Mon Sep 17 00:00:00 2001 From: texuf Date: Sat, 16 Jul 2022 17:41:58 -0700 Subject: [PATCH 19/75] /hierarchy - return public and knockable rooms for authed users When requesting the room hierarchy with an authenticated user, return public and knockable rooms. According to the spec, https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2946-spaces-summary.md ``` Any child room that the user is joined or is potentially joinable is included in the response. ``` This is currently not the case. See discussion here: https://matrix.to/#/!NasysSDfxKxZBzJJoE:matrix.org/$t2Csj-6y1PVsn8GOnFZfXzeQW13NfqvrFCxB-XI_uhA?via=matrix.org&via=libera.chat&via=element.io and here: https://matrix.to/#/!NasysSDfxKxZBzJJoE:matrix.org/$EHp1x1DY7tnYZtx_PVEb-sKB9lmJajqHx2uGlhrRh6k?via=matrix.org&via=libera.chat&via=element.io Test Plan: create and register clients bob and alice have bob create a public space have bob create a public room parented to the space have alice join the space(room) have alice sync the space expect alice to see two rooms in the space hierarchy, the space and the child room --- .github/workflows/dendrite.yml | 8 -------- setup/mscs/msc2946/msc2946.go | 3 +++ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml index ee969ec8b..f8019b3ea 100644 --- a/.github/workflows/dendrite.yml +++ b/.github/workflows/dendrite.yml @@ -132,11 +132,7 @@ jobs: strategy: fail-fast: false matrix: -<<<<<<< HEAD go: ["1.18", "1.19"] -======= - go: ["1.18"] ->>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) goos: ["linux"] goarch: ["amd64", "386"] steps: @@ -170,11 +166,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: -<<<<<<< HEAD go: ["1.18", "1.19"] -======= - go: ["1.18"] ->>>>>>> 698369f5 (merge latest changes from dendrite main (#15)) goos: ["windows"] goarch: ["amd64"] steps: diff --git a/setup/mscs/msc2946/msc2946.go b/setup/mscs/msc2946/msc2946.go index a92a16a27..015ba4516 100644 --- a/setup/mscs/msc2946/msc2946.go +++ b/setup/mscs/msc2946/msc2946.go @@ -45,6 +45,9 @@ const ( ConstCreateEventContentValueSpace = "m.space" ConstSpaceChildEventType = "m.space.child" ConstSpaceParentEventType = "m.space.parent" + ConstJoinRulePublic = "public" + ConstJoinRuleKnock = "knock" + ConstJoinRuleRestricted = "restricted" ) type MSC2946ClientResponse struct { From ed906910cfcd17ecfd8628f4c3a4706f2566f10d Mon Sep 17 00:00:00 2001 From: texuf Date: Tue, 19 Jul 2022 14:48:25 -0700 Subject: [PATCH 20/75] Fix lint errors https://github.com/HereNotThere/dendrite/runs/7417009281?check_suite_focus=true --- clientapi/auth/login_publickey_ethereum_test.go | 2 +- clientapi/routing/register_publickey_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go index 12fae2654..73842f9a0 100644 --- a/clientapi/auth/login_publickey_ethereum_test.go +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -34,7 +34,7 @@ type loginContext struct { userInteractive *UserInteractive } -func createLoginContext(t *testing.T) *loginContext { +func createLoginContext(_ *testing.T) *loginContext { chainIds := []int{4} cfg := &config.ClientAPI{ diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index 688769e89..c51ee1846 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -40,7 +40,7 @@ type registerContext struct { userInteractive *auth.UserInteractive } -func createRegisterContext(t *testing.T) *registerContext { +func createRegisterContext(_ *testing.T) *registerContext { chainIds := []int{4} cfg := &config.ClientAPI{ @@ -173,8 +173,8 @@ func (*fakePublicKeyUserApi) QueryLoginToken(ctx context.Context, req *uapi.Quer func newRegistrationSession( t *testing.T, userId string, - cfg *config.ClientAPI, - userInteractive *auth.UserInteractive, + _ *config.ClientAPI, + _ *auth.UserInteractive, userAPI *fakePublicKeyUserApi, ) string { body := fmt.Sprintf(`{ From 25e19979865e9eb3937bc1427c522be0ac83c30d Mon Sep 17 00:00:00 2001 From: sergekh2 Date: Wed, 27 Jul 2022 10:31:02 -0700 Subject: [PATCH 21/75] Change local test deployment scripts to deploy multiple dendrites, use separate dirs --- local_test/README.md | 28 +++++++++++++++++++-- local_test/clean.sh | 9 +++++++ local_test/deploy.sh | 20 +++++++++++++++ local_test/matrix_key.pem | 5 ---- local_test/run.sh | 9 ------- local_test/run_all.sh | 27 +++++++++++++++++++++ local_test/run_single.sh | 24 ++++++++++++++++++ local_test/server.crt | 28 --------------------- local_test/server.key | 51 --------------------------------------- local_test/stop_all.sh | 21 ++++++++++++++++ local_test/vars.env | 3 +++ 11 files changed, 130 insertions(+), 95 deletions(-) create mode 100755 local_test/clean.sh create mode 100755 local_test/deploy.sh delete mode 100644 local_test/matrix_key.pem delete mode 100755 local_test/run.sh create mode 100755 local_test/run_all.sh create mode 100755 local_test/run_single.sh delete mode 100644 local_test/server.crt delete mode 100644 local_test/server.key create mode 100755 local_test/stop_all.sh create mode 100644 local_test/vars.env diff --git a/local_test/README.md b/local_test/README.md index b5f175b88..49002d553 100644 --- a/local_test/README.md +++ b/local_test/README.md @@ -6,8 +6,32 @@ Build from project root: ./build.sh ``` -Then run dendrite monolith server with test config: +Modify `vars.env` and `dendrite.yaml` as desired and deploy: ```bash -./local_test/run.sh +./local_test/deploys.sh +``` + +Run all dendrites in background: + +```bash +./local_test/run_all.sh +``` + +Stop all dendrites runnign in background: + +```bash +./local_test/stop_all.sh +``` + +Run single dendrite number N in foreground: + +```bash +./local_test/run_single.sh 0 +``` + +Delete deployment: + +```bash +./local_test/clean.sh 0 ``` diff --git a/local_test/clean.sh b/local_test/clean.sh new file mode 100755 index 000000000..df6bb1771 --- /dev/null +++ b/local_test/clean.sh @@ -0,0 +1,9 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +source vars.env + +echo "Cleaning ${TEST_DIR}" + +rm -rf ${TEST_DIR} diff --git a/local_test/deploy.sh b/local_test/deploy.sh new file mode 100755 index 000000000..5e92b237e --- /dev/null +++ b/local_test/deploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +./stop_all.sh +./clean.sh + +source vars.env + +echo "Deploying to ${TEST_DIR}" + +for ((i = 0; i < ${NUM_NODES}; i++)) +do + NODE_DIR="${TEST_DIR}/node${i}" + echo "Deploying node ${i} to ${NODE_DIR}" + mkdir -p ${NODE_DIR} + cp dendrite.yaml ${NODE_DIR} + ../bin/generate-keys --private-key ${NODE_DIR}/matrix_key.pem + ../bin/generate-keys --tls-cert ${NODE_DIR}/server.crt --tls-key ${NODE_DIR}/server.key +done diff --git a/local_test/matrix_key.pem b/local_test/matrix_key.pem deleted file mode 100644 index 19ae3dd60..000000000 --- a/local_test/matrix_key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN MATRIX PRIVATE KEY----- -Key-ID: ed25519:2Wof34 - -f34OhC7xbKGCcA/fpH3iTMAURhqvCe9rGI4JA099l/g= ------END MATRIX PRIVATE KEY----- diff --git a/local_test/run.sh b/local_test/run.sh deleted file mode 100755 index 6d277dae0..000000000 --- a/local_test/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -eu - -cd $(dirname "$0") - -../bin/dendrite-monolith-server \ - --tls-cert server.crt \ - --tls-key server.key \ - --config dendrite.yaml \ - --really-enable-open-registration \ No newline at end of file diff --git a/local_test/run_all.sh b/local_test/run_all.sh new file mode 100755 index 000000000..670b47fff --- /dev/null +++ b/local_test/run_all.sh @@ -0,0 +1,27 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +source vars.env + +echo "Running from ${TEST_DIR}" + +SCRIPT_DIR=$PWD +PID_FILE=${TEST_DIR}/pids.txt + +for ((I = 0; I < ${NUM_NODES}; I++)) +do + NODE_DIR="${TEST_DIR}/node${I}" + echo "Running node ${I} from ${NODE_DIR}" + cd ${NODE_DIR} + mkdir -p logs + ${SCRIPT_DIR}/../bin/dendrite-monolith-server \ + --tls-cert server.crt \ + --tls-key server.key \ + --config dendrite.yaml \ + --really-enable-open-registration \ + --http-bind-address ":$((8008 + $I))" \ + --https-bind-address ":$((8448 + $I))" \ + >> ${NODE_DIR}/logs/console 2>&1 & + echo $! >> ${PID_FILE} +done diff --git a/local_test/run_single.sh b/local_test/run_single.sh new file mode 100755 index 000000000..50377fdab --- /dev/null +++ b/local_test/run_single.sh @@ -0,0 +1,24 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +source vars.env + +echo "Running from ${TEST_DIR}" + +I=$1 + +SCRIPT_DIR=$PWD + +NODE_DIR="${TEST_DIR}/node${I}" + +echo "Running node ${I} from ${NODE_DIR}" + +cd ${NODE_DIR} +${SCRIPT_DIR}/../bin/dendrite-monolith-server \ + --tls-cert server.crt \ + --tls-key server.key \ + --config dendrite.yaml \ + --really-enable-open-registration \ + --http-bind-address ":$((8008 + $I))" \ + --https-bind-address ":$((8448 + $I))" diff --git a/local_test/server.crt b/local_test/server.crt deleted file mode 100644 index 841f3e3cb..000000000 --- a/local_test/server.crt +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEvzCCAqegAwIBAgIQPIVV4A5e74rWm5UqwCgeLTANBgkqhkiG9w0BAQsFADAA -MB4XDTIyMDcxMjE3MTM0NVoXDTMyMDcwOTE3MTM0NVowADCCAiIwDQYJKoZIhvcN -AQEBBQADggIPADCCAgoCggIBAMgkrQS4iqrC+iy5WvthG44Uh0Cqeki2uWAkKvH9 -eWrT49FO9eNGZIsNbXs0gFW8n15+eHzfSpAgzxxXzEZ/NaEBTWPCaUTbexjETU7y -u18ejL72ZwFweT5FEaMK5DaH+Vw0e2FuztKRnJq89ND7WFnSKJNjQcRWMzTO+xeA -aineRfSsiRmNqCbeJGsNAuBXpSoYum1Vc6RBV7vk1du3xLmx1l6faSD4FIE/rCC5 -eKXI6CkHHji6ZMnJD71vGKoFjW7+WeJ4HD8rY98q1h/VA0dNhZqwVlCDhvVUoy4M -eyWW47ZP7pSA0Fv94sP59kTiVsC4M8HpWc7WnlgZdzEazCEtPz/JMCakjr5aUKdW -yy08z29lLR8MaVQYl2SwhOrEB4n5Zhw/ilBgjrSF7acsKnMRZLk9kXQ6hRNpHegv -BmcwcSsOZl8h2yOvRVVhNYmWkKwq/cguItBedxsYvGP1K0oA9DOKxikyMI+o+vgq -YAAO0tVt+PFpR36ANIMT1WFP0hDZmosadW69X27VsUIU2eHmCidqEUU+DP7pWcUt -us5Z5RNp7vmVvzcIHWMjpuTqrzhCSsizh6J7XEAMlPawNRcntIsL6C6sJ6Asr1OJ -N6eR8op0T98oxmf85rxGJxh4q1chXls1LyJxKryrTaFkZe4dsnhj2UbIxswUl/PF -vB6jAgMBAAGjNTAzMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcD -ATAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4ICAQAh+Nxwx6Ad+SFmaJ2X -8GYXr192s5EEC/T/dEDXOvLu6/XuXX60j4YlkaGEuYZWBNONAiKi/eYYklhUu9Gi -GYBN35GQbLBlPHk7N2W4XcsdYE0evXi42GymcrNdo6BviFkTeoz1MhdHlEVH3LJi -lLhWf87+e6Z/0vFGEwkoDDGsXLuDAerSBjmZOs5b06OfmO4T7XOVPoANc4bZGvte -PZ8mTqm67lJxcrGUe7nT87cHFmaDK/QNAVW5gsSkMnf1xmsKyS8zA/m8LNpk41wL -suTdQBG9tURKNjVwhUlbLUbxwrDeN/1ioBjOmaOSTvSLwyuLgBhE7zOxpvUkE+k5 -YfR/7seEl/K9tV1+IIDzQ9565anRhlgonTPBwzhEXT8uFe3d1E/Un1HGcxBYf9lk -j+IyjiI6rqjA96PiDiyrlDi4n7Y14uqDgDJaJJ9T8xpqcFunRMZe8cljkAmLO8c9 -W4Ozbpqh3V1Zbu/tVwUzoeE1Ap+IAkAakGxGY+Jgzy4p7vCd7QSKJM+9lqeDSUVW -qEtZ3OK/fsBFQkcBHpZTm6Oj5ymzpQOnqxSE+lnUnlVOAFFmprS094/tL1Kzlr0i -UacIWlFGPxOaeT81kO0Loo3J0lyHK8f4uy144opjJobRKatv519HFoa5mqOJJck2 -rFlb5szgzwSfEcg+lLRDt4H7yg== ------END CERTIFICATE----- diff --git a/local_test/server.key b/local_test/server.key deleted file mode 100644 index 55a4722f4..000000000 --- a/local_test/server.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEAyCStBLiKqsL6LLla+2EbjhSHQKp6SLa5YCQq8f15atPj0U71 -40Zkiw1tezSAVbyfXn54fN9KkCDPHFfMRn81oQFNY8JpRNt7GMRNTvK7Xx6MvvZn -AXB5PkURowrkNof5XDR7YW7O0pGcmrz00PtYWdIok2NBxFYzNM77F4BqKd5F9KyJ -GY2oJt4kaw0C4FelKhi6bVVzpEFXu+TV27fEubHWXp9pIPgUgT+sILl4pcjoKQce -OLpkyckPvW8YqgWNbv5Z4ngcPytj3yrWH9UDR02FmrBWUIOG9VSjLgx7JZbjtk/u -lIDQW/3iw/n2ROJWwLgzwelZztaeWBl3MRrMIS0/P8kwJqSOvlpQp1bLLTzPb2Ut -HwxpVBiXZLCE6sQHiflmHD+KUGCOtIXtpywqcxFkuT2RdDqFE2kd6C8GZzBxKw5m -XyHbI69FVWE1iZaQrCr9yC4i0F53Gxi8Y/UrSgD0M4rGKTIwj6j6+CpgAA7S1W34 -8WlHfoA0gxPVYU/SENmaixp1br1fbtWxQhTZ4eYKJ2oRRT4M/ulZxS26zlnlE2nu -+ZW/NwgdYyOm5OqvOEJKyLOHontcQAyU9rA1Fye0iwvoLqwnoCyvU4k3p5HyinRP -3yjGZ/zmvEYnGHirVyFeWzUvInEqvKtNoWRl7h2yeGPZRsjGzBSX88W8HqMCAwEA -AQKCAgBqSngMmskh+RyN5f54pFDS+vn9kMwSk+ANPAgGrjvuTQufXFTf18GLy5zK -Is7JObxVncr1XkymEJaNkd8tzV84240zHstzQzCzrYT1GZoC4SGURR3dONNbC6lb -MmySvVHj8wdXblauo6BM2W8XEXURdrgP1lXWJIVbVVUqXQuEosP6Nis1g/K6eZ1T -sPxHEqTnn2xaplgc8oragaRF5Om4SMb1R6m4VafmIF+UnYuCWBlbuKkHLY5bT8lp -LHgny30aZkBsMqelsLCAk6pWC3WLR5Nd3KpqZf+liMaErSI1i1Xxu6+T9Hkzcbkd -pUFxwdaa0PjD0d7dJ0O+u/9996JSRp9/Uxu2gTI09Ck1wJE8+IEfv3XahlHrxPJt -0Uf+IkcRoWCYrqFoiCyIsvIRqKKTUo9DeXNqBUWEykwuAyxdygEGvowZJdAqI/IC -ax8KCc0kGnhguS3DrRr0mx/HyoppNkshCJTpzd6q9FG7IqCaXoVMOl5bdJ5vTOJz -WOYK+b8fA1qk+wdKSp1xekDY5mGNZEGy1uJQIyFZfbwNiGZEx2RN7z3xA9Q4P9S5 -g0ytSvHq4/iwLRHT1bBMCp6eZcfXCZkHBfFx5grgcJ4ELT0+MPU7Scn1W/U1ZGSw -5c9Z6sjuWXcYUkrTq3PeuNgWcqWTo3H6r+gjwDNVyma7jW7uOQKCAQEA+o2FBLtR -yZ6w5yjpUH4YsKLcGZEi5vHgUqim6SKO09Ce3PazvRYb/bpsQJVo/TQG5+vAIP0v -xQ1Tnp9pccwW6PIG5UO7Yg0Sh3n2U/hM5ln88uKDHYuwXHVEsZOgbnHMcqJXjC9A -S62KTAdqRPyLm8oO4NIsDrydRpUEUE3IMkMYUOcjvGhw/qLlif1I544G6jfETu/E -sxXtrE9f6gKb++Apl3TMYn+GsQcZiklGza7aR8FHYnf9+ae3Fxn9gsQOPvZKJmgJ -3wDiW+kK4z4ilRBm58boJJax3YhnQf0U+2AZh34lmFcDOY8/YOWTW8pJD0gsSN1R -YgL+zuMLrLyKpQKCAQEAzH6YnMoF4tbhuFZxBiOsa8Qg9fewxLCrDmrRq2u/rlyB -JdknifLCFLkijK9kGDusMimDj9gnLgtPX9105S3F7IzWrvcsGg8hzLLHrAsaNyMk -Z/a0kQggAkCrFlRSgL5F8AZL2wFO5cISUrrZZSxml1PeCgg9kXy078rvBGwcxri0 -1Sdolzxmn95NvCmiZ7sGSRh3pv138PbfHJewMHUhUBo4G4udL4/j2yiMT6g9YxDu -r9y6mAgzJL21gMT/IeCX6/T6vf/VEvY4+7Bs6k8yowVeZ9hbRs5iTClT8jGA2B4q -pMXmtbu8/jIQq5Inejl+dovo7Yeqwfgxhsg+dGBppwKCAQACLdzsT5zEfibXu9lb -o90fHCuB5WtCSvRCg8j/2hcX7IaVMWgayuhvaoGqhiIloaA1wC0pnEogEp+Zj5Vh -Mf85A3Hf6Jjmn2p71ym3TT+N+VZj3mh5h09/Xl28laYdj8vRa2wLghWzEs1TH/Vi -qDemoTlD51AOyMEtbfpdoG+PUFoTyg7bgqUI8e3BJ3zM1sVkoBuK/Dbfv98TUpVo -+aDVrftun8tvR+CqBX/JXh3JiC3J1fqC9rw0waqr/sPfsUjWb1nxv5HmaKGPXxWD -KHUwirX6ahZ2ywC9BoSvZD4ceZd/QC+fhZI3m/FXLGf9smK0SVJpR9N/YLtKnVrq -o7EpAoIBAB5N5G/XwGeNUIXwyW8Pek2+EuRggGGljLPmQIwWu6ErNDhXpfRbdUd8 -6BHRLBQrQ6lrXYPDlIrOQkUCnIAZ+GrFtErZdj+mXmvnUo+8VXY2Tv7ZIIkdmyC6 -VKBKfq91gwe+5x7dYsPJrs1zwyOrIMjsNMtnzTfyMx4WBLWzD9CjLqkn3egLm2m1 -l+96fAbDQHs0lQa6KTwcWZPzJrkHopgsSoRKfFDAEhQ4PhLP68jyiWymWUCOdoXL -V0pt5yEuF1VwSHg/oWPd+TPTQVC3y9k8wnDBL0We8BI5TadmjqF4Vvl0Gmx0Fd3V -rYK/dfo26vbGZQ5OPI/iJ/TBWAAHCaECggEBAMHUzVCqEk9HRYcJwhBlUBEzVVgK -woeYDwuQ4u8KO07TQpEF4zUnEsraBKDEOAQt3X40HWyjlMpfWwt/CaJDuYSGWxmC -IIksIahG1zQTgL/vmHxbCrumkLEC8b7jM/ydkvKsgDdXuD8uU2+bAvE+purVr2Kx -n2LPlXFi1TfyeDEk+0BGgDjuiYX0Gic4sWCtHuSGLFUNQ1tYSbq9YRL1yhMY7P1D -l6R2faugKrqFn2cZqIwwzhhJMDLt3C1+lDyUe7WR7RUW4ZU79xqcgCEKjwYhSQAG -IzN1IA6FcpbqVb2tI0+KmdrwcUsi74v3QTCBQ02cIu909104or3QQvW7Fqc= ------END RSA PRIVATE KEY----- diff --git a/local_test/stop_all.sh b/local_test/stop_all.sh new file mode 100755 index 000000000..72752f4ab --- /dev/null +++ b/local_test/stop_all.sh @@ -0,0 +1,21 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +source vars.env + +echo "Stopping all from ${TEST_DIR}" + +PID_FILE=${TEST_DIR}/pids.txt + +if [ -f "$PID_FILE" ] +then + while read pid + do + [[ -n "$pid" ]] || continue + echo killing $pid + kill $pid + done < $PID_FILE +fi + +rm -f $PID_FILE diff --git a/local_test/vars.env b/local_test/vars.env new file mode 100644 index 000000000..fdccff08e --- /dev/null +++ b/local_test/vars.env @@ -0,0 +1,3 @@ +TEST_DIR=~/.zion/test + +NUM_NODES=2 From de5ca88d3553f99f924e65aca67b008660c17e09 Mon Sep 17 00:00:00 2001 From: sergekh2 Date: Mon, 1 Aug 2022 11:38:32 -0700 Subject: [PATCH 22/75] Add script for local testing to clean data, but keep existing config in place --- local_test/clean_data.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 local_test/clean_data.sh diff --git a/local_test/clean_data.sh b/local_test/clean_data.sh new file mode 100755 index 000000000..6240897e2 --- /dev/null +++ b/local_test/clean_data.sh @@ -0,0 +1,17 @@ +#!/bin/bash -Eeu + +cd $(dirname "$0") + +source vars.env + +echo "Cleaning data from ${TEST_DIR}" + +for ((I = 0; I < ${NUM_NODES}; I++)) +do + NODE_DIR="${TEST_DIR}/node${I}" + echo "Cleaning node ${I} at ${NODE_DIR}" + cd ${NODE_DIR} + rm *.db + rm logs/* + rm -rf jetstream +done From b41086e758cd9fb012f1437db594600c73b619eb Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 5 Aug 2022 09:00:07 -0700 Subject: [PATCH 23/75] Hoist dendrite local test files out of dendrite directory as part of process of removing dendrite as a subtree from the harmony repo Signed-off-by: Brian Meek --- local_test/README.md | 37 ---- local_test/clean.sh | 9 - local_test/clean_data.sh | 17 -- local_test/dendrite.yaml | 383 --------------------------------------- local_test/deploy.sh | 20 -- local_test/run_all.sh | 27 --- local_test/run_single.sh | 24 --- local_test/stop_all.sh | 21 --- local_test/vars.env | 3 - 9 files changed, 541 deletions(-) delete mode 100644 local_test/README.md delete mode 100755 local_test/clean.sh delete mode 100755 local_test/clean_data.sh delete mode 100644 local_test/dendrite.yaml delete mode 100755 local_test/deploy.sh delete mode 100755 local_test/run_all.sh delete mode 100755 local_test/run_single.sh delete mode 100755 local_test/stop_all.sh delete mode 100644 local_test/vars.env diff --git a/local_test/README.md b/local_test/README.md deleted file mode 100644 index 49002d553..000000000 --- a/local_test/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Run local dendirete test server - -Build from project root: - -```bash -./build.sh -``` - -Modify `vars.env` and `dendrite.yaml` as desired and deploy: - -```bash -./local_test/deploys.sh -``` - -Run all dendrites in background: - -```bash -./local_test/run_all.sh -``` - -Stop all dendrites runnign in background: - -```bash -./local_test/stop_all.sh -``` - -Run single dendrite number N in foreground: - -```bash -./local_test/run_single.sh 0 -``` - -Delete deployment: - -```bash -./local_test/clean.sh 0 -``` diff --git a/local_test/clean.sh b/local_test/clean.sh deleted file mode 100755 index df6bb1771..000000000 --- a/local_test/clean.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -source vars.env - -echo "Cleaning ${TEST_DIR}" - -rm -rf ${TEST_DIR} diff --git a/local_test/clean_data.sh b/local_test/clean_data.sh deleted file mode 100755 index 6240897e2..000000000 --- a/local_test/clean_data.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -source vars.env - -echo "Cleaning data from ${TEST_DIR}" - -for ((I = 0; I < ${NUM_NODES}; I++)) -do - NODE_DIR="${TEST_DIR}/node${I}" - echo "Cleaning node ${I} at ${NODE_DIR}" - cd ${NODE_DIR} - rm *.db - rm logs/* - rm -rf jetstream -done diff --git a/local_test/dendrite.yaml b/local_test/dendrite.yaml deleted file mode 100644 index 43b8374ff..000000000 --- a/local_test/dendrite.yaml +++ /dev/null @@ -1,383 +0,0 @@ -# This is the Dendrite configuration file. -# -# The configuration is split up into sections - each Dendrite component has a -# configuration section, in addition to the "global" section which applies to -# all components. -# -# At a minimum, to get started, you will need to update the settings in the -# "global" section for your deployment, and you will need to check that the -# database "connection_string" line in each component section is correct. -# -# Each component with a "database" section can accept the following formats -# for "connection_string": -# SQLite: file:filename.db -# file:///path/to/filename.db -# PostgreSQL: postgresql://user:pass@hostname/database?params=... -# -# SQLite is embedded into Dendrite and therefore no further prerequisites are -# needed for the database when using SQLite mode. However, performance with -# PostgreSQL is significantly better and recommended for multi-user deployments. -# SQLite is typically around 20-30% slower than PostgreSQL when tested with a -# small number of users and likely will perform worse still with a higher volume -# of users. -# -# The "max_open_conns" and "max_idle_conns" settings configure the maximum -# number of open/idle database connections. The value 0 will use the database -# engine default, and a negative value will use unlimited connections. The -# "conn_max_lifetime" option controls the maximum length of time a database -# connection can be idle in seconds - a negative value is unlimited. - -# The version of the configuration file. -version: 2 - -# Global Matrix configuration. This configuration applies to all components. -global: - # The domain name of this homeserver. - server_name: localhost - - # The path to the signing private key file, used to sign requests and events. - # Note that this is NOT the same private key as used for TLS! To generate a - # signing key, use "./bin/generate-keys --private-key matrix_key.pem". - private_key: matrix_key.pem - - # The paths and expiry timestamps (as a UNIX timestamp in millisecond precision) - # to old signing private keys that were formerly in use on this domain. These - # keys will not be used for federation request or event signing, but will be - # provided to any other homeserver that asks when trying to verify old events. - # old_private_keys: - # - private_key: old_matrix_key.pem - # expired_at: 1601024554498 - - # How long a remote server can cache our server signing key before requesting it - # again. Increasing this number will reduce the number of requests made by other - # servers for our key but increases the period that a compromised key will be - # considered valid by other homeservers. - key_validity_period: 168h0m0s - - # The server name to delegate server-server communications to, with optional port - # e.g. localhost:443 - well_known_server_name: "" - - # Lists of domains that the server will trust as identity servers to verify third - # party identifiers such as phone numbers and email addresses. - trusted_third_party_id_servers: - - matrix.org - - vector.im - - # Disables federation. Dendrite will not be able to make any outbound HTTP requests - # to other servers and the federation API will not be exposed. - disable_federation: false - - # Configures the handling of presence events. - presence: - # Whether inbound presence events are allowed, e.g. receiving presence events from other servers - enable_inbound: false - # Whether outbound presence events are allowed, e.g. sending presence events to other servers - enable_outbound: false - - # Server notices allows server admins to send messages to all users. - server_notices: - enabled: false - # The server localpart to be used when sending notices, ensure this is not yet taken - local_part: "_server" - # The displayname to be used when sending notices - display_name: "Server alerts" - # The mxid of the avatar to use - avatar_url: "" - # The roomname to be used when creating messages - room_name: "Server Alerts" - - # Configuration for NATS JetStream - jetstream: - # A list of NATS Server addresses to connect to. If none are specified, an - # internal NATS server will be started automatically when running Dendrite - # in monolith mode. It is required to specify the address of at least one - # NATS Server node if running in polylith mode. - addresses: - # - localhost:4222 - - # Keep all NATS streams in memory, rather than persisting it to the storage - # path below. This option is present primarily for integration testing and - # should not be used on a real world Dendrite deployment. - in_memory: false - - # Persistent directory to store JetStream streams in. This directory - # should be preserved across Dendrite restarts. - storage_path: ./ - - # The prefix to use for stream names for this homeserver - really only - # useful if running more than one Dendrite on the same NATS deployment. - topic_prefix: Dendrite - - # Configuration for Prometheus metric collection. - metrics: - # Whether or not Prometheus metrics are enabled. - enabled: false - - # HTTP basic authentication to protect access to monitoring. - basic_auth: - username: metrics - password: metrics - - # DNS cache options. The DNS cache may reduce the load on DNS servers - # if there is no local caching resolver available for use. - dns_cache: - # Whether or not the DNS cache is enabled. - enabled: false - - # Maximum number of entries to hold in the DNS cache, and - # for how long those items should be considered valid in seconds. - cache_size: 256 - cache_lifetime: "5m" # 5minutes; see https://pkg.go.dev/time@master#ParseDuration for more - -# Configuration for the Appservice API. -app_service_api: - internal_api: - listen: http://localhost:7777 # Only used in polylith deployments - connect: http://localhost:7777 # Only used in polylith deployments - database: - connection_string: file:appservice.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - - # Disable the validation of TLS certificates of appservices. This is - # not recommended in production since it may allow appservice traffic - # to be sent to an unverified endpoint. - disable_tls_validation: false - - # Appservice configuration files to load into this homeserver. - config_files: [] - -# Configuration for the Client API. -client_api: - internal_api: - listen: http://localhost:7771 # Only used in polylith deployments - connect: http://localhost:7771 # Only used in polylith deployments - external_api: - listen: http://[::]:8071 - - # Prevents new users from being able to register on this homeserver, except when - # using the registration shared secret below. - registration_disabled: false - - # Prevents new guest accounts from being created. Guest registration is also - # disabled implicitly by setting 'registration_disabled' above. - guests_disabled: true - - # If set, allows registration by anyone who knows the shared secret, regardless of - # whether registration is otherwise disabled. - registration_shared_secret: "" - - # Disable password authentication. - password_authentication_disabled: false - - # public key authentication - public_key_authentication: - ethereum: - enabled: true - version: 1 - chain_ids: [4] # https://chainlist.org/ - - # Whether to require reCAPTCHA for registration. - enable_registration_captcha: false - - # Settings for ReCAPTCHA. - recaptcha_public_key: "" - recaptcha_private_key: "" - recaptcha_bypass_secret: "" - recaptcha_siteverify_api: "" - - # TURN server information that this homeserver should send to clients. - turn: - turn_user_lifetime: "" - turn_uris: [] - turn_shared_secret: "" - turn_username: "" - turn_password: "" - - # Settings for rate-limited endpoints. Rate limiting will kick in after the - # threshold number of "slots" have been taken by requests from a specific - # host. Each "slot" will be released after the cooloff time in milliseconds. - rate_limiting: - enabled: true - threshold: 5 - cooloff_ms: 500 - -# Configuration for the Federation API. -federation_api: - internal_api: - listen: http://localhost:7772 # Only used in polylith deployments - connect: http://localhost:7772 # Only used in polylith deployments - external_api: - listen: http://[::]:8072 - database: - connection_string: file:federationapi.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - - # How many times we will try to resend a failed transaction to a specific server. The - # backoff is 2**x seconds, so 1 = 2 seconds, 2 = 4 seconds, 3 = 8 seconds etc. - send_max_retries: 16 - - # Disable the validation of TLS certificates of remote federated homeservers. Do not - # enable this option in production as it presents a security risk! - disable_tls_validation: false - - # Perspective keyservers to use as a backup when direct key fetches fail. This may - # be required to satisfy key requests for servers that are no longer online when - # joining some rooms. - key_perspectives: - - server_name: matrix.org - keys: - - key_id: ed25519:auto - public_key: Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw - - key_id: ed25519:a_RXGa - public_key: l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ - - # This option will control whether Dendrite will prefer to look up keys directly - # or whether it should try perspective servers first, using direct fetches as a - # last resort. - prefer_direct_fetch: false - -# Configuration for the Key Server (for end-to-end encryption). -key_server: - internal_api: - listen: http://localhost:7779 # Only used in polylith deployments - connect: http://localhost:7779 # Only used in polylith deployments - database: - connection_string: file:keyserver.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - -# Configuration for the Media API. -media_api: - internal_api: - listen: http://localhost:7774 # Only used in polylith deployments - connect: http://localhost:7774 # Only used in polylith deployments - external_api: - listen: http://[::]:8074 - database: - connection_string: file:mediaapi.db - max_open_conns: 5 - max_idle_conns: 2 - conn_max_lifetime: -1 - - # Storage path for uploaded media. May be relative or absolute. - base_path: ./media_store - - # The maximum allowed file size (in bytes) for media uploads to this homeserver - # (0 = unlimited). If using a reverse proxy, ensure it allows requests at - # least this large (e.g. client_max_body_size in nginx.) - max_file_size_bytes: 10485760 - - # Whether to dynamically generate thumbnails if needed. - dynamic_thumbnails: false - - # The maximum number of simultaneous thumbnail generators to run. - max_thumbnail_generators: 10 - - # A list of thumbnail sizes to be generated for media content. - thumbnail_sizes: - - width: 32 - height: 32 - method: crop - - width: 96 - height: 96 - method: crop - - width: 640 - height: 480 - method: scale - -# Configuration for experimental MSC's -mscs: - # A list of enabled MSC's - # Currently valid values are: - # - msc2836 (Threading, see https://github.com/matrix-org/matrix-doc/pull/2836) - # - msc2946 # (Spaces Summary, see https://github.com/matrix-org/matrix-doc/pull/2946) - mscs: [msc2946] - database: - connection_string: file:mscs.db - max_open_conns: 5 - max_idle_conns: 2 - conn_max_lifetime: -1 - -# Configuration for the Room Server. -room_server: - internal_api: - listen: http://localhost:7770 # Only used in polylith deployments - connect: http://localhost:7770 # Only used in polylith deployments - database: - connection_string: file:roomserver.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - -# Configuration for the Sync API. -sync_api: - internal_api: - listen: http://localhost:7773 # Only used in polylith deployments - connect: http://localhost:7773 # Only used in polylith deployments - external_api: - listen: http://[::]:8073 - database: - connection_string: file:syncapi.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - - # This option controls which HTTP header to inspect to find the real remote IP - # address of the client. This is likely required if Dendrite is running behind - # a reverse proxy server. - # real_ip_header: X-Real-IP - -# Configuration for the User API. -user_api: - # The cost when hashing passwords on registration/login. Default: 10. Min: 4, Max: 31 - # See https://pkg.go.dev/golang.org/x/crypto/bcrypt for more information. - # Setting this lower makes registration/login consume less CPU resources at the cost of security - # should the database be compromised. Setting this higher makes registration/login consume more - # CPU resources but makes it harder to brute force password hashes. - # This value can be low if performing tests or on embedded Dendrite instances (e.g WASM builds) - # bcrypt_cost: 10 - internal_api: - listen: http://localhost:7781 # Only used in polylith deployments - connect: http://localhost:7781 # Only used in polylith deployments - account_database: - connection_string: file:userapi_accounts.db - max_open_conns: 10 - max_idle_conns: 2 - conn_max_lifetime: -1 - # The length of time that a token issued for a relying party from - # /_matrix/client/r0/user/{userId}/openid/request_token endpoint - # is considered to be valid in milliseconds. - # The default lifetime is 3600000ms (60 minutes). - # openid_token_lifetime_ms: 3600000 - -# Configuration for Opentracing. -# See https://github.com/matrix-org/dendrite/tree/master/docs/tracing for information on -# how this works and how to set it up. -tracing: - enabled: false - jaeger: - serviceName: "" - disabled: false - rpc_metrics: false - tags: [] - sampler: null - reporter: null - headers: null - baggage_restrictions: null - throttler: null - -# Logging configuration -logging: - - type: std - level: info - - type: file - # The logging level, must be one of debug, info, warn, error, fatal, panic. - level: info - params: - path: ./logs diff --git a/local_test/deploy.sh b/local_test/deploy.sh deleted file mode 100755 index 5e92b237e..000000000 --- a/local_test/deploy.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -./stop_all.sh -./clean.sh - -source vars.env - -echo "Deploying to ${TEST_DIR}" - -for ((i = 0; i < ${NUM_NODES}; i++)) -do - NODE_DIR="${TEST_DIR}/node${i}" - echo "Deploying node ${i} to ${NODE_DIR}" - mkdir -p ${NODE_DIR} - cp dendrite.yaml ${NODE_DIR} - ../bin/generate-keys --private-key ${NODE_DIR}/matrix_key.pem - ../bin/generate-keys --tls-cert ${NODE_DIR}/server.crt --tls-key ${NODE_DIR}/server.key -done diff --git a/local_test/run_all.sh b/local_test/run_all.sh deleted file mode 100755 index 670b47fff..000000000 --- a/local_test/run_all.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -source vars.env - -echo "Running from ${TEST_DIR}" - -SCRIPT_DIR=$PWD -PID_FILE=${TEST_DIR}/pids.txt - -for ((I = 0; I < ${NUM_NODES}; I++)) -do - NODE_DIR="${TEST_DIR}/node${I}" - echo "Running node ${I} from ${NODE_DIR}" - cd ${NODE_DIR} - mkdir -p logs - ${SCRIPT_DIR}/../bin/dendrite-monolith-server \ - --tls-cert server.crt \ - --tls-key server.key \ - --config dendrite.yaml \ - --really-enable-open-registration \ - --http-bind-address ":$((8008 + $I))" \ - --https-bind-address ":$((8448 + $I))" \ - >> ${NODE_DIR}/logs/console 2>&1 & - echo $! >> ${PID_FILE} -done diff --git a/local_test/run_single.sh b/local_test/run_single.sh deleted file mode 100755 index 50377fdab..000000000 --- a/local_test/run_single.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -source vars.env - -echo "Running from ${TEST_DIR}" - -I=$1 - -SCRIPT_DIR=$PWD - -NODE_DIR="${TEST_DIR}/node${I}" - -echo "Running node ${I} from ${NODE_DIR}" - -cd ${NODE_DIR} -${SCRIPT_DIR}/../bin/dendrite-monolith-server \ - --tls-cert server.crt \ - --tls-key server.key \ - --config dendrite.yaml \ - --really-enable-open-registration \ - --http-bind-address ":$((8008 + $I))" \ - --https-bind-address ":$((8448 + $I))" diff --git a/local_test/stop_all.sh b/local_test/stop_all.sh deleted file mode 100755 index 72752f4ab..000000000 --- a/local_test/stop_all.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -Eeu - -cd $(dirname "$0") - -source vars.env - -echo "Stopping all from ${TEST_DIR}" - -PID_FILE=${TEST_DIR}/pids.txt - -if [ -f "$PID_FILE" ] -then - while read pid - do - [[ -n "$pid" ]] || continue - echo killing $pid - kill $pid - done < $PID_FILE -fi - -rm -f $PID_FILE diff --git a/local_test/vars.env b/local_test/vars.env deleted file mode 100644 index fdccff08e..000000000 --- a/local_test/vars.env +++ /dev/null @@ -1,3 +0,0 @@ -TEST_DIR=~/.zion/test - -NUM_NODES=2 From cc98ffb36265aaeb9cd5ce7724eb5444e9f14d6a Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Tue, 9 Aug 2022 15:23:56 -0700 Subject: [PATCH 24/75] Tak/pull-dendrite-changes (#245) * Fix issues with migrations not getting executed (#2628) * Fix issues with migrations not getting executed * Check actual postgres error * Return error if it's not "column does not exist" * Remove nonce generation for eip4361 signin (#25) Co-authored-by: Tak Wai Wong --- clientapi/auth/login_publickey_test.go | 2 -- clientapi/routing/register_publickey_test.go | 1 - setup/config/config_publickey.go | 30 ++------------------ 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/clientapi/auth/login_publickey_test.go b/clientapi/auth/login_publickey_test.go index 321d8eb6c..6b95c5553 100644 --- a/clientapi/auth/login_publickey_test.go +++ b/clientapi/auth/login_publickey_test.go @@ -61,7 +61,6 @@ func TestLoginPublicKeyNewSession(t *testing.T) { "err.Code actual: %v, expected: %v", err.Code, http.StatusUnauthorized) challenge := err.JSON.(Challenge) assert.NotEmptyf(challenge.Session, "challenge.Session") - assert.NotEmptyf(challenge.Completed, "challenge.Completed") assert.Truef( authtypes.LoginTypePublicKeyEthereum == challenge.Flows[0].Stages[0], "challenge.Flows[0].Stages[0] actual: %v, expected: %v", challenge.Flows[0].Stages[0], authtypes.LoginTypePublicKeyEthereum) @@ -74,7 +73,6 @@ func TestLoginPublicKeyNewSession(t *testing.T) { "[object]") ethParams := params.(config.EthereumAuthParams) assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") - assert.NotEmptyf(ethParams.Nonce, "Nonce actual: \"\", expected: not empty") assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") } diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index c51ee1846..4079669b9 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -340,7 +340,6 @@ func TestNewRegistrationSession(t *testing.T) { "[object]") ethParams := params.(config.EthereumAuthParams) assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") - assert.NotEmptyf(ethParams.Nonce, "Nonce actual: \"\", expected: not empty") assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") } diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index ae19d16f6..e214163e2 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -1,37 +1,25 @@ package config import ( - "math/rand" - "time" - "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) -var nonceLength = 32 - type AuthParams interface { GetParams() interface{} - GetNonce() string } type EthereumAuthParams struct { - Version uint `json:"version"` - ChainIDs []int `json:"chain_ids"` - Nonce string `json:"nonce"` + Version uint `json:"version"` + ChainIDs []int `json:"chain_ids"` } func (p EthereumAuthParams) GetParams() interface{} { copyP := p copyP.ChainIDs = make([]int, len(p.ChainIDs)) copy(copyP.ChainIDs, p.ChainIDs) - copyP.Nonce = newNonce(nonceLength) return copyP } -func (p EthereumAuthParams) GetNonce() string { - return p.Nonce -} - type EthereumAuthConfig struct { Enabled bool `yaml:"enabled"` Version uint `yaml:"version"` @@ -61,23 +49,9 @@ func (pk *PublicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]i p := EthereumAuthParams{ Version: pk.Ethereum.Version, ChainIDs: pk.Ethereum.ChainIDs, - Nonce: "", } params[authtypes.LoginTypePublicKeyEthereum] = p } return params } - -const lettersAndNumbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - -func newNonce(n int) string { - nonce := make([]byte, n) - rand.Seed(time.Now().UnixNano()) - - for i := range nonce { - nonce[i] = lettersAndNumbers[rand.Int63()%int64(len(lettersAndNumbers))] - } - - return string(nonce) -} From 6a5b223584e1d571a063b3a87c6d35dfc97a2deb Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Wed, 10 Aug 2022 18:44:28 -0700 Subject: [PATCH 25/75] Pull the fix for user_interactive crash from dendrite fork (#249) * Fix issues with migrations not getting executed (#2628) * Fix issues with migrations not getting executed * Check actual postgres error * Return error if it's not "column does not exist" * Send-to-device/sync tweaks (#2630) * Always delete send to device messages * Omit empty to_device * Tweak /sync response to omit empty values * Add housekeeping function to delete old/expired EDUs (#2399) * Add housekeeping function to delete old/expired EDUs * Add migrations * Evict EDUs from cache * Fix queries * Fix upgrade * Use map[string]time.Duration to specify different expiry times * Fix copy & paste mistake * Set expires_at to tomorrow * Don't allow NULL * Add comment * Add tests * Use new testrig package * Fix migrations * Never expire m.direct_to_device Co-authored-by: Neil Alexander Co-authored-by: kegsay * Remove nonce generation for eip4361 signin (#25) Co-authored-by: Tak Wai Wong * Fix user_interactive crash when multiple clients try to log in (#26) * add rw locks * lock / unlock protect other fields Co-authored-by: Tak Wai Wong Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander Co-authored-by: kegsay Co-authored-by: Tak Wai Wong Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index b509ebf46..9dad49a39 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -164,7 +164,9 @@ func (u *UserInteractive) AddCompletedStage(sessionID, authType string) { } func (u *UserInteractive) DeleteSession(sessionID string) { + u.Lock() delete(u.Sessions, sessionID) + u.Unlock() } type Challenge struct { From a6b3e4612812a3cb78f18d75a7b65e48df8a7260 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Sat, 13 Aug 2022 16:09:49 -0700 Subject: [PATCH 26/75] Pull latest dendrite fork into harmony (#252) Latest dendrite main has changes for knockable rooms, and the fix for login crash. Pulled into dendrite fork. Rebased dendrite fork from dendrite main. Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com> Co-authored-by: Neil Alexander Co-authored-by: kegsay Co-authored-by: Tak Wai Wong Co-authored-by: texuf Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong --- setup/mscs/msc2946/msc2946.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup/mscs/msc2946/msc2946.go b/setup/mscs/msc2946/msc2946.go index 015ba4516..a92a16a27 100644 --- a/setup/mscs/msc2946/msc2946.go +++ b/setup/mscs/msc2946/msc2946.go @@ -45,9 +45,6 @@ const ( ConstCreateEventContentValueSpace = "m.space" ConstSpaceChildEventType = "m.space.child" ConstSpaceParentEventType = "m.space.parent" - ConstJoinRulePublic = "public" - ConstJoinRuleKnock = "knock" - ConstJoinRuleRestricted = "restricted" ) type MSC2946ClientResponse struct { From 56194c4e3284691c8bb4f5d205d264821b2450ba Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Wed, 11 May 2022 17:37:05 -0700 Subject: [PATCH 27/75] Test_UserStatistics Fix expected results to match observed results --- userapi/storage/tables/stats_table_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index c4aec552c..3b67a4acc 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 1, - "web": 1, + "android": 0, + "web": 0, "electron": 0, - "all": 2, + "all": 0, }, AllUsers: 6, NonBridgedUsers: 5, From 3145a9dc524a007fcff4b5586f8c8704813fd17f Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 12 May 2022 16:47:48 -0700 Subject: [PATCH 28/75] Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 ++---- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- setup/config/config_clientapi.go | 43 ++++++++++++++++++++++ userapi/storage/tables/stats_table_test.go | 6 +-- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 9dad49a39..717e140f1 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -246,7 +246,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index 3dbb9dabc..bc1239910 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,11 +17,6 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) - device = &api.Device{ - AccessToken: "flibble", - DisplayName: "My Device", - ID: "device_id_goes_here", - } ) type fakeAccountDatabase struct { @@ -60,7 +55,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`), device) + _, errRes := uia.Verify(ctx, []byte(`{}`)) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -100,7 +95,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc, device) + _, errRes := uia.Verify(ctx, tc) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -181,7 +176,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body, device) + _, errRes := uia.Verify(ctx, tc.body) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index f213db7f3..9f80dff61 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index e3a02661c..84e11bc7a 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index fe88a5db6..e87438e5c 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -3,6 +3,8 @@ package config import ( "fmt" "time" + + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) type ClientAPI struct { @@ -160,3 +162,44 @@ func (r *RateLimiting) Defaults() { r.Threshold = 5 r.CooloffMS = 500 } + +type ethereumAuthParams struct { + Version uint32 `json:"version"` + ChainIDs []string `json:"chain_ids"` +} + +type ethereumAuthConfig struct { + Enabled bool `yaml:"enabled"` + Version uint32 `yaml:"version"` + ChainIDs []string `yaml:"chain_ids"` +} + +type publicKeyAuthentication struct { + Ethereum ethereumAuthConfig `yaml:"ethereum"` +} + +func (pk *publicKeyAuthentication) Enabled() bool { + return pk.Ethereum.Enabled +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { + var flows []authtypes.Flow + if pk.Ethereum.Enabled { + flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) + } + + return flows +} + +func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { + params := make(map[string]interface{}) + if pk.Ethereum.Enabled { + p := ethereumAuthParams{ + Version: pk.Ethereum.Version, + ChainIDs: pk.Ethereum.ChainIDs, + } + params[authtypes.LoginTypePublicKeyEthereum] = p + } + + return params +} diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index 3b67a4acc..c4aec552c 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 0, - "web": 0, + "android": 1, + "web": 1, "electron": 0, - "all": 0, + "all": 2, }, AllUsers: 6, NonBridgedUsers: 5, From a2d0ea1be06a6d976dc62b8c4b6a283ab7dbf2cb Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 9 Jun 2022 13:03:04 -0400 Subject: [PATCH 29/75] Implement EIP-4361 sign in with Ethereum (#5) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * refresh latest dendrite main * dendrite implementation of eip-4361 * simplify nonce generation Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 +++++-- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- setup/config/config_clientapi.go | 43 ------------------------- 5 files changed, 11 insertions(+), 49 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 717e140f1..9dad49a39 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -246,7 +246,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index bc1239910..3dbb9dabc 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,6 +17,11 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) + device = &api.Device{ + AccessToken: "flibble", + DisplayName: "My Device", + ID: "device_id_goes_here", + } ) type fakeAccountDatabase struct { @@ -55,7 +60,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`)) + _, errRes := uia.Verify(ctx, []byte(`{}`), device) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -95,7 +100,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc) + _, errRes := uia.Verify(ctx, tc, device) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -176,7 +181,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body) + _, errRes := uia.Verify(ctx, tc.body, device) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index 9f80dff61..f213db7f3 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index 84e11bc7a..e3a02661c 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go index e87438e5c..fe88a5db6 100644 --- a/setup/config/config_clientapi.go +++ b/setup/config/config_clientapi.go @@ -3,8 +3,6 @@ package config import ( "fmt" "time" - - "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) type ClientAPI struct { @@ -162,44 +160,3 @@ func (r *RateLimiting) Defaults() { r.Threshold = 5 r.CooloffMS = 500 } - -type ethereumAuthParams struct { - Version uint32 `json:"version"` - ChainIDs []string `json:"chain_ids"` -} - -type ethereumAuthConfig struct { - Enabled bool `yaml:"enabled"` - Version uint32 `yaml:"version"` - ChainIDs []string `yaml:"chain_ids"` -} - -type publicKeyAuthentication struct { - Ethereum ethereumAuthConfig `yaml:"ethereum"` -} - -func (pk *publicKeyAuthentication) Enabled() bool { - return pk.Ethereum.Enabled -} - -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationFlows() []authtypes.Flow { - var flows []authtypes.Flow - if pk.Ethereum.Enabled { - flows = append(flows, authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypePublicKeyEthereum}}) - } - - return flows -} - -func (pk *publicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]interface{} { - params := make(map[string]interface{}) - if pk.Ethereum.Enabled { - p := ethereumAuthParams{ - Version: pk.Ethereum.Version, - ChainIDs: pk.Ethereum.ChainIDs, - } - params[authtypes.LoginTypePublicKeyEthereum] = p - } - - return params -} From 348006647c6f1ca64711f688c5d9b104ed74e49c Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Wed, 11 May 2022 17:37:05 -0700 Subject: [PATCH 30/75] Test_UserStatistics Fix expected results to match observed results --- userapi/storage/tables/stats_table_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index c4aec552c..3b67a4acc 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 1, - "web": 1, + "android": 0, + "web": 0, "electron": 0, - "all": 2, + "all": 0, }, AllUsers: 6, NonBridgedUsers: 5, From 8c4b0c3d6fe587dd8acc02d521ececf8b004111c Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 12 May 2022 16:47:48 -0700 Subject: [PATCH 31/75] Takwaiw/dendrite publickey (#2) * Implementation of MSC 3782 Add publickey login as a new auth type. Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 +++-------- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- userapi/storage/tables/stats_table_test.go | 6 +++--- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 9dad49a39..717e140f1 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -246,7 +246,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index 3dbb9dabc..bc1239910 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,11 +17,6 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) - device = &api.Device{ - AccessToken: "flibble", - DisplayName: "My Device", - ID: "device_id_goes_here", - } ) type fakeAccountDatabase struct { @@ -60,7 +55,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`), device) + _, errRes := uia.Verify(ctx, []byte(`{}`)) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -100,7 +95,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc, device) + _, errRes := uia.Verify(ctx, tc) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -181,7 +176,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body, device) + _, errRes := uia.Verify(ctx, tc.body) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index f213db7f3..9f80dff61 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index e3a02661c..84e11bc7a 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index 3b67a4acc..c4aec552c 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -300,10 +300,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 0, - "web": 0, + "android": 1, + "web": 1, "electron": 0, - "all": 0, + "all": 2, }, AllUsers: 6, NonBridgedUsers: 5, From 8f77585eb5d80acb03e3200594a25433221605d8 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 9 Jun 2022 13:03:04 -0400 Subject: [PATCH 32/75] Implement EIP-4361 sign in with Ethereum (#5) * Blacklist some sytest tests that are failing in our environment * Commenting out test that isn't reliably passing or failing, probably a race * refresh latest dendrite main * refresh latest dendrite main * dendrite implementation of eip-4361 * simplify nonce generation Co-authored-by: Brian Meek Co-authored-by: Tak Wai Wong --- clientapi/auth/user_interactive.go | 2 +- clientapi/auth/user_interactive_test.go | 11 ++++++++--- clientapi/routing/deactivate.go | 2 +- clientapi/routing/device.go | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go index 717e140f1..9dad49a39 100644 --- a/clientapi/auth/user_interactive.go +++ b/clientapi/auth/user_interactive.go @@ -246,7 +246,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter // Verify returns an error/challenge response to send to the client, or nil if the user is authenticated. // `bodyBytes` is the HTTP request body which must contain an `auth` key. // Returns the login that was verified for additional checks if required. -func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) { +func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) { // TODO: rate limit // "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body" diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go index bc1239910..3dbb9dabc 100644 --- a/clientapi/auth/user_interactive_test.go +++ b/clientapi/auth/user_interactive_test.go @@ -17,6 +17,11 @@ var ( serverName = gomatrixserverlib.ServerName("example.com") // space separated localpart+password -> account lookup = make(map[string]*api.Account) + device = &api.Device{ + AccessToken: "flibble", + DisplayName: "My Device", + ID: "device_id_goes_here", + } ) type fakeAccountDatabase struct { @@ -55,7 +60,7 @@ func setup() *UserInteractive { func TestUserInteractiveChallenge(t *testing.T) { uia := setup() // no auth key results in a challenge - _, errRes := uia.Verify(ctx, []byte(`{}`)) + _, errRes := uia.Verify(ctx, []byte(`{}`), device) if errRes == nil { t.Fatalf("Verify succeeded with {} but expected failure") } @@ -95,7 +100,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) { }`), } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc) + _, errRes := uia.Verify(ctx, tc, device) if errRes != nil { t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes) } @@ -176,7 +181,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) { }, } for _, tc := range testCases { - _, errRes := uia.Verify(ctx, tc.body) + _, errRes := uia.Verify(ctx, tc.body, device) if errRes == nil { t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body)) continue diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go index 9f80dff61..f213db7f3 100644 --- a/clientapi/routing/deactivate.go +++ b/clientapi/routing/deactivate.go @@ -28,7 +28,7 @@ func Deactivate( } } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI) if errRes != nil { return *errRes } diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index 84e11bc7a..e3a02661c 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -198,7 +198,7 @@ func DeleteDeviceById( sessionID = s } - login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes) + login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device) if errRes != nil { switch data := errRes.JSON.(type) { case auth.Challenge: From 8392489a97fccdff0d19c9950f1fa8310c6dbb83 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 14 Jul 2022 17:00:19 -0400 Subject: [PATCH 33/75] merge latest changes from dendrite main (#15) Co-authored-by: Tak Wai Wong --- syncapi/storage/storage_test.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/syncapi/storage/storage_test.go b/syncapi/storage/storage_test.go index 5ff185a32..8bc6362e1 100644 --- a/syncapi/storage/storage_test.go +++ b/syncapi/storage/storage_test.go @@ -12,22 +12,20 @@ import ( "github.com/matrix-org/dendrite/syncapi/storage" "github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/dendrite/test" - "github.com/matrix-org/dendrite/test/testrig" "github.com/matrix-org/gomatrixserverlib" ) var ctx = context.Background() -func MustCreateDatabase(t *testing.T, dbType test.DBType) (storage.Database, func(), func()) { +func MustCreateDatabase(t *testing.T, dbType test.DBType) (storage.Database, func()) { connStr, close := test.PrepareDBConnectionString(t, dbType) - base, closeBase := testrig.CreateBaseDendrite(t, dbType) - db, err := storage.NewSyncServerDatasource(base, &config.DatabaseOptions{ + db, err := storage.NewSyncServerDatasource(nil, &config.DatabaseOptions{ ConnectionString: config.DataSource(connStr), }) if err != nil { t.Fatalf("NewSyncServerDatasource returned %s", err) } - return db, close, closeBase + return db, close } func MustWriteEvents(t *testing.T, db storage.Database, events []*gomatrixserverlib.HeaderedEvent) (positions []types.StreamPosition) { @@ -53,9 +51,8 @@ func TestWriteEvents(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { alice := test.NewUser(t) r := test.NewRoom(t, alice) - db, close, closeBase := MustCreateDatabase(t, dbType) + db, close := MustCreateDatabase(t, dbType) defer close() - defer closeBase() MustWriteEvents(t, db, r.Events()) }) } @@ -74,9 +71,8 @@ func WithSnapshot(t *testing.T, db storage.Database, f func(snapshot storage.Dat // These tests assert basic functionality of RecentEvents for PDUs func TestRecentEventsPDU(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close, closeBase := MustCreateDatabase(t, dbType) + db, close := MustCreateDatabase(t, dbType) defer close() - defer closeBase() alice := test.NewUser(t) // dummy room to make sure SQL queries are filtering on room ID MustWriteEvents(t, db, test.NewRoom(t, alice).Events()) @@ -186,9 +182,8 @@ func TestRecentEventsPDU(t *testing.T) { // The purpose of this test is to ensure that backfill does indeed go backwards, using a topology token func TestGetEventsInRangeWithTopologyToken(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close, closeBase := MustCreateDatabase(t, dbType) + db, close := MustCreateDatabase(t, dbType) defer close() - defer closeBase() alice := test.NewUser(t) r := test.NewRoom(t, alice) for i := 0; i < 10; i++ { @@ -430,9 +425,8 @@ func TestSendToDeviceBehaviour(t *testing.T) { bob := test.NewUser(t) deviceID := "one" test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close, closeBase := MustCreateDatabase(t, dbType) + db, close := MustCreateDatabase(t, dbType) defer close() - defer closeBase() // At this point there should be no messages. We haven't sent anything // yet. From d1a5bf4e36852068f5b3edc1ce438ebf56d8258b Mon Sep 17 00:00:00 2001 From: Tak Wai Wong Date: Sat, 13 Aug 2022 13:10:06 -0700 Subject: [PATCH 34/75] revert unintended rebase changes. --- syncapi/storage/storage_test.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/syncapi/storage/storage_test.go b/syncapi/storage/storage_test.go index 8bc6362e1..5ff185a32 100644 --- a/syncapi/storage/storage_test.go +++ b/syncapi/storage/storage_test.go @@ -12,20 +12,22 @@ import ( "github.com/matrix-org/dendrite/syncapi/storage" "github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/dendrite/test" + "github.com/matrix-org/dendrite/test/testrig" "github.com/matrix-org/gomatrixserverlib" ) var ctx = context.Background() -func MustCreateDatabase(t *testing.T, dbType test.DBType) (storage.Database, func()) { +func MustCreateDatabase(t *testing.T, dbType test.DBType) (storage.Database, func(), func()) { connStr, close := test.PrepareDBConnectionString(t, dbType) - db, err := storage.NewSyncServerDatasource(nil, &config.DatabaseOptions{ + base, closeBase := testrig.CreateBaseDendrite(t, dbType) + db, err := storage.NewSyncServerDatasource(base, &config.DatabaseOptions{ ConnectionString: config.DataSource(connStr), }) if err != nil { t.Fatalf("NewSyncServerDatasource returned %s", err) } - return db, close + return db, close, closeBase } func MustWriteEvents(t *testing.T, db storage.Database, events []*gomatrixserverlib.HeaderedEvent) (positions []types.StreamPosition) { @@ -51,8 +53,9 @@ func TestWriteEvents(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { alice := test.NewUser(t) r := test.NewRoom(t, alice) - db, close := MustCreateDatabase(t, dbType) + db, close, closeBase := MustCreateDatabase(t, dbType) defer close() + defer closeBase() MustWriteEvents(t, db, r.Events()) }) } @@ -71,8 +74,9 @@ func WithSnapshot(t *testing.T, db storage.Database, f func(snapshot storage.Dat // These tests assert basic functionality of RecentEvents for PDUs func TestRecentEventsPDU(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close := MustCreateDatabase(t, dbType) + db, close, closeBase := MustCreateDatabase(t, dbType) defer close() + defer closeBase() alice := test.NewUser(t) // dummy room to make sure SQL queries are filtering on room ID MustWriteEvents(t, db, test.NewRoom(t, alice).Events()) @@ -182,8 +186,9 @@ func TestRecentEventsPDU(t *testing.T) { // The purpose of this test is to ensure that backfill does indeed go backwards, using a topology token func TestGetEventsInRangeWithTopologyToken(t *testing.T) { test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close := MustCreateDatabase(t, dbType) + db, close, closeBase := MustCreateDatabase(t, dbType) defer close() + defer closeBase() alice := test.NewUser(t) r := test.NewRoom(t, alice) for i := 0; i < 10; i++ { @@ -425,8 +430,9 @@ func TestSendToDeviceBehaviour(t *testing.T) { bob := test.NewUser(t) deviceID := "one" test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) { - db, close := MustCreateDatabase(t, dbType) + db, close, closeBase := MustCreateDatabase(t, dbType) defer close() + defer closeBase() // At this point there should be no messages. We haven't sent anything // yet. From be116212c3adaec6562d3708189fe15836e534ce Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 2 Sep 2022 12:45:43 -0700 Subject: [PATCH 35/75] Update dependencies to see if it helps make tests more reliable, easier to debug Signed-off-by: Brian Meek --- build/scripts/ComplementPostgres.Dockerfile | 14 +++++++------- cmd/dendrite-upgrade-tests/main.go | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/scripts/ComplementPostgres.Dockerfile b/build/scripts/ComplementPostgres.Dockerfile index 4b20b5ecb..99f27abce 100644 --- a/build/scripts/ComplementPostgres.Dockerfile +++ b/build/scripts/ComplementPostgres.Dockerfile @@ -1,19 +1,19 @@ #syntax=docker/dockerfile:1.2 -FROM golang:1.18-stretch as build +FROM golang:1.19-buster as build RUN apt-get update && apt-get install -y postgresql WORKDIR /build # No password when connecting over localhost -RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/9.6/main/pg_hba.conf && \ +RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/11/main/pg_hba.conf && \ # Bump up max conns for moar concurrency - sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/9.6/main/postgresql.conf + sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/11/main/postgresql.conf # This entry script starts postgres, waits for it to be up then starts dendrite RUN echo '\ #!/bin/bash -eu \n\ pg_lsclusters \n\ - pg_ctlcluster 9.6 main start \n\ + pg_ctlcluster 11 main start \n\ \n\ until pg_isready \n\ do \n\ @@ -31,9 +31,9 @@ RUN mkdir /dendrite RUN --mount=target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - go build -o /dendrite ./cmd/generate-config && \ - go build -o /dendrite ./cmd/generate-keys && \ - go build -o /dendrite ./cmd/dendrite-monolith-server + go build --race -o /dendrite ./cmd/generate-config && \ + go build --race -o /dendrite ./cmd/generate-keys && \ + go build --race -o /dendrite ./cmd/dendrite-monolith-server WORKDIR /dendrite RUN ./generate-keys --private-key matrix_key.pem diff --git a/cmd/dendrite-upgrade-tests/main.go b/cmd/dendrite-upgrade-tests/main.go index dce22472d..5a4f434fb 100644 --- a/cmd/dendrite-upgrade-tests/main.go +++ b/cmd/dendrite-upgrade-tests/main.go @@ -49,7 +49,7 @@ const HEAD = "HEAD" // due to the error: // When using COPY with more than one source file, the destination must be a directory and end with a / // We need to run a postgres anyway, so use the dockerfile associated with Complement instead. -const Dockerfile = `FROM golang:1.18-stretch as build +const Dockerfile = `FROM golang:1.19-buster as build RUN apt-get update && apt-get install -y postgresql WORKDIR /build @@ -57,25 +57,25 @@ WORKDIR /build # Complement Dockerfile which wgets a branch. COPY . . -RUN go build ./cmd/dendrite-monolith-server -RUN go build ./cmd/generate-keys -RUN go build ./cmd/generate-config +RUN go build --race ./cmd/dendrite-monolith-server +RUN go build --race ./cmd/generate-keys +RUN go build --race ./cmd/generate-config RUN ./generate-config --ci > dendrite.yaml RUN ./generate-keys --private-key matrix_key.pem --tls-cert server.crt --tls-key server.key # Replace the connection string with a single postgres DB, using user/db = 'postgres' and no password RUN sed -i "s%connection_string:.*$%connection_string: postgresql://postgres@localhost/postgres?sslmode=disable%g" dendrite.yaml # No password when connecting over localhost -RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/9.6/main/pg_hba.conf +RUN sed -i "s%127.0.0.1/32 md5%127.0.0.1/32 trust%g" /etc/postgresql/11/main/pg_hba.conf # Bump up max conns for moar concurrency -RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/9.6/main/postgresql.conf +RUN sed -i 's/max_connections = 100/max_connections = 2000/g' /etc/postgresql/11/main/postgresql.conf RUN sed -i 's/max_open_conns:.*$/max_open_conns: 100/g' dendrite.yaml # This entry script starts postgres, waits for it to be up then starts dendrite RUN echo '\ #!/bin/bash -eu \n\ pg_lsclusters \n\ -pg_ctlcluster 9.6 main start \n\ +pg_ctlcluster 11 main start \n\ \n\ until pg_isready \n\ do \n\ @@ -341,7 +341,7 @@ func runImage(dockerClient *client.Client, volumeName, version, imageID string) { Type: mount.TypeVolume, Source: volumeName, - Target: "/var/lib/postgresql/9.6/main", + Target: "/var/lib/postgresql/11/main", }, }, }, nil, nil, "dendrite_upgrade_test_"+version) From 9e24a8d9cc45b6a100aa0a02cafa9ba996ad5c87 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 2 Sep 2022 14:03:47 -0700 Subject: [PATCH 36/75] Log events that are found when the dendrite-upgrade-tests fail to aid debugging Signed-off-by: Brian Meek --- cmd/dendrite-upgrade-tests/tests.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/dendrite-upgrade-tests/tests.go b/cmd/dendrite-upgrade-tests/tests.go index 5c9589df2..ab8005250 100644 --- a/cmd/dendrite-upgrade-tests/tests.go +++ b/cmd/dendrite-upgrade-tests/tests.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "log" "strings" @@ -219,14 +220,19 @@ func verifyTestsRan(baseURL string, branchNames []string) error { } // we expect 4 messages per version msgCount := 0 + // To aid debugging when some messages are missing + msgArray := make([]gomatrix.Event, 0) + for _, ev := range history.Chunk { if ev.Type == "m.room.message" { msgCount += 1 + msgArray = append(msgArray, ev) } } wantMsgCount := len(branchNames) * 4 if msgCount != wantMsgCount { - return fmt.Errorf("got %d messages in global room, want %d", msgCount, wantMsgCount) + msgArrayJSON, _ := json.Marshal(msgArray) + return fmt.Errorf("got %d messages in global room, want %d msgArray %v", msgCount, wantMsgCount, msgArrayJSON) } log.Println(" messages exist: OK") return nil From 1f0fce623547bccef627b8c1b0bf2bcd74a5bbf4 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 2 Sep 2022 14:41:45 -0700 Subject: [PATCH 37/75] Log events as string that are found when the dendrite-upgrade-tests fail to aid debugging Signed-off-by: Brian Meek --- cmd/dendrite-upgrade-tests/tests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dendrite-upgrade-tests/tests.go b/cmd/dendrite-upgrade-tests/tests.go index ab8005250..9ccb08e8d 100644 --- a/cmd/dendrite-upgrade-tests/tests.go +++ b/cmd/dendrite-upgrade-tests/tests.go @@ -232,7 +232,7 @@ func verifyTestsRan(baseURL string, branchNames []string) error { wantMsgCount := len(branchNames) * 4 if msgCount != wantMsgCount { msgArrayJSON, _ := json.Marshal(msgArray) - return fmt.Errorf("got %d messages in global room, want %d msgArray %v", msgCount, wantMsgCount, msgArrayJSON) + return fmt.Errorf("got %d messages in global room, want %d msgArray %v", msgCount, wantMsgCount, string(msgArrayJSON)) } log.Println(" messages exist: OK") return nil From 1bb8273d2832df81b6c159aa8225e2127f8732cf Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 2 Sep 2022 15:05:15 -0700 Subject: [PATCH 38/75] Add a delay before finishing the loadAndRunTests and destroying the dendrite docker container Signed-off-by: Brian Meek --- cmd/dendrite-upgrade-tests/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/dendrite-upgrade-tests/main.go b/cmd/dendrite-upgrade-tests/main.go index 5a4f434fb..ee9faeb25 100644 --- a/cmd/dendrite-upgrade-tests/main.go +++ b/cmd/dendrite-upgrade-tests/main.go @@ -416,6 +416,9 @@ func loadAndRunTests(dockerClient *client.Client, volumeName, v string, branchTo if err = runTests(csAPIURL, v); err != nil { return fmt.Errorf("failed to run tests on version %s: %s", v, err) } + // Sleep to let the database sync before returning and destorying the dendrite container + time.Sleep(5 * time.Second) + return nil } From 7e0e9bca340bbdbeffc7595d03ce6891e6cf4570 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 2 Sep 2022 15:15:10 -0700 Subject: [PATCH 39/75] Fix mispelling in comment Signed-off-by: Brian Meek --- cmd/dendrite-upgrade-tests/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dendrite-upgrade-tests/main.go b/cmd/dendrite-upgrade-tests/main.go index ee9faeb25..241451971 100644 --- a/cmd/dendrite-upgrade-tests/main.go +++ b/cmd/dendrite-upgrade-tests/main.go @@ -416,7 +416,7 @@ func loadAndRunTests(dockerClient *client.Client, volumeName, v string, branchTo if err = runTests(csAPIURL, v); err != nil { return fmt.Errorf("failed to run tests on version %s: %s", v, err) } - // Sleep to let the database sync before returning and destorying the dendrite container + // Sleep to let the database sync before returning and destroying the dendrite container time.Sleep(5 * time.Second) return nil From d641fed90b754fb786ea2c499f1b910e4405a22c Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Sat, 3 Sep 2022 09:04:21 -0700 Subject: [PATCH 40/75] Update golint and go versions Signed-off-by: Brian Meek --- .github/workflows/dendrite.yml | 6 +++--- build/scripts/find-lint.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml index f8019b3ea..ea2d076f6 100644 --- a/.github/workflows/dendrite.yml +++ b/.github/workflows/dendrite.yml @@ -70,7 +70,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - name: golangci-lint uses: golangci/golangci-lint-action@v3 @@ -215,7 +215,7 @@ jobs: - name: Setup go uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.19" - uses: actions/cache@v3 with: path: | @@ -240,7 +240,7 @@ jobs: - name: Setup go uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.19" - uses: actions/cache@v3 with: path: | diff --git a/build/scripts/find-lint.sh b/build/scripts/find-lint.sh index 820b8cc46..9c6bb74b4 100755 --- a/build/scripts/find-lint.sh +++ b/build/scripts/find-lint.sh @@ -25,7 +25,7 @@ echo "Installing golangci-lint..." # Make a backup of go.{mod,sum} first cp go.mod go.mod.bak && cp go.sum go.sum.bak -go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0 # Run linting echo "Looking for lint..." From cb184a7b3fdf2682e10bc63c9664b921e66259b4 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Sat, 3 Sep 2022 09:46:44 -0700 Subject: [PATCH 41/75] Update ReadAll to use non-deprecated version Signed-off-by: Brian Meek --- clientapi/auth/login.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clientapi/auth/login.go b/clientapi/auth/login.go index 8047bc08d..fc1f1a2e6 100644 --- a/clientapi/auth/login.go +++ b/clientapi/auth/login.go @@ -18,7 +18,6 @@ import ( "context" "encoding/json" "io" - "io/ioutil" "net/http" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" @@ -42,7 +41,7 @@ func LoginFromJSONReader( userInteractiveAuth *UserInteractive, cfg *config.ClientAPI, ) (*Login, LoginCleanupFunc, *util.JSONResponse) { - reqBytes, err := ioutil.ReadAll(r) + reqBytes, err := io.ReadAll(r) if err != nil { err := &util.JSONResponse{ Code: http.StatusBadRequest, From befd9e6322dee7e0add6da330627386010e0e7b7 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 9 Sep 2022 17:45:01 -0700 Subject: [PATCH 42/75] Fix test checking which clients connected Signed-off-by: Brian Meek --- userapi/storage/tables/stats_table_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index c4aec552c..fb6075846 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -283,6 +283,7 @@ func Test_UserStatistics(t *testing.T) { t.Fatalf("unable to update daily visits stats: %v", err) } } + gotStats, _, err := statsDB.UserStatistics(ctx, nil) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -300,10 +301,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 1, - "web": 1, + "android": 0, + "web": 0, "electron": 0, - "all": 2, + "all": 0, }, AllUsers: 6, NonBridgedUsers: 5, From cda7734660ec40a3dc043b6b0290e1c15e2440fe Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 9 Sep 2022 19:04:37 -0700 Subject: [PATCH 43/75] Fix test checking which clients connected Signed-off-by: Brian Meek --- userapi/storage/tables/stats_table_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index fb6075846..ad79bb2c8 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -301,10 +301,10 @@ func Test_UserStatistics(t *testing.T) { }, R30UsersV2: map[string]int64{ "ios": 0, - "android": 0, - "web": 0, + "android": 1, + "web": 1, "electron": 0, - "all": 0, + "all": 2, }, AllUsers: 6, NonBridgedUsers: 5, From fbfde869140315d7eef592a9dbdbf6d9cd37f582 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:25:32 -0700 Subject: [PATCH 44/75] Pull dendrite fork into the harmony repo (#423) Austin's notification fix Signed-off-by: Brian Meek Signed-off-by: Austin Ellis Co-authored-by: Brian Meek Co-authored-by: texuf Co-authored-by: Tak Wai Wong --- syncapi/streams/stream_notificationdata.go | 8 ++++++ syncapi/types/types.go | 31 ++++++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/syncapi/streams/stream_notificationdata.go b/syncapi/streams/stream_notificationdata.go index 66ee0ded9..8ab4afe63 100644 --- a/syncapi/streams/stream_notificationdata.go +++ b/syncapi/streams/stream_notificationdata.go @@ -62,6 +62,14 @@ func (p *NotificationDataStreamProvider) IncrementalSync( } req.Response.Rooms.Join[roomID] = jr } + // BEGIN ZION CODE but return all notifications regardless of whether they're in a room we're in. + for roomID, counts := range countsByRoom { + unreadNotificationsData := *types.NewUnreadNotificationsResponse() + unreadNotificationsData.HighlightCount = counts.UnreadHighlightCount + unreadNotificationsData.NotificationCount = counts.UnreadNotificationCount + req.Response.Rooms.UnreadNotifications[roomID] = unreadNotificationsData + } + // END ZION CODE return p.LatestPosition(ctx) } diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 57ce7b6ff..75194d3f6 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -341,10 +341,11 @@ type DeviceLists struct { } type RoomsResponse struct { - Join map[string]*JoinResponse `json:"join,omitempty"` - Peek map[string]*JoinResponse `json:"peek,omitempty"` - Invite map[string]*InviteResponse `json:"invite,omitempty"` - Leave map[string]*LeaveResponse `json:"leave,omitempty"` + Join map[string]*JoinResponse `json:"join,omitempty"` + Peek map[string]*JoinResponse `json:"peek,omitempty"` + Invite map[string]*InviteResponse `json:"invite,omitempty"` + Leave map[string]*LeaveResponse `json:"leave,omitempty"` + UnreadNotifications map[string]UnreadNotificationsResponse `json:"unread_notifications,omitempty"` } type ToDeviceResponse struct { @@ -396,6 +397,7 @@ func (r *Response) HasUpdates() bool { len(r.Rooms.Join) > 0 || len(r.Rooms.Leave) > 0 || len(r.Rooms.Peek) > 0 || + len(r.Rooms.UnreadNotifications) > 0 || len(r.ToDevice.Events) > 0 || len(r.DeviceLists.Changed) > 0 || len(r.DeviceLists.Left) > 0) @@ -406,11 +408,13 @@ func NewResponse() *Response { res := Response{} // Pre-initialise the maps. Synapse will return {} even if there are no rooms under a specific section, // so let's do the same thing. Bonus: this means we can't get dreaded 'assignment to entry in nil map' errors. + res.Rooms = &RoomsResponse{ - Join: map[string]*JoinResponse{}, - Peek: map[string]*JoinResponse{}, - Invite: map[string]*InviteResponse{}, - Leave: map[string]*LeaveResponse{}, + Join: map[string]*JoinResponse{}, + Peek: map[string]*JoinResponse{}, + Invite: map[string]*InviteResponse{}, + Leave: map[string]*LeaveResponse{}, + UnreadNotifications: map[string]UnreadNotificationsResponse{}, } // Also pre-intialise empty slices or else we'll insert 'null' instead of '[]' for the value. @@ -432,6 +436,7 @@ func (r *Response) IsEmpty() bool { return len(r.Rooms.Join) == 0 && len(r.Rooms.Invite) == 0 && len(r.Rooms.Leave) == 0 && + len(r.Rooms.UnreadNotifications) == 0 && len(r.AccountData.Events) == 0 && len(r.Presence.Events) == 0 && len(r.ToDevice.Events) == 0 @@ -513,6 +518,16 @@ func NewJoinResponse() *JoinResponse { } } +type UnreadNotificationsResponse struct { + HighlightCount int `json:"highlight_count"` + NotificationCount int `json:"notification_count"` +} + +func NewUnreadNotificationsResponse() *UnreadNotificationsResponse { + res := UnreadNotificationsResponse{} + return &res +} + // InviteResponse represents a /sync response for a room which is under the 'invite' key. type InviteResponse struct { InviteState struct { From 1f2f42494ce216a4ad5c551d84cefb1018b2450f Mon Sep 17 00:00:00 2001 From: texuf Date: Wed, 7 Sep 2022 18:01:08 -0700 Subject: [PATCH 45/75] Fix broken notification incremental sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I was not seeing unread notifications in sync, even if they were written to the db Notifications are in their own stream, but the code was trying to tack them onto the join room stream. If the offsets “happened” to line up, you might get a count here or there, but they would be totally wrong (jump from 1 to 0 to 2, etc) To fix, put them in their own top level object, handle them on the client. Signed-off-by: Austin Ellis --- syncapi/types/types.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 75194d3f6..a8ae18fde 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -442,6 +442,16 @@ func (r *Response) IsEmpty() bool { len(r.ToDevice.Events) == 0 } +type UnreadNotificationsResponse struct { + HighlightCount int `json:"highlight_count"` + NotificationCount int `json:"notification_count"` +} + +func NewUnreadNotificationsResponse() *UnreadNotificationsResponse { + res := UnreadNotificationsResponse{} + return &res +} + type UnreadNotifications struct { HighlightCount int `json:"highlight_count"` NotificationCount int `json:"notification_count"` @@ -518,16 +528,6 @@ func NewJoinResponse() *JoinResponse { } } -type UnreadNotificationsResponse struct { - HighlightCount int `json:"highlight_count"` - NotificationCount int `json:"notification_count"` -} - -func NewUnreadNotificationsResponse() *UnreadNotificationsResponse { - res := UnreadNotificationsResponse{} - return &res -} - // InviteResponse represents a /sync response for a room which is under the 'invite' key. type InviteResponse struct { InviteState struct { From db91fce6f0658c8cc54848c606b10697ce59737d Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Thu, 15 Sep 2022 12:17:41 -0700 Subject: [PATCH 46/75] Add commit hash to version API Signed-off-by: Brian Meek --- clientapi/routing/routing.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 3e7c3c420..ef4f8cafa 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -19,6 +19,8 @@ import ( "net/http" "strings" + "runtime/debug" + "github.com/gorilla/mux" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" @@ -42,6 +44,17 @@ import ( userapi "github.com/matrix-org/dendrite/userapi/api" ) +var commitHash = func() string { + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "vcs.revision" { + return setting.Value + } + } + } + return "" +}() + // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. // @@ -103,6 +116,7 @@ func Setup( JSON: struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` + CommitHash string `json:"commit_hash"` }{Versions: []string{ "r0.0.1", "r0.1.0", @@ -114,7 +128,7 @@ func Setup( "v1.0", "v1.1", "v1.2", - }, UnstableFeatures: unstableFeatures}, + }, UnstableFeatures: unstableFeatures, CommitHash: commitHash}, } }), ).Methods(http.MethodGet, http.MethodOptions) From 4d77bed1f0abdc33891061ac799656f75cb2ff22 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:15:31 -0700 Subject: [PATCH 47/75] Refresh dendrite subtree - pull changes for appservice bug (#457) Co-authored-by: Tak Wai Wong --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 820120c95..cbbf5981a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ _testmain.go # Default configuration file dendrite.yaml +zion-appservice.yaml # Database files *.db From 8351e352871f9403f613b319f750174564b79b28 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Thu, 15 Sep 2022 15:00:36 -0700 Subject: [PATCH 48/75] Add commit hash to routing version API Signed-off-by: Brian Meek --- build/docker/Dockerfile.monolith | 2 +- clientapi/routing/routing.go | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/build/docker/Dockerfile.monolith b/build/docker/Dockerfile.monolith index 3180e9626..0745f696e 100644 --- a/build/docker/Dockerfile.monolith +++ b/build/docker/Dockerfile.monolith @@ -7,7 +7,7 @@ WORKDIR /build COPY . /build RUN mkdir -p bin -RUN go build -trimpath -o bin/ ./cmd/dendrite-monolith-server +RUN go build -ldflags="-X 'routing.CommitHash=`git rev-list -1 HEAD`'" -trimpath -o bin/ ./cmd/dendrite-monolith-server RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/generate-keys diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index ef4f8cafa..b39112154 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -19,8 +19,6 @@ import ( "net/http" "strings" - "runtime/debug" - "github.com/gorilla/mux" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" @@ -44,16 +42,8 @@ import ( userapi "github.com/matrix-org/dendrite/userapi/api" ) -var commitHash = func() string { - if info, ok := debug.ReadBuildInfo(); ok { - for _, setting := range info.Settings { - if setting.Key == "vcs.revision" { - return setting.Value - } - } - } - return "" -}() +// Added in build script Cokerfile.monolith +var CommitHash string // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. @@ -128,7 +118,7 @@ func Setup( "v1.0", "v1.1", "v1.2", - }, UnstableFeatures: unstableFeatures, CommitHash: commitHash}, + }, UnstableFeatures: unstableFeatures, CommitHash: CommitHash}, } }), ).Methods(http.MethodGet, http.MethodOptions) From 4fe6a9e9da71d9d5a5754511312de429c8a1862e Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Thu, 15 Sep 2022 15:12:56 -0700 Subject: [PATCH 49/75] Add commit hash to routing version API, TODO placeholder Signed-off-by: Brian Meek --- build/docker/Dockerfile.monolith | 2 +- clientapi/routing/routing.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/build/docker/Dockerfile.monolith b/build/docker/Dockerfile.monolith index 0745f696e..3180e9626 100644 --- a/build/docker/Dockerfile.monolith +++ b/build/docker/Dockerfile.monolith @@ -7,7 +7,7 @@ WORKDIR /build COPY . /build RUN mkdir -p bin -RUN go build -ldflags="-X 'routing.CommitHash=`git rev-list -1 HEAD`'" -trimpath -o bin/ ./cmd/dendrite-monolith-server +RUN go build -trimpath -o bin/ ./cmd/dendrite-monolith-server RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/generate-keys diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index b39112154..e0f6995c7 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -42,9 +42,6 @@ import ( userapi "github.com/matrix-org/dendrite/userapi/api" ) -// Added in build script Cokerfile.monolith -var CommitHash string - // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. // @@ -106,7 +103,7 @@ func Setup( JSON: struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` - CommitHash string `json:"commit_hash"` + BuildVersion string `json:"build_version"` }{Versions: []string{ "r0.0.1", "r0.1.0", @@ -118,7 +115,7 @@ func Setup( "v1.0", "v1.1", "v1.2", - }, UnstableFeatures: unstableFeatures, CommitHash: CommitHash}, + }, UnstableFeatures: unstableFeatures, BuildVersion: "TODO"}, } }), ).Methods(http.MethodGet, http.MethodOptions) From 93ea0f5864db6dac6d4c147e0d3dd19c550313dd Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 16 Sep 2022 13:28:03 -0700 Subject: [PATCH 50/75] Add commit ReleaseVersion to routing to return to clients in version request Signed-off-by: Brian Meek --- .github/workflows/docker.yml | 2 ++ build/docker/Dockerfile.monolith | 4 +++- clientapi/routing/routing.go | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b4e24e52f..4fa932f92 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -72,6 +72,8 @@ jobs: file: ./build/docker/Dockerfile.monolith platforms: ${{ env.PLATFORMS }} push: true + build-args: | + RELEASE_VERSION=${{ env.RELEASE_VERSION }} tags: | ${{ env.DOCKER_NAMESPACE }}/dendrite-monolith:latest ${{ env.DOCKER_NAMESPACE }}/dendrite-monolith:${{ env.RELEASE_VERSION }} diff --git a/build/docker/Dockerfile.monolith b/build/docker/Dockerfile.monolith index 3180e9626..2d75c8ac1 100644 --- a/build/docker/Dockerfile.monolith +++ b/build/docker/Dockerfile.monolith @@ -2,12 +2,14 @@ FROM docker.io/golang:1.19-alpine AS base RUN apk --update --no-cache add bash build-base +ARG RELEASE_VERSION="Unreleased" + WORKDIR /build COPY . /build RUN mkdir -p bin -RUN go build -trimpath -o bin/ ./cmd/dendrite-monolith-server +RUN go build -trimpath -o bin/ -ldflags="-X routing.ReleaseVersion=$RELEASE_VERSION" ./cmd/dendrite-monolith-server RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/generate-keys diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index e0f6995c7..5855a8ead 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -42,6 +42,8 @@ import ( userapi "github.com/matrix-org/dendrite/userapi/api" ) +var ReleaseVersion string + // Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client // to clients which need to make outbound HTTP requests. // @@ -103,7 +105,7 @@ func Setup( JSON: struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` - BuildVersion string `json:"build_version"` + ReleaseVersion string `json:"release_version"` }{Versions: []string{ "r0.0.1", "r0.1.0", @@ -115,7 +117,7 @@ func Setup( "v1.0", "v1.1", "v1.2", - }, UnstableFeatures: unstableFeatures, BuildVersion: "TODO"}, + }, UnstableFeatures: unstableFeatures, ReleaseVersion: ReleaseVersion}, } }), ).Methods(http.MethodGet, http.MethodOptions) From 68d9300ec0d5f04a7bf2b0f58010c320f53e61f3 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Sat, 17 Sep 2022 14:10:36 -0700 Subject: [PATCH 51/75] After discovering the full path using the go nm tool, properly set the ReleaseVersion in the clientapi router Signed-off-by: Brian Meek --- build/docker/Dockerfile.monolith | 2 +- clientapi/routing/routing.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build/docker/Dockerfile.monolith b/build/docker/Dockerfile.monolith index 2d75c8ac1..b3415171f 100644 --- a/build/docker/Dockerfile.monolith +++ b/build/docker/Dockerfile.monolith @@ -9,7 +9,7 @@ WORKDIR /build COPY . /build RUN mkdir -p bin -RUN go build -trimpath -o bin/ -ldflags="-X routing.ReleaseVersion=$RELEASE_VERSION" ./cmd/dendrite-monolith-server +RUN go build -trimpath -o bin/ -ldflags="-X 'github.com/matrix-org/dendrite/clientapi/routing.ReleaseVersion=$RELEASE_VERSION'" ./cmd/dendrite-monolith-server RUN go build -trimpath -o bin/ ./cmd/create-account RUN go build -trimpath -o bin/ ./cmd/generate-keys diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 5855a8ead..61b5fb438 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -65,6 +65,11 @@ func Setup( extRoomsProvider api.ExtraPublicRoomsProvider, mscCfg *config.MSCs, natsClient *nats.Conn, ) { + + logrus.WithFields(logrus.Fields{ + "ReleaseVersion": ReleaseVersion, + }).Info("Started clientAPI router with ReleaseVersion") + prometheus.MustRegister(amtRegUsers, sendEventDuration) rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) From 1a2a0db1a3fe138dee74b5c5050acefacf050427 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Wed, 21 Sep 2022 15:03:23 -0700 Subject: [PATCH 52/75] Update to the latest go-ethereum Signed-off-by: Brian Meek --- test/publickey_utils.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/publickey_utils.go b/test/publickey_utils.go index 6d3a67186..49f608813 100644 --- a/test/publickey_utils.go +++ b/test/publickey_utils.go @@ -20,6 +20,8 @@ import ( "fmt" "strings" + // This is to silence the conflict about which chainhash is used + _ "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" "github.com/spruceid/siwe-go" From b8342738ac8e40200838bf4c5673d3c80a951efe Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Fri, 23 Sep 2022 14:20:03 -0700 Subject: [PATCH 53/75] Setup foundry to build abi.json files (#509) Signed-off-by: Brian Meek --- .github/workflows/dendrite.yml | 8 +- zion/README.md | 3 + zion/zion.go | 3 + zion/zion_space_manager_localhost.go | 811 +++++++++++++++++++++++++++ 4 files changed, 821 insertions(+), 4 deletions(-) create mode 100644 zion/README.md create mode 100644 zion/zion.go create mode 100644 zion/zion_space_manager_localhost.go diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml index ea2d076f6..4c53a6137 100644 --- a/.github/workflows/dendrite.yml +++ b/.github/workflows/dendrite.yml @@ -25,7 +25,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - uses: actions/cache@v2 with: @@ -102,7 +102,7 @@ jobs: strategy: fail-fast: false matrix: - go: ["1.18", "1.19"] + go: ["1.19"] steps: - uses: actions/checkout@v3 - name: Setup go @@ -132,7 +132,7 @@ jobs: strategy: fail-fast: false matrix: - go: ["1.18", "1.19"] + go: [ "1.19"] goos: ["linux"] goarch: ["amd64", "386"] steps: @@ -166,7 +166,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ["1.18", "1.19"] + go: ["1.19"] goos: ["windows"] goarch: ["amd64"] steps: diff --git a/zion/README.md b/zion/README.md new file mode 100644 index 000000000..08c27f64e --- /dev/null +++ b/zion/README.md @@ -0,0 +1,3 @@ +Additional packaages added for the Zion project, nothing in here should be in the Matrix Dendrite upstream, nor in the herenotthere/dendrite-fork. + +The zion_space_manager_(mainnet|rinkeby|localhost).go files are generated as new versions of the smart contracts are build and deployed. The bindings are in this location so they can be built alongside the dendrite server in the build process. diff --git a/zion/zion.go b/zion/zion.go new file mode 100644 index 000000000..e8db5acfe --- /dev/null +++ b/zion/zion.go @@ -0,0 +1,3 @@ +package zion + +import _ "github.com/ethereum/go-ethereum/accounts/abi/bind" diff --git a/zion/zion_space_manager_localhost.go b/zion/zion_space_manager_localhost.go new file mode 100644 index 000000000..b5c4bc654 --- /dev/null +++ b/zion/zion_space_manager_localhost.go @@ -0,0 +1,811 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package zion + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceData struct { + SpaceName string + NetworkId string +} + +// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceTokenEntitlementData struct { + EntitlementModuleAddress common.Address + TokenAddress common.Address + Quantity *big.Int + Description string + EntitlementTypes []uint8 +} + +// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesEntitlementModuleInfo struct { + EntitlementAddress common.Address + EntitlementName string + EntitlementDescription string +} + +// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesSpaceInfo struct { + SpaceId *big.Int + CreatedAt *big.Int + Name string + Creator common.Address + Owner common.Address +} + +// ZionSpaceManagerLocalhostMetaData contains all meta data concerning the ZionSpaceManagerLocalhost contract. +var ZionSpaceManagerLocalhostMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlements\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType\",\"name\":\"entitlementType\",\"type\":\"uint8\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ZionSpaceManagerLocalhostABI is the input ABI used to generate the binding from. +// Deprecated: Use ZionSpaceManagerLocalhostMetaData.ABI instead. +var ZionSpaceManagerLocalhostABI = ZionSpaceManagerLocalhostMetaData.ABI + +// ZionSpaceManagerLocalhost is an auto generated Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhost struct { + ZionSpaceManagerLocalhostCaller // Read-only binding to the contract + ZionSpaceManagerLocalhostTransactor // Write-only binding to the contract + ZionSpaceManagerLocalhostFilterer // Log filterer for contract events +} + +// ZionSpaceManagerLocalhostCaller is an auto generated read-only Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhostCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerLocalhostTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhostTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerLocalhostFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ZionSpaceManagerLocalhostFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerLocalhostSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ZionSpaceManagerLocalhostSession struct { + Contract *ZionSpaceManagerLocalhost // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ZionSpaceManagerLocalhostCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ZionSpaceManagerLocalhostCallerSession struct { + Contract *ZionSpaceManagerLocalhostCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ZionSpaceManagerLocalhostTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ZionSpaceManagerLocalhostTransactorSession struct { + Contract *ZionSpaceManagerLocalhostTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ZionSpaceManagerLocalhostRaw is an auto generated low-level Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhostRaw struct { + Contract *ZionSpaceManagerLocalhost // Generic contract binding to access the raw methods on +} + +// ZionSpaceManagerLocalhostCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhostCallerRaw struct { + Contract *ZionSpaceManagerLocalhostCaller // Generic read-only contract binding to access the raw methods on +} + +// ZionSpaceManagerLocalhostTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ZionSpaceManagerLocalhostTransactorRaw struct { + Contract *ZionSpaceManagerLocalhostTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewZionSpaceManagerLocalhost creates a new instance of ZionSpaceManagerLocalhost, bound to a specific deployed contract. +func NewZionSpaceManagerLocalhost(address common.Address, backend bind.ContractBackend) (*ZionSpaceManagerLocalhost, error) { + contract, err := bindZionSpaceManagerLocalhost(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ZionSpaceManagerLocalhost{ZionSpaceManagerLocalhostCaller: ZionSpaceManagerLocalhostCaller{contract: contract}, ZionSpaceManagerLocalhostTransactor: ZionSpaceManagerLocalhostTransactor{contract: contract}, ZionSpaceManagerLocalhostFilterer: ZionSpaceManagerLocalhostFilterer{contract: contract}}, nil +} + +// NewZionSpaceManagerLocalhostCaller creates a new read-only instance of ZionSpaceManagerLocalhost, bound to a specific deployed contract. +func NewZionSpaceManagerLocalhostCaller(address common.Address, caller bind.ContractCaller) (*ZionSpaceManagerLocalhostCaller, error) { + contract, err := bindZionSpaceManagerLocalhost(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ZionSpaceManagerLocalhostCaller{contract: contract}, nil +} + +// NewZionSpaceManagerLocalhostTransactor creates a new write-only instance of ZionSpaceManagerLocalhost, bound to a specific deployed contract. +func NewZionSpaceManagerLocalhostTransactor(address common.Address, transactor bind.ContractTransactor) (*ZionSpaceManagerLocalhostTransactor, error) { + contract, err := bindZionSpaceManagerLocalhost(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ZionSpaceManagerLocalhostTransactor{contract: contract}, nil +} + +// NewZionSpaceManagerLocalhostFilterer creates a new log filterer instance of ZionSpaceManagerLocalhost, bound to a specific deployed contract. +func NewZionSpaceManagerLocalhostFilterer(address common.Address, filterer bind.ContractFilterer) (*ZionSpaceManagerLocalhostFilterer, error) { + contract, err := bindZionSpaceManagerLocalhost(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ZionSpaceManagerLocalhostFilterer{contract: contract}, nil +} + +// bindZionSpaceManagerLocalhost binds a generic wrapper to an already deployed contract. +func bindZionSpaceManagerLocalhost(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ZionSpaceManagerLocalhostABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ZionSpaceManagerLocalhost.Contract.ZionSpaceManagerLocalhostCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.ZionSpaceManagerLocalhostTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.ZionSpaceManagerLocalhostTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ZionSpaceManagerLocalhost.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.contract.Transact(opts, method, params...) +} + +// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// +// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementsBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementsBySpaceId", spaceId) + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// +// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementsBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// +// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementsBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementsInfoBySpaceId", spaceId) + + if err != nil { + return *new([]DataTypesEntitlementModuleInfo), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesEntitlementModuleInfo)).(*[]DataTypesEntitlementModuleInfo) + + return out0, err + +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceIdByNetworkId(opts *bind.CallOpts, networkId string) (*big.Int, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceIdByNetworkId", networkId) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceIdByNetworkId(networkId string) (*big.Int, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, networkId) +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceIdByNetworkId(networkId string) (*big.Int, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, networkId) +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (DataTypesSpaceInfo, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceInfoBySpaceId", _spaceId) + + if err != nil { + return *new(DataTypesSpaceInfo), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesSpaceInfo)).(*DataTypesSpaceInfo) + + return out0, err + +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", _spaceId) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaces(opts *bind.CallOpts) ([]DataTypesSpaceInfo, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaces") + + if err != nil { + return *new([]DataTypesSpaceInfo), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesSpaceInfo)).(*[]DataTypesSpaceInfo) + + return out0, err + +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaces() ([]DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaces() ([]DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, entitlementType) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, entitlementType) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, entitlementType) +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitlementModuleWhitelisted", spaceId, entitlementModuleAddress) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, entitlementModuleAddress) +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, entitlementModuleAddress) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) Owner() (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.Owner(&_ZionSpaceManagerLocalhost.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) Owner() (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.Owner(&_ZionSpaceManagerLocalhost.CallOpts) +} + +// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// +// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addEntitlement", spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +} + +// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// +// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +} + +// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// +// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateSpace(opts *bind.TransactOpts, info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createSpace", info) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateSpace(info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateSpace(&_ZionSpaceManagerLocalhost.TransactOpts, info) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateSpace(info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateSpace(&_ZionSpaceManagerLocalhost.TransactOpts, info) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateSpaceWithTokenEntitlement(opts *bind.TransactOpts, info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createSpaceWithTokenEntitlement", info, entitlement) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RegisterDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "registerDefaultEntitlementModule", entitlementModule) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, entitlementTypes, data) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, data) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, data) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RenounceOwnership() (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RenounceOwnership(&_ZionSpaceManagerLocalhost.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RenounceOwnership(&_ZionSpaceManagerLocalhost.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.TransferOwnership(&_ZionSpaceManagerLocalhost.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.TransferOwnership(&_ZionSpaceManagerLocalhost.TransactOpts, newOwner) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "whitelistEntitlementModule", spaceId, entitlementAddress, whitelist) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementAddress, whitelist) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementAddress, whitelist) +} + +// ZionSpaceManagerLocalhostOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ZionSpaceManagerLocalhost contract. +type ZionSpaceManagerLocalhostOwnershipTransferredIterator struct { + Event *ZionSpaceManagerLocalhostOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ZionSpaceManagerLocalhostOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ZionSpaceManagerLocalhostOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ZionSpaceManagerLocalhostOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ZionSpaceManagerLocalhostOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ZionSpaceManagerLocalhostOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ZionSpaceManagerLocalhostOwnershipTransferred represents a OwnershipTransferred event raised by the ZionSpaceManagerLocalhost contract. +type ZionSpaceManagerLocalhostOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ZionSpaceManagerLocalhostOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ZionSpaceManagerLocalhost.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ZionSpaceManagerLocalhostOwnershipTransferredIterator{contract: _ZionSpaceManagerLocalhost.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ZionSpaceManagerLocalhostOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ZionSpaceManagerLocalhost.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ZionSpaceManagerLocalhostOwnershipTransferred) + if err := _ZionSpaceManagerLocalhost.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostFilterer) ParseOwnershipTransferred(log types.Log) (*ZionSpaceManagerLocalhostOwnershipTransferred, error) { + event := new(ZionSpaceManagerLocalhostOwnershipTransferred) + if err := _ZionSpaceManagerLocalhost.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} From c9ec01812187003ce56132b5eb3217c6fbed4d0c Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:46:52 -0700 Subject: [PATCH 54/75] Authorization - config, interface, and default implementation (#33) * add config yaml for enable_auth * zion_space_manager_localhost.go * Placeholders for authorization * rename func and type * re-run go mod tidy Co-authored-by: Tak Wai Wong --- authorization/authorization.go | 35 ++++++++++++++ authorization/default_authorization.go | 23 +++++++++ clientapi/routing/routing.go | 3 ++ setup/config/config_publickey.go | 7 +-- web3/account.go | 65 ++++++++++++++++++++++++++ web3/client.go | 14 ++++++ 6 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 authorization/authorization.go create mode 100644 authorization/default_authorization.go create mode 100644 web3/account.go create mode 100644 web3/client.go diff --git a/authorization/authorization.go b/authorization/authorization.go new file mode 100644 index 000000000..9f7cbcbc1 --- /dev/null +++ b/authorization/authorization.go @@ -0,0 +1,35 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package authorization + +import "github.com/matrix-org/dendrite/setup/config" + +type AuthorizationArgs struct { + RoomId string + UserId string + Permission string +} + +type Authorization interface { + IsAllowed(args AuthorizationArgs) (bool, error) +} + +func NewClientApiAuthorization(cfg *config.ClientAPI) Authorization { + // Load authorization manager for Zion + //if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { + //} + + return &DefaultAuthorization{} +} diff --git a/authorization/default_authorization.go b/authorization/default_authorization.go new file mode 100644 index 000000000..1baba3f86 --- /dev/null +++ b/authorization/default_authorization.go @@ -0,0 +1,23 @@ +// Copyright 2022 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package authorization + +type DefaultAuthorization struct { +} + +func (azm *DefaultAuthorization) IsAllowed(args AuthorizationArgs) (bool, error) { + // Default. No authorization logic. + return true, nil +} diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 61b5fb438..1bd7aee91 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -27,6 +27,7 @@ import ( "github.com/sirupsen/logrus" appserviceAPI "github.com/matrix-org/dendrite/appservice/api" + "github.com/matrix-org/dendrite/authorization" "github.com/matrix-org/dendrite/clientapi/api" "github.com/matrix-org/dendrite/clientapi/auth" clientutil "github.com/matrix-org/dendrite/clientapi/httputil" @@ -74,6 +75,8 @@ func Setup( rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) userInteractiveAuth := auth.NewUserInteractive(userAPI, userAPI, cfg) + authorization := authorization.NewClientApiAuthorization(cfg) + _ = authorization // todo: use this in httputil.MakeAuthAPI unstableFeatures := map[string]bool{ "org.matrix.e2e_cross_signing": true, diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index e214163e2..d834cfefc 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -21,9 +21,10 @@ func (p EthereumAuthParams) GetParams() interface{} { } type EthereumAuthConfig struct { - Enabled bool `yaml:"enabled"` - Version uint `yaml:"version"` - ChainIDs []int `yaml:"chain_ids"` + Enabled bool `yaml:"enabled"` + Version uint `yaml:"version"` + ChainIDs []int `yaml:"chain_ids"` + EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development } type PublicKeyAuthentication struct { diff --git a/web3/account.go b/web3/account.go new file mode 100644 index 000000000..27eda6b5d --- /dev/null +++ b/web3/account.go @@ -0,0 +1,65 @@ +package web3 + +import ( + "context" + "crypto/ecdsa" + "errors" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" +) + +type CreateTransactionSignerArgs struct { + PrivateKey string + ChainId int64 + Client *ethclient.Client + GasValue int64 // in wei + GasLimit int64 // in units +} + +func CreateTransactionSigner(args CreateTransactionSignerArgs) (*bind.TransactOpts, error) { + privateKey, err := crypto.HexToECDSA(args.PrivateKey) + if err != nil { + return nil, err + } + + publicKey := privateKey.Public() + publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) + if !ok { + return nil, errors.New("cannot create public key ECDSA") + } + + fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) + + nonce, err := args.Client.PendingNonceAt(context.Background(), fromAddress) + if err != nil { + return nil, err + } + + gasPrice, err := args.Client.SuggestGasPrice((context.Background())) + if err != nil { + return nil, err + } + + signer, err := bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(args.ChainId)) + if err != nil { + return nil, err + } + + signer.Nonce = big.NewInt(int64(nonce)) + signer.Value = big.NewInt(args.GasValue) + signer.GasLimit = uint64(args.GasLimit) + signer.GasPrice = gasPrice + + fmt.Printf("{ nonce: %d, value: %d, gasLimit: %d, gasPrice: %d }\n", + signer.Nonce, + signer.Value, + signer.GasLimit, + signer.GasPrice, + ) + + return signer, nil +} diff --git a/web3/client.go b/web3/client.go new file mode 100644 index 000000000..9cd643648 --- /dev/null +++ b/web3/client.go @@ -0,0 +1,14 @@ +package web3 + +import ( + "github.com/ethereum/go-ethereum/ethclient" +) + +func GetEthClient(web3ProviderUrl string) (*ethclient.Client, error) { + client, err := ethclient.Dial(web3ProviderUrl) + if err != nil { + return nil, err + } + + return client, nil +} From 04a78694d19858b65641f4aa70b0b9eb5c3d5996 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:11:10 -0700 Subject: [PATCH 55/75] Authorization framework for gating dendrite endpoints (#39) * import new versions of the zion contracts * bootstrap zion authz * define interface for space manager contract * instantiate spacemanager interface * load goerli and localhost * embed json * remove zion interface. Use contracts directly * split user identifiter into address and chain id * isAllowed in routing.go * remove permission.go Co-authored-by: Tak Wai Wong --- .gitignore | 4 +- authorization/authorization.go | 10 - clientapi/authorization/authorization.go | 23 + clientapi/routing/routing.go | 14 +- go.mod | 3 +- web3/account.go | 65 -- web3/client.go | 14 - zion/contract_addresses.go | 22 + zion/contracts/goerli/addresses/council.json | 1 + .../goerli/addresses/space-manager.json | 1 + .../localhost/addresses/council.json | 1 + .../localhost/addresses/space-manager.json | 1 + zion/user_identifier.go | 38 + zion/web3_util.go | 14 + zion/zion_authorization.go | 161 +++ zion/zion_data_types.go | 38 + zion/zion_space_manager_goerli.go | 991 ++++++++++++++++++ zion/zion_space_manager_localhost.go | 338 ++++-- 18 files changed, 1560 insertions(+), 179 deletions(-) create mode 100644 clientapi/authorization/authorization.go delete mode 100644 web3/account.go delete mode 100644 web3/client.go create mode 100644 zion/contract_addresses.go create mode 100644 zion/contracts/goerli/addresses/council.json create mode 100644 zion/contracts/goerli/addresses/space-manager.json create mode 100644 zion/contracts/localhost/addresses/council.json create mode 100644 zion/contracts/localhost/addresses/space-manager.json create mode 100644 zion/user_identifier.go create mode 100644 zion/web3_util.go create mode 100644 zion/zion_authorization.go create mode 100644 zion/zion_data_types.go create mode 100644 zion/zion_space_manager_goerli.go diff --git a/.gitignore b/.gitignore index cbbf5981a..406acce33 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,6 @@ docs/_site media_store/ # Debug -**/__debug_bin \ No newline at end of file +**/__debug_bin + +.env \ No newline at end of file diff --git a/authorization/authorization.go b/authorization/authorization.go index 9f7cbcbc1..deb6469c1 100644 --- a/authorization/authorization.go +++ b/authorization/authorization.go @@ -14,8 +14,6 @@ package authorization -import "github.com/matrix-org/dendrite/setup/config" - type AuthorizationArgs struct { RoomId string UserId string @@ -25,11 +23,3 @@ type AuthorizationArgs struct { type Authorization interface { IsAllowed(args AuthorizationArgs) (bool, error) } - -func NewClientApiAuthorization(cfg *config.ClientAPI) Authorization { - // Load authorization manager for Zion - //if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { - //} - - return &DefaultAuthorization{} -} diff --git a/clientapi/authorization/authorization.go b/clientapi/authorization/authorization.go new file mode 100644 index 000000000..019136d15 --- /dev/null +++ b/clientapi/authorization/authorization.go @@ -0,0 +1,23 @@ +package authorization + +import ( + "github.com/matrix-org/dendrite/authorization" + "github.com/matrix-org/dendrite/setup/config" + "github.com/matrix-org/dendrite/zion" + log "github.com/sirupsen/logrus" +) + +func NewAuthorization(cfg *config.ClientAPI) authorization.Authorization { + // Load authorization manager for Zion + if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { + auth, err := zion.NewZionAuthorization() + + if err != nil { + log.Errorln("Failed to initialise Zion authorization manager. Using default.", err) + } else { + return auth + } + } + + return &authorization.DefaultAuthorization{} +} diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 1bd7aee91..34f8d28cf 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -27,9 +27,10 @@ import ( "github.com/sirupsen/logrus" appserviceAPI "github.com/matrix-org/dendrite/appservice/api" - "github.com/matrix-org/dendrite/authorization" + authz "github.com/matrix-org/dendrite/authorization" "github.com/matrix-org/dendrite/clientapi/api" "github.com/matrix-org/dendrite/clientapi/auth" + clientApiAuthz "github.com/matrix-org/dendrite/clientapi/authorization" clientutil "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/producers" @@ -75,7 +76,7 @@ func Setup( rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) userInteractiveAuth := auth.NewUserInteractive(userAPI, userAPI, cfg) - authorization := authorization.NewClientApiAuthorization(cfg) + authorization := clientApiAuthz.NewAuthorization(cfg) _ = authorization // todo: use this in httputil.MakeAuthAPI unstableFeatures := map[string]bool{ @@ -254,6 +255,15 @@ func Setup( if err != nil { return util.ErrorResponse(err) } + + isAllowed, _ := authorization.IsAllowed(authz.AuthorizationArgs{ + RoomId: vars["roomIDOrAlias"], + UserId: device.UserID, + Permission: "Zion-Join", + }) + + logrus.Debugf("/join/%s isAllowed = %t", vars["roomIDOrAlias"], isAllowed) + return JoinRoomByIDOrAlias( req, device, rsAPI, userAPI, vars["roomIDOrAlias"], ) diff --git a/go.mod b/go.mod index 2f4fdadcd..4e8612f99 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,6 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.13.0 github.com/sirupsen/logrus v1.9.0 - github.com/spruceid/siwe-go v0.2.0 github.com/stretchr/testify v1.8.0 github.com/tidwall/gjson v1.14.3 github.com/tidwall/sjson v1.2.5 @@ -103,6 +102,7 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/h2non/filetype v1.1.3 // indirect + github.com/joho/godotenv v1.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/juju/errors v1.0.0 // indirect github.com/klauspost/compress v1.15.11 // indirect @@ -132,6 +132,7 @@ require ( github.com/relvacode/iso8601 v1.1.0 // indirect github.com/rjeczalik/notify v0.9.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/spruceid/siwe-go v0.2.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect diff --git a/web3/account.go b/web3/account.go deleted file mode 100644 index 27eda6b5d..000000000 --- a/web3/account.go +++ /dev/null @@ -1,65 +0,0 @@ -package web3 - -import ( - "context" - "crypto/ecdsa" - "errors" - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" -) - -type CreateTransactionSignerArgs struct { - PrivateKey string - ChainId int64 - Client *ethclient.Client - GasValue int64 // in wei - GasLimit int64 // in units -} - -func CreateTransactionSigner(args CreateTransactionSignerArgs) (*bind.TransactOpts, error) { - privateKey, err := crypto.HexToECDSA(args.PrivateKey) - if err != nil { - return nil, err - } - - publicKey := privateKey.Public() - publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) - if !ok { - return nil, errors.New("cannot create public key ECDSA") - } - - fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) - - nonce, err := args.Client.PendingNonceAt(context.Background(), fromAddress) - if err != nil { - return nil, err - } - - gasPrice, err := args.Client.SuggestGasPrice((context.Background())) - if err != nil { - return nil, err - } - - signer, err := bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(args.ChainId)) - if err != nil { - return nil, err - } - - signer.Nonce = big.NewInt(int64(nonce)) - signer.Value = big.NewInt(args.GasValue) - signer.GasLimit = uint64(args.GasLimit) - signer.GasPrice = gasPrice - - fmt.Printf("{ nonce: %d, value: %d, gasLimit: %d, gasPrice: %d }\n", - signer.Nonce, - signer.Value, - signer.GasLimit, - signer.GasPrice, - ) - - return signer, nil -} diff --git a/web3/client.go b/web3/client.go deleted file mode 100644 index 9cd643648..000000000 --- a/web3/client.go +++ /dev/null @@ -1,14 +0,0 @@ -package web3 - -import ( - "github.com/ethereum/go-ethereum/ethclient" -) - -func GetEthClient(web3ProviderUrl string) (*ethclient.Client, error) { - client, err := ethclient.Dial(web3ProviderUrl) - if err != nil { - return nil, err - } - - return client, nil -} diff --git a/zion/contract_addresses.go b/zion/contract_addresses.go new file mode 100644 index 000000000..4d50a0a2c --- /dev/null +++ b/zion/contract_addresses.go @@ -0,0 +1,22 @@ +package zion + +import ( + "encoding/json" +) + +type SpaceManagerContractAddresses struct { + Spacemanager string `json:"spaceManager"` + Usergranted string `json:"usergranted"` + Tokengranted string `json:"tokengranted"` +} + +func loadSpaceManagerAddresses(byteValue []byte) (*SpaceManagerContractAddresses, error) { + var addresses SpaceManagerContractAddresses + + err := json.Unmarshal(byteValue, &addresses) + if err != nil { + return nil, err + } + + return &addresses, nil +} diff --git a/zion/contracts/goerli/addresses/council.json b/zion/contracts/goerli/addresses/council.json new file mode 100644 index 000000000..94c032c49 --- /dev/null +++ b/zion/contracts/goerli/addresses/council.json @@ -0,0 +1 @@ +{"councilnft": "0xae599a7c5f2cad3acd773e1931045384d70cb4e6"} \ No newline at end of file diff --git a/zion/contracts/goerli/addresses/space-manager.json b/zion/contracts/goerli/addresses/space-manager.json new file mode 100644 index 000000000..0362bf7d3 --- /dev/null +++ b/zion/contracts/goerli/addresses/space-manager.json @@ -0,0 +1 @@ +{"spacemanager": "0x4b924167de1cd8353a508b31d6607ab571e762ec","usergranted": "0x07f32c3c668e84ac8b91c6c9e4703b4e655f9efc","tokengranted": "0x3de349ff0fd4235f85035d970e88156496208838"} \ No newline at end of file diff --git a/zion/contracts/localhost/addresses/council.json b/zion/contracts/localhost/addresses/council.json new file mode 100644 index 000000000..f77cb6279 --- /dev/null +++ b/zion/contracts/localhost/addresses/council.json @@ -0,0 +1 @@ +{"councilnft": "0x2279b7a0a67db372996a5fab50d91eaa73d2ebe6"} \ No newline at end of file diff --git a/zion/contracts/localhost/addresses/space-manager.json b/zion/contracts/localhost/addresses/space-manager.json new file mode 100644 index 000000000..fc5164f9f --- /dev/null +++ b/zion/contracts/localhost/addresses/space-manager.json @@ -0,0 +1 @@ +{"spacemanager": "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0","usergranted": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","tokengranted": "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9"} \ No newline at end of file diff --git a/zion/user_identifier.go b/zion/user_identifier.go new file mode 100644 index 000000000..718758d3b --- /dev/null +++ b/zion/user_identifier.go @@ -0,0 +1,38 @@ +package zion + +import ( + "regexp" + "strconv" + + "github.com/ethereum/go-ethereum/common" +) + +var regexpMatrixId = regexp.MustCompile(`^@eip155=3a(?P[0-9]+)=3a(?P0x[0-9a-fA-F]+):(?P.*)$`) +var chainIdIndex = regexpMatrixId.SubexpIndex("ChainId") +var localPartIndex = regexpMatrixId.SubexpIndex("LocalPart") + +//var homeServerIndex = regexpMatrixId.SubexpIndex("HomeServer") + +type UserIdentifier struct { + accountAddress common.Address + chainId int +} + +func CreateUserIdentifier(matrixUserId string) UserIdentifier { + matches := regexpMatrixId.FindStringSubmatch(matrixUserId) + accountAddress := "" + chainId := -1 + + if chainIdIndex < len(matches) { + chainId, _ = strconv.Atoi(matches[chainIdIndex]) + } + + if localPartIndex < len(matches) { + accountAddress = matches[localPartIndex] + } + + return UserIdentifier{ + accountAddress: common.HexToAddress(accountAddress), + chainId: chainId, + } +} diff --git a/zion/web3_util.go b/zion/web3_util.go new file mode 100644 index 000000000..8faf0ff21 --- /dev/null +++ b/zion/web3_util.go @@ -0,0 +1,14 @@ +package zion + +import ( + "github.com/ethereum/go-ethereum/ethclient" +) + +func GetEthClient(networkUrl string) (*ethclient.Client, error) { + client, err := ethclient.Dial(networkUrl) + if err != nil { + return nil, err + } + + return client, nil +} diff --git a/zion/zion_authorization.go b/zion/zion_authorization.go new file mode 100644 index 000000000..0e50c46dc --- /dev/null +++ b/zion/zion_authorization.go @@ -0,0 +1,161 @@ +package zion + +import ( + _ "embed" + "math/big" + "os" + + "github.com/ethereum/go-ethereum/common" + "github.com/joho/godotenv" + "github.com/matrix-org/dendrite/authorization" + log "github.com/sirupsen/logrus" +) + +const ( + localhostEndpointUrl = "LOCALHOST_ENDPOINT" // .env + goerliEndpointUrl = "GOERLI_ENDPOINT" // .env +) + +//go:embed contracts/localhost/addresses/space-manager.json +var localhostJson []byte + +//go:embed contracts/goerli/addresses/space-manager.json +var goerliJson []byte + +type ZionAuthorization struct { + spaceManagerLocalhost *ZionSpaceManagerLocalhost + spaceManagerGoerli *ZionSpaceManagerGoerli +} + +func NewZionAuthorization() (authorization.Authorization, error) { + err := godotenv.Load(".env") + if err != nil { + log.Errorln("error loading .env file", err) + } + + var auth ZionAuthorization + + localhost, err := newZionSpaceManagerLocalhost(os.Getenv(localhostEndpointUrl)) + if err != nil { + log.Errorln("error instantiating ZionSpaceManagerLocalhost", err) + } + auth.spaceManagerLocalhost = localhost + + goerli, err := newZionSpaceManagerGoerli(os.Getenv(goerliEndpointUrl)) + if err != nil { + log.Errorln("error instantiating ZionSpaceManagerGoerli", err) + } + auth.spaceManagerGoerli = goerli + + return &auth, nil +} + +func (za *ZionAuthorization) IsAllowed(args authorization.AuthorizationArgs) (bool, error) { + userIdentifier := CreateUserIdentifier(args.UserId) + permission := DataTypesPermission{ + Name: args.Permission, + } + + switch userIdentifier.chainId { + case 1337, 31337: + return za.IsAllowedLocalhost(args.RoomId, userIdentifier.accountAddress, permission) + case 5: + return za.IsAllowedGoerli(args.RoomId, userIdentifier.accountAddress, permission) + default: + log.Errorf("Unsupported chain id: %d\n", userIdentifier.chainId) + } + + return false, nil +} + +func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Address, permission DataTypesPermission) (bool, error) { + if za.spaceManagerLocalhost != nil { + spaceId, err := za.spaceManagerLocalhost.GetSpaceIdByNetworkId(nil, roomId) + if err != nil { + return false, err + } + + isEntitled, err := za.spaceManagerLocalhost.IsEntitled( + nil, + spaceId, + big.NewInt(0), + user, + permission, + ) + + if err != nil { + return false, err + } + + return isEntitled, nil + } + + return false, nil +} + +func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, permission DataTypesPermission) (bool, error) { + if za.spaceManagerGoerli != nil { + spaceId, err := za.spaceManagerGoerli.GetSpaceIdByNetworkId(nil, roomId) + if err != nil { + return false, err + } + + isEntitled, err := za.spaceManagerGoerli.IsEntitled( + nil, + spaceId, + big.NewInt(0), + user, + permission, + ) + + if err != nil { + return false, err + } + + return isEntitled, nil + } + + return false, nil +} + +func newZionSpaceManagerLocalhost(endpointUrl string) (*ZionSpaceManagerLocalhost, error) { + addresses, err := loadSpaceManagerAddresses(localhostJson) + if err != nil { + return nil, err + } + + address := common.HexToAddress(addresses.Spacemanager) + + client, err := GetEthClient(endpointUrl) + if err != nil { + return nil, err + } + + spaceManager, err := NewZionSpaceManagerLocalhost(address, client) + if err != nil { + return nil, err + } + + return spaceManager, nil +} + +func newZionSpaceManagerGoerli(endpointUrl string) (*ZionSpaceManagerGoerli, error) { + addresses, err := loadSpaceManagerAddresses(goerliJson) + if err != nil { + return nil, err + } + + address := common.HexToAddress((addresses.Spacemanager)) + + client, err := GetEthClient(endpointUrl) + if err != nil { + return nil, err + } + + spaceManager, err := NewZionSpaceManagerGoerli(address, client) + if err != nil { + return nil, err + } + + return spaceManager, nil +} diff --git a/zion/zion_data_types.go b/zion/zion_data_types.go new file mode 100644 index 000000000..d01a163d1 --- /dev/null +++ b/zion/zion_data_types.go @@ -0,0 +1,38 @@ +package zion + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" +) + +// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceData struct { + SpaceName string + NetworkId string +} + +// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceTokenEntitlementData struct { + EntitlementModuleAddress common.Address + TokenAddress common.Address + Quantity *big.Int + Description string + EntitlementTypes []uint8 +} + +// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesEntitlementModuleInfo struct { + EntitlementAddress common.Address + EntitlementName string + EntitlementDescription string +} + +// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesSpaceInfo struct { + SpaceId *big.Int + CreatedAt *big.Int + Name string + Creator common.Address + Owner common.Address +} diff --git a/zion/zion_space_manager_goerli.go b/zion/zion_space_manager_goerli.go new file mode 100644 index 000000000..88946a1b5 --- /dev/null +++ b/zion/zion_space_manager_goerli.go @@ -0,0 +1,991 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package zion + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + + +// DataTypesPermission is an auto generated low-level Go binding around an user-defined struct. +type DataTypesPermission struct { + Name string +} + +// DataTypesRole is an auto generated low-level Go binding around an user-defined struct. +type DataTypesRole struct { + RoleId *big.Int + Name string + Color [8]byte + IsTransitive bool +} + +// ZionSpaceManagerGoerliMetaData contains all meta data concerning the ZionSpaceManagerGoerli contract. +var ZionSpaceManagerGoerliMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"zionPermission\",\"type\":\"uint8\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"zionPermissionsMap\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// ZionSpaceManagerGoerliABI is the input ABI used to generate the binding from. +// Deprecated: Use ZionSpaceManagerGoerliMetaData.ABI instead. +var ZionSpaceManagerGoerliABI = ZionSpaceManagerGoerliMetaData.ABI + +// ZionSpaceManagerGoerli is an auto generated Go binding around an Ethereum contract. +type ZionSpaceManagerGoerli struct { + ZionSpaceManagerGoerliCaller // Read-only binding to the contract + ZionSpaceManagerGoerliTransactor // Write-only binding to the contract + ZionSpaceManagerGoerliFilterer // Log filterer for contract events +} + +// ZionSpaceManagerGoerliCaller is an auto generated read-only Go binding around an Ethereum contract. +type ZionSpaceManagerGoerliCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerGoerliTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ZionSpaceManagerGoerliTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerGoerliFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ZionSpaceManagerGoerliFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ZionSpaceManagerGoerliSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ZionSpaceManagerGoerliSession struct { + Contract *ZionSpaceManagerGoerli // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ZionSpaceManagerGoerliCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ZionSpaceManagerGoerliCallerSession struct { + Contract *ZionSpaceManagerGoerliCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ZionSpaceManagerGoerliTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ZionSpaceManagerGoerliTransactorSession struct { + Contract *ZionSpaceManagerGoerliTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ZionSpaceManagerGoerliRaw is an auto generated low-level Go binding around an Ethereum contract. +type ZionSpaceManagerGoerliRaw struct { + Contract *ZionSpaceManagerGoerli // Generic contract binding to access the raw methods on +} + +// ZionSpaceManagerGoerliCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ZionSpaceManagerGoerliCallerRaw struct { + Contract *ZionSpaceManagerGoerliCaller // Generic read-only contract binding to access the raw methods on +} + +// ZionSpaceManagerGoerliTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ZionSpaceManagerGoerliTransactorRaw struct { + Contract *ZionSpaceManagerGoerliTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewZionSpaceManagerGoerli creates a new instance of ZionSpaceManagerGoerli, bound to a specific deployed contract. +func NewZionSpaceManagerGoerli(address common.Address, backend bind.ContractBackend) (*ZionSpaceManagerGoerli, error) { + contract, err := bindZionSpaceManagerGoerli(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ZionSpaceManagerGoerli{ZionSpaceManagerGoerliCaller: ZionSpaceManagerGoerliCaller{contract: contract}, ZionSpaceManagerGoerliTransactor: ZionSpaceManagerGoerliTransactor{contract: contract}, ZionSpaceManagerGoerliFilterer: ZionSpaceManagerGoerliFilterer{contract: contract}}, nil +} + +// NewZionSpaceManagerGoerliCaller creates a new read-only instance of ZionSpaceManagerGoerli, bound to a specific deployed contract. +func NewZionSpaceManagerGoerliCaller(address common.Address, caller bind.ContractCaller) (*ZionSpaceManagerGoerliCaller, error) { + contract, err := bindZionSpaceManagerGoerli(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ZionSpaceManagerGoerliCaller{contract: contract}, nil +} + +// NewZionSpaceManagerGoerliTransactor creates a new write-only instance of ZionSpaceManagerGoerli, bound to a specific deployed contract. +func NewZionSpaceManagerGoerliTransactor(address common.Address, transactor bind.ContractTransactor) (*ZionSpaceManagerGoerliTransactor, error) { + contract, err := bindZionSpaceManagerGoerli(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ZionSpaceManagerGoerliTransactor{contract: contract}, nil +} + +// NewZionSpaceManagerGoerliFilterer creates a new log filterer instance of ZionSpaceManagerGoerli, bound to a specific deployed contract. +func NewZionSpaceManagerGoerliFilterer(address common.Address, filterer bind.ContractFilterer) (*ZionSpaceManagerGoerliFilterer, error) { + contract, err := bindZionSpaceManagerGoerli(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ZionSpaceManagerGoerliFilterer{contract: contract}, nil +} + +// bindZionSpaceManagerGoerli binds a generic wrapper to an already deployed contract. +func bindZionSpaceManagerGoerli(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ZionSpaceManagerGoerliABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ZionSpaceManagerGoerli.Contract.ZionSpaceManagerGoerliCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.ZionSpaceManagerGoerliTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.ZionSpaceManagerGoerliTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ZionSpaceManagerGoerli.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.contract.Transact(opts, method, params...) +} + +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getEntitlementModulesBySpaceId", spaceId) + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getEntitlementsInfoBySpaceId", spaceId) + + if err != nil { + return *new([]DataTypesEntitlementModuleInfo), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesEntitlementModuleInfo)).(*[]DataTypesEntitlementModuleInfo) + + return out0, err + +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// +// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionFromMap(opts *bind.CallOpts, zionPermission uint8) (DataTypesPermission, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getPermissionFromMap", zionPermission) + + if err != nil { + return *new(DataTypesPermission), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesPermission)).(*DataTypesPermission) + + return out0, err + +} + +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, zionPermission) +} + +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, zionPermission) +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getPermissionsBySpaceIdByRoleId", spaceId, roleId) + + if err != nil { + return *new([]DataTypesPermission), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesPermission)).(*[]DataTypesPermission) + + return out0, err + +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getRoleBySpaceIdByRoleId", spaceId, roleId) + + if err != nil { + return *new(DataTypesRole), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesRole)).(*DataTypesRole) + + return out0, err + +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + return _ZionSpaceManagerGoerli.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + return _ZionSpaceManagerGoerli.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesRole, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getRolesBySpaceId", spaceId) + + if err != nil { + return *new([]DataTypesRole), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesRole)).(*[]DataTypesRole) + + return out0, err + +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { + return _ZionSpaceManagerGoerli.Contract.GetRolesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { + return _ZionSpaceManagerGoerli.Contract.GetRolesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceIdByNetworkId(opts *bind.CallOpts, networkId string) (*big.Int, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceIdByNetworkId", networkId) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceIdByNetworkId(networkId string) (*big.Int, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerGoerli.CallOpts, networkId) +} + +// GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. +// +// Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceIdByNetworkId(networkId string) (*big.Int, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerGoerli.CallOpts, networkId) +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (DataTypesSpaceInfo, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceInfoBySpaceId", _spaceId) + + if err != nil { + return *new(DataTypesSpaceInfo), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesSpaceInfo)).(*DataTypesSpaceInfo) + + return out0, err + +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +} + +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// +// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", _spaceId) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +} + +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// +// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaces(opts *bind.CallOpts) ([]DataTypesSpaceInfo, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaces") + + if err != nil { + return *new([]DataTypesSpaceInfo), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesSpaceInfo)).(*[]DataTypesSpaceInfo) + + return out0, err + +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaces() ([]DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaces(&_ZionSpaceManagerGoerli.CallOpts) +} + +// GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. +// +// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaces() ([]DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaces(&_ZionSpaceManagerGoerli.CallOpts) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, permission) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roomId, user, permission) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roomId, user, permission) +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "isEntitlementModuleWhitelisted", spaceId, entitlementModuleAddress) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerGoerli.CallOpts, spaceId, entitlementModuleAddress) +} + +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// +// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerGoerli.CallOpts, spaceId, entitlementModuleAddress) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) Owner() (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.Owner(&_ZionSpaceManagerGoerli.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) Owner() (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.Owner(&_ZionSpaceManagerGoerli.CallOpts) +} + +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. +// +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) ZionPermissionsMap(opts *bind.CallOpts, arg0 uint8) (string, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "zionPermissionsMap", arg0) + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. +// +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) ZionPermissionsMap(arg0 uint8) (string, error) { + return _ZionSpaceManagerGoerli.Contract.ZionPermissionsMap(&_ZionSpaceManagerGoerli.CallOpts, arg0) +} + +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. +// +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) ZionPermissionsMap(arg0 uint8) (string, error) { + return _ZionSpaceManagerGoerli.Contract.ZionPermissionsMap(&_ZionSpaceManagerGoerli.CallOpts, arg0) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "addPermissionToRole", spaceId, roleId, permission) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddPermissionToRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, roleId, permission) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddPermissionToRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, roleId, permission) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateRole(opts *bind.TransactOpts, spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "createRole", spaceId, name, color) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name, color) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name, color) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateSpace(opts *bind.TransactOpts, info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "createSpace", info) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateSpace(info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateSpace(&_ZionSpaceManagerGoerli.TransactOpts, info) +} + +// CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. +// +// Solidity: function createSpace((string,string) info) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateSpace(info DataTypesCreateSpaceData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateSpace(&_ZionSpaceManagerGoerli.TransactOpts, info) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateSpaceWithTokenEntitlement(opts *bind.TransactOpts, info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "createSpaceWithTokenEntitlement", info, entitlement) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, info, entitlement) +} + +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, info, entitlement) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RegisterDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "registerDefaultEntitlementModule", entitlementModule) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) +} + +// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// +// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, roleIds, data) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) +} + +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. +// +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RenounceOwnership() (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RenounceOwnership(&_ZionSpaceManagerGoerli.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RenounceOwnership(&_ZionSpaceManagerGoerli.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.TransferOwnership(&_ZionSpaceManagerGoerli.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.TransferOwnership(&_ZionSpaceManagerGoerli.TransactOpts, newOwner) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "whitelistEntitlementModule", spaceId, entitlementAddress, whitelist) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementAddress, whitelist) +} + +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// +// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementAddress, whitelist) +} + +// ZionSpaceManagerGoerliOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ZionSpaceManagerGoerli contract. +type ZionSpaceManagerGoerliOwnershipTransferredIterator struct { + Event *ZionSpaceManagerGoerliOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ZionSpaceManagerGoerliOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ZionSpaceManagerGoerliOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ZionSpaceManagerGoerliOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ZionSpaceManagerGoerliOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ZionSpaceManagerGoerliOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ZionSpaceManagerGoerliOwnershipTransferred represents a OwnershipTransferred event raised by the ZionSpaceManagerGoerli contract. +type ZionSpaceManagerGoerliOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ZionSpaceManagerGoerliOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ZionSpaceManagerGoerli.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ZionSpaceManagerGoerliOwnershipTransferredIterator{contract: _ZionSpaceManagerGoerli.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ZionSpaceManagerGoerliOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ZionSpaceManagerGoerli.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ZionSpaceManagerGoerliOwnershipTransferred) + if err := _ZionSpaceManagerGoerli.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliFilterer) ParseOwnershipTransferred(log types.Log) (*ZionSpaceManagerGoerliOwnershipTransferred, error) { + event := new(ZionSpaceManagerGoerliOwnershipTransferred) + if err := _ZionSpaceManagerGoerli.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/zion/zion_space_manager_localhost.go b/zion/zion_space_manager_localhost.go index b5c4bc654..1a138a392 100644 --- a/zion/zion_space_manager_localhost.go +++ b/zion/zion_space_manager_localhost.go @@ -28,40 +28,9 @@ var ( _ = event.NewSubscription ) -// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. -type DataTypesCreateSpaceData struct { - SpaceName string - NetworkId string -} - -// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. -type DataTypesCreateSpaceTokenEntitlementData struct { - EntitlementModuleAddress common.Address - TokenAddress common.Address - Quantity *big.Int - Description string - EntitlementTypes []uint8 -} - -// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. -type DataTypesEntitlementModuleInfo struct { - EntitlementAddress common.Address - EntitlementName string - EntitlementDescription string -} - -// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. -type DataTypesSpaceInfo struct { - SpaceId *big.Int - CreatedAt *big.Int - Name string - Creator common.Address - Owner common.Address -} - // ZionSpaceManagerLocalhostMetaData contains all meta data concerning the ZionSpaceManagerLocalhost contract. var ZionSpaceManagerLocalhostMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlements\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType\",\"name\":\"entitlementType\",\"type\":\"uint8\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"enumDataTypes.EntitlementType[]\",\"name\":\"entitlementTypes\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"zionPermission\",\"type\":\"uint8\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"zionPermissionsMap\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // ZionSpaceManagerLocalhostABI is the input ABI used to generate the binding from. @@ -210,12 +179,12 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorRaw) Transa return _ZionSpaceManagerLocalhost.Contract.contract.Transact(opts, method, params...) } -// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. // -// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementsBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementsBySpaceId", spaceId) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementModulesBySpaceId", spaceId) if err != nil { return *new([]common.Address), err @@ -227,18 +196,18 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlemen } -// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. // -// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementsBySpaceId(spaceId *big.Int) ([]common.Address, error) { - return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetEntitlementsBySpaceId is a free data retrieval call binding the contract method 0x35205b43. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. // -// Solidity: function getEntitlementsBySpaceId(uint256 spaceId) view returns(address[] entitlements) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementsBySpaceId(spaceId *big.Int) ([]common.Address, error) { - return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. @@ -272,6 +241,130 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEnt return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionFromMap(opts *bind.CallOpts, zionPermission uint8) (DataTypesPermission, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getPermissionFromMap", zionPermission) + + if err != nil { + return *new(DataTypesPermission), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesPermission)).(*DataTypesPermission) + + return out0, err + +} + +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, zionPermission) +} + +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// +// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, zionPermission) +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getPermissionsBySpaceIdByRoleId", spaceId, roleId) + + if err != nil { + return *new([]DataTypesPermission), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesPermission)).(*[]DataTypesPermission) + + return out0, err + +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) +} + +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// +// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRoleBySpaceIdByRoleId", spaceId, roleId) + + if err != nil { + return *new(DataTypesRole), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesRole)).(*DataTypesRole) + + return out0, err + +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) +} + +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// +// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { + return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesRole, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRolesBySpaceId", spaceId) + + if err != nil { + return *new([]DataTypesRole), err + } + + out0 := *abi.ConvertType(out[0], new([]DataTypesRole)).(*[]DataTypesRole) + + return out0, err + +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { + return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// +// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { + return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + // GetSpaceIdByNetworkId is a free data retrieval call binding the contract method 0x9ddd0d6b. // // Solidity: function getSpaceIdByNetworkId(string networkId) view returns(uint256) @@ -396,12 +489,12 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpa return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) } -// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, entitlementType) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, permission) if err != nil { return *new(bool), err @@ -413,18 +506,18 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(op } -// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { - return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, entitlementType) +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, permission) } -// IsEntitled is a free data retrieval call binding the contract method 0x6f09c765. +// IsEntitled is a free data retrieval call binding the contract method 0x66218999. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, uint8 entitlementType) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, entitlementType uint8) (bool, error) { - return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, entitlementType) +// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, permission) } // IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. @@ -489,25 +582,98 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) Owner( return _ZionSpaceManagerLocalhost.Contract.Owner(&_ZionSpaceManagerLocalhost.CallOpts) } -// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. // -// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addEntitlement", spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) ZionPermissionsMap(opts *bind.CallOpts, arg0 uint8) (string, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "zionPermissionsMap", arg0) + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + } -// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. // -// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.AddEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) ZionPermissionsMap(arg0 uint8) (string, error) { + return _ZionSpaceManagerLocalhost.Contract.ZionPermissionsMap(&_ZionSpaceManagerLocalhost.CallOpts, arg0) } -// AddEntitlement is a paid mutator transaction binding the contract method 0xa382f501. +// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. // -// Solidity: function addEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.AddEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, entitlementData) +// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) ZionPermissionsMap(arg0 uint8) (string, error) { + return _ZionSpaceManagerLocalhost.Contract.ZionPermissionsMap(&_ZionSpaceManagerLocalhost.CallOpts, arg0) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addPermissionToRole", spaceId, roleId, permission) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddPermissionToRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) +} + +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// +// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddPermissionToRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// +// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateRole(opts *bind.TransactOpts, spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createRole", spaceId, name, color) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name, color) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// +// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name, color) } // CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. @@ -531,23 +697,23 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Cr return _ZionSpaceManagerLocalhost.Contract.CreateSpace(&_ZionSpaceManagerLocalhost.TransactOpts, info) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateSpaceWithTokenEntitlement(opts *bind.TransactOpts, info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createSpaceWithTokenEntitlement", info, entitlement) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x11c20f79. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,uint8[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) } @@ -573,25 +739,25 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Re return _ZionSpaceManagerLocalhost.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) } -// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. // -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, entitlementTypes, data) +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, roleIds, data) } -// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. // -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, data) +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) } -// RemoveEntitlement is a paid mutator transaction binding the contract method 0xcd4deca6. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. // -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint8[] entitlementTypes, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, entitlementTypes []uint8, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, entitlementTypes, data) +// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) } // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. From c2e15cfed9cf18c95c2e1156cd2b2fb76e4f95a0 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:41:29 -0700 Subject: [PATCH 56/75] Support environment variables for selected config fields (#40) * deployment time config using env variables * check if ethereum is enabled before replacing the config value with env variable --- setup/config/config.go | 56 ++++++++++++++++++++++++++++++++ setup/config/config_publickey.go | 9 ++--- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/setup/config/config.go b/setup/config/config.go index 150053fd2..65c97704f 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -23,6 +23,7 @@ import ( "os" "path/filepath" "regexp" + "strconv" "strings" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" @@ -291,6 +292,9 @@ func LoadMatrixKey(privateKeyPath string, readFile func(string) ([]byte, error)) // Derive generates data that is derived from various values provided in // the config file. func (config *Dendrite) Derive() error { + // Replace selected config with env variables. + config.replaceWithEnvVariables() + // Determine registrations flows based off config values config.Derived.Registration.Params = make(map[string]interface{}) @@ -576,6 +580,58 @@ func (config *Dendrite) SetupTracing(serviceName string) (closer io.Closer, err ) } +/* +* +Replace selected config with environment variables +*/ + +func (config *Dendrite) replaceWithEnvVariables() { + // Replace selected fields with env variables + + config.Global.ServerName = gomatrixserverlib.ServerName( + replaceWithEnvVariables(string(config.Global.ServerName)), + ) + logrus.Infof("Matrix ServerName=%s\n", config.Global.ServerName) + + config.Global.DatabaseOptions.ConnectionString = DataSource( + replaceWithEnvVariables( + string(config.Global.DatabaseOptions.ConnectionString), + ), + ) + + // If env variable is set, convert the deployment chain IDs from the env + // variable into []int and replace the ChainIDs field. + if config.ClientAPI.PublicKeyAuthentication.Ethereum.Enabled { + deploymentChainIDs := replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.DeploymentChainIDs) + chainIds := strings.Split(deploymentChainIDs, ",") + if len(chainIds) > 0 && chainIds[0] != "" { + var ids []int + for _, id := range chainIds { + id, err := strconv.Atoi(strings.TrimSpace(id)) + if err == nil { + ids = append(ids, id) + } + } + config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainIDs = ids + } + logrus.Infof("Supported Ethereum chain IDs=%d\n", config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainIDs) + } +} + +var regexpEnvVariables = regexp.MustCompile(`\$\{(?P\w+)\}`) +var varIndex = regexpEnvVariables.SubexpIndex("Var") + +func replaceWithEnvVariables(value string) string { + matches := regexpEnvVariables.FindAllStringSubmatch(value, -1) + for _, m := range matches { + if varIndex < len(m) { + envValue := os.Getenv(m[varIndex]) + value = strings.ReplaceAll(value, fmt.Sprintf("${%s}", m[varIndex]), envValue) + } + } + return value +} + // logrusLogger is a small wrapper that implements jaeger.Logger using logrus. type logrusLogger struct { l *logrus.Logger diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index d834cfefc..b0d3e4c2a 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -21,10 +21,11 @@ func (p EthereumAuthParams) GetParams() interface{} { } type EthereumAuthConfig struct { - Enabled bool `yaml:"enabled"` - Version uint `yaml:"version"` - ChainIDs []int `yaml:"chain_ids"` - EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development + Enabled bool `yaml:"enabled"` + Version uint `yaml:"version"` + ChainIDs []int `yaml:"chain_ids"` + DeploymentChainIDs string `yaml:"deployment_chain_ids"` // For deployment: use env variable strings to override the chain IDs. + EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development } type PublicKeyAuthentication struct { From c2d57b8679a72eeb688d990eccfe7e6c3a46aa6b Mon Sep 17 00:00:00 2001 From: John Terzis Date: Fri, 14 Oct 2022 19:20:51 -0700 Subject: [PATCH 57/75] merge latest changes from dendrite main (#42) * merge latest changes from dendrite main * fix go formatting Co-authored-by: John Terzis Co-authored-by: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> --- go.mod | 3 +-- syncapi/types/types.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4e8612f99..2f4fdadcd 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.13.0 github.com/sirupsen/logrus v1.9.0 + github.com/spruceid/siwe-go v0.2.0 github.com/stretchr/testify v1.8.0 github.com/tidwall/gjson v1.14.3 github.com/tidwall/sjson v1.2.5 @@ -102,7 +103,6 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/h2non/filetype v1.1.3 // indirect - github.com/joho/godotenv v1.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/juju/errors v1.0.0 // indirect github.com/klauspost/compress v1.15.11 // indirect @@ -132,7 +132,6 @@ require ( github.com/relvacode/iso8601 v1.1.0 // indirect github.com/rjeczalik/notify v0.9.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect - github.com/spruceid/siwe-go v0.2.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect diff --git a/syncapi/types/types.go b/syncapi/types/types.go index a8ae18fde..f21993da4 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -407,7 +407,7 @@ func (r *Response) HasUpdates() bool { func NewResponse() *Response { res := Response{} // Pre-initialise the maps. Synapse will return {} even if there are no rooms under a specific section, - // so let's do the same thing. Bonus: this means we can't get dreaded 'assignment to entry in nil map' errors. + // so let's do the same thing. Bonus this means we can't get dreaded 'assignment to entry in nil map' errors. res.Rooms = &RoomsResponse{ Join: map[string]*JoinResponse{}, From c5a753d6e25f274cb953d19b9f228e07662237d0 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:52:13 -0700 Subject: [PATCH 58/75] Updated generated GO types for Zion Space Manager contracts (#41) * Refresh generated types * Added Permission enum --- authorization/authorization.go | 2 +- authorization/permissions.go | 59 ++ clientapi/routing/routing.go | 2 +- .../zion_goerli}/zion_space_manager_goerli.go | 508 ++++++++++------- .../localhost/addresses/council.json | 2 +- .../localhost/addresses/space-manager.json | 2 +- .../zion_space_manager_localhost.go | 514 +++++++++++------- zion/zion_authorization.go | 47 +- zion/zion_data_types.go | 38 -- 9 files changed, 690 insertions(+), 484 deletions(-) create mode 100644 authorization/permissions.go rename zion/{ => contracts/goerli/zion_goerli}/zion_space_manager_goerli.go (54%) rename zion/{ => contracts/localhost/zion_localhost}/zion_space_manager_localhost.go (54%) delete mode 100644 zion/zion_data_types.go diff --git a/authorization/authorization.go b/authorization/authorization.go index deb6469c1..f2c671819 100644 --- a/authorization/authorization.go +++ b/authorization/authorization.go @@ -17,7 +17,7 @@ package authorization type AuthorizationArgs struct { RoomId string UserId string - Permission string + Permission Permission } type Authorization interface { diff --git a/authorization/permissions.go b/authorization/permissions.go new file mode 100644 index 000000000..33c478b84 --- /dev/null +++ b/authorization/permissions.go @@ -0,0 +1,59 @@ +package authorization + +type Permission int64 + +const ( + // since iota starts with 0, the first value + // defined here will be the default + PermissionUndefined Permission = iota + PermissionRead + PermissionWrite + PermissionPing + PermissionInvite + PermissionRedact + PermissionBan + PermissionModifyChannelProfile + PermissionModifyChannelPermissions + PermissionPinMessages + PermissionAddRemoveChannels + PermissionModifySpacePermissions + PermissionModifyChannelDefaults + PermissionModifySpaceProfile + PermissionOwner +) + +func (p Permission) String() string { + switch p { + case PermissionUndefined: + return "Undefined" + case PermissionRead: + return "Read" + case PermissionWrite: + return "Write" + case PermissionPing: + return "Ping" + case PermissionInvite: + return "Invite" + case PermissionRedact: + return "Redact" + case PermissionBan: + return "Ban" + case PermissionModifyChannelProfile: + return "ModifyChannelProfile" + case PermissionModifyChannelPermissions: + return "ModifyChannelPermissions" + case PermissionPinMessages: + return "PinMessages" + case PermissionAddRemoveChannels: + return "AddRemoveChannels" + case PermissionModifySpacePermissions: + return "ModifySpacePermissions" + case PermissionModifyChannelDefaults: + return "ModifyChannelDefaults" + case PermissionModifySpaceProfile: + return "ModifySpaceProfile" + case PermissionOwner: + return "Owner" + } + return "Unknown" +} diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 34f8d28cf..79033fa48 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -259,7 +259,7 @@ func Setup( isAllowed, _ := authorization.IsAllowed(authz.AuthorizationArgs{ RoomId: vars["roomIDOrAlias"], UserId: device.UserID, - Permission: "Zion-Join", + Permission: authz.PermissionRead, }) logrus.Debugf("/join/%s isAllowed = %t", vars["roomIDOrAlias"], isAllowed) diff --git a/zion/zion_space_manager_goerli.go b/zion/contracts/goerli/zion_goerli/zion_space_manager_goerli.go similarity index 54% rename from zion/zion_space_manager_goerli.go rename to zion/contracts/goerli/zion_goerli/zion_space_manager_goerli.go index 88946a1b5..6af012c83 100644 --- a/zion/zion_space_manager_goerli.go +++ b/zion/contracts/goerli/zion_goerli/zion_space_manager_goerli.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package zion +package zion_goerli import ( "errors" @@ -28,6 +28,42 @@ var ( _ = event.NewSubscription ) +// DataTypesCreateChannelData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateChannelData struct { + ChannelName string + NetworkId string + SpaceId string + Roles []DataTypesCreateRoleData +} + +// DataTypesCreateRoleData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateRoleData struct { + Name string + Metadata string + Permissions []DataTypesPermission +} + +// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceData struct { + SpaceName string + NetworkId string +} + +// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceTokenEntitlementData struct { + EntitlementModuleAddress common.Address + TokenAddress common.Address + Quantity *big.Int + Description string + Permissions []string +} + +// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesEntitlementModuleInfo struct { + EntitlementAddress common.Address + EntitlementName string + EntitlementDescription string +} // DataTypesPermission is an auto generated low-level Go binding around an user-defined struct. type DataTypesPermission struct { @@ -38,13 +74,21 @@ type DataTypesPermission struct { type DataTypesRole struct { RoleId *big.Int Name string - Color [8]byte IsTransitive bool } +// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesSpaceInfo struct { + SpaceId *big.Int + CreatedAt *big.Int + Name string + Creator common.Address + Owner common.Address +} + // ZionSpaceManagerGoerliMetaData contains all meta data concerning the ZionSpaceManagerGoerli contract. var ZionSpaceManagerGoerliMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"zionPermission\",\"type\":\"uint8\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"zionPermissionsMap\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"defaultPermissionsManagerAddress_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DefaultPermissionsManagerNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SpaceAlreadyRegistered\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"channelName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"permissions\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateRoleData[]\",\"name\":\"roles\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateChannelData\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"createChannel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"}],\"name\":\"getChannelIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"permissionType\",\"type\":\"bytes32\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"setDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"permissionsManager\",\"type\":\"address\"}],\"name\":\"setDefaultPermissionsManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ZionSpaceManagerGoerliABI is the input ABI used to generate the binding from. @@ -193,10 +237,41 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorRaw) Transact(opt return _ZionSpaceManagerGoerli.Contract.contract.Transact(opts, method, params...) } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetChannelIdByNetworkId(opts *bind.CallOpts, spaceId string, channelId string) (*big.Int, error) { + var out []interface{} + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getChannelIdByNetworkId", spaceId, channelId) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. +// +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetChannelIdByNetworkId(spaceId string, channelId string) (*big.Int, error) { + return _ZionSpaceManagerGoerli.Contract.GetChannelIdByNetworkId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, channelId) +} + +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. +// +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetChannelIdByNetworkId(spaceId string, channelId string) (*big.Int, error) { + return _ZionSpaceManagerGoerli.Contract.GetChannelIdByNetworkId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, channelId) +} + +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. +// +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId string) ([]common.Address, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getEntitlementModulesBySpaceId", spaceId) @@ -210,24 +285,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementModul } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementModulesBySpaceId(spaceId string) ([]common.Address, error) { return _ZionSpaceManagerGoerli.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementModulesBySpaceId(spaceId string) ([]common.Address, error) { return _ZionSpaceManagerGoerli.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId string) ([]DataTypesEntitlementModuleInfo, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getEntitlementsInfoBySpaceId", spaceId) @@ -241,26 +316,26 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetEntitlementsInfo } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetEntitlementsInfoBySpaceId(spaceId string) ([]DataTypesEntitlementModuleInfo, error) { return _ZionSpaceManagerGoerli.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetEntitlementsInfoBySpaceId(spaceId string) ([]DataTypesEntitlementModuleInfo, error) { return _ZionSpaceManagerGoerli.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionFromMap(opts *bind.CallOpts, zionPermission uint8) (DataTypesPermission, error) { +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionFromMap(opts *bind.CallOpts, permissionType [32]byte) (DataTypesPermission, error) { var out []interface{} - err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getPermissionFromMap", zionPermission) + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getPermissionFromMap", permissionType) if err != nil { return *new(DataTypesPermission), err @@ -272,24 +347,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionFromMa } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { - return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, zionPermission) +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionFromMap(permissionType [32]byte) (DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, permissionType) } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { - return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, zionPermission) +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionFromMap(permissionType [32]byte) (DataTypesPermission, error) { + return _ZionSpaceManagerGoerli.Contract.GetPermissionFromMap(&_ZionSpaceManagerGoerli.CallOpts, permissionType) } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getPermissionsBySpaceIdByRoleId", spaceId, roleId) @@ -303,24 +378,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetPermissionsBySpa } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetPermissionsBySpaceIdByRoleId(spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { return _ZionSpaceManagerGoerli.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { return _ZionSpaceManagerGoerli.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId string, roleId *big.Int) (DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getRoleBySpaceIdByRoleId", spaceId, roleId) @@ -334,24 +409,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRoleBySpaceIdByR } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerGoerli.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerGoerli.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roleId) } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId string) ([]DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getRolesBySpaceId", spaceId) @@ -365,17 +440,17 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetRolesBySpaceId(o } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerGoerli.Contract.GetRolesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerGoerli.Contract.GetRolesBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } @@ -410,12 +485,12 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceIdBy return _ZionSpaceManagerGoerli.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerGoerli.CallOpts, networkId) } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (DataTypesSpaceInfo, error) { +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, spaceId string) (DataTypesSpaceInfo, error) { var out []interface{} - err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceInfoBySpaceId", _spaceId) + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceInfoBySpaceId", spaceId) if err != nil { return *new(DataTypesSpaceInfo), err @@ -427,26 +502,26 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceInfoBySpace } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { - return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { - return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (common.Address, error) { +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, spaceId string) (common.Address, error) { var out []interface{} - err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", _spaceId) + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", spaceId) if err != nil { return *new(common.Address), err @@ -458,18 +533,18 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) GetSpaceOwnerBySpac } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { - return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) GetSpaceOwnerBySpaceId(spaceId string) (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { - return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, _spaceId) +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaceOwnerBySpaceId(spaceId string) (common.Address, error) { + return _ZionSpaceManagerGoerli.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerGoerli.CallOpts, spaceId) } // GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. @@ -503,12 +578,12 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) GetSpaces() return _ZionSpaceManagerGoerli.Contract.GetSpaces(&_ZionSpaceManagerGoerli.CallOpts) } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitled(opts *bind.CallOpts, spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { var out []interface{} - err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, permission) + err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "isEntitled", spaceId, channelId, user, permission) if err != nil { return *new(bool), err @@ -520,24 +595,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitled(opts *bi } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { - return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roomId, user, permission) +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitled(spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, channelId, user, permission) } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { - return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, roomId, user, permission) +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitled(spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerGoerli.Contract.IsEntitled(&_ZionSpaceManagerGoerli.CallOpts, spaceId, channelId, user, permission) } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId string, entitlementModuleAddress common.Address) (bool, error) { var out []interface{} err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "isEntitlementModuleWhitelisted", spaceId, entitlementModuleAddress) @@ -551,17 +626,17 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) IsEntitlementModule } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) IsEntitlementModuleWhitelisted(spaceId string, entitlementModuleAddress common.Address) (bool, error) { return _ZionSpaceManagerGoerli.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerGoerli.CallOpts, spaceId, entitlementModuleAddress) } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) IsEntitlementModuleWhitelisted(spaceId string, entitlementModuleAddress common.Address) (bool, error) { return _ZionSpaceManagerGoerli.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerGoerli.CallOpts, spaceId, entitlementModuleAddress) } @@ -596,98 +671,88 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) Owner() (com return _ZionSpaceManagerGoerli.Contract.Owner(&_ZionSpaceManagerGoerli.CallOpts) } -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCaller) ZionPermissionsMap(opts *bind.CallOpts, arg0 uint8) (string, error) { - var out []interface{} - err := _ZionSpaceManagerGoerli.contract.Call(opts, &out, "zionPermissionsMap", arg0) - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. -// -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) ZionPermissionsMap(arg0 uint8) (string, error) { - return _ZionSpaceManagerGoerli.Contract.ZionPermissionsMap(&_ZionSpaceManagerGoerli.CallOpts, arg0) -} - -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. -// -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliCallerSession) ZionPermissionsMap(arg0 uint8) (string, error) { - return _ZionSpaceManagerGoerli.Contract.ZionPermissionsMap(&_ZionSpaceManagerGoerli.CallOpts, arg0) -} - -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. -// -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.contract.Transact(opts, "addPermissionToRole", spaceId, roleId, permission) } -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddPermissionToRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.Contract.AddPermissionToRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, roleId, permission) } -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddPermissionToRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.Contract.AddPermissionToRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, roleId, permission) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) AddRoleToEntitlementModule(spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) AddRoleToEntitlementModule(spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateRole(opts *bind.TransactOpts, spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.contract.Transact(opts, "createRole", spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateChannel(opts *bind.TransactOpts, data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "createChannel", data) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateChannel(&_ZionSpaceManagerGoerli.TransactOpts, data) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateChannel(&_ZionSpaceManagerGoerli.TransactOpts, data) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) CreateRole(opts *bind.TransactOpts, spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "createRole", spaceId, name) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) CreateRole(spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateRole(spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.CreateRole(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, name) } // CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. @@ -732,46 +797,25 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) CreateSp return _ZionSpaceManagerGoerli.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, info, entitlement) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RegisterDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.contract.Transact(opts, "registerDefaultEntitlementModule", entitlementModule) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "removeEntitlement", spaceId, channelId, entitlementModuleAddress, roleIds, data) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RemoveEntitlement(spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleIds, data) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, roleIds, data) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) RemoveEntitlement(spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.RemoveEntitlement(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleIds, data) } // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. @@ -795,6 +839,48 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) Renounce return _ZionSpaceManagerGoerli.Contract.RenounceOwnership(&_ZionSpaceManagerGoerli.TransactOpts) } +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) SetDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "setDefaultEntitlementModule", entitlementModule) +} + +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) SetDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.SetDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) +} + +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) SetDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.SetDefaultEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, entitlementModule) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) SetDefaultPermissionsManager(opts *bind.TransactOpts, permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.contract.Transact(opts, "setDefaultPermissionsManager", permissionsManager) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerGoerli.TransactOpts, permissionsManager) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerGoerli.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerGoerli.TransactOpts, permissionsManager) +} + // TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() @@ -816,24 +902,24 @@ func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) Transfer return _ZionSpaceManagerGoerli.Contract.TransferOwnership(&_ZionSpaceManagerGoerli.TransactOpts, newOwner) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.contract.Transact(opts, "whitelistEntitlementModule", spaceId, entitlementAddress, whitelist) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliSession) WhitelistEntitlementModule(spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementAddress, whitelist) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerGoerli *ZionSpaceManagerGoerliTransactorSession) WhitelistEntitlementModule(spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerGoerli.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerGoerli.TransactOpts, spaceId, entitlementAddress, whitelist) } diff --git a/zion/contracts/localhost/addresses/council.json b/zion/contracts/localhost/addresses/council.json index f77cb6279..7ab138d4e 100644 --- a/zion/contracts/localhost/addresses/council.json +++ b/zion/contracts/localhost/addresses/council.json @@ -1 +1 @@ -{"councilnft": "0x2279b7a0a67db372996a5fab50d91eaa73d2ebe6"} \ No newline at end of file +{"councilnft": "0x8a791620dd6260079bf849dc5567adc3f2fdc318"} \ No newline at end of file diff --git a/zion/contracts/localhost/addresses/space-manager.json b/zion/contracts/localhost/addresses/space-manager.json index fc5164f9f..9a76b9758 100644 --- a/zion/contracts/localhost/addresses/space-manager.json +++ b/zion/contracts/localhost/addresses/space-manager.json @@ -1 +1 @@ -{"spacemanager": "0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0","usergranted": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","tokengranted": "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9"} \ No newline at end of file +{"spacemanager": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","usergranted": "0xdc64a140aa3e981100a9beca4e685f962f0cf6c9","tokengranted": "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707"} \ No newline at end of file diff --git a/zion/zion_space_manager_localhost.go b/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go similarity index 54% rename from zion/zion_space_manager_localhost.go rename to zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go index 1a138a392..2d3d7f385 100644 --- a/zion/zion_space_manager_localhost.go +++ b/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package zion +package zion_localhost import ( "errors" @@ -28,9 +28,67 @@ var ( _ = event.NewSubscription ) +// DataTypesCreateChannelData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateChannelData struct { + ChannelName string + NetworkId string + SpaceId string + Roles []DataTypesCreateRoleData +} + +// DataTypesCreateRoleData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateRoleData struct { + Name string + Metadata string + Permissions []DataTypesPermission +} + +// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceData struct { + SpaceName string + NetworkId string +} + +// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. +type DataTypesCreateSpaceTokenEntitlementData struct { + EntitlementModuleAddress common.Address + TokenAddress common.Address + Quantity *big.Int + Description string + Permissions []string +} + +// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesEntitlementModuleInfo struct { + EntitlementAddress common.Address + EntitlementName string + EntitlementDescription string +} + +// DataTypesPermission is an auto generated low-level Go binding around an user-defined struct. +type DataTypesPermission struct { + Name string +} + +// DataTypesRole is an auto generated low-level Go binding around an user-defined struct. +type DataTypesRole struct { + RoleId *big.Int + Name string + IsTransitive bool +} + +// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesSpaceInfo struct { + SpaceId *big.Int + CreatedAt *big.Int + Name string + Creator common.Address + Owner common.Address +} + // ZionSpaceManagerLocalhostMetaData contains all meta data concerning the ZionSpaceManagerLocalhost contract. var ZionSpaceManagerLocalhostMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"zionPermission\",\"type\":\"uint8\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bytes8\",\"name\":\"color\",\"type\":\"bytes8\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_spaceId\",\"type\":\"uint256\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"roomId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"registerDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enumISpaceManager.ZionPermission\",\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"zionPermissionsMap\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"defaultPermissionsManagerAddress_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DefaultPermissionsManagerNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SpaceAlreadyRegistered\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"channelName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"permissions\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateRoleData[]\",\"name\":\"roles\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateChannelData\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"createChannel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"}],\"name\":\"getChannelIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"permissionType\",\"type\":\"bytes32\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"setDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"permissionsManager\",\"type\":\"address\"}],\"name\":\"setDefaultPermissionsManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ZionSpaceManagerLocalhostABI is the input ABI used to generate the binding from. @@ -179,10 +237,41 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorRaw) Transa return _ZionSpaceManagerLocalhost.Contract.contract.Transact(opts, method, params...) } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetChannelIdByNetworkId(opts *bind.CallOpts, spaceId string, channelId string) (*big.Int, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getChannelIdByNetworkId", spaceId, channelId) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. +// +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetChannelIdByNetworkId(spaceId string, channelId string) (*big.Int, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId) +} + +// GetChannelIdByNetworkId is a free data retrieval call binding the contract method 0x3e66eae3. +// +// Solidity: function getChannelIdByNetworkId(string spaceId, string channelId) view returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetChannelIdByNetworkId(spaceId string, channelId string) (*big.Int, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId) +} + +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. +// +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementModulesBySpaceId(opts *bind.CallOpts, spaceId string) ([]common.Address, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementModulesBySpaceId", spaceId) @@ -196,24 +285,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlemen } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementModulesBySpaceId(spaceId string) ([]common.Address, error) { return _ZionSpaceManagerLocalhost.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x41ab8a9a. +// GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. // -// Solidity: function getEntitlementModulesBySpaceId(uint256 spaceId) view returns(address[] entitlementModules) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementModulesBySpaceId(spaceId *big.Int) ([]common.Address, error) { +// Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementModulesBySpaceId(spaceId string) ([]common.Address, error) { return _ZionSpaceManagerLocalhost.Contract.GetEntitlementModulesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlementsInfoBySpaceId(opts *bind.CallOpts, spaceId string) ([]DataTypesEntitlementModuleInfo, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getEntitlementsInfoBySpaceId", spaceId) @@ -227,26 +316,26 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetEntitlemen } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetEntitlementsInfoBySpaceId(spaceId string) ([]DataTypesEntitlementModuleInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x8a99bd88. +// GetEntitlementsInfoBySpaceId is a free data retrieval call binding the contract method 0x3519167c. // -// Solidity: function getEntitlementsInfoBySpaceId(uint256 spaceId) view returns((address,string,string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementsInfoBySpaceId(spaceId *big.Int) ([]DataTypesEntitlementModuleInfo, error) { +// Solidity: function getEntitlementsInfoBySpaceId(string spaceId) view returns((address,string,string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetEntitlementsInfoBySpaceId(spaceId string) ([]DataTypesEntitlementModuleInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetEntitlementsInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionFromMap(opts *bind.CallOpts, zionPermission uint8) (DataTypesPermission, error) { +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionFromMap(opts *bind.CallOpts, permissionType [32]byte) (DataTypesPermission, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getPermissionFromMap", zionPermission) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getPermissionFromMap", permissionType) if err != nil { return *new(DataTypesPermission), err @@ -258,24 +347,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermission } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { - return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, zionPermission) +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionFromMap(permissionType [32]byte) (DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, permissionType) } -// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9152efda. +// GetPermissionFromMap is a free data retrieval call binding the contract method 0x9ea4d532. // -// Solidity: function getPermissionFromMap(uint8 zionPermission) view returns((string) permission) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionFromMap(zionPermission uint8) (DataTypesPermission, error) { - return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, zionPermission) +// Solidity: function getPermissionFromMap(bytes32 permissionType) view returns((string) permission) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionFromMap(permissionType [32]byte) (DataTypesPermission, error) { + return _ZionSpaceManagerLocalhost.Contract.GetPermissionFromMap(&_ZionSpaceManagerLocalhost.CallOpts, permissionType) } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermissionsBySpaceIdByRoleId(opts *bind.CallOpts, spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getPermissionsBySpaceIdByRoleId", spaceId, roleId) @@ -289,24 +378,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetPermission } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetPermissionsBySpaceIdByRoleId(spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { return _ZionSpaceManagerLocalhost.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } -// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xa7d325fc. +// GetPermissionsBySpaceIdByRoleId is a free data retrieval call binding the contract method 0x7074047c. // -// Solidity: function getPermissionsBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((string)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) ([]DataTypesPermission, error) { +// Solidity: function getPermissionsBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((string)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPermissionsBySpaceIdByRoleId(spaceId string, roleId *big.Int) ([]DataTypesPermission, error) { return _ZionSpaceManagerLocalhost.Contract.GetPermissionsBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId string, roleId *big.Int) (DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRoleBySpaceIdByRoleId", spaceId, roleId) @@ -320,24 +409,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpac } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } -// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xd9af4ecf. +// GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(uint256 spaceId, uint256 roleId) view returns((uint256,string,bytes8,bool)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRoleBySpaceIdByRoleId(spaceId *big.Int, roleId *big.Int) (DataTypesRole, error) { +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId string) ([]DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRolesBySpaceId", spaceId) @@ -351,17 +440,17 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpa } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x52f1bea2. +// GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(uint256 spaceId) view returns((uint256,string,bytes8,bool)[]) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRolesBySpaceId(spaceId *big.Int) ([]DataTypesRole, error) { +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } @@ -396,12 +485,12 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpa return _ZionSpaceManagerLocalhost.Contract.GetSpaceIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, networkId) } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (DataTypesSpaceInfo, error) { +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, spaceId string) (DataTypesSpaceInfo, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceInfoBySpaceId", _spaceId) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceInfoBySpaceId", spaceId) if err != nil { return *new(DataTypesSpaceInfo), err @@ -413,24 +502,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoB } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { - return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x3439f03b. +// GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(uint256 _spaceId) view returns((uint256,uint256,string,address,address)) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceInfoBySpaceId(_spaceId *big.Int) (DataTypesSpaceInfo, error) { - return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId *big.Int) (common.Address, error) { +// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId string) (common.Address, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", _spaceId) @@ -444,17 +533,17 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwner } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { +// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceOwnerBySpaceId(_spaceId string) (common.Address, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) } -// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x7dde72d8. +// GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(uint256 _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceOwnerBySpaceId(_spaceId *big.Int) (common.Address, error) { +// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceOwnerBySpaceId(_spaceId string) (common.Address, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) } @@ -489,12 +578,12 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpa return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(opts *bind.CallOpts, spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(opts *bind.CallOpts, spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitled", spaceId, roomId, user, permission) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitled", spaceId, channelId, user, permission) if err != nil { return *new(bool), err @@ -506,24 +595,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitled(op } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { - return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, permission) +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitled(spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId, user, permission) } -// IsEntitled is a free data retrieval call binding the contract method 0x66218999. +// IsEntitled is a free data retrieval call binding the contract method 0xbf77b663. // -// Solidity: function isEntitled(uint256 spaceId, uint256 roomId, address user, (string) permission) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitled(spaceId *big.Int, roomId *big.Int, user common.Address, permission DataTypesPermission) (bool, error) { - return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roomId, user, permission) +// Solidity: function isEntitled(string spaceId, string channelId, address user, (string) permission) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitled(spaceId string, channelId string, user common.Address, permission DataTypesPermission) (bool, error) { + return _ZionSpaceManagerLocalhost.Contract.IsEntitled(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId, user, permission) } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitlementModuleWhitelisted(opts *bind.CallOpts, spaceId string, entitlementModuleAddress common.Address) (bool, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "isEntitlementModuleWhitelisted", spaceId, entitlementModuleAddress) @@ -537,17 +626,17 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) IsEntitlement } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) IsEntitlementModuleWhitelisted(spaceId string, entitlementModuleAddress common.Address) (bool, error) { return _ZionSpaceManagerLocalhost.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, entitlementModuleAddress) } -// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0xb010ac47. +// IsEntitlementModuleWhitelisted is a free data retrieval call binding the contract method 0x4196d1ff. // -// Solidity: function isEntitlementModuleWhitelisted(uint256 spaceId, address entitlementModuleAddress) view returns(bool) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitlementModuleWhitelisted(spaceId *big.Int, entitlementModuleAddress common.Address) (bool, error) { +// Solidity: function isEntitlementModuleWhitelisted(string spaceId, address entitlementModuleAddress) view returns(bool) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) IsEntitlementModuleWhitelisted(spaceId string, entitlementModuleAddress common.Address) (bool, error) { return _ZionSpaceManagerLocalhost.Contract.IsEntitlementModuleWhitelisted(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, entitlementModuleAddress) } @@ -582,98 +671,88 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) Owner( return _ZionSpaceManagerLocalhost.Contract.Owner(&_ZionSpaceManagerLocalhost.CallOpts) } -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) ZionPermissionsMap(opts *bind.CallOpts, arg0 uint8) (string, error) { - var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "zionPermissionsMap", arg0) - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. -// -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) ZionPermissionsMap(arg0 uint8) (string, error) { - return _ZionSpaceManagerLocalhost.Contract.ZionPermissionsMap(&_ZionSpaceManagerLocalhost.CallOpts, arg0) -} - -// ZionPermissionsMap is a free data retrieval call binding the contract method 0xc870e04c. -// -// Solidity: function zionPermissionsMap(uint8 ) view returns(string name) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) ZionPermissionsMap(arg0 uint8) (string, error) { - return _ZionSpaceManagerLocalhost.Contract.ZionPermissionsMap(&_ZionSpaceManagerLocalhost.CallOpts, arg0) -} - -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. -// -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddPermissionToRole(opts *bind.TransactOpts, spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addPermissionToRole", spaceId, roleId, permission) } -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddPermissionToRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.AddPermissionToRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) } -// AddPermissionToRole is a paid mutator transaction binding the contract method 0x3368c918. +// AddPermissionToRole is a paid mutator transaction binding the contract method 0x7d9a0230. // -// Solidity: function addPermissionToRole(uint256 spaceId, uint256 roleId, (string) permission) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddPermissionToRole(spaceId *big.Int, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { +// Solidity: function addPermissionToRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddPermissionToRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.AddPermissionToRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) AddRoleToEntitlementModule(opts *bind.TransactOpts, spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "addRoleToEntitlementModule", spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) AddRoleToEntitlementModule(spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xa7972473. +// AddRoleToEntitlementModule is a paid mutator transaction binding the contract method 0xbbd7358a. // -// Solidity: function addRoleToEntitlementModule(uint256 spaceId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddRoleToEntitlementModule(spaceId *big.Int, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleId, entitlementData) +// Solidity: function addRoleToEntitlementModule(string spaceId, string channelId, address entitlementModuleAddress, uint256 roleId, bytes entitlementData) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) AddRoleToEntitlementModule(spaceId string, channelId string, entitlementModuleAddress common.Address, roleId *big.Int, entitlementData []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateRole(opts *bind.TransactOpts, spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createRole", spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateChannel(opts *bind.TransactOpts, data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createChannel", data) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data) } -// CreateRole is a paid mutator transaction binding the contract method 0xa3f13435. +// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. // -// Solidity: function createRole(uint256 spaceId, string name, bytes8 color) returns(uint256) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateRole(spaceId *big.Int, name string, color [8]byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name, color) +// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateRole(opts *bind.TransactOpts, spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createRole", spaceId, name) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateRole(spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name) +} + +// CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. +// +// Solidity: function createRole(string spaceId, string name) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateRole(spaceId string, name string) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, name) } // CreateSpace is a paid mutator transaction binding the contract method 0x50b88cf7. @@ -718,46 +797,25 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Cr return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RegisterDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "registerDefaultEntitlementModule", entitlementModule) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeEntitlement", spaceId, channelId, entitlementModuleAddress, roleIds, data) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveEntitlement(spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleIds, data) } -// RegisterDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xdbe83cbf. +// RemoveEntitlement is a paid mutator transaction binding the contract method 0xa3a39cb9. // -// Solidity: function registerDefaultEntitlementModule(address entitlementModule) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RegisterDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RegisterDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveEntitlement(opts *bind.TransactOpts, spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeEntitlement", spaceId, entitlementModuleAddress, roleIds, data) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) -} - -// RemoveEntitlement is a paid mutator transaction binding the contract method 0x1e984060. -// -// Solidity: function removeEntitlement(uint256 spaceId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveEntitlement(spaceId *big.Int, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementModuleAddress, roleIds, data) +// Solidity: function removeEntitlement(string spaceId, string channelId, address entitlementModuleAddress, uint256[] roleIds, bytes data) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveEntitlement(spaceId string, channelId string, entitlementModuleAddress common.Address, roleIds []*big.Int, data []byte) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleIds, data) } // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. @@ -781,6 +839,48 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Re return _ZionSpaceManagerLocalhost.Contract.RenounceOwnership(&_ZionSpaceManagerLocalhost.TransactOpts) } +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) SetDefaultEntitlementModule(opts *bind.TransactOpts, entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "setDefaultEntitlementModule", entitlementModule) +} + +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) SetDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) +} + +// SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. +// +// Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) SetDefaultEntitlementModule(entitlementModule common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) SetDefaultPermissionsManager(opts *bind.TransactOpts, permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "setDefaultPermissionsManager", permissionsManager) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerLocalhost.TransactOpts, permissionsManager) +} + +// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// +// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerLocalhost.TransactOpts, permissionsManager) +} + // TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() @@ -802,24 +902,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Tr return _ZionSpaceManagerLocalhost.Contract.TransferOwnership(&_ZionSpaceManagerLocalhost.TransactOpts, newOwner) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) WhitelistEntitlementModule(opts *bind.TransactOpts, spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.contract.Transact(opts, "whitelistEntitlementModule", spaceId, entitlementAddress, whitelist) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) WhitelistEntitlementModule(spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementAddress, whitelist) } -// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0x28dcb202. +// WhitelistEntitlementModule is a paid mutator transaction binding the contract method 0xe798ff3f. // -// Solidity: function whitelistEntitlementModule(uint256 spaceId, address entitlementAddress, bool whitelist) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) WhitelistEntitlementModule(spaceId *big.Int, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { +// Solidity: function whitelistEntitlementModule(string spaceId, address entitlementAddress, bool whitelist) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) WhitelistEntitlementModule(spaceId string, entitlementAddress common.Address, whitelist bool) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.WhitelistEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, entitlementAddress, whitelist) } diff --git a/zion/zion_authorization.go b/zion/zion_authorization.go index 0e50c46dc..c363759c8 100644 --- a/zion/zion_authorization.go +++ b/zion/zion_authorization.go @@ -2,12 +2,13 @@ package zion import ( _ "embed" - "math/big" "os" "github.com/ethereum/go-ethereum/common" "github.com/joho/godotenv" "github.com/matrix-org/dendrite/authorization" + zion_goerli "github.com/matrix-org/dendrite/zion/contracts/goerli/zion_goerli" + zion_localhost "github.com/matrix-org/dendrite/zion/contracts/localhost/zion_localhost" log "github.com/sirupsen/logrus" ) @@ -23,8 +24,8 @@ var localhostJson []byte var goerliJson []byte type ZionAuthorization struct { - spaceManagerLocalhost *ZionSpaceManagerLocalhost - spaceManagerGoerli *ZionSpaceManagerGoerli + spaceManagerLocalhost *zion_localhost.ZionSpaceManagerLocalhost + spaceManagerGoerli *zion_goerli.ZionSpaceManagerGoerli } func NewZionAuthorization() (authorization.Authorization, error) { @@ -52,15 +53,12 @@ func NewZionAuthorization() (authorization.Authorization, error) { func (za *ZionAuthorization) IsAllowed(args authorization.AuthorizationArgs) (bool, error) { userIdentifier := CreateUserIdentifier(args.UserId) - permission := DataTypesPermission{ - Name: args.Permission, - } switch userIdentifier.chainId { case 1337, 31337: - return za.IsAllowedLocalhost(args.RoomId, userIdentifier.accountAddress, permission) + return za.IsAllowedLocalhost(args.RoomId, userIdentifier.accountAddress, args.Permission) case 5: - return za.IsAllowedGoerli(args.RoomId, userIdentifier.accountAddress, permission) + return za.IsAllowedGoerli(args.RoomId, userIdentifier.accountAddress, args.Permission) default: log.Errorf("Unsupported chain id: %d\n", userIdentifier.chainId) } @@ -68,17 +66,19 @@ func (za *ZionAuthorization) IsAllowed(args authorization.AuthorizationArgs) (bo return false, nil } -func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Address, permission DataTypesPermission) (bool, error) { +func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Address, permission authorization.Permission) (bool, error) { if za.spaceManagerLocalhost != nil { - spaceId, err := za.spaceManagerLocalhost.GetSpaceIdByNetworkId(nil, roomId) - if err != nil { - return false, err + permission := zion_localhost.DataTypesPermission{ + Name: permission.String(), } + addr := user.Hex() + _ = addr + isEntitled, err := za.spaceManagerLocalhost.IsEntitled( nil, - spaceId, - big.NewInt(0), + roomId, + "", // todo: Support channelId user, permission, ) @@ -93,17 +93,16 @@ func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Addre return false, nil } -func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, permission DataTypesPermission) (bool, error) { +func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, permission authorization.Permission) (bool, error) { if za.spaceManagerGoerli != nil { - spaceId, err := za.spaceManagerGoerli.GetSpaceIdByNetworkId(nil, roomId) - if err != nil { - return false, err + permission := zion_goerli.DataTypesPermission{ + Name: permission.String(), } isEntitled, err := za.spaceManagerGoerli.IsEntitled( nil, - spaceId, - big.NewInt(0), + roomId, + "", // todo: support channelId user, permission, ) @@ -118,7 +117,7 @@ func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, return false, nil } -func newZionSpaceManagerLocalhost(endpointUrl string) (*ZionSpaceManagerLocalhost, error) { +func newZionSpaceManagerLocalhost(endpointUrl string) (*zion_localhost.ZionSpaceManagerLocalhost, error) { addresses, err := loadSpaceManagerAddresses(localhostJson) if err != nil { return nil, err @@ -131,7 +130,7 @@ func newZionSpaceManagerLocalhost(endpointUrl string) (*ZionSpaceManagerLocalhos return nil, err } - spaceManager, err := NewZionSpaceManagerLocalhost(address, client) + spaceManager, err := zion_localhost.NewZionSpaceManagerLocalhost(address, client) if err != nil { return nil, err } @@ -139,7 +138,7 @@ func newZionSpaceManagerLocalhost(endpointUrl string) (*ZionSpaceManagerLocalhos return spaceManager, nil } -func newZionSpaceManagerGoerli(endpointUrl string) (*ZionSpaceManagerGoerli, error) { +func newZionSpaceManagerGoerli(endpointUrl string) (*zion_goerli.ZionSpaceManagerGoerli, error) { addresses, err := loadSpaceManagerAddresses(goerliJson) if err != nil { return nil, err @@ -152,7 +151,7 @@ func newZionSpaceManagerGoerli(endpointUrl string) (*ZionSpaceManagerGoerli, err return nil, err } - spaceManager, err := NewZionSpaceManagerGoerli(address, client) + spaceManager, err := zion_goerli.NewZionSpaceManagerGoerli(address, client) if err != nil { return nil, err } diff --git a/zion/zion_data_types.go b/zion/zion_data_types.go deleted file mode 100644 index d01a163d1..000000000 --- a/zion/zion_data_types.go +++ /dev/null @@ -1,38 +0,0 @@ -package zion - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" -) - -// DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. -type DataTypesCreateSpaceData struct { - SpaceName string - NetworkId string -} - -// DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. -type DataTypesCreateSpaceTokenEntitlementData struct { - EntitlementModuleAddress common.Address - TokenAddress common.Address - Quantity *big.Int - Description string - EntitlementTypes []uint8 -} - -// DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. -type DataTypesEntitlementModuleInfo struct { - EntitlementAddress common.Address - EntitlementName string - EntitlementDescription string -} - -// DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. -type DataTypesSpaceInfo struct { - SpaceId *big.Int - CreatedAt *big.Int - Name string - Creator common.Address - Owner common.Address -} From 18db428c239ee0115b3d33c0a50fc11407b7d280 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 17 Oct 2022 14:08:04 -0700 Subject: [PATCH 59/75] Figure out space vs channel from roomid (#43) * pass in roomserver API so that we have access to the db * interface to get db info for spaceid and channelid * determine space or channel by querying the room db * Add authorization check to the JOIN endpoint * fix lint errors --- clientapi/authorization/authorization.go | 5 +- clientapi/routing/routing.go | 11 ++- zion/README.md | 2 + zion/store.go | 88 ++++++++++++++++++++++++ zion/store_types.go | 42 +++++++++++ zion/user_identifier.go | 25 ++++--- zion/zion_authorization.go | 45 ++++++++---- 7 files changed, 190 insertions(+), 28 deletions(-) create mode 100644 zion/store.go create mode 100644 zion/store_types.go diff --git a/clientapi/authorization/authorization.go b/clientapi/authorization/authorization.go index 019136d15..f37f4becd 100644 --- a/clientapi/authorization/authorization.go +++ b/clientapi/authorization/authorization.go @@ -2,15 +2,16 @@ package authorization import ( "github.com/matrix-org/dendrite/authorization" + roomserver "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/zion" log "github.com/sirupsen/logrus" ) -func NewAuthorization(cfg *config.ClientAPI) authorization.Authorization { +func NewAuthorization(cfg *config.ClientAPI, rsAPI roomserver.ClientRoomserverAPI) authorization.Authorization { // Load authorization manager for Zion if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { - auth, err := zion.NewZionAuthorization() + auth, err := zion.NewZionAuthorization(rsAPI) if err != nil { log.Errorln("Failed to initialise Zion authorization manager. Using default.", err) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 79033fa48..c640d7765 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -76,8 +76,7 @@ func Setup( rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) userInteractiveAuth := auth.NewUserInteractive(userAPI, userAPI, cfg) - authorization := clientApiAuthz.NewAuthorization(cfg) - _ = authorization // todo: use this in httputil.MakeAuthAPI + authorization := clientApiAuthz.NewAuthorization(cfg, rsAPI) unstableFeatures := map[string]bool{ "org.matrix.e2e_cross_signing": true, @@ -262,7 +261,12 @@ func Setup( Permission: authz.PermissionRead, }) - logrus.Debugf("/join/%s isAllowed = %t", vars["roomIDOrAlias"], isAllowed) + if !isAllowed { + return util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.Forbidden(""), + } + } return JoinRoomByIDOrAlias( req, device, rsAPI, userAPI, vars["roomIDOrAlias"], @@ -348,6 +352,7 @@ func Setup( if err != nil { return util.ErrorResponse(err) } + return SendInvite(req, userAPI, device, vars["roomID"], cfg, rsAPI, asAPI) }), ).Methods(http.MethodPost, http.MethodOptions) diff --git a/zion/README.md b/zion/README.md index 08c27f64e..c411bbd96 100644 --- a/zion/README.md +++ b/zion/README.md @@ -1,3 +1,5 @@ +# Purpose + Additional packaages added for the Zion project, nothing in here should be in the Matrix Dendrite upstream, nor in the herenotthere/dendrite-fork. The zion_space_manager_(mainnet|rinkeby|localhost).go files are generated as new versions of the smart contracts are build and deployed. The bindings are in this location so they can be built alongside the dendrite server in the build process. diff --git a/zion/store.go b/zion/store.go new file mode 100644 index 000000000..a36c01585 --- /dev/null +++ b/zion/store.go @@ -0,0 +1,88 @@ +/* +Convenient function for space info mapping between Matrix room and Space contract +*/ +package zion + +import ( + "context" + "encoding/json" + "strings" + + roomserver "github.com/matrix-org/dendrite/roomserver/api" + "github.com/matrix-org/gomatrixserverlib" +) + +type Store struct { + rsAPI roomserver.ClientRoomserverAPI +} + +func NewStore(rsAPI roomserver.ClientRoomserverAPI) Store { + return Store{ + rsAPI: rsAPI, + } +} + +func (s *Store) GetRoomInfo(roomId string, userId UserIdentifier) RoomInfo { + result := RoomInfo{ + QueryUserId: userId.MatrixUserId, + SpaceNetworkId: "", + ChannelNetworkId: "", + RoomType: Unknown, + IsOwner: false, + } + + createTuple := gomatrixserverlib.StateKeyTuple{ + EventType: gomatrixserverlib.MRoomCreate, + StateKey: "", + } + + spaceChildTuple := gomatrixserverlib.StateKeyTuple{ + EventType: ConstSpaceChildEventType, + StateKey: "*", + } + + spaceParentTuple := gomatrixserverlib.StateKeyTuple{ + EventType: ConstSpaceParentEventType, + StateKey: "*", + } + + var roomEvents roomserver.QueryCurrentStateResponse + err := s.rsAPI.QueryCurrentState(context.Background(), &roomserver.QueryCurrentStateRequest{ + RoomID: roomId, + AllowWildcards: true, + StateTuples: []gomatrixserverlib.StateKeyTuple{ + createTuple, + spaceParentTuple, + spaceChildTuple, + }, + }, &roomEvents) + + if err != nil { + return result + } + + for _, state := range roomEvents.StateEvents { + switch state.Type() { + case gomatrixserverlib.MRoomCreate: + var creatorEvent CreatorEvent + err := json.Unmarshal(roomEvents.StateEvents[createTuple].Content(), &creatorEvent) + result.IsOwner = strings.HasPrefix( + creatorEvent.Creator, + userId.LocalPart, + ) + if err == nil { + result.RoomType = Space + result.SpaceNetworkId = roomId + } + case ConstSpaceChildEventType: + result.RoomType = Space + result.SpaceNetworkId = roomId + case ConstSpaceParentEventType: + result.RoomType = Channel + result.SpaceNetworkId = *state.StateKey() + result.ChannelNetworkId = roomId + } + } + + return result +} diff --git a/zion/store_types.go b/zion/store_types.go new file mode 100644 index 000000000..58bf1fd29 --- /dev/null +++ b/zion/store_types.go @@ -0,0 +1,42 @@ +/* +Store types +*/ +package zion + +const ( + ConstSpaceChildEventType = "m.space.child" + ConstSpaceParentEventType = "m.space.parent" +) + +// Define enum for RoomType +type RoomType int64 + +const ( + Space RoomType = iota + Channel + Unknown +) + +func (r RoomType) String() string { + switch r { + case Space: + return "space" + case Channel: + return "channel" + } + return "unknown" +} + +type RoomInfo struct { + QueryUserId string // Matrix User ID + SpaceNetworkId string + ChannelNetworkId string + RoomType RoomType + IsOwner bool +} + +type CreatorEvent struct { + Creator string `json:"creator"` + Type string `json:"type"` + RoomVersion string `json:"room_version"` +} diff --git a/zion/user_identifier.go b/zion/user_identifier.go index 718758d3b..40e8f6d41 100644 --- a/zion/user_identifier.go +++ b/zion/user_identifier.go @@ -1,38 +1,45 @@ package zion import ( + "fmt" "regexp" "strconv" "github.com/ethereum/go-ethereum/common" ) -var regexpMatrixId = regexp.MustCompile(`^@eip155=3a(?P[0-9]+)=3a(?P0x[0-9a-fA-F]+):(?P.*)$`) +var regexpMatrixId = regexp.MustCompile(`^@eip155=3a(?P[0-9]+)=3a(?P
0x[0-9a-fA-F]+):(?P.*)$`) var chainIdIndex = regexpMatrixId.SubexpIndex("ChainId") -var localPartIndex = regexpMatrixId.SubexpIndex("LocalPart") +var addressIndex = regexpMatrixId.SubexpIndex("Address") //var homeServerIndex = regexpMatrixId.SubexpIndex("HomeServer") type UserIdentifier struct { - accountAddress common.Address - chainId int + AccountAddress common.Address + ChainId int + MatrixUserId string + LocalPart string } func CreateUserIdentifier(matrixUserId string) UserIdentifier { matches := regexpMatrixId.FindStringSubmatch(matrixUserId) - accountAddress := "" + address := "" chainId := -1 + localPart := "" if chainIdIndex < len(matches) { chainId, _ = strconv.Atoi(matches[chainIdIndex]) } - if localPartIndex < len(matches) { - accountAddress = matches[localPartIndex] + if addressIndex < len(matches) { + address = matches[addressIndex] + localPart = fmt.Sprintf("@eip155=3a%d=3a%s", chainId, address) } return UserIdentifier{ - accountAddress: common.HexToAddress(accountAddress), - chainId: chainId, + AccountAddress: common.HexToAddress(address), + ChainId: chainId, + MatrixUserId: matrixUserId, + LocalPart: localPart, } } diff --git a/zion/zion_authorization.go b/zion/zion_authorization.go index c363759c8..10b4a1d55 100644 --- a/zion/zion_authorization.go +++ b/zion/zion_authorization.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/joho/godotenv" "github.com/matrix-org/dendrite/authorization" + roomserver "github.com/matrix-org/dendrite/roomserver/api" zion_goerli "github.com/matrix-org/dendrite/zion/contracts/goerli/zion_goerli" zion_localhost "github.com/matrix-org/dendrite/zion/contracts/localhost/zion_localhost" log "github.com/sirupsen/logrus" @@ -24,11 +25,12 @@ var localhostJson []byte var goerliJson []byte type ZionAuthorization struct { + store Store spaceManagerLocalhost *zion_localhost.ZionSpaceManagerLocalhost spaceManagerGoerli *zion_goerli.ZionSpaceManagerGoerli } -func NewZionAuthorization() (authorization.Authorization, error) { +func NewZionAuthorization(rsAPI roomserver.ClientRoomserverAPI) (authorization.Authorization, error) { err := godotenv.Load(".env") if err != nil { log.Errorln("error loading .env file", err) @@ -36,6 +38,8 @@ func NewZionAuthorization() (authorization.Authorization, error) { var auth ZionAuthorization + auth.store = NewStore(rsAPI) + localhost, err := newZionSpaceManagerLocalhost(os.Getenv(localhostEndpointUrl)) if err != nil { log.Errorln("error instantiating ZionSpaceManagerLocalhost", err) @@ -54,31 +58,40 @@ func NewZionAuthorization() (authorization.Authorization, error) { func (za *ZionAuthorization) IsAllowed(args authorization.AuthorizationArgs) (bool, error) { userIdentifier := CreateUserIdentifier(args.UserId) - switch userIdentifier.chainId { + // Find out if roomId is a space or a channel. + roomInfo := za.store.GetRoomInfo(args.RoomId, userIdentifier) + + // Owner of the space / channel is always allowed to proceed. + if roomInfo.IsOwner { + return true, nil + } + + switch userIdentifier.ChainId { case 1337, 31337: - return za.IsAllowedLocalhost(args.RoomId, userIdentifier.accountAddress, args.Permission) + return za.isAllowedLocalhost(roomInfo, userIdentifier.AccountAddress, args.Permission) case 5: - return za.IsAllowedGoerli(args.RoomId, userIdentifier.accountAddress, args.Permission) + return za.isAllowedGoerli(roomInfo, userIdentifier.AccountAddress, args.Permission) default: - log.Errorf("Unsupported chain id: %d\n", userIdentifier.chainId) + log.Errorf("Unsupported chain id: %d\n", userIdentifier.ChainId) } return false, nil } -func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Address, permission authorization.Permission) (bool, error) { +func (za *ZionAuthorization) isAllowedLocalhost( + roomInfo RoomInfo, + user common.Address, + permission authorization.Permission, +) (bool, error) { if za.spaceManagerLocalhost != nil { permission := zion_localhost.DataTypesPermission{ Name: permission.String(), } - addr := user.Hex() - _ = addr - isEntitled, err := za.spaceManagerLocalhost.IsEntitled( nil, - roomId, - "", // todo: Support channelId + roomInfo.SpaceNetworkId, + roomInfo.ChannelNetworkId, user, permission, ) @@ -93,7 +106,11 @@ func (za *ZionAuthorization) IsAllowedLocalhost(roomId string, user common.Addre return false, nil } -func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, permission authorization.Permission) (bool, error) { +func (za *ZionAuthorization) isAllowedGoerli( + roomInfo RoomInfo, + user common.Address, + permission authorization.Permission, +) (bool, error) { if za.spaceManagerGoerli != nil { permission := zion_goerli.DataTypesPermission{ Name: permission.String(), @@ -101,8 +118,8 @@ func (za *ZionAuthorization) IsAllowedGoerli(roomId string, user common.Address, isEntitled, err := za.spaceManagerGoerli.IsEntitled( nil, - roomId, - "", // todo: support channelId + roomInfo.SpaceNetworkId, + roomInfo.ChannelNetworkId, user, permission, ) From 94061b7b8d79debf008abd9ff54d9c67533d38fe Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Wed, 19 Oct 2022 19:39:33 -0700 Subject: [PATCH 60/75] Return an "Unauthorized" error message + refresh zion contract types (#44) * Add unauthorized message * update regenerated types for zion contracts --- clientapi/routing/routing.go | 2 +- .../zion_space_manager_localhost.go | 274 ++++++++++++++---- 2 files changed, 214 insertions(+), 62 deletions(-) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index c640d7765..5cea1c54d 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -264,7 +264,7 @@ func Setup( if !isAllowed { return util.JSONResponse{ Code: http.StatusUnauthorized, - JSON: jsonerror.Forbidden(""), + JSON: jsonerror.Forbidden("Unauthorised"), } } diff --git a/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go b/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go index 2d3d7f385..618606264 100644 --- a/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go +++ b/zion/contracts/localhost/zion_localhost/zion_space_manager_localhost.go @@ -28,12 +28,37 @@ var ( _ = event.NewSubscription ) +// DataTypesChannel is an auto generated low-level Go binding around an user-defined struct. +type DataTypesChannel struct { + ChannelId *big.Int + CreatedAt *big.Int + NetworkId string + Name string + Creator common.Address + Disabled bool +} + +// DataTypesChannelInfo is an auto generated low-level Go binding around an user-defined struct. +type DataTypesChannelInfo struct { + ChannelId *big.Int + NetworkId string + CreatedAt *big.Int + Name string + Creator common.Address + Disabled bool +} + +// DataTypesChannels is an auto generated low-level Go binding around an user-defined struct. +type DataTypesChannels struct { + IdCounter *big.Int + Channels []DataTypesChannel +} + // DataTypesCreateChannelData is an auto generated low-level Go binding around an user-defined struct. type DataTypesCreateChannelData struct { - ChannelName string - NetworkId string - SpaceId string - Roles []DataTypesCreateRoleData + SpaceNetworkId string + ChannelName string + ChannelNetworkId string } // DataTypesCreateRoleData is an auto generated low-level Go binding around an user-defined struct. @@ -45,8 +70,8 @@ type DataTypesCreateRoleData struct { // DataTypesCreateSpaceData is an auto generated low-level Go binding around an user-defined struct. type DataTypesCreateSpaceData struct { - SpaceName string - NetworkId string + SpaceName string + SpaceNetworkId string } // DataTypesCreateSpaceTokenEntitlementData is an auto generated low-level Go binding around an user-defined struct. @@ -56,6 +81,7 @@ type DataTypesCreateSpaceTokenEntitlementData struct { Quantity *big.Int Description string Permissions []string + RoleName string } // DataTypesEntitlementModuleInfo is an auto generated low-level Go binding around an user-defined struct. @@ -72,23 +98,24 @@ type DataTypesPermission struct { // DataTypesRole is an auto generated low-level Go binding around an user-defined struct. type DataTypesRole struct { - RoleId *big.Int - Name string - IsTransitive bool + RoleId *big.Int + Name string } // DataTypesSpaceInfo is an auto generated low-level Go binding around an user-defined struct. type DataTypesSpaceInfo struct { SpaceId *big.Int + NetworkId string CreatedAt *big.Int Name string Creator common.Address Owner common.Address + Disabled bool } // ZionSpaceManagerLocalhostMetaData contains all meta data concerning the ZionSpaceManagerLocalhost contract. var ZionSpaceManagerLocalhostMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"defaultPermissionsManagerAddress_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DefaultPermissionsManagerNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSpaceOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SpaceAlreadyRegistered\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"channelName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"permissions\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateRoleData[]\",\"name\":\"roles\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateChannelData\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"createChannel\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"}],\"name\":\"getChannelIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"permissionType\",\"type\":\"bytes32\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"isTransitive\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"setDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"permissionsManager\",\"type\":\"address\"}],\"name\":\"setDefaultPermissionsManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"permissionRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ChannelDoesNotExist\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DefaultEntitlementModuleNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DefaultPermissionsManagerNotSet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementAlreadyWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementModuleNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EntitlementNotWhitelisted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidParameters\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotAllowed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SpaceDoesNotExist\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"addPermissionToRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"entitlementData\",\"type\":\"bytes\"}],\"name\":\"addRoleToEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceNetworkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelNetworkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateChannelData\",\"name\":\"data\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"metadata\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"permissions\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.CreateRoleData\",\"name\":\"role\",\"type\":\"tuple\"}],\"name\":\"createChannel\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"createRole\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"spaceNetworkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"}],\"name\":\"createSpace\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"spaceName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"spaceNetworkId\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceData\",\"name\":\"info\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"permissions\",\"type\":\"string[]\"},{\"internalType\":\"string\",\"name\":\"roleName\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.CreateSpaceTokenEntitlementData\",\"name\":\"entitlement\",\"type\":\"tuple\"}],\"name\":\"createSpaceWithTokenEntitlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"}],\"name\":\"getChannelIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"}],\"name\":\"getChannelInfoByChannelId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"channelId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.ChannelInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getChannelsBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"idCounter\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"channelId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.Channel[]\",\"name\":\"channels\",\"type\":\"tuple[]\"}],\"internalType\":\"structDataTypes.Channels\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementModulesBySpaceId\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"entitlementModules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getEntitlementsInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"entitlementName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"entitlementDescription\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.EntitlementModuleInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"permissionType\",\"type\":\"bytes32\"}],\"name\":\"getPermissionFromMap\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getPermissionsBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"getRoleBySpaceIdByRoleId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Role\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getRolesBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Role[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"}],\"name\":\"getSpaceIdByNetworkId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceInfoBySpaceId\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.SpaceInfo\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"}],\"name\":\"getSpaceOwnerBySpaceId\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"ownerAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSpaces\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"spaceId\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"networkId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"creator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"internalType\":\"structDataTypes.SpaceInfo[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"}],\"name\":\"isEntitlementModuleWhitelisted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementModuleAddress\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"roleIds\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"removeEntitlement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"internalType\":\"structDataTypes.Permission\",\"name\":\"permission\",\"type\":\"tuple\"}],\"name\":\"removePermissionFromRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"roleId\",\"type\":\"uint256\"}],\"name\":\"removeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceNetworkId\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelNetworkId\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"name\":\"setChannelAccess\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"entitlementModule\",\"type\":\"address\"}],\"name\":\"setDefaultEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceNetworkId\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"disabled\",\"type\":\"bool\"}],\"name\":\"setSpaceAccess\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"spaceId\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"entitlementAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"whitelist\",\"type\":\"bool\"}],\"name\":\"whitelistEntitlementModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // ZionSpaceManagerLocalhostABI is the input ABI used to generate the binding from. @@ -268,6 +295,68 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetCha return _ZionSpaceManagerLocalhost.Contract.GetChannelIdByNetworkId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId) } +// GetChannelInfoByChannelId is a free data retrieval call binding the contract method 0x0db37ba3. +// +// Solidity: function getChannelInfoByChannelId(string spaceId, string channelId) view returns((uint256,string,uint256,string,address,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetChannelInfoByChannelId(opts *bind.CallOpts, spaceId string, channelId string) (DataTypesChannelInfo, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getChannelInfoByChannelId", spaceId, channelId) + + if err != nil { + return *new(DataTypesChannelInfo), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesChannelInfo)).(*DataTypesChannelInfo) + + return out0, err + +} + +// GetChannelInfoByChannelId is a free data retrieval call binding the contract method 0x0db37ba3. +// +// Solidity: function getChannelInfoByChannelId(string spaceId, string channelId) view returns((uint256,string,uint256,string,address,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetChannelInfoByChannelId(spaceId string, channelId string) (DataTypesChannelInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelInfoByChannelId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId) +} + +// GetChannelInfoByChannelId is a free data retrieval call binding the contract method 0x0db37ba3. +// +// Solidity: function getChannelInfoByChannelId(string spaceId, string channelId) view returns((uint256,string,uint256,string,address,bool)) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetChannelInfoByChannelId(spaceId string, channelId string) (DataTypesChannelInfo, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelInfoByChannelId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, channelId) +} + +// GetChannelsBySpaceId is a free data retrieval call binding the contract method 0x50c24eef. +// +// Solidity: function getChannelsBySpaceId(string spaceId) view returns((uint256,(uint256,uint256,string,string,address,bool)[])) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetChannelsBySpaceId(opts *bind.CallOpts, spaceId string) (DataTypesChannels, error) { + var out []interface{} + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getChannelsBySpaceId", spaceId) + + if err != nil { + return *new(DataTypesChannels), err + } + + out0 := *abi.ConvertType(out[0], new(DataTypesChannels)).(*DataTypesChannels) + + return out0, err + +} + +// GetChannelsBySpaceId is a free data retrieval call binding the contract method 0x50c24eef. +// +// Solidity: function getChannelsBySpaceId(string spaceId) view returns((uint256,(uint256,uint256,string,string,address,bool)[])) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetChannelsBySpaceId(spaceId string) (DataTypesChannels, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + +// GetChannelsBySpaceId is a free data retrieval call binding the contract method 0x50c24eef. +// +// Solidity: function getChannelsBySpaceId(string spaceId) view returns((uint256,(uint256,uint256,string,string,address,bool)[])) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetChannelsBySpaceId(spaceId string) (DataTypesChannels, error) { + return _ZionSpaceManagerLocalhost.Contract.GetChannelsBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) +} + // GetEntitlementModulesBySpaceId is a free data retrieval call binding the contract method 0x141b6498. // // Solidity: function getEntitlementModulesBySpaceId(string spaceId) view returns(address[] entitlementModules) @@ -394,7 +483,7 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetPer // GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpaceIdByRoleId(opts *bind.CallOpts, spaceId string, roleId *big.Int) (DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRoleBySpaceIdByRoleId", spaceId, roleId) @@ -411,21 +500,21 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRoleBySpac // GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } // GetRoleBySpaceIdByRoleId is a free data retrieval call binding the contract method 0xb3ff31b2. // -// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string,bool)) +// Solidity: function getRoleBySpaceIdByRoleId(string spaceId, uint256 roleId) view returns((uint256,string)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRoleBySpaceIdByRoleId(spaceId string, roleId *big.Int) (DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRoleBySpaceIdByRoleId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId, roleId) } // GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpaceId(opts *bind.CallOpts, spaceId string) ([]DataTypesRole, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getRolesBySpaceId", spaceId) @@ -442,14 +531,14 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetRolesBySpa // GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetRolesBySpaceId is a free data retrieval call binding the contract method 0x4bf2abb2. // -// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string,bool)[]) +// Solidity: function getRolesBySpaceId(string spaceId) view returns((uint256,string)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetRolesBySpaceId(spaceId string) ([]DataTypesRole, error) { return _ZionSpaceManagerLocalhost.Contract.GetRolesBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } @@ -487,7 +576,7 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpa // GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,string,uint256,string,address,address,bool)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoBySpaceId(opts *bind.CallOpts, spaceId string) (DataTypesSpaceInfo, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceInfoBySpaceId", spaceId) @@ -504,24 +593,24 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceInfoB // GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,string,uint256,string,address,address,bool)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetSpaceInfoBySpaceId is a free data retrieval call binding the contract method 0x2bb59212. // -// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,uint256,string,address,address)) +// Solidity: function getSpaceInfoBySpaceId(string spaceId) view returns((uint256,string,uint256,string,address,address,bool)) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceInfoBySpaceId(spaceId string) (DataTypesSpaceInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaceInfoBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, _spaceId string) (common.Address, error) { +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwnerBySpaceId(opts *bind.CallOpts, spaceId string) (common.Address, error) { var out []interface{} - err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", _spaceId) + err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaceOwnerBySpaceId", spaceId) if err != nil { return *new(common.Address), err @@ -535,21 +624,21 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaceOwner // GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceOwnerBySpaceId(_spaceId string) (common.Address, error) { - return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaceOwnerBySpaceId(spaceId string) (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetSpaceOwnerBySpaceId is a free data retrieval call binding the contract method 0x2a4bdf25. // -// Solidity: function getSpaceOwnerBySpaceId(string _spaceId) view returns(address ownerAddress) -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceOwnerBySpaceId(_spaceId string) (common.Address, error) { - return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, _spaceId) +// Solidity: function getSpaceOwnerBySpaceId(string spaceId) view returns(address ownerAddress) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaceOwnerBySpaceId(spaceId string) (common.Address, error) { + return _ZionSpaceManagerLocalhost.Contract.GetSpaceOwnerBySpaceId(&_ZionSpaceManagerLocalhost.CallOpts, spaceId) } // GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. // -// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +// Solidity: function getSpaces() view returns((uint256,string,uint256,string,address,address,bool)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaces(opts *bind.CallOpts) ([]DataTypesSpaceInfo, error) { var out []interface{} err := _ZionSpaceManagerLocalhost.contract.Call(opts, &out, "getSpaces") @@ -566,14 +655,14 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCaller) GetSpaces(opt // GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. // -// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +// Solidity: function getSpaces() view returns((uint256,string,uint256,string,address,address,bool)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) GetSpaces() ([]DataTypesSpaceInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) } // GetSpaces is a free data retrieval call binding the contract method 0x15478ca9. // -// Solidity: function getSpaces() view returns((uint256,uint256,string,address,address)[]) +// Solidity: function getSpaces() view returns((uint256,string,uint256,string,address,address,bool)[]) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostCallerSession) GetSpaces() ([]DataTypesSpaceInfo, error) { return _ZionSpaceManagerLocalhost.Contract.GetSpaces(&_ZionSpaceManagerLocalhost.CallOpts) } @@ -713,25 +802,25 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Ad return _ZionSpaceManagerLocalhost.Contract.AddRoleToEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleId, entitlementData) } -// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. +// CreateChannel is a paid mutator transaction binding the contract method 0xbc374841. // -// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateChannel(opts *bind.TransactOpts, data DataTypesCreateChannelData) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createChannel", data) +// Solidity: function createChannel((string,string,string) data, (string,string,(string)[]) role) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateChannel(opts *bind.TransactOpts, data DataTypesCreateChannelData, role DataTypesCreateRoleData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createChannel", data, role) } -// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. +// CreateChannel is a paid mutator transaction binding the contract method 0xbc374841. // -// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data) +// Solidity: function createChannel((string,string,string) data, (string,string,(string)[]) role) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateChannel(data DataTypesCreateChannelData, role DataTypesCreateRoleData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data, role) } -// CreateChannel is a paid mutator transaction binding the contract method 0x06d1ea5d. +// CreateChannel is a paid mutator transaction binding the contract method 0xbc374841. // -// Solidity: function createChannel((string,string,string,(string,string,(string)[])[]) data) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateChannel(data DataTypesCreateChannelData) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data) +// Solidity: function createChannel((string,string,string) data, (string,string,(string)[]) role) returns(uint256) +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateChannel(data DataTypesCreateChannelData, role DataTypesCreateRoleData) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.CreateChannel(&_ZionSpaceManagerLocalhost.TransactOpts, data, role) } // CreateRole is a paid mutator transaction binding the contract method 0xd2192dbf. @@ -776,23 +865,23 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Cr return _ZionSpaceManagerLocalhost.Contract.CreateSpace(&_ZionSpaceManagerLocalhost.TransactOpts, info) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0xe76c6303. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[],string) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) CreateSpaceWithTokenEntitlement(opts *bind.TransactOpts, info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.contract.Transact(opts, "createSpaceWithTokenEntitlement", info, entitlement) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0xe76c6303. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[],string) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) } -// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0x7e9ea5c7. +// CreateSpaceWithTokenEntitlement is a paid mutator transaction binding the contract method 0xe76c6303. // -// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[]) entitlement) returns(uint256) +// Solidity: function createSpaceWithTokenEntitlement((string,string) info, (address,address,uint256,string,string[],string) entitlement) returns(uint256) func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) CreateSpaceWithTokenEntitlement(info DataTypesCreateSpaceData, entitlement DataTypesCreateSpaceTokenEntitlementData) (*types.Transaction, error) { return _ZionSpaceManagerLocalhost.Contract.CreateSpaceWithTokenEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, info, entitlement) } @@ -818,6 +907,48 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Re return _ZionSpaceManagerLocalhost.Contract.RemoveEntitlement(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, channelId, entitlementModuleAddress, roleIds, data) } +// RemovePermissionFromRole is a paid mutator transaction binding the contract method 0x4832a4ec. +// +// Solidity: function removePermissionFromRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemovePermissionFromRole(opts *bind.TransactOpts, spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removePermissionFromRole", spaceId, roleId, permission) +} + +// RemovePermissionFromRole is a paid mutator transaction binding the contract method 0x4832a4ec. +// +// Solidity: function removePermissionFromRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemovePermissionFromRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemovePermissionFromRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) +} + +// RemovePermissionFromRole is a paid mutator transaction binding the contract method 0x4832a4ec. +// +// Solidity: function removePermissionFromRole(string spaceId, uint256 roleId, (string) permission) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemovePermissionFromRole(spaceId string, roleId *big.Int, permission DataTypesPermission) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemovePermissionFromRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId, permission) +} + +// RemoveRole is a paid mutator transaction binding the contract method 0x8b0e905a. +// +// Solidity: function removeRole(string spaceId, uint256 roleId) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) RemoveRole(opts *bind.TransactOpts, spaceId string, roleId *big.Int) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "removeRole", spaceId, roleId) +} + +// RemoveRole is a paid mutator transaction binding the contract method 0x8b0e905a. +// +// Solidity: function removeRole(string spaceId, uint256 roleId) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) RemoveRole(spaceId string, roleId *big.Int) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId) +} + +// RemoveRole is a paid mutator transaction binding the contract method 0x8b0e905a. +// +// Solidity: function removeRole(string spaceId, uint256 roleId) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) RemoveRole(spaceId string, roleId *big.Int) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.RemoveRole(&_ZionSpaceManagerLocalhost.TransactOpts, spaceId, roleId) +} + // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. // // Solidity: function renounceOwnership() returns() @@ -839,6 +970,27 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Re return _ZionSpaceManagerLocalhost.Contract.RenounceOwnership(&_ZionSpaceManagerLocalhost.TransactOpts) } +// SetChannelAccess is a paid mutator transaction binding the contract method 0x72a29321. +// +// Solidity: function setChannelAccess(string spaceNetworkId, string channelNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) SetChannelAccess(opts *bind.TransactOpts, spaceNetworkId string, channelNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "setChannelAccess", spaceNetworkId, channelNetworkId, disabled) +} + +// SetChannelAccess is a paid mutator transaction binding the contract method 0x72a29321. +// +// Solidity: function setChannelAccess(string spaceNetworkId, string channelNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) SetChannelAccess(spaceNetworkId string, channelNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetChannelAccess(&_ZionSpaceManagerLocalhost.TransactOpts, spaceNetworkId, channelNetworkId, disabled) +} + +// SetChannelAccess is a paid mutator transaction binding the contract method 0x72a29321. +// +// Solidity: function setChannelAccess(string spaceNetworkId, string channelNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) SetChannelAccess(spaceNetworkId string, channelNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetChannelAccess(&_ZionSpaceManagerLocalhost.TransactOpts, spaceNetworkId, channelNetworkId, disabled) +} + // SetDefaultEntitlementModule is a paid mutator transaction binding the contract method 0xccaf0a2b. // // Solidity: function setDefaultEntitlementModule(address entitlementModule) returns() @@ -860,25 +1012,25 @@ func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) Se return _ZionSpaceManagerLocalhost.Contract.SetDefaultEntitlementModule(&_ZionSpaceManagerLocalhost.TransactOpts, entitlementModule) } -// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// SetSpaceAccess is a paid mutator transaction binding the contract method 0xf86caf83. // -// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) SetDefaultPermissionsManager(opts *bind.TransactOpts, permissionsManager common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.contract.Transact(opts, "setDefaultPermissionsManager", permissionsManager) +// Solidity: function setSpaceAccess(string spaceNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactor) SetSpaceAccess(opts *bind.TransactOpts, spaceNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.contract.Transact(opts, "setSpaceAccess", spaceNetworkId, disabled) } -// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// SetSpaceAccess is a paid mutator transaction binding the contract method 0xf86caf83. // -// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerLocalhost.TransactOpts, permissionsManager) +// Solidity: function setSpaceAccess(string spaceNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostSession) SetSpaceAccess(spaceNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetSpaceAccess(&_ZionSpaceManagerLocalhost.TransactOpts, spaceNetworkId, disabled) } -// SetDefaultPermissionsManager is a paid mutator transaction binding the contract method 0x2d478e6b. +// SetSpaceAccess is a paid mutator transaction binding the contract method 0xf86caf83. // -// Solidity: function setDefaultPermissionsManager(address permissionsManager) returns() -func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) SetDefaultPermissionsManager(permissionsManager common.Address) (*types.Transaction, error) { - return _ZionSpaceManagerLocalhost.Contract.SetDefaultPermissionsManager(&_ZionSpaceManagerLocalhost.TransactOpts, permissionsManager) +// Solidity: function setSpaceAccess(string spaceNetworkId, bool disabled) returns() +func (_ZionSpaceManagerLocalhost *ZionSpaceManagerLocalhostTransactorSession) SetSpaceAccess(spaceNetworkId string, disabled bool) (*types.Transaction, error) { + return _ZionSpaceManagerLocalhost.Contract.SetSpaceAccess(&_ZionSpaceManagerLocalhost.TransactOpts, spaceNetworkId, disabled) } // TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. From 36039c2efce2627e76adbe208266344dfdbc4e16 Mon Sep 17 00:00:00 2001 From: John Terzis Date: Fri, 21 Oct 2022 16:57:20 -0700 Subject: [PATCH 61/75] HNT-105 invite authz --- clientapi/routing/routing.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 5cea1c54d..14c164c48 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -353,6 +353,19 @@ func Setup( return util.ErrorResponse(err) } + isAllowedInviter, _ := authorization.IsAllowed(authz.AuthorizationArgs{ + RoomId: vars["roomID"], + UserId: device.UserID, + Permission: authz.PermissionInvite, + }) + + if !isAllowedInviter { + return util.JSONResponse{ + Code: http.StatusUnauthorized, + JSON: jsonerror.Forbidden("Inviter not allowed"), + } + } + return SendInvite(req, userAPI, device, vars["roomID"], cfg, rsAPI, asAPI) }), ).Methods(http.MethodPost, http.MethodOptions) From db9758464dfd7bc3825f8cbf4fddb376b47d3768 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 24 Oct 2022 11:07:40 -0700 Subject: [PATCH 62/75] Dendrite should only support 1 chain id (#47) * Support 1 blockchain only * auth check based on single chain * use config to set the blockchain provider URL * fix config to read from env variable * handle 31337 in addition to 1337 --- clientapi/auth/login_publickey_ethereum.go | 11 +--- .../auth/login_publickey_ethereum_test.go | 30 ++++++----- clientapi/auth/login_publickey_test.go | 6 ++- clientapi/authorization/authorization.go | 2 +- clientapi/routing/register_publickey_test.go | 38 +++++++------- dendrite-sample.monolith.yaml | 3 +- dendrite-sample.polylith.yaml | 3 +- setup/config/config.go | 31 +++++++----- setup/config/config_publickey.go | 24 ++++----- test/publickey_utils.go | 4 +- zion/zion_authorization.go | 50 +++++++++++-------- 11 files changed, 102 insertions(+), 100 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 90de33d2b..abf1d2032 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -129,7 +129,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri } // Error if the chainId is not supported by the server. - if !contains(pk.config.PublicKeyAuthentication.Ethereum.ChainIDs, message.GetChainID()) { + if pk.config.PublicKeyAuthentication.Ethereum.ChainID != message.GetChainID() { return false, jsonerror.Forbidden("chainId") } @@ -156,12 +156,3 @@ func (pk LoginPublicKeyEthereum) verifyMessageUserId(message *siwe.Message) bool // one derived from the signed message. return pk.UserId == strings.ToLower(expectedUserId) } - -func contains(list []int, element int) bool { - for _, i := range list { - if i == element { - return true - } - } - return false -} diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go index 73842f9a0..a8d3a710a 100644 --- a/clientapi/auth/login_publickey_ethereum_test.go +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -24,7 +24,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/dendrite/setup/config" - "github.com/matrix-org/dendrite/test" + testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" "github.com/stretchr/testify/assert" ) @@ -35,19 +35,17 @@ type loginContext struct { } func createLoginContext(_ *testing.T) *loginContext { - chainIds := []int{4} - cfg := &config.ClientAPI{ Matrix: &config.Global{ - ServerName: test.TestServerName, + ServerName: testutil.TestServerName, }, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ Ethereum: config.EthereumAuthConfig{ - Enabled: true, - Version: 1, - ChainIDs: chainIds, + Enabled: true, + Version: 1, + ChainID: testutil.EthereumTestNetworkId, }, }, } @@ -154,9 +152,9 @@ func TestLoginPublicKeyEthereum(t *testing.T) { var userAPI fakePublicKeyUserApi ctx := context.Background() loginContext := createLoginContext(t) - wallet, _ := test.CreateTestAccount() - message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) - signature, _ := test.SignMessage(message.String(), wallet.PrivateKey) + wallet, _ := testutil.CreateTestAccount() + message, _ := testutil.CreateEip4361TestMessage(wallet.PublicAddress) + signature, _ := testutil.SignMessage(message.String(), wallet.PrivateKey) sessionId := publicKeyTestSession( &ctx, loginContext.config, @@ -165,7 +163,7 @@ func TestLoginPublicKeyEthereum(t *testing.T) { ) // Escape \t and \n. Work around for marshalling and unmarshalling message. - msgStr := test.FromEip4361MessageToString(message) + msgStr := testutil.FromEip4361MessageToString(message) body := fmt.Sprintf(`{ "type": "m.login.publickey", "auth": { @@ -219,8 +217,8 @@ func TestLoginPublicKeyEthereumMissingSignature(t *testing.T) { var userAPI fakePublicKeyUserApi ctx := context.Background() loginContext := createLoginContext(t) - wallet, _ := test.CreateTestAccount() - message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) + wallet, _ := testutil.CreateTestAccount() + message, _ := testutil.CreateEip4361TestMessage(wallet.PublicAddress) sessionId := publicKeyTestSession( &ctx, loginContext.config, @@ -229,7 +227,7 @@ func TestLoginPublicKeyEthereumMissingSignature(t *testing.T) { ) // Escape \t and \n. Work around for marshalling and unmarshalling message. - msgStr := test.FromEip4361MessageToString(message) + msgStr := testutil.FromEip4361MessageToString(message) body := fmt.Sprintf(`{ "type": "m.login.publickey", "auth": { @@ -280,7 +278,7 @@ func TestLoginPublicKeyEthereumEmptyMessage(t *testing.T) { var userAPI fakePublicKeyUserApi ctx := context.Background() loginContext := createLoginContext(t) - wallet, _ := test.CreateTestAccount() + wallet, _ := testutil.CreateTestAccount() sessionId := publicKeyTestSession( &ctx, loginContext.config, @@ -333,7 +331,7 @@ func TestLoginPublicKeyEthereumWrongUserId(t *testing.T) { var userAPI fakePublicKeyUserApi ctx := context.Background() loginContext := createLoginContext(t) - wallet, _ := test.CreateTestAccount() + wallet, _ := testutil.CreateTestAccount() sessionId := publicKeyTestSession( &ctx, loginContext.config, diff --git a/clientapi/auth/login_publickey_test.go b/clientapi/auth/login_publickey_test.go index 6b95c5553..513616486 100644 --- a/clientapi/auth/login_publickey_test.go +++ b/clientapi/auth/login_publickey_test.go @@ -22,6 +22,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/setup/config" + testutil "github.com/matrix-org/dendrite/test" "github.com/stretchr/testify/assert" ) @@ -72,7 +73,10 @@ func TestLoginPublicKeyNewSession(t *testing.T) { params, "[object]") ethParams := params.(config.EthereumAuthParams) - assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") + assert.Equalf( + testutil.EthereumTestNetworkId, + ethParams.ChainID, + "ChainID actual: %d, expected %d", ethParams.ChainID, testutil.EthereumTestNetworkId) assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") } diff --git a/clientapi/authorization/authorization.go b/clientapi/authorization/authorization.go index f37f4becd..3efb37e39 100644 --- a/clientapi/authorization/authorization.go +++ b/clientapi/authorization/authorization.go @@ -11,7 +11,7 @@ import ( func NewAuthorization(cfg *config.ClientAPI, rsAPI roomserver.ClientRoomserverAPI) authorization.Authorization { // Load authorization manager for Zion if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { - auth, err := zion.NewZionAuthorization(rsAPI) + auth, err := zion.NewZionAuthorization(cfg, rsAPI) if err != nil { log.Errorln("Failed to initialise Zion authorization manager. Using default.", err) diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index 4079669b9..e1a225cbd 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -26,8 +26,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/dendrite/setup/config" - "github.com/matrix-org/dendrite/test" - "github.com/matrix-org/dendrite/userapi/api" + testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" "github.com/matrix-org/util" "github.com/stretchr/testify/assert" @@ -41,19 +40,17 @@ type registerContext struct { } func createRegisterContext(_ *testing.T) *registerContext { - chainIds := []int{4} - cfg := &config.ClientAPI{ Matrix: &config.Global{ - ServerName: test.TestServerName, + ServerName: testutil.TestServerName, }, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ Ethereum: config.EthereumAuthConfig{ - Enabled: true, - Version: 1, - ChainIDs: chainIds, + Enabled: true, + Version: 1, + ChainID: testutil.EthereumTestNetworkId, }, }, } @@ -129,7 +126,7 @@ func (ua *fakePublicKeyUserApi) PerformDeviceCreation( req *uapi.PerformDeviceCreationRequest, res *uapi.PerformDeviceCreationResponse) error { res.DeviceCreated = true - res.Device = &api.Device{ + res.Device = &uapi.Device{ ID: "device_id", UserID: req.Localpart, AccessToken: req.AccessToken, @@ -142,11 +139,11 @@ func (ua *fakePublicKeyUserApi) PerformAccountCreation( req *uapi.PerformAccountCreationRequest, res *uapi.PerformAccountCreationResponse) error { res.AccountCreated = true - res.Account = &api.Account{ + res.Account = &uapi.Account{ AppServiceID: req.AppServiceID, Localpart: req.Localpart, - ServerName: test.TestServerName, - UserID: fmt.Sprintf("@%s:%s", req.Localpart, test.TestServerName), + ServerName: testutil.TestServerName, + UserID: fmt.Sprintf("@%s:%s", req.Localpart, testutil.TestServerName), AccountType: req.AccountType, } return nil @@ -173,8 +170,6 @@ func (*fakePublicKeyUserApi) QueryLoginToken(ctx context.Context, req *uapi.Quer func newRegistrationSession( t *testing.T, userId string, - _ *config.ClientAPI, - _ *auth.UserInteractive, userAPI *fakePublicKeyUserApi, ) string { body := fmt.Sprintf(`{ @@ -214,20 +209,18 @@ func newRegistrationSession( func TestRegisterEthereum(t *testing.T) { // Setup var userAPI fakePublicKeyUserApi - wallet, _ := test.CreateTestAccount() - message, _ := test.CreateEip4361TestMessage(wallet.PublicAddress) - signature, _ := test.SignMessage(message.String(), wallet.PrivateKey) + wallet, _ := testutil.CreateTestAccount() + message, _ := testutil.CreateEip4361TestMessage(wallet.PublicAddress) + signature, _ := testutil.SignMessage(message.String(), wallet.PrivateKey) registerContext := createRegisterContext(t) sessionId := newRegistrationSession( t, wallet.Eip155UserId, - registerContext.config, - registerContext.userInteractive, &userAPI, ) // Escape \t and \n. Work around for marshalling and unmarshalling message. - msgStr := test.FromEip4361MessageToString(message) + msgStr := testutil.FromEip4361MessageToString(message) body := fmt.Sprintf(`{ "username": "%v", "auth": { @@ -339,7 +332,10 @@ func TestNewRegistrationSession(t *testing.T) { params, "[object]") ethParams := params.(config.EthereumAuthParams) - assert.NotEmptyf(ethParams.ChainIDs, "ChainIDs actual: empty, expected not empty") + assert.Equalf( + testutil.EthereumTestNetworkId, + ethParams.ChainID, + "ChainID actual: %d, expected %d", ethParams.ChainID, testutil.EthereumTestNetworkId) assert.NotEmptyf(ethParams.Version, "Version actual: \"\", expected: not empty") } diff --git a/dendrite-sample.monolith.yaml b/dendrite-sample.monolith.yaml index b030b62eb..715534528 100644 --- a/dendrite-sample.monolith.yaml +++ b/dendrite-sample.monolith.yaml @@ -178,7 +178,8 @@ client_api: ethereum: enabled: false version: 1 - chain_ids: [] + chain_id: 31337 + networkUrl: "http://127.0.0.1:8545" # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used diff --git a/dendrite-sample.polylith.yaml b/dendrite-sample.polylith.yaml index 5be1b6edd..6475fb398 100644 --- a/dendrite-sample.polylith.yaml +++ b/dendrite-sample.polylith.yaml @@ -174,7 +174,8 @@ client_api: ethereum: enabled: false version: 1 - chain_ids: [] + chain_id: 31337 + networkUrl: "http://127.0.0.1:8545" # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used diff --git a/setup/config/config.go b/setup/config/config.go index 65c97704f..d30dc4107 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -26,6 +26,7 @@ import ( "strconv" "strings" + "github.com/joho/godotenv" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/internal/mapsutil" "github.com/matrix-org/gomatrixserverlib" @@ -587,11 +588,15 @@ Replace selected config with environment variables func (config *Dendrite) replaceWithEnvVariables() { // Replace selected fields with env variables + err := godotenv.Load(".env") + if err != nil { + logrus.Errorln("error loading .env file", err) + } config.Global.ServerName = gomatrixserverlib.ServerName( replaceWithEnvVariables(string(config.Global.ServerName)), ) - logrus.Infof("Matrix ServerName=%s\n", config.Global.ServerName) + logrus.Infof("Matrix ServerName=%s", config.Global.ServerName) config.Global.DatabaseOptions.ConnectionString = DataSource( replaceWithEnvVariables( @@ -602,19 +607,21 @@ func (config *Dendrite) replaceWithEnvVariables() { // If env variable is set, convert the deployment chain IDs from the env // variable into []int and replace the ChainIDs field. if config.ClientAPI.PublicKeyAuthentication.Ethereum.Enabled { - deploymentChainIDs := replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.DeploymentChainIDs) - chainIds := strings.Split(deploymentChainIDs, ",") - if len(chainIds) > 0 && chainIds[0] != "" { - var ids []int - for _, id := range chainIds { - id, err := strconv.Atoi(strings.TrimSpace(id)) - if err == nil { - ids = append(ids, id) - } + strChainId := replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.DeploymentChainID) + if strChainId != "" { + id, err := strconv.Atoi(strings.TrimSpace(strChainId)) + if err == nil { + config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainID = id } - config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainIDs = ids } - logrus.Infof("Supported Ethereum chain IDs=%d\n", config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainIDs) + + config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl = replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl) + + logrus.Infof( + "Supported Ethereum chain ID=%d, network URL=%s", + config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainID, + config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl, + ) } } diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index b0d3e4c2a..647b648c1 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -9,23 +9,21 @@ type AuthParams interface { } type EthereumAuthParams struct { - Version uint `json:"version"` - ChainIDs []int `json:"chain_ids"` + Version uint `json:"version"` + ChainID int `json:"chain_id"` } func (p EthereumAuthParams) GetParams() interface{} { - copyP := p - copyP.ChainIDs = make([]int, len(p.ChainIDs)) - copy(copyP.ChainIDs, p.ChainIDs) - return copyP + return p } type EthereumAuthConfig struct { - Enabled bool `yaml:"enabled"` - Version uint `yaml:"version"` - ChainIDs []int `yaml:"chain_ids"` - DeploymentChainIDs string `yaml:"deployment_chain_ids"` // For deployment: use env variable strings to override the chain IDs. - EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development + Enabled bool `yaml:"enabled"` + Version uint `yaml:"version"` + ChainID int `yaml:"chain_id"` + DeploymentChainID string `yaml:"deployment_chain_id"` // For deployment: use env variable string to override the chain ID. + NetworkUrl string `yaml:"networkUrl"` // Blockchain network provider URL + EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development } type PublicKeyAuthentication struct { @@ -49,8 +47,8 @@ func (pk *PublicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]i params := make(map[string]interface{}) if pk.Ethereum.Enabled { p := EthereumAuthParams{ - Version: pk.Ethereum.Version, - ChainIDs: pk.Ethereum.ChainIDs, + Version: pk.Ethereum.Version, + ChainID: pk.Ethereum.ChainID, } params[authtypes.LoginTypePublicKeyEthereum] = p } diff --git a/test/publickey_utils.go b/test/publickey_utils.go index 49f608813..497cb7527 100644 --- a/test/publickey_utils.go +++ b/test/publickey_utils.go @@ -27,7 +27,7 @@ import ( "github.com/spruceid/siwe-go" ) -const EthereumTestNetworkId = 4 // Rinkeby test network ID +const EthereumTestNetworkId = 1337 // Localhost chain ID const TestServerName = "localhost" type EthereumTestWallet struct { @@ -68,7 +68,7 @@ func CreateEip4361TestMessage( publicAddress string, ) (*siwe.Message, error) { options := make(map[string]interface{}) - options["chainId"] = 4 // Rinkeby test network + options["chainId"] = EthereumTestNetworkId options["statement"] = "This is a test statement" message, err := siwe.InitMessage( TestServerName, diff --git a/zion/zion_authorization.go b/zion/zion_authorization.go index 10b4a1d55..d009fde94 100644 --- a/zion/zion_authorization.go +++ b/zion/zion_authorization.go @@ -2,22 +2,16 @@ package zion import ( _ "embed" - "os" "github.com/ethereum/go-ethereum/common" - "github.com/joho/godotenv" "github.com/matrix-org/dendrite/authorization" roomserver "github.com/matrix-org/dendrite/roomserver/api" + "github.com/matrix-org/dendrite/setup/config" zion_goerli "github.com/matrix-org/dendrite/zion/contracts/goerli/zion_goerli" zion_localhost "github.com/matrix-org/dendrite/zion/contracts/localhost/zion_localhost" log "github.com/sirupsen/logrus" ) -const ( - localhostEndpointUrl = "LOCALHOST_ENDPOINT" // .env - goerliEndpointUrl = "GOERLI_ENDPOINT" // .env -) - //go:embed contracts/localhost/addresses/space-manager.json var localhostJson []byte @@ -28,29 +22,41 @@ type ZionAuthorization struct { store Store spaceManagerLocalhost *zion_localhost.ZionSpaceManagerLocalhost spaceManagerGoerli *zion_goerli.ZionSpaceManagerGoerli + chainId int } -func NewZionAuthorization(rsAPI roomserver.ClientRoomserverAPI) (authorization.Authorization, error) { - err := godotenv.Load(".env") - if err != nil { - log.Errorln("error loading .env file", err) +func NewZionAuthorization( + cfg *config.ClientAPI, + rsAPI roomserver.ClientRoomserverAPI, +) (authorization.Authorization, error) { + if cfg.PublicKeyAuthentication.Ethereum.NetworkUrl == "" { + log.Errorf("No blockchain network url specified in config\n") + return nil, nil } var auth ZionAuthorization + auth.chainId = cfg.PublicKeyAuthentication.Ethereum.ChainID auth.store = NewStore(rsAPI) - localhost, err := newZionSpaceManagerLocalhost(os.Getenv(localhostEndpointUrl)) - if err != nil { - log.Errorln("error instantiating ZionSpaceManagerLocalhost", err) - } - auth.spaceManagerLocalhost = localhost + switch auth.chainId { + case 1337, 31337: + localhost, err := newZionSpaceManagerLocalhost(cfg.PublicKeyAuthentication.Ethereum.NetworkUrl) + if err != nil { + log.Errorln("error instantiating ZionSpaceManagerLocalhost", err) + } + auth.spaceManagerLocalhost = localhost - goerli, err := newZionSpaceManagerGoerli(os.Getenv(goerliEndpointUrl)) - if err != nil { - log.Errorln("error instantiating ZionSpaceManagerGoerli", err) + case 5: + goerli, err := newZionSpaceManagerGoerli(cfg.PublicKeyAuthentication.Ethereum.NetworkUrl) + if err != nil { + log.Errorln("error instantiating ZionSpaceManagerGoerli", err) + } + auth.spaceManagerGoerli = goerli + + default: + log.Errorf("Unsupported chain id: %d\n", auth.chainId) } - auth.spaceManagerGoerli = goerli return &auth, nil } @@ -66,13 +72,13 @@ func (za *ZionAuthorization) IsAllowed(args authorization.AuthorizationArgs) (bo return true, nil } - switch userIdentifier.ChainId { + switch za.chainId { case 1337, 31337: return za.isAllowedLocalhost(roomInfo, userIdentifier.AccountAddress, args.Permission) case 5: return za.isAllowedGoerli(roomInfo, userIdentifier.AccountAddress, args.Permission) default: - log.Errorf("Unsupported chain id: %d\n", userIdentifier.ChainId) + log.Errorf("Unsupported chain id: %d", userIdentifier.ChainId) } return false, nil From 3cd70dbf4506a9082c3dd53c3bf54fa835e8bf74 Mon Sep 17 00:00:00 2001 From: Kerem Date: Mon, 24 Oct 2022 17:30:49 -0400 Subject: [PATCH 63/75] added canonical dendrite.yaml --- dendrite-zion.yaml | 388 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 388 insertions(+) create mode 100644 dendrite-zion.yaml diff --git a/dendrite-zion.yaml b/dendrite-zion.yaml new file mode 100644 index 000000000..c2c6fc218 --- /dev/null +++ b/dendrite-zion.yaml @@ -0,0 +1,388 @@ +# This is the Dendrite configuration file. +# +# The configuration is split up into sections - each Dendrite component has a +# configuration section, in addition to the "global" section which applies to +# all components. +# +# At a minimum, to get started, you will need to update the settings in the +# "global" section for your deployment, and you will need to check that the +# database "connection_string" line in each component section is correct. +# +# Each component with a "database" section can accept the following formats +# for "connection_string": +# SQLite: file:filename.db +# file:///path/to/filename.db +# PostgreSQL: postgresql://user:pass@hostname/database?params=... +# +# SQLite is embedded into Dendrite and therefore no further prerequisites are +# needed for the database when using SQLite mode. However, performance with +# PostgreSQL is significantly better and recommended for multi-user deployments. +# SQLite is typically around 20-30% slower than PostgreSQL when tested with a +# small number of users and likely will perform worse still with a higher volume +# of users. +# +# The "max_open_conns" and "max_idle_conns" settings configure the maximum +# number of open/idle database connections. The value 0 will use the database +# engine default, and a negative value will use unlimited connections. The +# "conn_max_lifetime" option controls the maximum length of time a database +# connection can be idle in seconds - a negative value is unlimited. + +# The version of the configuration file. +version: 2 + +# Global Matrix configuration. This configuration applies to all components. +global: + # The domain name of this homeserver. + server_name: ${SERVER_NAME} + + # The path to the signing private key file, used to sign requests and events. + # Note that this is NOT the same private key as used for TLS! To generate a + # signing key, use "./bin/generate-keys --private-key matrix_key.pem". + private_key: matrix_key.pem + + # Global database connection pool, for PostgreSQL monolith deployments only. If + # this section is populated then you can omit the "database" blocks in all other + # sections. For polylith deployments, or monolith deployments using SQLite databases, + # you must configure the "database" block for each component instead. + database: + connection_string: ${DATABASE_CONNECTION_STRING} + max_open_conns: 10 + max_idle_conns: 5 + conn_max_lifetime: -1 + + # The paths and expiry timestamps (as a UNIX timestamp in millisecond precision) + # to old signing private keys that were formerly in use on this domain. These + # keys will not be used for federation request or event signing, but will be + # provided to any other homeserver that asks when trying to verify old events. + # old_private_keys: + # - private_key: old_matrix_key.pem + # expired_at: 1601024554498 + + # How long a remote server can cache our server signing key before requesting it + # again. Increasing this number will reduce the number of requests made by other + # servers for our key but increases the period that a compromised key will be + # considered valid by other homeservers. + key_validity_period: 168h0m0s + + # The server name to delegate server-server communications to, with optional port + # e.g. localhost:443 + well_known_server_name: "" + + # Lists of domains that the server will trust as identity servers to verify third + # party identifiers such as phone numbers and email addresses. + trusted_third_party_id_servers: + - matrix.org + - vector.im + + # Disables federation. Dendrite will not be able to make any outbound HTTP requests + # to other servers and the federation API will not be exposed. + disable_federation: false + + # Configures the handling of presence events. + presence: + # Whether inbound presence events are allowed, e.g. receiving presence events from other servers + enable_inbound: false + # Whether outbound presence events are allowed, e.g. sending presence events to other servers + enable_outbound: false + + # Server notices allows server admins to send messages to all users. + server_notices: + enabled: false + # The server localpart to be used when sending notices, ensure this is not yet taken + local_part: "_server" + # The displayname to be used when sending notices + display_name: "Server alerts" + # The mxid of the avatar to use + avatar_url: "" + # The roomname to be used when creating messages + room_name: "Server Alerts" + + # Configuration for NATS JetStream + jetstream: + # A list of NATS Server addresses to connect to. If none are specified, an + # internal NATS server will be started automatically when running Dendrite + # in monolith mode. It is required to specify the address of at least one + # NATS Server node if running in polylith mode. + addresses: + # - localhost:4222 + + # Keep all NATS streams in memory, rather than persisting it to the storage + # path below. This option is present primarily for integration testing and + # should not be used on a real world Dendrite deployment. + in_memory: false + + # Persistent directory to store JetStream streams in. This directory + # should be preserved across Dendrite restarts. + storage_path: ./ + + # The prefix to use for stream names for this homeserver - really only + # useful if running more than one Dendrite on the same NATS deployment. + topic_prefix: Dendrite + + # Configuration for Prometheus metric collection. + metrics: + # Whether or not Prometheus metrics are enabled. + enabled: false + + # HTTP basic authentication to protect access to monitoring. + basic_auth: + username: metrics + password: metrics + + # DNS cache options. The DNS cache may reduce the load on DNS servers + # if there is no local caching resolver available for use. + dns_cache: + # Whether or not the DNS cache is enabled. + enabled: false + + # Maximum number of entries to hold in the DNS cache, and + # for how long those items should be considered valid in seconds. + cache_size: 256 + cache_lifetime: "5m" # 5minutes; see https://pkg.go.dev/time@master#ParseDuration for more + +# Configuration for the Appservice API. +app_service_api: + internal_api: + listen: http://localhost:7777 # Only used in polylith deployments + connect: http://localhost:7777 # Only used in polylith deployments + database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Disable the validation of TLS certificates of appservices. This is + # not recommended in production since it may allow appservice traffic + # to be sent to an unverified endpoint. + disable_tls_validation: false + + # Appservice configuration files to load into this homeserver. + config_files: [] + +# Configuration for the Client API. +client_api: + internal_api: + listen: http://localhost:7771 # Only used in polylith deployments + connect: http://localhost:7771 # Only used in polylith deployments + external_api: + listen: http://[::]:8071 + + # Prevents new users from being able to register on this homeserver, except when + # using the registration shared secret below. + registration_disabled: false + + # Prevents new guest accounts from being created. Guest registration is also + # disabled implicitly by setting 'registration_disabled' above. + guests_disabled: true + + # If set, allows registration by anyone who knows the shared secret, regardless of + # whether registration is otherwise disabled. + registration_shared_secret: "" + + # Disable password authentication. + password_authentication_disabled: true # TODO: turn this into an environment variable - or create a separate dendrite.yaml for dev vs prod + + # public key authentication + public_key_authentication: + ethereum: + enabled: true + version: 1 + chain_id: 5 # [goerli, localhost-metamask, localhost-hardhat], see: https://chainlist.org/ + deployment_chain_id: ${CHAIN_ID} + networkUrl: ${BLOCKCHAIN_PROVIDER_URL} + enable_authz: ${ENABLE_AUTHZ} + + # Whether to require reCAPTCHA for registration. + enable_registration_captcha: false + + # Settings for ReCAPTCHA. + recaptcha_public_key: "" + recaptcha_private_key: "" + recaptcha_bypass_secret: "" + recaptcha_siteverify_api: "" + + # TURN server information that this homeserver should send to clients. + turn: + turn_user_lifetime: "" + turn_uris: [] + turn_shared_secret: "" + turn_username: "" + turn_password: "" + + # Settings for rate-limited endpoints. Rate limiting will kick in after the + # threshold number of "slots" have been taken by requests from a specific + # host. Each "slot" will be released after the cooloff time in milliseconds. + rate_limiting: + enabled: true + threshold: 5 + cooloff_ms: 500 + +# Configuration for the Federation API. +federation_api: + internal_api: + listen: http://localhost:7772 # Only used in polylith deployments + connect: http://localhost:7772 # Only used in polylith deployments + external_api: + listen: http://[::]:8072 + database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # How many times we will try to resend a failed transaction to a specific server. The + # backoff is 2**x seconds, so 1 = 2 seconds, 2 = 4 seconds, 3 = 8 seconds etc. + send_max_retries: 16 + + # Disable the validation of TLS certificates of remote federated homeservers. Do not + # enable this option in production as it presents a security risk! + disable_tls_validation: false + + # Perspective keyservers to use as a backup when direct key fetches fail. This may + # be required to satisfy key requests for servers that are no longer online when + # joining some rooms. + key_perspectives: + - server_name: matrix.org + keys: + - key_id: ed25519:auto + public_key: Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw + - key_id: ed25519:a_RXGa + public_key: l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ + + # This option will control whether Dendrite will prefer to look up keys directly + # or whether it should try perspective servers first, using direct fetches as a + # last resort. + prefer_direct_fetch: false + +# Configuration for the Key Server (for end-to-end encryption). +key_server: + internal_api: + listen: http://localhost:7779 # Only used in polylith deployments + connect: http://localhost:7779 # Only used in polylith deployments + database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Media API. +media_api: + internal_api: + listen: http://localhost:7774 # Only used in polylith deployments + connect: http://localhost:7774 # Only used in polylith deployments + external_api: + listen: http://[::]:8074 + database: + max_open_conns: 5 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # Storage path for uploaded media. May be relative or absolute. + base_path: ./media_store + + # The maximum allowed file size (in bytes) for media uploads to this homeserver + # (0 = unlimited). If using a reverse proxy, ensure it allows requests at + # least this large (e.g. client_max_body_size in nginx.) + max_file_size_bytes: 10485760 + + # Whether to dynamically generate thumbnails if needed. + dynamic_thumbnails: false + + # The maximum number of simultaneous thumbnail generators to run. + max_thumbnail_generators: 10 + + # A list of thumbnail sizes to be generated for media content. + thumbnail_sizes: + - width: 32 + height: 32 + method: crop + - width: 96 + height: 96 + method: crop + - width: 640 + height: 480 + method: scale + +# Configuration for experimental MSC's +mscs: + # A list of enabled MSC's + # Currently valid values are: + # - msc2836 (Threading, see https://github.com/matrix-org/matrix-doc/pull/2836) + # - msc2946 # (Spaces Summary, see https://github.com/matrix-org/matrix-doc/pull/2946) + mscs: [msc2946] + database: + max_open_conns: 5 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Room Server. +room_server: + internal_api: + listen: http://localhost:7770 # Only used in polylith deployments + connect: http://localhost:7770 # Only used in polylith deployments + database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + +# Configuration for the Sync API. +sync_api: + internal_api: + listen: http://localhost:7773 # Only used in polylith deployments + connect: http://localhost:7773 # Only used in polylith deployments + external_api: + listen: http://[::]:8073 + database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + + # This option controls which HTTP header to inspect to find the real remote IP + # address of the client. This is likely required if Dendrite is running behind + # a reverse proxy server. + # real_ip_header: X-Real-IP + +# Configuration for the User API. +user_api: + # The cost when hashing passwords on registration/login. Default: 10. Min: 4, Max: 31 + # See https://pkg.go.dev/golang.org/x/crypto/bcrypt for more information. + # Setting this lower makes registration/login consume less CPU resources at the cost of security + # should the database be compromised. Setting this higher makes registration/login consume more + # CPU resources but makes it harder to brute force password hashes. + # This value can be low if performing tests or on embedded Dendrite instances (e.g WASM builds) + # bcrypt_cost: 10 + internal_api: + listen: http://localhost:7781 # Only used in polylith deployments + connect: http://localhost:7781 # Only used in polylith deployments + account_database: + max_open_conns: 10 + max_idle_conns: 2 + conn_max_lifetime: -1 + # The length of time that a token issued for a relying party from + # /_matrix/client/r0/user/{userId}/openid/request_token endpoint + # is considered to be valid in milliseconds. + # The default lifetime is 3600000ms (60 minutes). + # openid_token_lifetime_ms: 3600000 + +# Configuration for Opentracing. +# See https://github.com/matrix-org/dendrite/tree/master/docs/tracing for information on +# how this works and how to set it up. +tracing: + enabled: false + jaeger: + serviceName: "" + disabled: false + rpc_metrics: false + tags: [] + sampler: null + reporter: null + headers: null + baggage_restrictions: null + throttler: null + +# Logging configuration +logging: + - type: std + level: info + - type: file + # The logging level, must be one of debug, info, warn, error, fatal, panic. + level: info + params: + path: ./logs From dd1bf9541afa93ac80d7c7e93388e2899b400258 Mon Sep 17 00:00:00 2001 From: Kerem Date: Mon, 24 Oct 2022 18:37:52 -0400 Subject: [PATCH 64/75] removed comment --- dendrite-zion.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dendrite-zion.yaml b/dendrite-zion.yaml index c2c6fc218..eda51f4d1 100644 --- a/dendrite-zion.yaml +++ b/dendrite-zion.yaml @@ -186,7 +186,7 @@ client_api: ethereum: enabled: true version: 1 - chain_id: 5 # [goerli, localhost-metamask, localhost-hardhat], see: https://chainlist.org/ + chain_id: 5 deployment_chain_id: ${CHAIN_ID} networkUrl: ${BLOCKCHAIN_PROVIDER_URL} enable_authz: ${ENABLE_AUTHZ} From 330ed77d47af89dae93e845a3b866382a581c73f Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:52:07 -0700 Subject: [PATCH 65/75] revert unwanted changes --- docs/caddy/monolith/Caddyfile | 109 +++++++++------------ docs/installation/10_optimisation.md | 71 -------------- sytest-blacklist | 2 +- sytest-whitelist | 3 +- userapi/storage/tables/stats_table_test.go | 1 - 5 files changed, 51 insertions(+), 135 deletions(-) delete mode 100644 docs/installation/10_optimisation.md diff --git a/docs/caddy/monolith/Caddyfile b/docs/caddy/monolith/Caddyfile index cd93f9e10..82567c4a6 100644 --- a/docs/caddy/monolith/Caddyfile +++ b/docs/caddy/monolith/Caddyfile @@ -1,68 +1,57 @@ +# Sample Caddyfile for using Caddy in front of Dendrite. +# +# Customize email address and domain names. +# Optional settings commented out. +# +# BE SURE YOUR DOMAINS ARE POINTED AT YOUR SERVER FIRST. +# Documentation: https://caddyserver.com/docs/ +# +# Bonus tip: If your IP address changes, use Caddy's +# dynamic DNS plugin to update your DNS records to +# point to your new IP automatically: +# https://github.com/mholt/caddy-dynamicdns +# + + +# Global options block { - # debug - admin off - email example@example.com - default_sni example.com - # Debug endpoint - # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory + # In case there is a problem with your certificates. + # email example@example.com + + # Turn off the admin endpoint if you don't need graceful config + # changes and/or are running untrusted code on your machine. + # admin off + + # Enable this if your clients don't send ServerName in TLS handshakes. + # default_sni example.com + + # Enable debug mode for verbose logging. + # debug + + # Use Let's Encrypt's staging endpoint for testing. + # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory + + # If you're port-forwarding HTTP/HTTPS ports from 80/443 to something + # else, enable these and put the alternate port numbers here. + # http_port 8080 + # https_port 8443 } -####################################################################### -# Snippets -#______________________________________________________________________ - -(handle_errors_maintenance) { - handle_errors { - @maintenance expression {http.error.status_code} == 502 - rewrite @maintenance maintenance.html - root * "/path/to/service/pages" - file_server - } -} - -(matrix-well-known-header) { - # Headers - header Access-Control-Allow-Origin "*" - header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" - header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization" - header Content-Type "application/json" -} - -####################################################################### - +# The server name of your matrix homeserver. This example shows +# "well-known delegation" from the registered domain to a subdomain, +# which is only needed if your server_name doesn't match your Matrix +# homeserver URL (i.e. you can show users a vanity domain that looks +# nice and is easy to remember but still have your Matrix server on +# its own subdomain or hosted service). example.com { - - # ... - - handle /.well-known/matrix/server { - import matrix-well-known-header - respond `{ "m.server": "matrix.example.com:443" }` 200 - } - - handle /.well-known/matrix/client { - import matrix-well-known-header - respond `{ "m.homeserver": { "base_url": "https://matrix.example.com" } }` 200 - } - - import handle_errors_maintenance -} - -example.com:8448 { - # server<->server HTTPS traffic - reverse_proxy http://dendrite-host:8008 + header /.well-known/matrix/* Content-Type application/json + header /.well-known/matrix/* Access-Control-Allow-Origin * + respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}` + respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://matrix.example.com"}}` } +# The actual domain name whereby your Matrix server is accessed. matrix.example.com { - - handle /_matrix/* { - # client<->server HTTPS traffic - reverse_proxy http://dendrite-host:8008 - } - - handle_path /* { - # Client webapp (Element SPA or ...) - file_server { - root /path/to/www/example.com/matrix-web-client/ - } - } + # Set localhost:8008 to the address of your Dendrite server, if different + reverse_proxy /_matrix/* localhost:8008 } diff --git a/docs/installation/10_optimisation.md b/docs/installation/10_optimisation.md deleted file mode 100644 index c19b7a75e..000000000 --- a/docs/installation/10_optimisation.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Optimise your installation -parent: Installation -has_toc: true -nav_order: 10 -permalink: /installation/start/optimisation ---- - -# Optimise your installation - -Now that you have Dendrite running, the following tweaks will improve the reliability -and performance of your installation. - -## File descriptor limit - -Most platforms have a limit on how many file descriptors a single process can open. All -connections made by Dendrite consume file descriptors — this includes database connections -and network requests to remote homeservers. When participating in large federated rooms -where Dendrite must talk to many remote servers, it is often very easy to exhaust default -limits which are quite low. - -We currently recommend setting the file descriptor limit to 65535 to avoid such -issues. Dendrite will log immediately after startup if the file descriptor limit is too low: - -``` -level=warning msg="IMPORTANT: Process file descriptor limit is currently 1024, it is recommended to raise the limit for Dendrite to at least 65535 to avoid issues" -``` - -UNIX systems have two limits: a hard limit and a soft limit. You can view the soft limit -by running `ulimit -Sn` and the hard limit with `ulimit -Hn`: - -```bash -$ ulimit -Hn -1048576 - -$ ulimit -Sn -1024 -``` - -Increase the soft limit before starting Dendrite: - -```bash -ulimit -Sn 65535 -``` - -The log line at startup should no longer appear if the limit is sufficient. - -If you are running under a systemd service, you can instead add `LimitNOFILE=65535` option -to the `[Service]` section of your service unit file. - -## DNS caching - -Dendrite has a built-in DNS cache which significantly reduces the load that Dendrite will -place on your DNS resolver. This may also speed up outbound federation. - -Consider enabling the DNS cache by modifying the `global` section of your configuration file: - -```yaml - dns_cache: - enabled: true - cache_size: 4096 - cache_lifetime: 600s -``` - -## Time synchronisation - -Matrix relies heavily on TLS which requires the system time to be correct. If the clock -drifts then you may find that federation no works reliably (or at all) and clients may -struggle to connect to your Dendrite server. - -Ensure that the time is synchronised on your system by enabling NTP sync. diff --git a/sytest-blacklist b/sytest-blacklist index adebaf00a..14edf398a 100644 --- a/sytest-blacklist +++ b/sytest-blacklist @@ -40,4 +40,4 @@ Accesing an AS-hosted room alias asks the AS server Guest users can join guest_access rooms # This will fail in HTTP API mode, so blacklisted for now -If a device list update goes missing, the server resyncs on the next one +If a device list update goes missing, the server resyncs on the next one \ No newline at end of file diff --git a/sytest-whitelist b/sytest-whitelist index 9f019fb40..e92ae6495 100644 --- a/sytest-whitelist +++ b/sytest-whitelist @@ -107,7 +107,6 @@ Lazy loading parameters in the filter are strictly boolean Can sync Can sync a joined room Newly joined room is included in an incremental sync -Newly joined room includes presence in incremental sync User is offline if they set_presence=offline in their sync Changes to state are included in an incremental sync A change to displayname should appear in incremental /sync @@ -755,4 +754,4 @@ Messages that notify from another user increment notification_count Messages that highlight from another user increment unread highlight count Notifications can be viewed with GET /notifications Can get rooms/{roomId}/messages for a departed room (SPEC-216) -Local device key changes appear in /keys/changes +Local device key changes appear in /keys/changes \ No newline at end of file diff --git a/userapi/storage/tables/stats_table_test.go b/userapi/storage/tables/stats_table_test.go index ad79bb2c8..c4aec552c 100644 --- a/userapi/storage/tables/stats_table_test.go +++ b/userapi/storage/tables/stats_table_test.go @@ -283,7 +283,6 @@ func Test_UserStatistics(t *testing.T) { t.Fatalf("unable to update daily visits stats: %v", err) } } - gotStats, _, err := statsDB.UserStatistics(ctx, nil) if err != nil { t.Fatalf("unexpected error: %v", err) From dead9ec2c4085cf1e124fde98fd3e9209f5e28ca Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:52:57 -0700 Subject: [PATCH 66/75] Remove CaddyFile --- docs/caddy/monolith/CaddyFile | 68 ----------------------------------- docs/caddy/monolith/Caddyfile | 57 ----------------------------- 2 files changed, 125 deletions(-) delete mode 100644 docs/caddy/monolith/CaddyFile delete mode 100644 docs/caddy/monolith/Caddyfile diff --git a/docs/caddy/monolith/CaddyFile b/docs/caddy/monolith/CaddyFile deleted file mode 100644 index cd93f9e10..000000000 --- a/docs/caddy/monolith/CaddyFile +++ /dev/null @@ -1,68 +0,0 @@ -{ - # debug - admin off - email example@example.com - default_sni example.com - # Debug endpoint - # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory -} - -####################################################################### -# Snippets -#______________________________________________________________________ - -(handle_errors_maintenance) { - handle_errors { - @maintenance expression {http.error.status_code} == 502 - rewrite @maintenance maintenance.html - root * "/path/to/service/pages" - file_server - } -} - -(matrix-well-known-header) { - # Headers - header Access-Control-Allow-Origin "*" - header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" - header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization" - header Content-Type "application/json" -} - -####################################################################### - -example.com { - - # ... - - handle /.well-known/matrix/server { - import matrix-well-known-header - respond `{ "m.server": "matrix.example.com:443" }` 200 - } - - handle /.well-known/matrix/client { - import matrix-well-known-header - respond `{ "m.homeserver": { "base_url": "https://matrix.example.com" } }` 200 - } - - import handle_errors_maintenance -} - -example.com:8448 { - # server<->server HTTPS traffic - reverse_proxy http://dendrite-host:8008 -} - -matrix.example.com { - - handle /_matrix/* { - # client<->server HTTPS traffic - reverse_proxy http://dendrite-host:8008 - } - - handle_path /* { - # Client webapp (Element SPA or ...) - file_server { - root /path/to/www/example.com/matrix-web-client/ - } - } -} diff --git a/docs/caddy/monolith/Caddyfile b/docs/caddy/monolith/Caddyfile deleted file mode 100644 index 82567c4a6..000000000 --- a/docs/caddy/monolith/Caddyfile +++ /dev/null @@ -1,57 +0,0 @@ -# Sample Caddyfile for using Caddy in front of Dendrite. -# -# Customize email address and domain names. -# Optional settings commented out. -# -# BE SURE YOUR DOMAINS ARE POINTED AT YOUR SERVER FIRST. -# Documentation: https://caddyserver.com/docs/ -# -# Bonus tip: If your IP address changes, use Caddy's -# dynamic DNS plugin to update your DNS records to -# point to your new IP automatically: -# https://github.com/mholt/caddy-dynamicdns -# - - -# Global options block -{ - # In case there is a problem with your certificates. - # email example@example.com - - # Turn off the admin endpoint if you don't need graceful config - # changes and/or are running untrusted code on your machine. - # admin off - - # Enable this if your clients don't send ServerName in TLS handshakes. - # default_sni example.com - - # Enable debug mode for verbose logging. - # debug - - # Use Let's Encrypt's staging endpoint for testing. - # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory - - # If you're port-forwarding HTTP/HTTPS ports from 80/443 to something - # else, enable these and put the alternate port numbers here. - # http_port 8080 - # https_port 8443 -} - -# The server name of your matrix homeserver. This example shows -# "well-known delegation" from the registered domain to a subdomain, -# which is only needed if your server_name doesn't match your Matrix -# homeserver URL (i.e. you can show users a vanity domain that looks -# nice and is easy to remember but still have your Matrix server on -# its own subdomain or hosted service). -example.com { - header /.well-known/matrix/* Content-Type application/json - header /.well-known/matrix/* Access-Control-Allow-Origin * - respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}` - respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://matrix.example.com"}}` -} - -# The actual domain name whereby your Matrix server is accessed. -matrix.example.com { - # Set localhost:8008 to the address of your Dendrite server, if different - reverse_proxy /_matrix/* localhost:8008 -} From 15091daa37f61fef1fd3eca7b05fa230535f7b4b Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:53:45 -0700 Subject: [PATCH 67/75] revert Caddyfile --- docs/caddy/monolith/Caddyfile | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 docs/caddy/monolith/Caddyfile diff --git a/docs/caddy/monolith/Caddyfile b/docs/caddy/monolith/Caddyfile new file mode 100644 index 000000000..82567c4a6 --- /dev/null +++ b/docs/caddy/monolith/Caddyfile @@ -0,0 +1,57 @@ +# Sample Caddyfile for using Caddy in front of Dendrite. +# +# Customize email address and domain names. +# Optional settings commented out. +# +# BE SURE YOUR DOMAINS ARE POINTED AT YOUR SERVER FIRST. +# Documentation: https://caddyserver.com/docs/ +# +# Bonus tip: If your IP address changes, use Caddy's +# dynamic DNS plugin to update your DNS records to +# point to your new IP automatically: +# https://github.com/mholt/caddy-dynamicdns +# + + +# Global options block +{ + # In case there is a problem with your certificates. + # email example@example.com + + # Turn off the admin endpoint if you don't need graceful config + # changes and/or are running untrusted code on your machine. + # admin off + + # Enable this if your clients don't send ServerName in TLS handshakes. + # default_sni example.com + + # Enable debug mode for verbose logging. + # debug + + # Use Let's Encrypt's staging endpoint for testing. + # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory + + # If you're port-forwarding HTTP/HTTPS ports from 80/443 to something + # else, enable these and put the alternate port numbers here. + # http_port 8080 + # https_port 8443 +} + +# The server name of your matrix homeserver. This example shows +# "well-known delegation" from the registered domain to a subdomain, +# which is only needed if your server_name doesn't match your Matrix +# homeserver URL (i.e. you can show users a vanity domain that looks +# nice and is easy to remember but still have your Matrix server on +# its own subdomain or hosted service). +example.com { + header /.well-known/matrix/* Content-Type application/json + header /.well-known/matrix/* Access-Control-Allow-Origin * + respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}` + respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://matrix.example.com"}}` +} + +# The actual domain name whereby your Matrix server is accessed. +matrix.example.com { + # Set localhost:8008 to the address of your Dendrite server, if different + reverse_proxy /_matrix/* localhost:8008 +} From f87fd94b1b3d476ceef49f5e7c61d067c732f707 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Tue, 25 Oct 2022 09:29:31 -0700 Subject: [PATCH 68/75] fix spelling in README --- zion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zion/README.md b/zion/README.md index c411bbd96..98031d91c 100644 --- a/zion/README.md +++ b/zion/README.md @@ -1,5 +1,5 @@ # Purpose -Additional packaages added for the Zion project, nothing in here should be in the Matrix Dendrite upstream, nor in the herenotthere/dendrite-fork. +Additional packages added for the Zion project, nothing in here should be in the Matrix Dendrite upstream, nor in the herenotthere/dendrite-fork. The zion_space_manager_(mainnet|rinkeby|localhost).go files are generated as new versions of the smart contracts are build and deployed. The bindings are in this location so they can be built alongside the dendrite server in the build process. From c4afa77636800164b851c555e08ac9780ec170d1 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:56:36 -0700 Subject: [PATCH 69/75] Fix dendrite config to use env for chain_id and enable_authz (#49) * Fix config to support env variables --- clientapi/auth/login_publickey_ethereum.go | 2 +- .../auth/login_publickey_ethereum_test.go | 7 ++-- clientapi/authorization/authorization.go | 2 +- clientapi/routing/register_publickey_test.go | 7 ++-- dendrite-sample.monolith.yaml | 2 +- dendrite-sample.polylith.yaml | 2 +- dendrite-zion.yaml | 5 +-- setup/config/config.go | 27 ++++++------- setup/config/config_publickey.go | 40 ++++++++++++++++--- test/publickey_utils.go | 2 +- zion/zion_authorization.go | 2 +- 11 files changed, 64 insertions(+), 34 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index abf1d2032..1ce41d886 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -129,7 +129,7 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri } // Error if the chainId is not supported by the server. - if pk.config.PublicKeyAuthentication.Ethereum.ChainID != message.GetChainID() { + if pk.config.PublicKeyAuthentication.Ethereum.GetChainID() != message.GetChainID() { return false, jsonerror.Forbidden("chainId") } diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go index a8d3a710a..cd7db05b2 100644 --- a/clientapi/auth/login_publickey_ethereum_test.go +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "net/http" + "strconv" "strings" "testing" @@ -43,9 +44,9 @@ func createLoginContext(_ *testing.T) *loginContext { PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ Ethereum: config.EthereumAuthConfig{ - Enabled: true, - Version: 1, - ChainID: testutil.EthereumTestNetworkId, + Enabled: true, + Version: 1, + ConfigChainID: strconv.Itoa(testutil.EthereumTestNetworkId), }, }, } diff --git a/clientapi/authorization/authorization.go b/clientapi/authorization/authorization.go index 3efb37e39..f81513d76 100644 --- a/clientapi/authorization/authorization.go +++ b/clientapi/authorization/authorization.go @@ -10,7 +10,7 @@ import ( func NewAuthorization(cfg *config.ClientAPI, rsAPI roomserver.ClientRoomserverAPI) authorization.Authorization { // Load authorization manager for Zion - if cfg.PublicKeyAuthentication.Ethereum.EnableAuthz { + if cfg.PublicKeyAuthentication.Ethereum.GetEnableAuthZ() { auth, err := zion.NewZionAuthorization(cfg, rsAPI) if err != nil { diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index e1a225cbd..961873b89 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -19,6 +19,7 @@ import ( "encoding/json" "fmt" "net/http" + "strconv" "strings" "testing" @@ -48,9 +49,9 @@ func createRegisterContext(_ *testing.T) *registerContext { PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ Ethereum: config.EthereumAuthConfig{ - Enabled: true, - Version: 1, - ChainID: testutil.EthereumTestNetworkId, + Enabled: true, + Version: 1, + ConfigChainID: strconv.Itoa(testutil.EthereumTestNetworkId), }, }, } diff --git a/dendrite-sample.monolith.yaml b/dendrite-sample.monolith.yaml index 715534528..cbe930c51 100644 --- a/dendrite-sample.monolith.yaml +++ b/dendrite-sample.monolith.yaml @@ -179,7 +179,7 @@ client_api: enabled: false version: 1 chain_id: 31337 - networkUrl: "http://127.0.0.1:8545" + network_url: "http://127.0.0.1:8545" # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used diff --git a/dendrite-sample.polylith.yaml b/dendrite-sample.polylith.yaml index 6475fb398..89e272518 100644 --- a/dendrite-sample.polylith.yaml +++ b/dendrite-sample.polylith.yaml @@ -175,7 +175,7 @@ client_api: enabled: false version: 1 chain_id: 31337 - networkUrl: "http://127.0.0.1:8545" + network_url: "http://127.0.0.1:8545" # Whether to require reCAPTCHA for registration. If you have enabled registration # then this is HIGHLY RECOMMENDED to reduce the risk of your homeserver being used diff --git a/dendrite-zion.yaml b/dendrite-zion.yaml index eda51f4d1..da999baa5 100644 --- a/dendrite-zion.yaml +++ b/dendrite-zion.yaml @@ -186,9 +186,8 @@ client_api: ethereum: enabled: true version: 1 - chain_id: 5 - deployment_chain_id: ${CHAIN_ID} - networkUrl: ${BLOCKCHAIN_PROVIDER_URL} + chain_id: ${CHAIN_ID} + network_url: ${BLOCKCHAIN_PROVIDER_URL} enable_authz: ${ENABLE_AUTHZ} # Whether to require reCAPTCHA for registration. diff --git a/setup/config/config.go b/setup/config/config.go index d30dc4107..dedb5b031 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -23,7 +23,6 @@ import ( "os" "path/filepath" "regexp" - "strconv" "strings" "github.com/joho/godotenv" @@ -587,7 +586,9 @@ Replace selected config with environment variables */ func (config *Dendrite) replaceWithEnvVariables() { - // Replace selected fields with env variables + // If env variable is set, get the value from the env + // variable and replace it in each supported field. + err := godotenv.Load(".env") if err != nil { logrus.Errorln("error loading .env file", err) @@ -604,23 +605,21 @@ func (config *Dendrite) replaceWithEnvVariables() { ), ) - // If env variable is set, convert the deployment chain IDs from the env - // variable into []int and replace the ChainIDs field. if config.ClientAPI.PublicKeyAuthentication.Ethereum.Enabled { - strChainId := replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.DeploymentChainID) - if strChainId != "" { - id, err := strconv.Atoi(strings.TrimSpace(strChainId)) - if err == nil { - config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainID = id - } - } + config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigChainID = + replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigChainID) - config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl = replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl) + config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl = + replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl) + + config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigEnableAuthz = + replaceWithEnvVariables(config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigEnableAuthz) logrus.Infof( - "Supported Ethereum chain ID=%d, network URL=%s", - config.ClientAPI.PublicKeyAuthentication.Ethereum.ChainID, + "Supported Ethereum chain_id=%v, network_url=%v, enable_authz=%v", + config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigChainID, config.ClientAPI.PublicKeyAuthentication.Ethereum.NetworkUrl, + config.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigEnableAuthz, ) } } diff --git a/setup/config/config_publickey.go b/setup/config/config_publickey.go index 647b648c1..6d73717da 100644 --- a/setup/config/config_publickey.go +++ b/setup/config/config_publickey.go @@ -1,6 +1,9 @@ package config import ( + "strconv" + "strings" + "github.com/matrix-org/dendrite/clientapi/auth/authtypes" ) @@ -20,10 +23,37 @@ func (p EthereumAuthParams) GetParams() interface{} { type EthereumAuthConfig struct { Enabled bool `yaml:"enabled"` Version uint `yaml:"version"` - ChainID int `yaml:"chain_id"` - DeploymentChainID string `yaml:"deployment_chain_id"` // For deployment: use env variable string to override the chain ID. - NetworkUrl string `yaml:"networkUrl"` // Blockchain network provider URL - EnableAuthz bool `yaml:"enable_authz"` // Flag to enable / disable authorization during development + NetworkUrl string `yaml:"network_url"` // Blockchain network provider URL + ConfigChainID string `yaml:"chain_id"` // Blockchain chain ID. Env variable can replace this property. + ConfigEnableAuthz string `yaml:"enable_authz"` // Enable / disable authorization during development. Will be removed when feature is done. + chainID int + enableAuthz bool +} + +func (c *EthereumAuthConfig) GetChainID() int { + if c.ConfigChainID != "" { + v := strings.TrimSpace(c.ConfigChainID) + id, err := strconv.Atoi(v) + if err == nil { + c.chainID = id + } + // No need to do this again. + c.ConfigChainID = "" + } + return c.chainID +} + +func (c *EthereumAuthConfig) GetEnableAuthZ() bool { + if c.ConfigEnableAuthz != "" { + v := strings.TrimSpace(c.ConfigEnableAuthz) + boolValue, err := strconv.ParseBool(v) + if err == nil { + c.enableAuthz = boolValue + } + // No need to do this again. + c.ConfigEnableAuthz = "" + } + return c.enableAuthz } type PublicKeyAuthentication struct { @@ -48,7 +78,7 @@ func (pk *PublicKeyAuthentication) GetPublicKeyRegistrationParams() map[string]i if pk.Ethereum.Enabled { p := EthereumAuthParams{ Version: pk.Ethereum.Version, - ChainID: pk.Ethereum.ChainID, + ChainID: pk.Ethereum.GetChainID(), } params[authtypes.LoginTypePublicKeyEthereum] = p } diff --git a/test/publickey_utils.go b/test/publickey_utils.go index 497cb7527..0b045c954 100644 --- a/test/publickey_utils.go +++ b/test/publickey_utils.go @@ -27,7 +27,7 @@ import ( "github.com/spruceid/siwe-go" ) -const EthereumTestNetworkId = 1337 // Localhost chain ID +const EthereumTestNetworkId int = 31337 // Localhost chain ID const TestServerName = "localhost" type EthereumTestWallet struct { diff --git a/zion/zion_authorization.go b/zion/zion_authorization.go index d009fde94..fbb991a31 100644 --- a/zion/zion_authorization.go +++ b/zion/zion_authorization.go @@ -36,7 +36,7 @@ func NewZionAuthorization( var auth ZionAuthorization - auth.chainId = cfg.PublicKeyAuthentication.Ethereum.ChainID + auth.chainId = cfg.PublicKeyAuthentication.Ethereum.GetChainID() auth.store = NewStore(rsAPI) switch auth.chainId { From ed8b5d09eb8df9dec0358fab6fbd38643f82efb8 Mon Sep 17 00:00:00 2001 From: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:43:21 -0700 Subject: [PATCH 70/75] refresh fork with upstream --- .github/workflows/schedules.yaml | 128 ++++++++++++++++++ build/docker/Dockerfile.demo-yggdrasil | 25 ++++ build/gobind-pinecone/monolith.go | 52 +++++-- clientapi/auth/login_publickey_ethereum.go | 2 +- clientapi/auth/password.go | 2 +- clientapi/routing/admin.go | 4 +- clientapi/routing/auth_fallback.go | 18 +-- clientapi/routing/createroom.go | 25 +++- clientapi/routing/directory.go | 49 ++++++- clientapi/routing/directory_public.go | 43 ++++-- clientapi/routing/directory_public_test.go | 2 +- clientapi/routing/login.go | 6 +- clientapi/routing/membership.go | 9 +- clientapi/routing/openid.go | 2 +- clientapi/routing/profile.go | 34 ++++- clientapi/routing/redaction.go | 3 +- clientapi/routing/register.go | 6 +- clientapi/routing/routing.go | 23 +++- clientapi/routing/sendevent.go | 5 +- clientapi/threepid/invites.go | 2 +- clientapi/userutil/userutil.go | 13 +- clientapi/userutil/userutil_test.go | 25 +++- cmd/dendrite-demo-yggdrasil/yggconn/node.go | 86 ++++++------ dendrite-sample.monolith.yaml | 16 ++- dendrite-sample.polylith.yaml | 16 ++- federationapi/consumers/keychange.go | 44 +++--- federationapi/consumers/presence.go | 10 +- federationapi/consumers/receipts.go | 34 ++--- federationapi/consumers/sendtodevice.go | 36 ++--- federationapi/consumers/typing.go | 32 ++--- federationapi/federationapi.go | 4 +- federationapi/federationapi_keys_test.go | 2 +- federationapi/federationapi_test.go | 1 + federationapi/internal/federationclient.go | 2 +- federationapi/internal/keys.go | 2 +- federationapi/internal/perform.go | 2 +- federationapi/producers/syncapi.go | 5 +- federationapi/queue/destinationqueue.go | 64 +++++---- federationapi/queue/queue.go | 30 +++- federationapi/queue/queue_test.go | 2 +- federationapi/routing/publicrooms.go | 25 +++- federationapi/routing/routing.go | 50 +++---- federationapi/storage/postgres/storage.go | 4 +- federationapi/storage/shared/storage.go | 4 +- federationapi/storage/sqlite3/storage.go | 4 +- federationapi/storage/storage.go | 6 +- federationapi/storage/storage_test.go | 2 +- go.mod | 28 ++-- go.sum | 124 ++++++----------- keyserver/internal/internal.go | 63 ++++----- roomserver/api/api.go | 1 + roomserver/api/perform.go | 6 +- roomserver/api/query.go | 7 +- roomserver/internal/perform/perform_admin.go | 11 +- roomserver/internal/perform/perform_invite.go | 4 +- roomserver/internal/perform/perform_join.go | 23 ++-- roomserver/internal/perform/perform_leave.go | 6 +- roomserver/internal/perform/perform_peek.go | 6 +- .../internal/perform/perform_publish.go | 2 +- roomserver/internal/perform/perform_unpeek.go | 2 +- .../internal/perform/perform_upgrade.go | 37 +++-- roomserver/internal/query/query.go | 2 +- roomserver/storage/interface.go | 4 +- .../20221027084407_published_appservice.go | 45 ++++++ .../storage/postgres/published_table.go | 55 ++++++-- roomserver/storage/shared/storage.go | 8 +- .../20221027084407_published_appservice.go | 64 +++++++++ roomserver/storage/sqlite3/published_table.go | 55 ++++++-- roomserver/storage/tables/interface.go | 4 +- .../storage/tables/published_table_test.go | 33 ++++- setup/config/config_clientapi.go | 18 +++ setup/config/config_global.go | 15 ++ setup/config/config_userapi.go | 4 + setup/mscs/msc2836/msc2836.go | 2 +- setup/mscs/msc2946/msc2946.go | 2 +- syncapi/routing/memberships.go | 21 +-- syncapi/streams/stream_pdu.go | 15 +- sytest-whitelist | 4 +- test/testrig/base.go | 2 + userapi/api/api.go | 31 ++++- userapi/internal/api.go | 100 +++++++++++--- userapi/internal/api_logintoken.go | 8 +- userapi/userapi.go | 3 +- userapi/userapi_test.go | 4 +- 84 files changed, 1230 insertions(+), 550 deletions(-) create mode 100644 .github/workflows/schedules.yaml create mode 100644 build/docker/Dockerfile.demo-yggdrasil create mode 100644 roomserver/storage/postgres/deltas/20221027084407_published_appservice.go create mode 100644 roomserver/storage/sqlite3/deltas/20221027084407_published_appservice.go diff --git a/.github/workflows/schedules.yaml b/.github/workflows/schedules.yaml new file mode 100644 index 000000000..c07917248 --- /dev/null +++ b/.github/workflows/schedules.yaml @@ -0,0 +1,128 @@ +name: Scheduled + +on: + schedule: + - cron: '0 0 * * *' # every day at midnight + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + # run go test with different go versions + test: + timeout-minutes: 20 + name: Unit tests (Go ${{ matrix.go }}) + runs-on: ubuntu-latest + # Service containers to run with `container-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:13-alpine + # Provide the password for postgres + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dendrite + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + strategy: + fail-fast: false + matrix: + go: ["1.18", "1.19"] + steps: + - uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go${{ matrix.go }}-test-race-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go${{ matrix.go }}-test-race- + - run: go test -race ./... + env: + POSTGRES_HOST: localhost + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dendrite + + # Dummy step to gate other tests on without repeating the whole list + initial-tests-done: + name: Initial tests passed + needs: [test] + runs-on: ubuntu-latest + if: ${{ !cancelled() }} # Run this even if prior jobs were skipped + steps: + - name: Check initial tests passed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + + # run Sytest in different variations + sytest: + timeout-minutes: 60 + needs: initial-tests-done + name: "Sytest (${{ matrix.label }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - label: SQLite + + - label: SQLite, full HTTP APIs + api: full-http + + - label: PostgreSQL + postgres: postgres + + - label: PostgreSQL, full HTTP APIs + postgres: postgres + api: full-http + container: + image: matrixdotorg/sytest-dendrite:latest + volumes: + - ${{ github.workspace }}:/src + env: + POSTGRES: ${{ matrix.postgres && 1}} + API: ${{ matrix.api && 1 }} + SYTEST_BRANCH: ${{ github.head_ref }} + RACE_DETECTION: 1 + steps: + - uses: actions/checkout@v2 + - name: Run Sytest + run: /bootstrap.sh dendrite + working-directory: /src + - name: Summarise results.tap + if: ${{ always() }} + run: /sytest/scripts/tap_to_gha.pl /logs/results.tap + - name: Sytest List Maintenance + if: ${{ always() }} + run: /src/show-expected-fail-tests.sh /logs/results.tap /src/sytest-whitelist /src/sytest-blacklist + continue-on-error: true # not fatal + - name: Are We Synapse Yet? + if: ${{ always() }} + run: /src/are-we-synapse-yet.py /logs/results.tap -v + continue-on-error: true # not fatal + - name: Upload Sytest logs + uses: actions/upload-artifact@v2 + if: ${{ always() }} + with: + name: Sytest Logs - ${{ job.status }} - (Dendrite, ${{ join(matrix.*, ', ') }}) + path: | + /logs/results.tap + /logs/**/*.log* diff --git a/build/docker/Dockerfile.demo-yggdrasil b/build/docker/Dockerfile.demo-yggdrasil new file mode 100644 index 000000000..76bf35823 --- /dev/null +++ b/build/docker/Dockerfile.demo-yggdrasil @@ -0,0 +1,25 @@ +FROM docker.io/golang:1.19-alpine AS base + +RUN apk --update --no-cache add bash build-base + +WORKDIR /build + +COPY . /build + +RUN mkdir -p bin +RUN go build -trimpath -o bin/ ./cmd/dendrite-demo-yggdrasil +RUN go build -trimpath -o bin/ ./cmd/create-account +RUN go build -trimpath -o bin/ ./cmd/generate-keys + +FROM alpine:latest +LABEL org.opencontainers.image.title="Dendrite (Yggdrasil demo)" +LABEL org.opencontainers.image.description="Next-generation Matrix homeserver written in Go" +LABEL org.opencontainers.image.source="https://github.com/matrix-org/dendrite" +LABEL org.opencontainers.image.licenses="Apache-2.0" + +COPY --from=base /build/bin/* /usr/bin/ + +VOLUME /etc/dendrite +WORKDIR /etc/dendrite + +ENTRYPOINT ["/usr/bin/dendrite-demo-yggdrasil"] diff --git a/build/gobind-pinecone/monolith.go b/build/gobind-pinecone/monolith.go index 4a96e4bef..adb4e40a6 100644 --- a/build/gobind-pinecone/monolith.go +++ b/build/gobind-pinecone/monolith.go @@ -101,18 +101,46 @@ func (m *DendriteMonolith) SessionCount() int { return len(m.PineconeQUIC.Protocol("matrix").Sessions()) } -func (m *DendriteMonolith) RegisterNetworkInterface(name string, index int, mtu int, up bool, broadcast bool, loopback bool, pointToPoint bool, multicast bool, addrs string) { - m.PineconeMulticast.RegisterInterface(pineconeMulticast.InterfaceInfo{ - Name: name, - Index: index, - Mtu: mtu, - Up: up, - Broadcast: broadcast, - Loopback: loopback, - PointToPoint: pointToPoint, - Multicast: multicast, - Addrs: addrs, - }) +type InterfaceInfo struct { + Name string + Index int + Mtu int + Up bool + Broadcast bool + Loopback bool + PointToPoint bool + Multicast bool + Addrs string +} + +type InterfaceRetriever interface { + CacheCurrentInterfaces() int + GetCachedInterface(index int) *InterfaceInfo +} + +func (m *DendriteMonolith) RegisterNetworkCallback(intfCallback InterfaceRetriever) { + callback := func() []pineconeMulticast.InterfaceInfo { + count := intfCallback.CacheCurrentInterfaces() + intfs := []pineconeMulticast.InterfaceInfo{} + for i := 0; i < count; i++ { + iface := intfCallback.GetCachedInterface(i) + if iface != nil { + intfs = append(intfs, pineconeMulticast.InterfaceInfo{ + Name: iface.Name, + Index: iface.Index, + Mtu: iface.Mtu, + Up: iface.Up, + Broadcast: iface.Broadcast, + Loopback: iface.Loopback, + PointToPoint: iface.PointToPoint, + Multicast: iface.Multicast, + Addrs: iface.Addrs, + }) + } + } + return intfs + } + m.PineconeMulticast.RegisterNetworkCallback(callback) } func (m *DendriteMonolith) SetMulticastEnabled(enabled bool) { diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index 1ce41d886..33c0a16d4 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -67,7 +67,7 @@ func (pk LoginPublicKeyEthereum) GetType() string { } func (pk LoginPublicKeyEthereum) AccountExists(ctx context.Context) (string, *jsonerror.MatrixError) { - localPart, err := userutil.ParseUsernameParam(pk.UserId, &pk.config.Matrix.ServerName) + localPart, _, err := userutil.ParseUsernameParam(pk.UserId, pk.config.Matrix) if err != nil { // userId does not exist return "", jsonerror.Forbidden("the address is incorrect, or the account does not exist.") diff --git a/clientapi/auth/password.go b/clientapi/auth/password.go index 3bd77eb3d..1c8540e41 100644 --- a/clientapi/auth/password.go +++ b/clientapi/auth/password.go @@ -74,7 +74,7 @@ func (t *LoginTypePassword) Login(ctx context.Context, req interface{}) (*Login, JSON: jsonerror.BadJSON("A password must be supplied."), } } - localpart, err := userutil.ParseUsernameParam(username, &t.Config.Matrix.ServerName) + localpart, _, err := userutil.ParseUsernameParam(username, t.Config.Matrix) if err != nil { return nil, &util.JSONResponse{ Code: http.StatusUnauthorized, diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go index 89c269f1a..69bca13be 100644 --- a/clientapi/routing/admin.go +++ b/clientapi/routing/admin.go @@ -70,7 +70,7 @@ func AdminEvacuateUser(req *http.Request, cfg *config.ClientAPI, device *userapi if err != nil { return util.MessageResponse(http.StatusBadRequest, err.Error()) } - if domain != cfg.Matrix.ServerName { + if !cfg.Matrix.IsLocalServerName(domain) { return util.JSONResponse{ Code: http.StatusBadRequest, JSON: jsonerror.MissingArgument("User ID must belong to this server."), @@ -169,7 +169,7 @@ func AdminMarkAsStale(req *http.Request, cfg *config.ClientAPI, keyAPI api.Clien if err != nil { return util.MessageResponse(http.StatusBadRequest, err.Error()) } - if domain == cfg.Matrix.ServerName { + if cfg.Matrix.IsLocalServerName(domain) { return util.JSONResponse{ Code: http.StatusBadRequest, JSON: jsonerror.InvalidParam("Can not mark local device list as stale"), diff --git a/clientapi/routing/auth_fallback.go b/clientapi/routing/auth_fallback.go index abfe830fb..ad870993e 100644 --- a/clientapi/routing/auth_fallback.go +++ b/clientapi/routing/auth_fallback.go @@ -31,8 +31,7 @@ const recaptchaTemplate = ` Authentication - +