-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accounts): Allow funds to be sent to accounts on init and execute (
- Loading branch information
1 parent
8de3966
commit 5be33f5
Showing
19 changed files
with
1,124 additions
and
265 deletions.
There are no files selected for viewing
261 changes: 211 additions & 50 deletions
261
api/cosmos/accounts/testing/counter/v1/counter.pulsar.go
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,52 @@ | ||
package accounts | ||
|
||
import ( | ||
"google.golang.org/protobuf/proto" | ||
|
||
bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" | ||
v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" | ||
"cosmossdk.io/core/address" | ||
"cosmossdk.io/x/accounts/internal/implementation" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// protoV2GogoWrapper is a wrapper of a protov2 message into a gogo message. | ||
// this is exceptionally allowed to enable accounts to be decoupled from | ||
// the SDK, since x/accounts can support only protov1 in its APIs. | ||
// But in order to keep it decoupled from the SDK we need to use the API module. | ||
// This is a hack to make an API module type work in x/accounts. Once the SDK | ||
// has protov2 support, we can migrate internal/implementation/encoding.go to | ||
// work with protov2. | ||
type protoV2GogoWrapper struct { | ||
gogoProtoPlusV2 | ||
} | ||
|
||
func (h protoV2GogoWrapper) XXX_MessageName() string { | ||
return string(proto.MessageName(h.gogoProtoPlusV2)) | ||
} | ||
|
||
func defaultCoinsTransferMsgFunc(addrCdc address.Codec) coinsTransferMsgFunc { | ||
return func(from, to []byte, coins sdk.Coins) (implementation.ProtoMsg, implementation.ProtoMsg, error) { | ||
fromAddr, err := addrCdc.BytesToString(from) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
toAddr, err := addrCdc.BytesToString(to) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
v2Coins := make([]*v1beta1.Coin, len(coins)) | ||
for i, coin := range coins { | ||
v2Coins[i] = &v1beta1.Coin{ | ||
Denom: coin.Denom, | ||
Amount: coin.Amount.String(), | ||
} | ||
} | ||
return protoV2GogoWrapper{&bankv1beta1.MsgSend{ | ||
FromAddress: fromAddr, | ||
ToAddress: toAddr, | ||
Amount: v2Coins, | ||
}}, new(bankv1beta1.MsgSendResponse), nil | ||
} | ||
} |
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
Oops, something went wrong.