diff --git a/golang/cosmos/x/swingset/client/cli/tx.go b/golang/cosmos/x/swingset/client/cli/tx.go index 365dcd2139f..af44a3d4dd4 100644 --- a/golang/cosmos/x/swingset/client/cli/tx.go +++ b/golang/cosmos/x/swingset/client/cli/tx.go @@ -229,7 +229,7 @@ func NewCmdSubmitCoreEvalProposal() *cobra.Command { Specify at least one pair of permit.json and code.js files`, RunE: func(cmd *cobra.Command, args []string) error { if len(args)%2 != 0 { - return fmt.Errorf("must specify an even number of permit.json and code.js files") + return fmt.Errorf("must specify paired permit.json and code.js files") } clientCtx, err := client.GetClientTxContext(cmd) diff --git a/golang/cosmos/x/swingset/keeper/querier.go b/golang/cosmos/x/swingset/keeper/querier.go index 005bcf57895..32fc1e622f6 100644 --- a/golang/cosmos/x/swingset/keeper/querier.go +++ b/golang/cosmos/x/swingset/keeper/querier.go @@ -44,7 +44,7 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier case LegacyQueryKeys: return legacyQueryKeys(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc) default: - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query endpoint") + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown swingset query path") } } } diff --git a/golang/cosmos/x/swingset/types/types.go b/golang/cosmos/x/swingset/types/types.go index 1a8ddfc7b42..b22defd0303 100644 --- a/golang/cosmos/x/swingset/types/types.go +++ b/golang/cosmos/x/swingset/types/types.go @@ -3,6 +3,7 @@ package types import ( "encoding/json" "errors" + "fmt" vstoragetypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,18 +26,16 @@ func NewEgress(nickname string, peer sdk.AccAddress, powerFlags []string) *Egres } } -// FIXME: Should have @endo/nat +// Nat is analogous to @endo/nat +// https://github.com/endojs/endo/blob/master/packages/nat func Nat(num float64) (uint64, error) { - if num < 0 { - return 0, errors.New("Not a natural") - } - - nat := uint64(num) - if float64(nat) != num { - return 0, errors.New("Not a precise integer") + if 0 <= num && num < (1<<53) { + nat := uint64(num) + if float64(nat) == num { + return nat, nil + } } - - return nat, nil + return 0, errors.New("Not a Nat") } type Messages struct { @@ -60,11 +59,11 @@ func UnmarshalMessagesJSON(jsonString string) (ret *Messages, err error) { ackFloat, ok := packet[1].(float64) if !ok { - return nil, errors.New("Ack is not an integer") + return nil, errors.New("Ack is not a number") } ret.Ack, err = Nat(ackFloat) if err != nil { - return nil, err + return nil, errors.New("Ack is not a Nat") } msgs, ok := packet[0].([]interface{}) @@ -77,21 +76,21 @@ func UnmarshalMessagesJSON(jsonString string) (ret *Messages, err error) { for i, rawMsg := range msgs { arrMsg, ok := rawMsg.([]interface{}) if !ok || len(arrMsg) != 2 { - return nil, errors.New("Message is not a pair") + return nil, fmt.Errorf("Messages[%d] is not a pair", i) } numFloat, ok := arrMsg[0].(float64) if !ok { - return nil, errors.New("Message Num is not an integer") + return nil, fmt.Errorf("Messages[%d] Num is not a number", i) } ret.Nums[i], err = Nat(numFloat) if err != nil { - return nil, errors.New("Message num is not a Nat") + return nil, fmt.Errorf("Messages[%d] Num is not a Nat", i) } ret.Messages[i], ok = arrMsg[1].(string) if !ok { - return nil, errors.New("Message is not a string") + return nil, fmt.Errorf("Messages[%d] body is not a string", i) } } diff --git a/golang/cosmos/x/vbank/keeper/querier.go b/golang/cosmos/x/vbank/keeper/querier.go index 8b0735c7cf1..b69b9d7bcb1 100644 --- a/golang/cosmos/x/vbank/keeper/querier.go +++ b/golang/cosmos/x/vbank/keeper/querier.go @@ -23,7 +23,7 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return queryState(ctx, path[1:], req, k, legacyQuerierCdc) default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown vbank query path") } } } diff --git a/golang/cosmos/x/vstorage/keeper/querier.go b/golang/cosmos/x/vstorage/keeper/querier.go index 9da34af3214..f9180fabc54 100644 --- a/golang/cosmos/x/vstorage/keeper/querier.go +++ b/golang/cosmos/x/vstorage/keeper/querier.go @@ -51,7 +51,7 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier } return queryChildren(ctx, entryPath, req, keeper, legacyQuerierCdc) default: - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query endpoint") + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query path") } } }