dendrite/zion/zion_authorization.go
Tak Wai Wong 1c61837bfd fix client and dendrite to always use v2 smart contracts (#1259)
Remove the logic to switch between v1 and v2 smart contracts. Always use
v2.
2023-01-19 13:11:35 -08:00

37 lines
1 KiB
Go

package zion
import (
_ "embed"
"errors"
"github.com/matrix-org/dendrite/authorization"
roomserver "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
log "github.com/sirupsen/logrus"
)
var ErrSpaceDisabled = errors.New("space disabled")
var ErrChannelDisabled = errors.New("channel disabled")
func NewZionAuthorization(cfg *config.ClientAPI, roomQueryAPI roomserver.QueryEventsAPI) (authorization.Authorization, error) {
// create the authorization states
store := NewStore(roomQueryAPI)
chainId := cfg.PublicKeyAuthentication.Ethereum.GetChainID()
// initialise the eth client.
if cfg.PublicKeyAuthentication.Ethereum.NetworkUrl == "" {
log.Errorf("No blockchain network url specified in config\n")
return nil, nil
}
ethClient, err := GetEthClient(cfg.PublicKeyAuthentication.Ethereum.NetworkUrl)
if err != nil {
log.Errorf("Cannot connect to eth client %v\n", cfg.PublicKeyAuthentication.Ethereum.NetworkUrl)
return nil, err
}
return NewZionAuthorizationV2(
chainId,
ethClient,
store,
)
}