planetmint-go/util/issue_commands.go
Julian Strobl e10416b23d
Use globally defined keyring backend from client.toml (#156)
This partially reverts commit 1927c4d47219c428e4d12cfd9015f0137af7a030.

// Closes #142

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-10-19 09:48:18 +02:00

59 lines
1.6 KiB
Go

package util
import (
"bytes"
"errors"
"fmt"
"os/exec"
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/config"
)
func InitRDDLReissuanceProcess(ctx sdk.Context, proposerAddress string, tx_unsigned string, blk_height int64) error {
//get_last_PoPBlockHeight() // TODO: to be read form the upcoming PoP-store
// Construct the command
sending_validator_address := config.GetConfig().ValidatorAddress
fmt.Println("REISSUE: create Proposal")
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-proposal",
"--from", sending_validator_address, "-y",
proposerAddress, tx_unsigned, strconv.FormatInt(blk_height, 10))
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
// Start the command in a non-blocking way
err := cmd.Start()
errstr := stderr.String()
if err != nil || len(errstr) > 0 {
if err == nil {
err = errors.New(errstr)
}
}
return err
}
func SendRDDLReissuanceResult(ctx sdk.Context, proposerAddress string, txID string, blk_height uint64) error {
// Construct the command
sending_validator_address := config.GetConfig().ValidatorAddress
fmt.Println("REISSUE: create Result")
cmd := exec.Command("planetmint-god", "tx", "dao", "reissue-rddl-result",
"--from", sending_validator_address, "-y",
proposerAddress, txID, strconv.FormatUint(blk_height, 10))
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
// Start the command in a non-blocking way
err := cmd.Start()
errstr := stderr.String()
if err != nil || len(errstr) > 0 {
if err == nil {
err = errors.New(errstr)
}
}
return err
}