Skip to content

Commit

Permalink
fix handleMsgSideChainStakeMigration
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jan 5, 2024
1 parent b2fff33 commit 24e5a14
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion x/stake/handler_sidechain.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,23 @@ func handleMsgSideChainStakeMigration(ctx sdk.Context, msg MsgSideChainStakeMigr
return sdkErr.Result()
}

// unbond immediately
ubd, sdkErr := k.BeginUnbonding(ctx, msg.RefundAddress, msg.Validator, shares, false)
if sdkErr != nil {
return sdkErr.Result()
}
ubd, events, sdkErr := k.CompleteUnbonding(ctx, ubd.DelegatorAddr, ubd.ValidatorAddr)
if sdkErr != nil {
return sdkErr.Result()
}

// send coins to pegAccount
_, sdkErr = k.BankKeeper.SendCoins(ctx, msg.RefundAddress, sdk.PegAccount, sdk.Coins{ubd.Balance})
if sdkErr != nil {
return sdkErr.Result()
}

// send cross-chain package
bscAmount := bsc.ConvertBCAmountToBSCAmount(ubd.Balance.Amount)
stakeMigrationSynPackage := types.StakeMigrationSynPackage{
OperatorAddress: msg.OperatorAddress,
Expand Down Expand Up @@ -559,7 +571,8 @@ func handleMsgSideChainStakeMigration(ctx sdk.Context, msg MsgSideChainStakeMigr
txTags = append(txTags, sdk.MakeTag(types.TagStakeMigrationSendSequence, []byte(strconv.FormatUint(sendSeq, 10))))

return sdk.Result{
Tags: txTags,
Tags: txTags,
Events: events,
}
}

Expand Down

0 comments on commit 24e5a14

Please sign in to comment.