Skip to content

Commit 55fbd63

Browse files
authored
Merge pull request #100 from koinos/3-fixes
v3 fixes
2 parents 7473e14 + 4acdb9d commit 55fbd63

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/ethereum/go-ethereum v1.10.9
1010
github.com/joho/godotenv v1.3.0
1111
github.com/koinos/koinos-proto-golang v0.2.1-0.20220224180227-6fbc5fe4a89a
12-
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886
12+
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed
1313
github.com/minio/sio v0.3.0
1414
github.com/mr-tron/base58 v1.2.0
1515
github.com/multiformats/go-multihash v0.1.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ github.com/koinos/koinos-util-golang v0.0.0-20220301213529-8bf7f9fb7703 h1:3RYpw
280280
github.com/koinos/koinos-util-golang v0.0.0-20220301213529-8bf7f9fb7703/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
281281
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886 h1:aCqcoOZnpL0+xJ/T2c2hZIDH5JHKRR87ZczRqI0WDfs=
282282
github.com/koinos/koinos-util-golang v0.0.0-20220301215016-a6dd44e1b886/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
283+
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed h1:Zga+bkh2cIoD/J/qZZLoOt/F/UHRBz9o5i1PlaTuWGw=
284+
github.com/koinos/koinos-util-golang v0.0.0-20220309184603-4faf8205b8ed/go.mod h1:0+oSa/Ml9+INjfAGubMtKNOq+e4a/OoEz7GfaQPN/P8=
283285
github.com/koinos/protobuf-go v1.27.2-0.20211016005428-adb3d63afc5e h1:e92AS0/Aklop09SUlZXIaKJKMAtFsp1bMCf8SKRdVVE=
284286
github.com/koinos/protobuf-go v1.27.2-0.20211016005428-adb3d63afc5e/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
285287
github.com/koinos/protobuf-go v1.27.2-0.20211026185306-2456c83214fe h1:PJ+2AnN4ibN2WxldiClplZZosQNPnXj7S5vOeFNtV+M=

internal/cli/commands.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (c *BalanceCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
178178
balance, err := ee.RPCClient.GetAccountBalance(address, contractID, cliutil.KoinBalanceOfEntry)
179179

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

192192
// Build the mana result
193-
manaDec, err := util.SatoshiToDecimal(int64(mana), cliutil.KoinPrecision)
193+
manaDec, err := util.SatoshiToDecimal(mana, cliutil.KoinPrecision)
194194
if err != nil {
195195
return nil, err
196196
}
@@ -771,7 +771,7 @@ func (c *RcLimitCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
771771
return nil, err
772772
}
773773

774-
dAmount, err := util.SatoshiToDecimal(int64(limit), cliutil.KoinPrecision)
774+
dAmount, err := util.SatoshiToDecimal(limit, cliutil.KoinPrecision)
775775
if err != nil {
776776
return nil, err
777777
}
@@ -943,14 +943,15 @@ func (c *TransferCommand) Execute(ctx context.Context, ee *ExecutionEnvironment)
943943
if err != nil {
944944
return nil, err
945945
}
946-
dBalance, err := util.SatoshiToDecimal(int64(balance), cliutil.KoinPrecision)
946+
dBalance, err := util.SatoshiToDecimal(balance, cliutil.KoinPrecision)
947947
if err != nil {
948948
return nil, err
949949
}
950950

951951
// Ensure a transfer greater than opened account balance
952-
if int64(balance) <= sAmount {
953-
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)
952+
953+
if balance <= sAmount {
954+
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)
954955
}
955956

956957
toAddress := base58.Decode(c.Address)

internal/cli/interpreter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (ee *ExecutionEnvironment) GetRcLimit() (uint64, error) {
134134
return 0, fmt.Errorf("%w: %s", cliutil.ErrInvalidAmount, err.Error())
135135
}
136136

137-
return uint64(val), nil
137+
return val, nil
138138
}
139139

140140
// else it's relative

internal/cliutil/util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
const (
1616
// Version number (this should probably not live here)
17-
Version = "v0.2.0"
17+
Version = "v0.3.1"
1818
)
1919

2020
// Hardcoded Koin contract constants
@@ -45,7 +45,7 @@ func TransactionReceiptToString(receipt *protocol.TransactionReceipt, operations
4545
}
4646

4747
// Build the mana result
48-
manaDec, err := util.SatoshiToDecimal(int64(receipt.RcUsed), KoinPrecision)
48+
manaDec, err := util.SatoshiToDecimal(receipt.RcUsed, KoinPrecision)
4949
if err != nil {
5050
s += "\n" + err.Error()
5151
return s

0 commit comments

Comments
 (0)