Skip to content

Commit

Permalink
[ioctl][ws][#3] project sub command to support interaction with ws co…
Browse files Browse the repository at this point in the history
…ntracts (#4281)


* feat(ioctl/ws): ioctl support ws project contracts interactions
  • Loading branch information
saitofun authored May 30, 2024
1 parent c4a08ba commit 66bf477
Show file tree
Hide file tree
Showing 14 changed files with 949 additions and 1,139 deletions.
63 changes: 56 additions & 7 deletions ioctl/cmd/ws/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"

"github.com/iotexproject/iotex-core/ioctl/config"
"github.com/iotexproject/iotex-core/ioctl/flag"
)

var (
Expand All @@ -13,12 +14,14 @@ var (
Short: config.TranslateInLang(wsCmdShorts, config.UILanguage),
}

// wsCmdShorts command multi-lang supports
wsCmdShorts = map[config.Language]string{
config.English: "W3bstream node operations",
config.Chinese: "W3bstream节点操作",
}
)

// flags multi-language
var (
_flagChainEndpointUsages = map[config.Language]string{
config.English: "set endpoint for once",
config.Chinese: "一次设置端点",
Expand All @@ -39,16 +42,46 @@ var (
config.Chinese: "一次设置ipfs网关",
}

_flagContractAddressUsages = map[config.Language]string{
_flagProjectRegisterContractAddressUsages = map[config.Language]string{
config.English: "set w3bsteram project register contract address for once",
config.Chinese: "一次设置w3bstream项目注册合约地址",
}

_flagProjectStoreContractAddressUsages = map[config.Language]string{
config.English: "set w3bsteram project store contract address for once",
config.Chinese: "一次设置w3bstream项目存储合约地址",
}

_flagFleetManagementContractAddressUsages = map[config.Language]string{
config.English: "set w3bsteram fleet management contract address for once",
config.Chinese: "一次设置w3bstream项目管理合约地址",
}

_flagProverStoreContractAddressUsages = map[config.Language]string{
config.English: "set w3bsteram prover store contract address for once",
config.Chinese: "一次设置w3bstream prover存储合约地址",
}
_flagTransferAmountUsages = map[config.Language]string{
config.English: "amount(rau) need to pay, default 0",
config.Chinese: "需要支付的token数量(单位rau), 默认0",
}

_flagProjectDevicesContractAddressUsages = map[config.Language]string{
config.English: "set w3bsteram project devices contract address for once",
config.Chinese: "一次设置w3bstream project设备合约地址",
}
_flagProjectIDUsages = map[config.Language]string{
config.English: "project id",
config.Chinese: "项目ID",
}
)

func init() {
WsCmd.AddCommand(wsMessage)
WsCmd.AddCommand(wsProject)
var (
// transferAmount
transferAmount = flag.NewUint64VarP("amount", "", 0, config.TranslateInLang(_flagTransferAmountUsages, config.UILanguage))
)

func init() {
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.Endpoint, "endpoint",
config.ReadConfig.Endpoint, config.TranslateInLang(_flagChainEndpointUsages, config.UILanguage),
Expand All @@ -66,7 +99,23 @@ func init() {
config.ReadConfig.IPFSGateway, config.TranslateInLang(_flagIPFSGatewayUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsProjectRegisterContract, "contract-address",
config.ReadConfig.WsProjectDevicesContract, config.TranslateInLang(_flagContractAddressUsages, config.UILanguage),
&config.ReadConfig.WsProjectRegisterContract, "project-register-contract",
config.ReadConfig.WsProjectRegisterContract, config.TranslateInLang(_flagProjectRegisterContractAddressUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsProjectStoreContract, "project-store-contract",
config.ReadConfig.WsProjectStoreContract, config.TranslateInLang(_flagProjectStoreContractAddressUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsFleetManagementContract, "fleet-management-contract",
config.ReadConfig.WsFleetManagementContract, config.TranslateInLang(_flagFleetManagementContractAddressUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsProverStoreContract, "prover-store-contract",
config.ReadConfig.WsProverStoreContract, config.TranslateInLang(_flagProverStoreContractAddressUsages, config.UILanguage),
)
WsCmd.PersistentFlags().StringVar(
&config.ReadConfig.WsProjectDevicesContract, "project-devices-contract",
config.ReadConfig.WsProjectDevicesContract, config.TranslateInLang(_flagProjectDevicesContractAddressUsages, config.UILanguage),
)
}
56 changes: 0 additions & 56 deletions ioctl/cmd/ws/ws_test.go

This file was deleted.

2 changes: 2 additions & 0 deletions ioctl/cmd/ws/wsmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var (
func init() {
wsMessage.AddCommand(wsMessageSend)
wsMessage.AddCommand(wsMessageQuery)

WsCmd.AddCommand(wsMessage)
}

type sendMessageReq struct {
Expand Down
4 changes: 0 additions & 4 deletions ioctl/cmd/ws/wsmessagesend.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ var (
config.Chinese: "向w3bstream发送消息请求zk证明",
}

_flagProjectIDUsages = map[config.Language]string{
config.English: "project id",
config.Chinese: "项目ID",
}
_flagProjectVersionUsages = map[config.Language]string{
config.English: "project version",
config.Chinese: "项目版本",
Expand Down
Loading

0 comments on commit 66bf477

Please sign in to comment.