mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
chore(sonar): define a constant instead of duplicating literal
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
702b9d6f7e
commit
0e045fa703
@ -14,6 +14,8 @@ import (
|
||||
|
||||
const (
|
||||
flagSerialPort = "serial-port"
|
||||
|
||||
SerialPort = "/dev/ttyACM0"
|
||||
)
|
||||
|
||||
func TrustWalletCmd() *cobra.Command {
|
||||
@ -43,7 +45,7 @@ Provided mnemonics must be 12 or 24 words long and adhere to bip39.`,
|
||||
Args: cobra.RangeArgs(0, 1),
|
||||
}
|
||||
|
||||
cmd.Flags().String(flagSerialPort, "/dev/ttyACM0", "The serial port your Trust Wallet is connected to")
|
||||
cmd.Flags().String(flagSerialPort, SerialPort, "The serial port your Trust Wallet is connected to")
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
@ -107,7 +109,7 @@ raw planetmint key (hex encoded)`,
|
||||
Args: cobra.ExactArgs(0),
|
||||
}
|
||||
|
||||
cmd.Flags().String(flagSerialPort, "/dev/ttyACM0", "The serial port your Trust Wallet is connected to")
|
||||
cmd.Flags().String(flagSerialPort, SerialPort, "The serial port your Trust Wallet is connected to")
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
|
@ -15,6 +15,10 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
const (
|
||||
SerialPort = "/dev/ttyACM0"
|
||||
)
|
||||
|
||||
// E2ETestSuite struct definition of machine suite
|
||||
type E2ETestSuite struct {
|
||||
suite.Suite
|
||||
@ -111,7 +115,7 @@ func (s *E2ETestSuite) TestOccSigning() {
|
||||
msg := banktypes.NewMsgSend(addr, val.Address, coin)
|
||||
|
||||
libConfig := lib.GetConfig()
|
||||
libConfig.SetSerialPort("/dev/ttyACM0")
|
||||
libConfig.SetSerialPort(SerialPort)
|
||||
|
||||
out, err := lib.BroadcastTxWithFileLock(addr, msg)
|
||||
s.Require().NoError(err)
|
||||
@ -124,7 +128,7 @@ func (s *E2ETestSuite) TestOccSigning() {
|
||||
|
||||
// set sample mnemonic on trust wallet
|
||||
func setKeys() (string, error) {
|
||||
connector, err := trustwallet.NewTrustWalletConnector("/dev/ttyACM0")
|
||||
connector, err := trustwallet.NewTrustWalletConnector(SerialPort)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -132,7 +136,7 @@ func setKeys() (string, error) {
|
||||
}
|
||||
|
||||
func loadKeys() (*trustwallet.PlanetMintKeys, error) {
|
||||
connector, err := trustwallet.NewTrustWalletConnector("/dev/ttyACM0")
|
||||
connector, err := trustwallet.NewTrustWalletConnector(SerialPort)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -8,6 +8,12 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
NoDataReturned = "no data returned"
|
||||
NoPublicKeyReturned = "no public key returned"
|
||||
NoSignatureReturned = "no signature returned"
|
||||
)
|
||||
|
||||
var (
|
||||
keys *PlanetMintKeys
|
||||
)
|
||||
@ -47,7 +53,7 @@ func (t *Connector) ValiseGet() (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no data returned")
|
||||
return "", errors.New(NoDataReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) CreateMnemonic() (string, error) {
|
||||
@ -58,7 +64,7 @@ func (t *Connector) CreateMnemonic() (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no data returned")
|
||||
return "", errors.New(NoDataReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) InjectPlanetminkeyToSE050(slot int) (bool, error) {
|
||||
@ -69,7 +75,7 @@ func (t *Connector) InjectPlanetminkeyToSE050(slot int) (bool, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1] == "0", nil
|
||||
}
|
||||
return false, errors.New("no data returned")
|
||||
return false, errors.New(NoDataReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) RecoverFromMnemonic(mnemonic string) (string, error) {
|
||||
@ -80,7 +86,7 @@ func (t *Connector) RecoverFromMnemonic(mnemonic string) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no data returned")
|
||||
return "", errors.New(NoDataReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) GetPlanetmintKeys() (*PlanetMintKeys, error) {
|
||||
@ -111,7 +117,7 @@ func (t *Connector) GetSeedSE050() (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no data returned")
|
||||
return "", errors.New(NoDataReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) SignHashWithPlanetmint(dataToSign string) (string, error) {
|
||||
@ -122,7 +128,7 @@ func (t *Connector) SignHashWithPlanetmint(dataToSign string) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no signature returned")
|
||||
return "", errors.New(NoSignatureReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) SignHashWithRDDL(dataToSign string) (string, error) {
|
||||
@ -133,7 +139,7 @@ func (t *Connector) SignHashWithRDDL(dataToSign string) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no signature returned")
|
||||
return "", errors.New(NoSignatureReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) CreateOptegaKeypair(ctx int) (string, error) {
|
||||
@ -144,7 +150,7 @@ func (t *Connector) CreateOptegaKeypair(ctx int) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no public key returned")
|
||||
return "", errors.New(NoPublicKeyReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) SignWithOptega(ctx int, dataToSign, pubkey string) (string, error) {
|
||||
@ -155,7 +161,7 @@ func (t *Connector) SignWithOptega(ctx int, dataToSign, pubkey string) (string,
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no signature returned")
|
||||
return "", errors.New(NoSignatureReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) UnwrapPublicKey(publicKey string) (bool, string) {
|
||||
@ -187,7 +193,7 @@ func (t *Connector) CreateSE050KeypairNIST(ctx int) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no public key returned")
|
||||
return "", errors.New(NoPublicKeyReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) GetPublicKeyFromSE050(ctx int) (string, error) {
|
||||
@ -202,7 +208,7 @@ func (t *Connector) GetPublicKeyFromSE050(ctx int) (string, error) {
|
||||
}
|
||||
return pubKey, nil
|
||||
}
|
||||
return "", errors.New("no public key returned")
|
||||
return "", errors.New(NoPublicKeyReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) SignWithSE050(dataToSign string, ctx int) (string, error) {
|
||||
@ -213,7 +219,7 @@ func (t *Connector) SignWithSE050(dataToSign string, ctx int) (string, error) {
|
||||
if len(response.Data) > 1 {
|
||||
return response.Data[1], nil
|
||||
}
|
||||
return "", errors.New("no signature returned")
|
||||
return "", errors.New(NoSignatureReturned)
|
||||
}
|
||||
|
||||
func (t *Connector) VerifySE050Signature(dataToSign, signature string, ctx int) (bool, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user