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

Changed the default denom to mycoin #42

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 9 additions & 6 deletions cmd/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ var reAmt = regexp.MustCompile("(\\d+)")

func ParseCoin(str string) (types.Coin, error) {

var coin types.Coin
var coin types.Coin = types.Coin{ Amount: 0, Denom: "mycoin" }

if len(str) > 0 {
amt, err := strconv.Atoi(reAmt.FindString(str))
if err != nil {
return coin, err
amt, err := strconv.ParseInt(reAmt.FindString(str), 10, 64)
if err == nil {
coin.Amount = amt

denom := reDenom.FindString(str)
if denom != "" {
coin.Denom = denom
}
}
denom := reDenom.FindString(str)
coin = types.Coin{denom, int64(amt)}
}

return coin, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestParse(t *testing.T) {
errMsg string
}{
//testing ParseCoin Function
{types.Coin{} == makeCoin(""), "parseCoin makes bad empty coin"},
{types.Coin{"mycoin", 0} == makeCoin(""), "parseCoin makes bad empty coin"},
{types.Coin{"fooCoin", 1} == makeCoin("1fooCoin"), "parseCoin makes bad coins"},
{types.Coin{"barCoin", 10} == makeCoin("10 barCoin"), "parseCoin makes bad coins"},

Expand Down
2 changes: 1 addition & 1 deletion state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
}
if !tx.Input.Coins.IsGTE(types.Coins{tx.Fee}) {
log.Info(cmn.Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
return abci.ErrBaseInsufficientFunds.AppendLog(cmn.Fmt("input coins is %d, but fee is %d", tx.Input.Coins, types.Coins{tx.Fee}))
return abci.ErrBaseInsufficientFunds.AppendLog(cmn.Fmt("input coins is %v, but fee is %v", tx.Input.Coins, types.Coins{tx.Fee}))
}

// Validate call address
Expand Down