-
Notifications
You must be signed in to change notification settings - Fork 55
/
util.go
32 lines (27 loc) · 870 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
type BulkSendCoinsOperation struct {
Inputs []banktypes.Input
Outputs []banktypes.Output
}
func NewBulkSendCoinsOperation() *BulkSendCoinsOperation {
return &BulkSendCoinsOperation{
Inputs: []banktypes.Input{},
Outputs: []banktypes.Output{},
}
}
func (op *BulkSendCoinsOperation) SendCoins(fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) {
if amt.IsValid() && !amt.IsZero() {
op.Inputs = append(op.Inputs, banktypes.NewInput(fromAddr, amt))
op.Outputs = append(op.Outputs, banktypes.NewOutput(toAddr, amt))
}
}
func (op *BulkSendCoinsOperation) Run(ctx sdk.Context, bankKeeper BankKeeper) error {
if len(op.Inputs) > 0 && len(op.Outputs) > 0 {
return bankKeeper.InputOutputCoins(ctx, op.Inputs, op.Outputs)
}
return nil
}