-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: nulnut <[email protected]> Co-authored-by: fx0x55 <[email protected]>
- Loading branch information
1 parent
bf2703b
commit 00b456e
Showing
14 changed files
with
572 additions
and
25 deletions.
There are no files selected for viewing
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,43 @@ | ||
package keeper | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ethereum/go-ethereum/common" | ||
evmtypes "github.com/evmos/ethermint/x/evm/types" | ||
|
||
"github.com/functionx/fx-core/v7/x/ibc/applications/transfer/types" | ||
) | ||
|
||
func (k Keeper) HandlerIbcCall(ctx sdk.Context, sourcePort, sourceChannel string, data types.FungibleTokenPacketData) error { | ||
var mp types.MemoPacket | ||
if err := k.cdc.UnmarshalInterfaceJSON([]byte(data.Memo), &mp); err != nil { | ||
return nil | ||
} | ||
|
||
if err := mp.ValidateBasic(); err != nil { | ||
return err | ||
} | ||
|
||
attr := sdk.NewAttribute(types.AttributeKeyIBCCallType, types.IbcCallType_name[int32(mp.GetType())]) | ||
ctx.EventManager().EmitEvents(sdk.Events{sdk.NewEvent(types.EventTypeIBCCall, attr)}) | ||
switch packet := mp.(type) { | ||
case *types.IbcCallEvmPacket: | ||
hexSender := types.IntermediateSender(sourcePort, sourceChannel, data.Sender) | ||
return k.HandlerIbcCallEvm(ctx, hexSender, packet) | ||
default: | ||
return types.ErrMemoNotSupport.Wrapf("invalid call type %s", mp.GetType()) | ||
} | ||
} | ||
|
||
func (k Keeper) HandlerIbcCallEvm(ctx sdk.Context, sender common.Address, evmData *types.IbcCallEvmPacket) error { | ||
txResp, err := k.evmKeeper.CallEVM(ctx, sender, | ||
evmData.MustGetToAddr(), evmData.Value.BigInt(), evmData.GasLimit, evmData.MustGetMessage(), true) | ||
if err != nil { | ||
return err | ||
} | ||
if txResp.Failed() { | ||
return errorsmod.Wrap(evmtypes.ErrVMExecution, txResp.VmError) | ||
} | ||
return 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
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
Oops, something went wrong.