mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
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.
This commit is contained in:
parent
425b28f2cc
commit
1c61837bfd
|
|
@ -26,7 +26,6 @@ type EthereumAuthConfig struct {
|
|||
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. todo: remove this flag when feature is done.
|
||||
ContractVersion string // todo: remove this setting when v2 migration is done.
|
||||
chainID int
|
||||
enableAuthz bool // todo: remove this flag when feature is done.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ var (
|
|||
version = flag.Bool("version", false, "Shows the current version and exits immediately.")
|
||||
enableRegistrationWithoutVerification = flag.Bool("really-enable-open-registration", false, "This allows open registration without secondary verification (reCAPTCHA). This is NOT RECOMMENDED and will SIGNIFICANTLY increase the risk that your server will be used to send spam or conduct attacks, which may result in your server being banned from rooms.")
|
||||
enableAuthorizationChecks = flag.Bool("enable-authz", false, "Enables authorization checks (aka space/channel gating).")
|
||||
contractVersion = flag.String("contract-version", "v1", "Contract version to use. Valid values are v1 and v2. Default is v1. Remove this flag when v2 migration is done.")
|
||||
)
|
||||
|
||||
// ParseFlags parses the commandline flags and uses them to create a config.
|
||||
|
|
@ -61,11 +60,5 @@ func ParseFlags(monolith bool) *config.Dendrite {
|
|||
cfg.ClientAPI.PublicKeyAuthentication.Ethereum.ConfigEnableAuthz = strconv.FormatBool(*enableAuthorizationChecks)
|
||||
logrus.Info("--enable-authz flag is set to ", *enableAuthorizationChecks)
|
||||
|
||||
// cmdline --contract-version. Contract version to use. Valid values are v1
|
||||
// and v2. Default is v1.
|
||||
// todo: Remove this flag when v2 migration is done.
|
||||
cfg.ClientAPI.PublicKeyAuthentication.Ethereum.ContractVersion = *contractVersion
|
||||
logrus.Info("--contract-version flag is set to ", *contractVersion)
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package zion
|
|||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/matrix-org/dendrite/authorization"
|
||||
roomserver "github.com/matrix-org/dendrite/roomserver/api"
|
||||
|
|
@ -12,13 +11,6 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type ContractVersion uint8
|
||||
|
||||
const (
|
||||
v1 ContractVersion = 1
|
||||
v2 ContractVersion = 2
|
||||
)
|
||||
|
||||
var ErrSpaceDisabled = errors.New("space disabled")
|
||||
var ErrChannelDisabled = errors.New("channel disabled")
|
||||
|
||||
|
|
@ -26,11 +18,6 @@ func NewZionAuthorization(cfg *config.ClientAPI, roomQueryAPI roomserver.QueryEv
|
|||
// create the authorization states
|
||||
store := NewStore(roomQueryAPI)
|
||||
chainId := cfg.PublicKeyAuthentication.Ethereum.GetChainID()
|
||||
contractVersion := v1 // default
|
||||
if cfg.PublicKeyAuthentication.Ethereum.ContractVersion == "v2" {
|
||||
contractVersion = v2
|
||||
}
|
||||
|
||||
// initialise the eth client.
|
||||
if cfg.PublicKeyAuthentication.Ethereum.NetworkUrl == "" {
|
||||
log.Errorf("No blockchain network url specified in config\n")
|
||||
|
|
@ -41,22 +28,9 @@ func NewZionAuthorization(cfg *config.ClientAPI, roomQueryAPI roomserver.QueryEv
|
|||
log.Errorf("Cannot connect to eth client %v\n", cfg.PublicKeyAuthentication.Ethereum.NetworkUrl)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch contractVersion {
|
||||
case v1:
|
||||
return NewZionAuthorizationV1(
|
||||
chainId,
|
||||
ethClient,
|
||||
store,
|
||||
)
|
||||
case v2:
|
||||
return NewZionAuthorizationV2(
|
||||
chainId,
|
||||
ethClient,
|
||||
store,
|
||||
)
|
||||
default:
|
||||
errMsg := fmt.Sprintf("Unsupported contract version: %d", contractVersion)
|
||||
return nil, errors.New(errMsg)
|
||||
}
|
||||
return NewZionAuthorizationV2(
|
||||
chainId,
|
||||
ethClient,
|
||||
store,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue