Skip to content

Commit

Permalink
create account if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 24, 2024
1 parent 96eec93 commit 6f809e9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,24 @@ func (k MoveSendKeeper) InputOutputCoins(ctx context.Context, input types.Input,
recipients := make([]sdk.AccAddress, 0, len(outputs))
amounts := make([]math.Int, 0, len(outputs))
for _, output := range outputs {
// Create account if recipient does not exist.
outAddress := addrMap[output.Address]
accExists := k.ak.HasAccount(ctx, outAddress)
if !accExists {
defer telemetry.IncrCounter(1, "new", "account")
k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, outAddress))
}

amount := output.Coins.AmountOf(coin.Denom)
if !amount.IsPositive() {
continue

Check warning on line 179 in x/bank/keeper/send.go

View check run for this annotation

Codecov / codecov/patch

x/bank/keeper/send.go#L179

Added line #L179 was not covered by tests
}

recipients = append(recipients, addrMap[output.Address])
recipients = append(recipients, outAddress)
amounts = append(amounts, output.Coins.AmountOf(coin.Denom))
}

err = k.mk.MultiSend(ctx, fromAddr, coin.Denom, recipients, amounts)
if err != nil {
if err = k.mk.MultiSend(ctx, fromAddr, coin.Denom, recipients, amounts); err != nil {
return err
}

Check warning on line 188 in x/bank/keeper/send.go

View check run for this annotation

Codecov / codecov/patch

x/bank/keeper/send.go#L187-L188

Added lines #L187 - L188 were not covered by tests
}
Expand Down

0 comments on commit 6f809e9

Please sign in to comment.