forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DelegatableCoins and LockedCoinsFromDelegating interfaces with ba…
…sic tests
- Loading branch information
Showing
17 changed files
with
589 additions
and
43 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: v1 | ||
plugins: | ||
- name: gocosmos | ||
out: ../.. | ||
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v1 | ||
deps: | ||
- remote: buf.build | ||
owner: cosmos | ||
repository: cosmos-proto | ||
commit: 1935555c206d4afb9e94615dfd0fad31 | ||
- remote: buf.build | ||
owner: cosmos | ||
repository: gogo-proto | ||
commit: 34d970b699f84aa382f3c29773a60836 |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: v1 | ||
deps: | ||
- buf.build/cosmos/gogo-proto | ||
- buf.build/cosmos/cosmos-proto |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package vesting | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" | ||
) | ||
|
||
// RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the | ||
// provided LegacyAmino codec. These types are used for Amino JSON serialization | ||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||
cdc.RegisterConcrete(&MockVestedDelegateVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) | ||
} | ||
|
||
// RegisterInterface associates protoName with AccountI and VestingAccount | ||
// Interfaces and creates a registry of it's concrete implementations | ||
func RegisterInterfaces(registry types.InterfaceRegistry) { | ||
registry.RegisterInterface( | ||
"cosmos.vesting.v1beta1.VestingAccount", | ||
(*exported.VestingAccount)(nil), | ||
&MockVestedDelegateVestingAccount{}, | ||
) | ||
|
||
registry.RegisterImplementations( | ||
(*authtypes.AccountI)(nil), | ||
&MockVestedDelegateVestingAccount{}, | ||
) | ||
|
||
registry.RegisterImplementations( | ||
(*authtypes.GenesisAccount)(nil), | ||
&MockVestedDelegateVestingAccount{}, | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package vesting | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
) | ||
|
||
// LockedCoinsFromDelegating prevents the mock vesting account from delegating | ||
// any unvested tokens. | ||
func (mvdva MockVestedDelegateVestingAccount) LockedCoinsFromDelegating(blockTime time.Time) sdk.Coins { | ||
return mvdva.ContinuousVestingAccount.LockedCoins(blockTime) | ||
} | ||
|
||
func NewMockVestedDelegateVestingAccount(cva *types.ContinuousVestingAccount) *MockVestedDelegateVestingAccount { | ||
return &MockVestedDelegateVestingAccount{ | ||
ContinuousVestingAccount: cva, | ||
} | ||
} |
Oops, something went wrong.