Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all:

clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.17.16 --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.17.71 --depth 1 --single-branch

clone-injective-core:
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.17.0 --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-core.git -b c-655/add_chainlink_data_streams_oracle --depth 1 --single-branch

copy-exchange-client: clone-injective-indexer
rm -rf exchange/*
Expand Down
139 changes: 137 additions & 2 deletions chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/evm/precompiles/bank/i_bank_module.abigen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

139 changes: 137 additions & 2 deletions chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/evm/precompiles/exchange/i_exchange_module.abigen.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/evm/precompiles/staking/i_staking_module.abigen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions chain/evm/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package types
const (
EventTypeEthereumTx = TypeMsgEthereumTx
EventTypeBlockBloom = "block_bloom"
EventTypeTxLog = "tx_log"

AttributeKeyContractAddress = "contract"
AttributeKeyRecipient = "recipient"
Expand All @@ -13,7 +12,7 @@ const (
AttributeKeyTxIndex = "txIndex"
AttributeKeyTxGasUsed = "txGasUsed"
AttributeKeyTxType = "txType"
AttributeKeyTxLog = "txLog"

// tx failed in eth vm execution
AttributeKeyEthereumTxFailed = "ethereumTxFailed"
AttributeValueCategory = ModuleName
Expand Down
72 changes: 7 additions & 65 deletions chain/evm/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package types

import (
"encoding/hex"
"encoding/json"
"fmt"
"math/big"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/gogoproto/proto"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -86,64 +84,20 @@ func logsFromTxResponse(dst []*ethtypes.Log, rsp *MsgEthereumTxResponse, blockNu
return dst
}

// DecodeMsgLogsFromEvents decodes a protobuf-encoded byte slice into ethereum logs, for a single message.
func DecodeMsgLogsFromEvents(in []byte, events []abci.Event, msgIndex int, blockNumber uint64) ([]*ethtypes.Log, error) {
// DecodeMsgLogs decodes a protobuf-encoded byte slice into ethereum logs, for a single message.
func DecodeMsgLogs(in []byte, msgIndex int, blockNumber uint64) ([]*ethtypes.Log, error) {
txResponses, err := DecodeTxResponses(in)
if err != nil {
return nil, err
}

var logs []*ethtypes.Log
if msgIndex < len(txResponses) {
logs = logsFromTxResponse(nil, txResponses[msgIndex], blockNumber)
}

if len(logs) == 0 {
logs, err = TxLogsFromEvents(events, msgIndex)
if msgIndex >= len(txResponses) {
return nil, fmt.Errorf("invalid message index: %d", msgIndex)
}

return logs, err
return logsFromTxResponse(nil, txResponses[msgIndex], blockNumber), nil
}

// TxLogsFromEvents parses ethereum logs from cosmos events for specific msg index
func TxLogsFromEvents(events []abci.Event, msgIndex int) ([]*ethtypes.Log, error) {
for _, event := range events {
if event.Type != EventTypeTxLog {
continue
}

if msgIndex > 0 {
// not the eth tx we want
msgIndex--
continue
}

return ParseTxLogsFromEvent(event)
}

return []*ethtypes.Log{}, nil
}

// ParseTxLogsFromEvent parse tx logs from one event
func ParseTxLogsFromEvent(event abci.Event) ([]*ethtypes.Log, error) {
logs := make([]*Log, 0, len(event.Attributes))
for _, attr := range event.Attributes {
if attr.Key != AttributeKeyTxLog {
continue
}

var log Log
if err := json.Unmarshal([]byte(attr.Value), &log); err != nil {
return nil, err
}

logs = append(logs, &log)
}
return LogsToEthereum(logs), nil
}

// DecodeTxLogsFromEvents decodes a protobuf-encoded byte slice into ethereum logs
func DecodeTxLogsFromEvents(in []byte, events []abci.Event, blockNumber uint64) ([]*ethtypes.Log, error) {
// DecodeTxLogs decodes a protobuf-encoded byte slice into ethereum logs
func DecodeTxLogs(in []byte, blockNumber uint64) ([]*ethtypes.Log, error) {
txResponses, err := DecodeTxResponses(in)
if err != nil {
return nil, err
Expand All @@ -152,18 +106,6 @@ func DecodeTxLogsFromEvents(in []byte, events []abci.Event, blockNumber uint64)
for _, response := range txResponses {
logs = logsFromTxResponse(logs, response, blockNumber)
}
if len(logs) == 0 {
for _, event := range events {
if event.Type != EventTypeTxLog {
continue
}
txLogs, err := ParseTxLogsFromEvent(event)
if err != nil {
return nil, err
}
logs = append(logs, txLogs...)
}
}
return logs, nil
}

Expand Down
20 changes: 20 additions & 0 deletions chain/exchange/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
// RegisterLegacyAminoCodec registers the necessary x/exchange interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// Register oneof interfaces
cdc.RegisterInterface((*isOpenNotionalCap_Cap)(nil), nil)
cdc.RegisterInterface((*isFullDerivativeMarket_Info)(nil), nil)

cdc.RegisterConcrete(&MsgDeposit{}, "exchange/MsgDeposit", nil)
cdc.RegisterConcrete(&MsgWithdraw{}, "exchange/MsgWithdraw", nil)
cdc.RegisterConcrete(&MsgInstantSpotMarketLaunch{}, "exchange/MsgInstantSpotMarketLaunch", nil)
Expand All @@ -34,7 +38,11 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgSubaccountTransfer{}, "exchange/MsgSubaccountTransfer", nil)
cdc.RegisterConcrete(&MsgExternalTransfer{}, "exchange/MsgExternalTransfer", nil)
cdc.RegisterConcrete(&MsgIncreasePositionMargin{}, "exchange/MsgIncreasePositionMargin", nil)
cdc.RegisterConcrete(&MsgDecreasePositionMargin{}, "exchange/MsgDecreasePositionMargin", nil)
cdc.RegisterConcrete(&MsgLiquidatePosition{}, "exchange/MsgLiquidatePosition", nil)
cdc.RegisterConcrete(&MsgEmergencySettleMarket{}, "exchange/MsgEmergencySettleMarket", nil)
cdc.RegisterConcrete(&MsgAuthorizeStakeGrants{}, "exchange/MsgAuthorizeStakeGrants", nil)
cdc.RegisterConcrete(&MsgActivateStakeGrant{}, "exchange/MsgActivateStakeGrant", nil)
cdc.RegisterConcrete(&MsgBatchUpdateOrders{}, "exchange/MsgBatchUpdateOrders", nil)
cdc.RegisterConcrete(&MsgPrivilegedExecuteContract{}, "exchange/MsgPrivilegedExecuteContract", nil)
cdc.RegisterConcrete(&MsgRewardsOptOut{}, "exchange/MsgRewardsOptOut", nil)
Expand Down Expand Up @@ -80,6 +88,14 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&BatchUpdateOrdersAuthz{}, "exchange/BatchUpdateOrdersAuthz", nil)

cdc.RegisterConcrete(&Params{}, "exchange/Params", nil)

// Register oneof implementations for OpenNotionalCap
cdc.RegisterConcrete(&OpenNotionalCap_Uncapped{}, "exchange/OpenNotionalCapUncapped", nil)
cdc.RegisterConcrete(&OpenNotionalCap_Capped{}, "exchange/OpenNotionalCapCapped", nil)

// Register oneof implementations for FullDerivativeMarket
cdc.RegisterConcrete(&FullDerivativeMarket_PerpetualInfo{}, "exchange/FullDerivativeMarketPerpetualInfo", nil)
cdc.RegisterConcrete(&FullDerivativeMarket_FuturesInfo{}, "exchange/FullDerivativeMarketFuturesInfo", nil)
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
Expand All @@ -103,7 +119,11 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&MsgSubaccountTransfer{},
&MsgExternalTransfer{},
&MsgIncreasePositionMargin{},
&MsgDecreasePositionMargin{},
&MsgLiquidatePosition{},
&MsgEmergencySettleMarket{},
&MsgAuthorizeStakeGrants{},
&MsgActivateStakeGrant{},
&MsgBatchUpdateOrders{},
&MsgPrivilegedExecuteContract{},
&MsgRewardsOptOut{},
Expand Down
2 changes: 2 additions & 0 deletions chain/exchange/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@ var (
ErrPositionNotOffsettable = errors.Register(ModuleName, 109, "position not offsettable")
ErrOffsettingSubaccountIDsEmpty = errors.Register(ModuleName, 110, "offsetting subaccount IDs cannot be empty")
ErrInvalidOpenNotionalCap = errors.Register(ModuleName, 111, "invalid open notional cap")
ErrOpenNotionalCapBreached = errors.Register(ModuleName, 112, "open notional cap breached")
ErrNoOffsettingPositionsFound = errors.Register(ModuleName, 113, "no valid offsetting positions found")
)
Loading