Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and refactor #12

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/suid/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func mergeCoins(slice []string, gas, primaryobj string) {
usr, err := user.Current()
if err != nil {
fmt.Errorf("failed to get current user: %s", err)
return
}
filePath := filepath.Join(usr.HomeDir, configFilePath)
config, err := ReadConfigFile(filePath)
Expand All @@ -138,8 +139,6 @@ func mergeCoins(slice []string, gas, primaryobj string) {
"--gas-budget="+gasBudget,
"--json")

cmd.Stdout = nil

outputFile := "output.txt"
filePathOutput := filepath.Join(usr.HomeDir, configPath, outputFile)
file, err := os.Create(filePathOutput)
Expand All @@ -153,7 +152,7 @@ func mergeCoins(slice []string, gas, primaryobj string) {

err = cmd.Run()
if err != nil {
log.Fatal("Run failed", err)
log.Fatal("Run failed - ", err)
}

outputBytes, err := os.ReadFile(filePathOutput)
Expand Down
22 changes: 5 additions & 17 deletions cmd/suid/cmd/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,16 @@ type DefaultConfig struct {
type Result struct {
Result struct {
Data []struct {
CoinType string `json:"coinType"`
CoinObjectId string `json:"coinObjectId"`
Version string `json:"version"`
Digest string `json:"digest"`
Balance string `json:"balance"`
PreviousTransaction string `json:"previousTransaction"`
CoinObjectId string `json:"coinObjectId"`
} `json:"data"`
} `json:"result"`
}

type Response struct {
JSONRPC string `json:"jsonrpc"`
Result []struct {
ValidatorAddress string `json:"validatorAddress"`
StakingPool string `json:"stakingPool"`
Stakes []struct {
StakedSuiID string `json:"stakedSuiId"`
StakeRequestEpoch string `json:"stakeRequestEpoch"`
StakeActiveEpoch string `json:"stakeActiveEpoch"`
Principal string `json:"principal"`
Status string `json:"status"`
EstimatedReward string `json:"estimatedReward"`
Result []struct {
Stakes []struct {
StakedSuiID string `json:"stakedSuiId"`
Status string `json:"status"`
} `json:"stakes"`
} `json:"result"`
ID string `json:"id"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/suid/cmd/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (
infoLog = log.New(os.Stdout, "INFO: ", log.Ldate|log.Ltime)
errorLog = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
binary = "suid"
version = "1.0.4"
version = "1.1.0"
configPath = ".sui-config/"
configFilePath = ".sui-config/config.toml"
)
8 changes: 7 additions & 1 deletion cmd/suid/cmd/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ func getPayObj() {
}
var coinObjectIds []string
for _, data := range result.Result.Data {
//infoLog.Printf("Found Coin Object:", data)
coinObjectIds = append(coinObjectIds, data.CoinObjectId)
}

a := coinObjectIds[0]
if len(coinObjectIds) == 0 {
errorLog.Println("No coin objects found for withdrawal.")
return
}

a := coinObjectIds[0]
infoLog.Println("Coin Object ID:", a)
getWithdrawData(a)
}

Expand Down
6 changes: 3 additions & 3 deletions releases
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tag_name = "v1.0.4"
release_name = "Release of suid SUI tool v1.0.4"
body = "Fix."
tag_name = "v1.1.0"
release_name = "Release of suid SUI tool v1.1.0"
body = "Fix suix_getCoins function."
Loading