Skip to content

Commit

Permalink
update sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode committed May 11, 2024
1 parent 26c8651 commit 2376c28
Show file tree
Hide file tree
Showing 24 changed files with 382 additions and 385 deletions.
2 changes: 1 addition & 1 deletion cmd/console/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Command_Claim_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

txhash, err := cli.ClaimRewards()
txhash, err := cli.ReceiveReward()
if err != nil {
if txhash == "" {
out.Err(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion cmd/console/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Command_Exit_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

txhash, err := cli.ExitSminer(cli.GetSignatureAcc())
txhash, err := cli.MinerExitPrep()
if err != nil {
if txhash == "" {
out.Err(err.Error())
Expand Down
18 changes: 6 additions & 12 deletions cmd/console/increase.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strconv"

cess "github.com/CESSProject/cess-go-sdk"
"github.com/CESSProject/cess-go-sdk/core/pattern"
"github.com/CESSProject/cess-go-sdk/chain"
"github.com/CESSProject/cess-miner/configs"
"github.com/CESSProject/cess-miner/pkg/confile"
"github.com/CESSProject/p2p-go/out"
Expand Down Expand Up @@ -71,12 +71,6 @@ func increaseStakingCmd_Runfunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

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

cfg, err := buildAuthenticationConfig(cmd)
if err != nil {
out.Err(err.Error())
Expand All @@ -96,7 +90,7 @@ func increaseStakingCmd_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

txhash, err := cli.IncreaseStakingAmount(cli.GetSignatureAcc(), stakes)
txhash, err := cli.IncreaseCollateral(cli.GetSignatureAccPulickey(), os.Args[3])
if err != nil {
if txhash == "" {
out.Err(err.Error())
Expand Down Expand Up @@ -152,18 +146,18 @@ func increaseSpaceCmd_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

accInfo, err := cli.QueryAccountInfo(cli.GetSignatureAccPulickey())
accInfo, err := cli.QueryAccountInfo(cli.GetSignatureAcc(), -1)
if err != nil {
if err.Error() != pattern.ERR_Empty {
if err.Error() != chain.ERR_Empty {
out.Err(err.Error())
os.Exit(1)
}
out.Err("signature account does not exist, possible: 1.balance is empty 2.rpc address error")
os.Exit(1)
}

token := space * pattern.StakingStakePerTiB
token_cess, _ := new(big.Int).SetString(fmt.Sprintf("%d%s", token, pattern.TokenPrecision_CESS), 10)
token := space * chain.StakingStakePerTiB
token_cess, _ := new(big.Int).SetString(fmt.Sprintf("%d%s", token, chain.TokenPrecision_CESS), 10)
if accInfo.Data.Free.CmpAbs(token_cess) < 0 {
out.Err(fmt.Sprintf("signature account balance less than %d %s", token, cli.GetTokenSymbol()))
os.Exit(1)
Expand Down
28 changes: 17 additions & 11 deletions cmd/console/reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,34 @@ func Command_Reward_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

rewardInfo, err := cli.QueryRewards(cli.GetSignatureAccPulickey())
rewardInfo, err := cli.QueryRewardMap(cli.GetSignatureAccPulickey(), -1)
if err != nil {
out.Err(err.Error())
os.Exit(1)
}
var total string
var totalStr string
var claimed string
var claimedStr string
var unclaimed string

if len(rewardInfo.Total) == 0 {
rewardInfo.Total = "0"
if len(rewardInfo.TotalReward.Bytes()) == 0 {
totalStr = "0"
} else {
totalStr = rewardInfo.TotalReward.String()
}
if len(rewardInfo.Claimed) == 0 {
rewardInfo.Claimed = "0"
if len(rewardInfo.RewardIssued.Bytes()) == 0 {
claimedStr = "0"
} else {
claimedStr = rewardInfo.RewardIssued.String()
}

t, ok := new(big.Int).SetString(rewardInfo.Total, 10)
t, ok := new(big.Int).SetString(totalStr, 10)
if !ok {
out.Err(err.Error())
os.Exit(1)
}
c, ok := new(big.Int).SetString(rewardInfo.Claimed, 10)
c, ok := new(big.Int).SetString(claimedStr, 10)
if !ok {
out.Err(err.Error())
os.Exit(1)
Expand All @@ -90,8 +96,8 @@ func Command_Reward_Runfunc(cmd *cobra.Command, args []string) {
u := t.String()

var sep uint8 = 0
for i := len(rewardInfo.Total) - 1; i >= 0; i-- {
total = fmt.Sprintf("%c%s", rewardInfo.Total[i], total)
for i := len(totalStr) - 1; i >= 0; i-- {
total = fmt.Sprintf("%c%s", totalStr[i], total)
sep++
if sep%3 == 0 {
total = fmt.Sprintf("_%s", total)
Expand All @@ -100,8 +106,8 @@ func Command_Reward_Runfunc(cmd *cobra.Command, args []string) {
total = strings.TrimPrefix(total, "_")

sep = 0
for i := len(rewardInfo.Claimed) - 1; i >= 0; i-- {
claimed = fmt.Sprintf("%c%s", rewardInfo.Claimed[i], claimed)
for i := len(claimedStr) - 1; i >= 0; i-- {
claimed = fmt.Sprintf("%c%s", claimedStr[i], claimed)
sep++
if sep%3 == 0 {
claimed = fmt.Sprintf("_%s", claimed)
Expand Down
Loading

0 comments on commit 2376c28

Please sign in to comment.