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

v3 fixes #100

Merged
merged 3 commits into from
Mar 9, 2022
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/ethereum/go-ethereum v1.10.9
github.com/joho/godotenv v1.3.0
github.com/koinos/koinos-proto-golang v0.2.1-0.20220224180227-6fbc5fe4a89a
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed
github.com/minio/sio v0.3.0
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multihash v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ github.com/koinos/koinos-util-golang v0.0.0-20220301213529-8bf7f9fb7703 h1:3RYpw
github.com/koinos/koinos-util-golang v0.0.0-20220301213529-8bf7f9fb7703/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886 h1:aCqcoOZnpL0+xJ/T2c2hZIDH5JHKRR87ZczRqI0WDfs=
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed h1:Zga+bkh2cIoD/J/qZZLoOt/F/UHRBz9o5i1PlaTuWGw=
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
github.com/koinos/protobuf-go v1.27.2-0.20211016005428-adb3d63afc5e h1:e92AS0/Aklop09SUlZXIaKJKMAtFsp1bMCf8SKRdVVE=
github.com/koinos/protobuf-go v1.27.2-0.20211016005428-adb3d63afc5e/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
github.com/koinos/protobuf-go v1.27.2-0.20211026185306-2456c83214fe h1:PJ+2AnN4ibN2WxldiClplZZosQNPnXj7S5vOeFNtV+M=
Expand Down
13 changes: 7 additions & 6 deletions internal/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (c *BalanceCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
balance, err := ee.RPCClient.GetAccountBalance(address, contractID, cliutil.KoinBalanceOfEntry)

// Build the result
dec, err := util.SatoshiToDecimal(int64(balance), cliutil.KoinPrecision)
dec, err := util.SatoshiToDecimal(balance, cliutil.KoinPrecision)
if err != nil {
return nil, err
}
Expand All @@ -190,7 +190,7 @@ func (c *BalanceCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
}

// Build the mana result
manaDec, err := util.SatoshiToDecimal(int64(mana), cliutil.KoinPrecision)
manaDec, err := util.SatoshiToDecimal(mana, cliutil.KoinPrecision)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -771,7 +771,7 @@ func (c *RcLimitCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
return nil, err
}

dAmount, err := util.SatoshiToDecimal(int64(limit), cliutil.KoinPrecision)
dAmount, err := util.SatoshiToDecimal(limit, cliutil.KoinPrecision)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -943,14 +943,15 @@ func (c *TransferCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
if err != nil {
return nil, err
}
dBalance, err := util.SatoshiToDecimal(int64(balance), cliutil.KoinPrecision)
dBalance, err := util.SatoshiToDecimal(balance, cliutil.KoinPrecision)
if err != nil {
return nil, err
}

// Ensure a transfer greater than opened account balance
if int64(balance) <= sAmount {
return nil, fmt.Errorf("%w: insufficient balance %s %s on opened wallet %s, cannot transfer %s %s", cliutil.ErrInvalidAmount, dBalance, cliutil.KoinSymbol, myAddress, dAmount, cliutil.KoinSymbol)

if balance <= sAmount {
return nil, fmt.Errorf("%w: insufficient balance %s %s on opened wallet %s, cannot transfer %s %s", cliutil.ErrInvalidAmount, dBalance, cliutil.KoinSymbol, base58.Encode(myAddress), dAmount, cliutil.KoinSymbol)
}

toAddress := base58.Decode(c.Address)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (ee *ExecutionEnvironment) GetRcLimit() (uint64, error) {
return 0, fmt.Errorf("%w: %s", cliutil.ErrInvalidAmount, err.Error())
}

return uint64(val), nil
return val, nil
}

// else it's relative
Expand Down
4 changes: 2 additions & 2 deletions internal/cliutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

const (
// Version number (this should probably not live here)
Version = "v0.2.0"
Version = "v0.3.1"
)

// Hardcoded Koin contract constants
Expand Down Expand Up @@ -45,7 +45,7 @@ func TransactionReceiptToString(receipt *protocol.TransactionReceipt, operations
}

// Build the mana result
manaDec, err := util.SatoshiToDecimal(int64(receipt.RcUsed), KoinPrecision)
manaDec, err := util.SatoshiToDecimal(receipt.RcUsed, KoinPrecision)
if err != nil {
s += "\n" + err.Error()
return s
Expand Down