-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
180 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
version: 1 | ||
validation: sovereign | ||
accounts: | ||
- name: alice | ||
coins: | ||
- 20000token | ||
- 200000000stake | ||
- name: bob | ||
coins: | ||
- 10000token | ||
- 100000000stake | ||
accounts: | ||
- name: alice | ||
coins: | ||
- 20000token | ||
- 10000foocoin | ||
- 200000000stake | ||
- name: bob | ||
coins: | ||
- 10000token | ||
- 100000000stake | ||
client: | ||
openapi: | ||
path: docs/static/openapi.yml | ||
faucet: | ||
name: bob | ||
coins: | ||
- 5token | ||
- 100000stake | ||
- 5token | ||
- 100000stake | ||
validators: | ||
- name: alice | ||
bonded: 100000000stake | ||
- name: alice | ||
bonded: 100000000stake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
package types | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
sdkerrors "cosmossdk.io/errors" | ||
) | ||
|
||
// x/loan module sentinel errors | ||
var ( | ||
ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") | ||
ErrSample = sdkerrors.Register(ModuleName, 1101, "sample error") | ||
ErrWrongLoanState = sdkerrors.Register(ModuleName, 2, "wrong loan state") | ||
ErrDeadline = sdkerrors.Register(ModuleName, 3, "deadline") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
package types | ||
|
||
import ( | ||
"strconv" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
var _ sdk.Msg = &MsgRequestLoan{} | ||
|
||
func NewMsgRequestLoan(creator string, amount string, fee string, collateral string, deadline string) *MsgRequestLoan { | ||
return &MsgRequestLoan{ | ||
Creator: creator, | ||
Amount: amount, | ||
Fee: fee, | ||
Collateral: collateral, | ||
Deadline: deadline, | ||
} | ||
} | ||
|
||
func (msg *MsgRequestLoan) ValidateBasic() error { | ||
_, err := sdk.AccAddressFromBech32(msg.Creator) | ||
if err != nil { | ||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) | ||
} | ||
amount, _ := sdk.ParseCoinsNormalized(msg.Amount) | ||
if !amount.IsValid() { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "amount is not a valid Coins object") | ||
} | ||
if amount.Empty() { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "amount is empty") | ||
} | ||
fee, _ := sdk.ParseCoinsNormalized(msg.Fee) | ||
if !fee.IsValid() { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "fee is not a valid Coins object") | ||
} | ||
deadline, err := strconv.ParseInt(msg.Deadline, 10, 64) | ||
if err != nil { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "deadline is not an integer") | ||
} | ||
if deadline <= 0 { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "deadline should be a positive integer") | ||
} | ||
collateral, _ := sdk.ParseCoinsNormalized(msg.Collateral) | ||
if !collateral.IsValid() { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "collateral is not a valid Coins object") | ||
} | ||
if collateral.Empty() { | ||
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "collateral is empty") | ||
} | ||
return nil | ||
} | ||
} |