Skip to content

Commit

Permalink
use sender adr
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 5, 2023
1 parent ef2e9ec commit ecdba9e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x/cronos/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,21 @@ func (k Keeper) onPacketResult(
contractAddress,
packetSenderAddress string,
) error {
sender, err := sdk.AccAddressFromBech32(packetSenderAddress)
if err != nil {
return fmt.Errorf("invalid bech32 address: %s, err: %w", packetSenderAddress, err)
}
senderAddr := common.BytesToAddress(sender)
contractAddr := common.HexToAddress(contractAddress)
if senderAddr != contractAddr {
return fmt.Errorf("sender is not authenticated: expected %s, got %s\n", senderAddr, contractAddr)
}
data, err := cronosprecompiles.OnPacketResultCallback(packet.SourceChannel, packet.Sequence, acknowledgement)
if err != nil {
return err
}
gasLimit := k.GetParams(ctx).MaxCallbackGas
_, _, err = k.CallEVM(ctx, &contractAddr, data, big.NewInt(0), gasLimit)
_, _, err = k.CallEVM(ctx, &senderAddr, data, big.NewInt(0), gasLimit)
return err
}

Expand Down

0 comments on commit ecdba9e

Please sign in to comment.