-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into fmt-zcn-#10
- Loading branch information
Showing
17 changed files
with
682 additions
and
304 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/0chain/gosdk/zcncore" | ||
"github.com/spf13/cobra" | ||
"log" | ||
) | ||
|
||
var getFaucetConfigCmd = &cobra.Command{ | ||
Use: "fc-config", | ||
Short: "Show facuet configurations.", | ||
Long: `Show facuet configurations.`, | ||
Args: cobra.MinimumNArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
var ( | ||
fields = new(zcncore.InputMap) | ||
cb = NewJSONInfoCB(fields) | ||
err error | ||
) | ||
if err = zcncore.GetFaucetSCConfig(cb); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err = cb.Waiting(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
printMap(fields.Fields) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(getFaucetConfigCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"sync" | ||
|
||
"github.com/0chain/gosdk/zcncore" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var updateFaucetCmd = &cobra.Command{ | ||
Use: "fc-update-config", | ||
Short: "Update the Faucet smart contract", | ||
Long: `Update the Faucet smart contract.`, | ||
Args: cobra.MinimumNArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
input := new(zcncore.InputMap) | ||
input.Fields = setupInputMap(cmd.Flags()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
var wg sync.WaitGroup | ||
statusBar := &ZCNStatus{wg: &wg} | ||
txn, err := zcncore.NewTransaction(statusBar, 0) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
wg.Add(1) | ||
if err = txn.FaucetUpdateConfig(input); err != nil { | ||
log.Fatal(err) | ||
} | ||
wg.Wait() | ||
|
||
if !statusBar.success { | ||
log.Fatal("fatal:", statusBar.errMsg) | ||
} | ||
|
||
statusBar.success = false | ||
wg.Add(1) | ||
if err = txn.Verify(); err != nil { | ||
log.Fatal(err) | ||
} | ||
wg.Wait() | ||
|
||
if !statusBar.success { | ||
log.Fatal("fatal:", statusBar.errMsg) | ||
} | ||
|
||
fmt.Printf("faucet smart contract settings updated\nHash: %v\n", txn.GetTransactionHash()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(updateFaucetCmd) | ||
updateFaucetCmd.PersistentFlags().StringSlice("keys", nil, "list of keys") | ||
updateFaucetCmd.PersistentFlags().StringSlice("values", nil, "list of new values") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/0chain/gosdk/zcncore" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var mnGlobalsCmd = &cobra.Command{ | ||
Use: "global-config", | ||
Short: "Show global configurations.", | ||
Long: `Show global configurations.`, | ||
Args: cobra.MinimumNArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var ( | ||
fields = new(zcncore.InputMap) | ||
cb = NewJSONInfoCB(fields) | ||
err error | ||
) | ||
if err = zcncore.GetMinerSCGlobals(cb); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err = cb.Waiting(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
printMap(fields.Fields) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(mnGlobalsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/0chain/gosdk/zcncore" | ||
"github.com/spf13/cobra" | ||
"log" | ||
) | ||
|
||
var getInterestPoolConfigCmd = &cobra.Command{ | ||
Use: "ip-config", | ||
Short: "Show interest pool configurations.", | ||
Long: `Show interest pool configurations.`, | ||
Args: cobra.MinimumNArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
var ( | ||
fields = new(zcncore.InputMap) | ||
cb = NewJSONInfoCB(fields) | ||
err error | ||
) | ||
if err = zcncore.GetInterestPoolSCConfig(cb); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err = cb.Waiting(); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
printMap(fields.Fields) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(getInterestPoolConfigCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"sync" | ||
|
||
"github.com/0chain/gosdk/zcncore" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var updateInterestPoolConfigCmd = &cobra.Command{ | ||
Use: "ip-update-config", | ||
Short: "Update the interest pool configurations.", | ||
Long: `Update the interest pool configurations.`, | ||
Args: cobra.MinimumNArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
input := new(zcncore.InputMap) | ||
input.Fields = setupInputMap(cmd.Flags()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
var wg sync.WaitGroup | ||
statusBar := &ZCNStatus{wg: &wg} | ||
txn, err := zcncore.NewTransaction(statusBar, 0) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
wg.Add(1) | ||
if err = txn.InterestPoolUpdateConfig(input); err != nil { | ||
log.Fatal(err) | ||
} | ||
wg.Wait() | ||
|
||
if !statusBar.success { | ||
log.Fatal("fatal:", statusBar.errMsg) | ||
} | ||
|
||
statusBar.success = false | ||
wg.Add(1) | ||
if err = txn.Verify(); err != nil { | ||
log.Fatal(err) | ||
} | ||
wg.Wait() | ||
|
||
if !statusBar.success { | ||
log.Fatal("fatal:", statusBar.errMsg) | ||
} | ||
|
||
fmt.Printf("interest pool smart contract settings updated\nHash: %v\n", txn.GetTransactionHash()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(updateInterestPoolConfigCmd) | ||
updateInterestPoolConfigCmd.PersistentFlags().StringSlice("keys", nil, "list of keys") | ||
updateInterestPoolConfigCmd.PersistentFlags().StringSlice("values", nil, "list of new values") | ||
} |
Oops, something went wrong.