Skip to content

Commit

Permalink
Base com (#143)
Browse files Browse the repository at this point in the history
* update spaceMgt

* update sdk to v0.3.4
  • Loading branch information
AstaFrode committed Jul 11, 2023
1 parent cc94287 commit adb992b
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 182 deletions.
11 changes: 6 additions & 5 deletions cmd/console/claimCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/CESSProject/cess-bucket/node"
cess "github.com/CESSProject/cess-go-sdk"
"github.com/CESSProject/cess-go-sdk/config"
"github.com/CESSProject/p2p-go/out"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -45,7 +46,7 @@ func Command_Claim_Runfunc(cmd *cobra.Command, args []string) {
// Build profile instances
n.Confile, err = buildAuthenticationConfig(cmd)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

Expand All @@ -58,20 +59,20 @@ func Command_Claim_Runfunc(cmd *cobra.Command, args []string) {
cess.TransactionTimeout(configs.TimeToWaitEvent),
)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

txhash, err := n.ClaimRewards()
if err != nil {
if txhash == "" {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}
configs.Warn(txhash)
out.Warn(txhash)
os.Exit(0)
}

configs.Ok(txhash)
out.Ok(txhash)
os.Exit(0)
}
12 changes: 6 additions & 6 deletions cmd/console/configCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"os"
"path/filepath"

"github.com/CESSProject/cess-bucket/configs"
"github.com/CESSProject/cess-bucket/pkg/confile"
"github.com/CESSProject/p2p-go/out"
"github.com/spf13/cobra"
)

Expand All @@ -36,24 +36,24 @@ func init() {
func CreateConfigFile() {
f, err := os.Create(confile.DefaultProfile)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
return
}
defer f.Close()
_, err = f.WriteString(confile.TempleteProfile)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
return
}
err = f.Sync()
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
return
}
pwd, err := os.Getwd()
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
return
}
configs.Ok(filepath.Join(pwd, confile.DefaultProfile))
out.Ok(filepath.Join(pwd, confile.DefaultProfile))
}
11 changes: 6 additions & 5 deletions cmd/console/exitCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/CESSProject/cess-bucket/node"
cess "github.com/CESSProject/cess-go-sdk"
"github.com/CESSProject/cess-go-sdk/config"
"github.com/CESSProject/p2p-go/out"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -45,7 +46,7 @@ func Command_Exit_Runfunc(cmd *cobra.Command, args []string) {
// Build profile instances
n.Confile, err = buildAuthenticationConfig(cmd)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

Expand All @@ -58,20 +59,20 @@ func Command_Exit_Runfunc(cmd *cobra.Command, args []string) {
cess.TransactionTimeout(configs.TimeToWaitEvent),
)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

txhash, err := n.Exit(configs.Name)
if err != nil {
if txhash == "" {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}
configs.Warn(txhash)
out.Warn(txhash)
os.Exit(0)
}

configs.Ok(txhash)
out.Ok(txhash)
os.Exit(0)
}
15 changes: 8 additions & 7 deletions cmd/console/increaseCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
cess "github.com/CESSProject/cess-go-sdk"
"github.com/CESSProject/cess-go-sdk/config"
"github.com/CESSProject/cess-go-sdk/core/pattern"
"github.com/CESSProject/p2p-go/out"
"github.com/spf13/cobra"
)

Expand All @@ -41,20 +42,20 @@ func Command_Increase_Runfunc(cmd *cobra.Command, args []string) {
)

if len(os.Args) < 3 {
configs.Err("Please enter the stakes amount")
out.Err("Please enter the stakes amount")
os.Exit(1)
}

stakes, ok := new(big.Int).SetString(os.Args[2]+pattern.TokenPrecision_CESS, 10)
if !ok {
configs.Err("Please enter the correct stakes amount")
out.Err("Please enter the correct stakes amount")
os.Exit(1)
}

// Build profile instances
n.Confile, err = buildAuthenticationConfig(cmd)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

Expand All @@ -67,20 +68,20 @@ func Command_Increase_Runfunc(cmd *cobra.Command, args []string) {
cess.TransactionTimeout(configs.TimeToWaitEvent),
)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

txhash, err := n.IncreaseStakingAmount(stakes)
if err != nil {
if txhash == "" {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}
configs.Warn(txhash)
out.Warn(txhash)
os.Exit(0)
}

configs.Ok(txhash)
out.Ok(txhash)
os.Exit(0)
}
7 changes: 4 additions & 3 deletions cmd/console/rewardCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/CESSProject/cess-bucket/node"
cess "github.com/CESSProject/cess-go-sdk"
"github.com/CESSProject/cess-go-sdk/config"
"github.com/CESSProject/p2p-go/out"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -48,7 +49,7 @@ func Command_Reward_Runfunc(cmd *cobra.Command, args []string) {
// Build profile instances
n.Confile, err = buildAuthenticationConfig(cmd)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

Expand All @@ -61,13 +62,13 @@ func Command_Reward_Runfunc(cmd *cobra.Command, args []string) {
cess.TransactionTimeout(configs.TimeToWaitEvent),
)
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}

rewardInfo, err := n.QuaryStorageNodeRewardInfo(n.GetStakingPublickey())
if err != nil {
configs.Err(err.Error())
out.Err(err.Error())
os.Exit(1)
}
var total string
Expand Down
Loading

0 comments on commit adb992b

Please sign in to comment.