Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ioctl][ws][#2] add w3bstream contracts address configurations #4280

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ioctl/cmd/ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func init() {
config.ReadConfig.IPFSGateway, config.TranslateInLang(_flagIPFSGatewayUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsRegisterContract, "contract-address",
config.ReadConfig.WsRegisterContract, config.TranslateInLang(_flagContractAddressUsages, config.UILanguage),
&config.ReadConfig.WsProjectRegisterContract, "contract-address",
config.ReadConfig.WsProjectDevicesContract, config.TranslateInLang(_flagContractAddressUsages, config.UILanguage),
)
}
2 changes: 1 addition & 1 deletion ioctl/cmd/ws/wsproject.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func init() {
wsProject.AddCommand(wsProjectQuery)
wsProject.AddCommand(wsProjectConfig)

wsProjectRegisterContractAddress = config.ReadConfig.WsRegisterContract
wsProjectRegisterContractAddress = config.ReadConfig.WsProjectRegisterContract
wsProjectIPFSEndpoint = config.ReadConfig.IPFSEndpoint
wsProjectIPFSGatewayEndpoint = config.ReadConfig.IPFSGateway
}
Expand Down
32 changes: 28 additions & 4 deletions ioctl/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ type Config struct {
IPFSEndpoint string `json:"ipfsEndpoint" yaml:"ipfsEndpoint"`
// IPFSGateway ipfs gateway for resource fetching (with scheme)
IPFSGateway string `json:"ipfsGateway" yaml:"ipfsGateway"`
// WsRegisterContract w3bstream project register contract address
WsRegisterContract string `json:"wsRegisterContract" yaml:"wsRegisterContract"`
// WsProjectRegisterContract w3bstream project register contract address
WsProjectRegisterContract string `json:"wsProjectRegisterContract" yaml:"wsProjectRegisterContract"`
// WsProjectStoreContract w3bstream project store contract address
WsProjectStoreContract string `json:"wsProjectStoreContract" yaml:"wsProjectStoreContract"`
// WsFleetManagementContract w3bstream fleet management contract address
WsFleetManagementContract string `json:"wsFleetManagementContract" yaml:"wsFleetManagementContract"`
// WsProverStoreContract w3bstream Prover store contract address
WsProverStoreContract string `json:"wsProverStoreContract" yaml:"wsProverStoreContract"`
// WsProjectDevicesContract w3bstream Project devices contract address
WsProjectDevicesContract string `json:"wsProjectDevicesContract" yaml:"wsProjectDevicesContract"`
}

var (
Expand Down Expand Up @@ -140,8 +148,24 @@ func init() {
ReadConfig.IPFSGateway = _defaultIPFSGateway
completeness = false
}
if ReadConfig.WsRegisterContract == "" {
ReadConfig.WsRegisterContract = _defaultWsRegisterContract
if ReadConfig.WsProjectRegisterContract == "" {
ReadConfig.WsProjectRegisterContract = _defaultWsProjectRegisterContract
completeness = false
}
if ReadConfig.WsProjectStoreContract == "" {
ReadConfig.WsProjectStoreContract = _defaultWsProjectStoreContract
completeness = false
}
if ReadConfig.WsFleetManagementContract == "" {
ReadConfig.WsFleetManagementContract = _defaultWsFleetManagementContract
completeness = false
}
if ReadConfig.WsProverStoreContract == "" {
ReadConfig.WsProverStoreContract = _defaultWsProverStoreContract
completeness = false
}
if ReadConfig.WsProjectDevicesContract == "" {
ReadConfig.WsProjectDevicesContract = _defaultWsProjectDevicesContract
completeness = false
}
if !completeness {
Expand Down
46 changes: 37 additions & 9 deletions ioctl/config/configsetget.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ const (
_defaultIPFSEndpoint = "ipfs.mainnet.iotex.io"
// _defaultIPFSGateway default IPFS gateway for resource fetching
_defaultIPFSGateway = "https://ipfs.io"
// _defaultWsRegisterContract default project register contract address
_defaultWsRegisterContract = "0x184C72E39a642058CCBc369485c7fd614B40a03d"
// _defaultWsProjectRegisterContract default project register contract address
_defaultWsProjectRegisterContract = "0x80b49a5788DcE3eAbFcc46780dEA965602f869C9"
// _defaultWsProjectStoreContract default project store contract address
_defaultWsProjectStoreContract = "0xf9B976C0127BC38E56fb97B0B1e1408e6F2737CE"
// _defaultWsFleetManagementContract default fleet management contract address
_defaultWsFleetManagementContract = "0x698D8cEfe0c2E603DCA4B7815cb8E67F251eCF37"
// _defaultWsProverStoreContract default prover store contract address
_defaultWsProverStoreContract = "0xa9bed62ADB1708E0c501664C9CE6A34BC4Fc246b"
// _defaultWsProjectDevicesContract default project devices contract address
_defaultWsProjectDevicesContract = "0x3d6b6c7bDB72e8BF73780f433342759d8b329Ca5"
)

var (
_supportedLanguage = []string{"English", "中文"}
_validArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsRegisterContract"}
_validGetArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "analyserEndpoint", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsRegisterContract", "all"}
_validArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsProjectRegisterContract", "wsProjectStoreContract", "wsFleetManagementContract", "wsProverStoreContract", "wsProjectDevicesContract"}
_validGetArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "analyserEndpoint", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsProjectRegisterContract", "wsProjectStoreContract", "wsFleetManagementContract", "wsProverStoreContract", "wsProjectDevicesContract", "all"}
_validExpl = []string{"iotexscan", "iotxplorer"}
_endpointCompile = regexp.MustCompile("^" + _endpointPattern + "$")
)
Expand Down Expand Up @@ -163,8 +171,16 @@ func Get(arg string) error {
fmt.Println(ReadConfig.IPFSEndpoint)
case "ipfsGateway":
fmt.Println(ReadConfig.IPFSGateway)
case "wsRegisterContract":
fmt.Println(ReadConfig.WsRegisterContract)
case "wsProjectRegisterContract":
fmt.Println(ReadConfig.WsProjectRegisterContract)
case "wsProjectStoreContract":
fmt.Println(ReadConfig.WsProjectStoreContract)
case "wsFleetManagementContract":
fmt.Println(ReadConfig.WsFleetManagementContract)
case "wsProverStoreContract":
fmt.Println(ReadConfig.WsProverStoreContract)
case "wsProjectDevicesContract":
fmt.Println(ReadConfig.WsProjectDevicesContract)
case "all":
fmt.Println(ReadConfig.String())
}
Expand Down Expand Up @@ -299,8 +315,16 @@ func set(args []string) error {
ReadConfig.IPFSEndpoint = args[1]
case "ipfsGateway":
ReadConfig.IPFSGateway = args[1]
case "wsRegisterContract":
ReadConfig.WsRegisterContract = args[1]
case "wsProjectRegisterContract":
ReadConfig.WsProjectRegisterContract = args[1]
case "wsProjectStoreContract":
ReadConfig.WsProjectStoreContract = args[1]
case "wsFleetManagementContract":
ReadConfig.WsFleetManagementContract = args[1]
case "wsProverStoreContract":
ReadConfig.WsProverStoreContract = args[1]
case "wsProjectDevicesContract":
ReadConfig.WsProjectDevicesContract = args[1]
}
err := writeConfig()
if err != nil {
Expand All @@ -322,7 +346,11 @@ func reset() error {
ReadConfig.WsEndpoint = _defaultWsEndpoint
ReadConfig.IPFSEndpoint = _defaultIPFSEndpoint
ReadConfig.IPFSGateway = _defaultIPFSGateway
ReadConfig.WsRegisterContract = _defaultWsRegisterContract
ReadConfig.WsProjectRegisterContract = _defaultWsProjectRegisterContract
ReadConfig.WsProjectStoreContract = _defaultWsProjectStoreContract
ReadConfig.WsFleetManagementContract = _defaultWsFleetManagementContract
ReadConfig.WsProverStoreContract = _defaultWsProverStoreContract
ReadConfig.WsProjectDevicesContract = _defaultWsProjectDevicesContract

err := writeConfig()
if err != nil {
Expand Down
62 changes: 51 additions & 11 deletions ioctl/newcmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,22 @@ const (
_defaultIPFSEndpoint = "ipfs.mainnet.iotex.io"
// _defaultIPFSGateway default IPFS gateway for resource fetching
_defaultIPFSGateway = "https://ipfs.io"
// _defaultWsRegisterContract default w3bstream project register contract address
_defaultWsRegisterContract = "0x184C72E39a642058CCBc369485c7fd614B40a03d"
// _defaultWsProjectRegisterContract default project register contract address
_defaultWsProjectRegisterContract = "0x80b49a5788DcE3eAbFcc46780dEA965602f869C9"
// _defaultWsProjectStoreContract default project store contract address
_defaultWsProjectStoreContract = "0xf9B976C0127BC38E56fb97B0B1e1408e6F2737CE"
// _defaultWsFleetManagementContract default fleet management contract address
_defaultWsFleetManagementContract = "0x698D8cEfe0c2E603DCA4B7815cb8E67F251eCF37"
// _defaultWsProverStoreContract default prover store contract address
_defaultWsProverStoreContract = "0xa9bed62ADB1708E0c501664C9CE6A34BC4Fc246b"
// _defaultWsProjectDevicesContract default project device contract address
_defaultWsProjectDevicesContract = "0x3d6b6c7bDB72e8BF73780f433342759d8b329Ca5"
)

var (
_supportedLanguage = []string{"English", "中文"}
_validArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsRegisterContract"}
_validGetArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "analyserEndpoint", "wsRegisterContract", "all"}
_validArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "wsProjectRegisterContract", "wsProjectStoreContract", "wsFleetManagementContract", "wsProverStoreContract", "wsProjectDevicesContract"}
_validGetArgs = []string{"endpoint", "wallet", "explorer", "defaultacc", "language", "nsv2height", "wsEndpoint", "ipfsEndpoint", "ipfsGateway", "analyserEndpoint", "wsProjectRegisterContract", "wsProjectStoreContract", "wsFleetManagementContract", "wsProverStoreContract", "wsProjectDevicesContract", "all"}
_validExpl = []string{"iotexscan", "iotxplorer"}
_endpointCompile = regexp.MustCompile("^" + _endpointPattern + "$")
_configDir = os.Getenv("HOME") + "/.config/ioctl/default"
Expand Down Expand Up @@ -133,8 +141,20 @@ func InitConfig() (config.Config, string, error) {
if info.readConfig.IPFSGateway == "" {
info.readConfig.IPFSGateway = _defaultIPFSGateway
}
if info.readConfig.WsRegisterContract == "" {
info.readConfig.WsRegisterContract = _defaultWsRegisterContract
if info.readConfig.WsProjectRegisterContract == "" {
info.readConfig.WsProjectRegisterContract = _defaultWsProjectRegisterContract
}
if info.readConfig.WsProjectStoreContract == "" {
info.readConfig.WsProjectStoreContract = _defaultWsProjectStoreContract
}
if info.readConfig.WsFleetManagementContract == "" {
info.readConfig.WsFleetManagementContract = _defaultWsFleetManagementContract
}
if info.readConfig.WsProverStoreContract == "" {
info.readConfig.WsProverStoreContract = _defaultWsProverStoreContract
}
if info.readConfig.WsProjectDevicesContract == "" {
info.readConfig.WsProjectDevicesContract = _defaultWsProjectDevicesContract
}
if !completeness {
if err = info.writeConfig(); err != nil {
Expand Down Expand Up @@ -168,7 +188,11 @@ func (c *info) reset() error {
c.readConfig.WsEndpoint = _defaultWsEndpoint
c.readConfig.IPFSEndpoint = _defaultIPFSEndpoint
c.readConfig.IPFSGateway = _defaultIPFSGateway
c.readConfig.WsRegisterContract = _defaultWsRegisterContract
c.readConfig.WsProjectRegisterContract = _defaultWsProjectRegisterContract
c.readConfig.WsProjectStoreContract = _defaultWsProjectStoreContract
c.readConfig.WsFleetManagementContract = _defaultWsFleetManagementContract
c.readConfig.WsProverStoreContract = _defaultWsProverStoreContract
c.readConfig.WsProjectDevicesContract = _defaultWsProjectDevicesContract

err := c.writeConfig()
if err != nil {
Expand Down Expand Up @@ -233,8 +257,16 @@ func (c *info) set(args []string, insecure bool, client ioctl.Client) (string, e
c.readConfig.IPFSEndpoint = args[1]
case "ipfsGateway":
c.readConfig.IPFSGateway = args[1]
case "wsRegisterContract":
c.readConfig.WsRegisterContract = args[1]
case "wsProjectRegisterContract":
c.readConfig.WsProjectRegisterContract = args[1]
case "wsProjectStoreContract":
c.readConfig.WsProjectStoreContract = args[1]
case "wsFleetManagementContract":
c.readConfig.WsFleetManagementContract = args[1]
case "wsProverStoreContract":
c.readConfig.WsProverStoreContract = args[1]
case "wsProjectDevicesContract":
c.readConfig.WsProjectDevicesContract = args[1]
default:
return "", config.ErrConfigNotMatch
}
Expand Down Expand Up @@ -276,8 +308,16 @@ func (c *info) get(arg string) (string, error) {
return c.readConfig.IPFSEndpoint, nil
case "ipfsGateway":
return c.readConfig.IPFSGateway, nil
case "wsRegisterContract":
return c.readConfig.WsRegisterContract, nil
case "wsProjectRegisterContract":
return c.readConfig.WsProjectRegisterContract, nil
case "wsProjectStoreContract":
return c.readConfig.WsProjectStoreContract, nil
case "wsFleetManagementContract":
return c.readConfig.WsFleetManagementContract, nil
case "wsProverStoreContract":
return c.readConfig.WsProverStoreContract, nil
case "wsProjectDevicesContract":
return c.readConfig.WsProjectDevicesContract, nil
case "all":
return jsonString(c.readConfig)
default:
Expand Down
Loading
Loading