You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.0 KiB
54 lines
1.0 KiB
package cmd
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/woop-chain/go-sdk/pkg/address"
|
|
"github.com/woop-chain/go-sdk/pkg/common"
|
|
"github.com/woop-chain/go-sdk/pkg/validation"
|
|
)
|
|
|
|
type oneAddress struct {
|
|
address string
|
|
}
|
|
|
|
func (oneAddress oneAddress) String() string {
|
|
return oneAddress.address
|
|
}
|
|
|
|
func (oneAddress *oneAddress) Set(s string) error {
|
|
err := validation.ValidateAddress(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = address.Bech32ToAddress(s)
|
|
if err != nil {
|
|
return errors.Wrap(err, "not a valid one address")
|
|
}
|
|
oneAddress.address = s
|
|
return nil
|
|
}
|
|
|
|
func (oneAddress oneAddress) Type() string {
|
|
return "one-address"
|
|
}
|
|
|
|
type chainIDWrapper struct {
|
|
chainID *common.ChainID
|
|
}
|
|
|
|
func (chainIDWrapper chainIDWrapper) String() string {
|
|
return chainIDWrapper.chainID.Name
|
|
}
|
|
|
|
func (chainIDWrapper *chainIDWrapper) Set(s string) error {
|
|
chain, err := common.StringToChainID(s)
|
|
chainIDWrapper.chainID = chain
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (chainIDWrapper chainIDWrapper) Type() string {
|
|
return "chain-id"
|
|
}
|
|
|