Skip to content

Commit

Permalink
Merge pull request #26 from rarimo/feature/listener
Browse files Browse the repository at this point in the history
Rootupdater module
  • Loading branch information
olegfomenko authored Aug 29, 2024
2 parents 333f514 + aff7e97 commit 452e5e6
Show file tree
Hide file tree
Showing 48 changed files with 4,839 additions and 96 deletions.
35 changes: 34 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ import (
rarimocoremodule "github.com/rarimo/rarimo-core/x/rarimocore"
rarimocoremodulekeeper "github.com/rarimo/rarimo-core/x/rarimocore/keeper"
rarimocoremoduletypes "github.com/rarimo/rarimo-core/x/rarimocore/types"
rootupdatermodule "github.com/rarimo/rarimo-core/x/rootupdater"
rootupdatermodulekeeper "github.com/rarimo/rarimo-core/x/rootupdater/keeper"
rootupdatermoduletypes "github.com/rarimo/rarimo-core/x/rootupdater/types"
tokenmanagermodule "github.com/rarimo/rarimo-core/x/tokenmanager"
tokenmanagermodulekeeper "github.com/rarimo/rarimo-core/x/tokenmanager/keeper"
tokenmanagermoduletypes "github.com/rarimo/rarimo-core/x/tokenmanager/types"
Expand Down Expand Up @@ -206,6 +209,8 @@ var (
vestingmintmodule.AppModuleBasic{},
identitymodule.AppModuleBasic{},
cscalistmodule.AppModuleBasic{},
rootupdatermodule.AppModuleBasic{},

// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -288,6 +293,9 @@ type App struct {
VestingmintKeeper vestingmintmodulekeeper.Keeper
IdentityKeeper identitymodulekeeper.Keeper
CSCAListKeeper cscalistkeeper.Keeper

RootupdaterKeeper rootupdatermodulekeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration
RarimocoreKeeper rarimocoremodulekeeper.Keeper

Expand Down Expand Up @@ -352,6 +360,8 @@ func New(
vestingmintmoduletypes.StoreKey,
identitymoduletypes.StoreKey,
cscalisttypes.StoreKey,
rootupdatermoduletypes.StoreKey,

// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
Expand Down Expand Up @@ -644,14 +654,27 @@ func New(
)
feeMarketModule := feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketSs) // <- ACTUAL module creation in app.go that you need

app.RootupdaterKeeper = *rootupdatermodulekeeper.NewKeeper(
appCodec,
keys[rootupdatermoduletypes.StoreKey],
keys[rootupdatermoduletypes.MemStoreKey],
app.GetSubspace(rootupdatermoduletypes.ModuleName),
app.RarimocoreKeeper,
)
rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper)

// Set authority to x/gov module account to only expect the module account to update params
evmSs := app.GetSubspace(evmtypes.ModuleName)
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
nil, geth.NewEVM, cast.ToString(appOpts.Get(srvflags.EVMTracer)), evmSs,
)
app.EvmKeeper = app.EvmKeeper.SetHooks(app.IdentityKeeper)
app.EvmKeeper = app.EvmKeeper.SetHooks(evmkeeper.NewMultiEvmHooks(
app.IdentityKeeper,
app.RootupdaterKeeper,
))

evmModule := evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs) // <- ACTUAL module creation in app.go that you need

app.VestingmintKeeper = *vestingmintmodulekeeper.NewKeeper(
Expand Down Expand Up @@ -737,6 +760,8 @@ func New(
vestingmintModule,
identityModule,
cscaListModule,
rootupdaterModule,

// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -776,6 +801,8 @@ func New(
vestingmintmoduletypes.ModuleName,
identitymoduletypes.ModuleName,
cscalisttypes.ModuleName,
rootupdatermoduletypes.ModuleName,

// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -810,6 +837,8 @@ func New(
vestingmintmoduletypes.ModuleName,
identitymoduletypes.ModuleName,
cscalisttypes.ModuleName,
rootupdatermoduletypes.ModuleName,

// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -854,6 +883,7 @@ func New(
identitymoduletypes.ModuleName,
cscalisttypes.ModuleName,

rootupdatermoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down Expand Up @@ -890,6 +920,8 @@ func New(
multisigModule,
evmModule,
feeMarketModule,
rootupdaterModule,

// this line is used by starport scaffolding # stargate/app/appModule
)
app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -1136,6 +1168,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
//paramsKeeper.Subspace(monitoringptypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
107 changes: 107 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52536,6 +52536,8 @@ paths:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
details:
title: Corresponding to type details
Expand Down Expand Up @@ -53027,6 +53029,8 @@ paths:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
details:
title: Corresponding to type details
Expand Down Expand Up @@ -54943,6 +54947,56 @@ paths:
type: string
tags:
- Query
/rarimo/rarimo-core/rootupdater/params:
get:
summary: Parameters queries the parameters of the module.
operationId: RarimoRarimocoreRootupdaterParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
contract_address:
type: string
root:
type: string
last_signed_root:
type: string
last_signed_root_index:
type: string
event_name:
type: string
root_timestamp:
type: string
format: int64
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/rarimo/rarimo-core/tokenmanager/collection:
get:
operationId: RarimoRarimocoreTokenmanagerCollectionAll
Expand Down Expand Up @@ -57544,6 +57598,7 @@ paths:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down Expand Up @@ -58928,6 +58983,7 @@ paths:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down Expand Up @@ -91007,6 +91063,8 @@ definitions:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
rarimo.rarimocore.rarimocore.Operation:
type: object
Expand All @@ -91027,6 +91085,8 @@ definitions:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
details:
title: Corresponding to type details
Expand Down Expand Up @@ -91377,6 +91437,8 @@ definitions:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
details:
title: Corresponding to type details
Expand Down Expand Up @@ -91735,6 +91797,8 @@ definitions:
- IDENTITY_STATE_TRANSFER
- WORLDCOIN_IDENTITY_TRANSFER
- CSCA_ROOT_UPDATE
- ARBITRARY
- PASSPORT_ROOT_UPDATE
default: TRANSFER
details:
title: Corresponding to type details
Expand Down Expand Up @@ -92092,6 +92156,44 @@ definitions:
type: string
validator:
type: string
rarimo.rarimocore.rootupdater.Params:
type: object
properties:
contract_address:
type: string
root:
type: string
last_signed_root:
type: string
last_signed_root_index:
type: string
event_name:
type: string
root_timestamp:
type: string
format: int64
description: Params defines the parameters for the module.
rarimo.rarimocore.rootupdater.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
contract_address:
type: string
root:
type: string
last_signed_root:
type: string
last_signed_root_index:
type: string
event_name:
type: string
root_timestamp:
type: string
format: int64
description: QueryParamsResponse is response type for the Query/Params RPC method.
rarimo.rarimocore.tokenmanager.Collection:
type: object
properties:
Expand Down Expand Up @@ -92211,6 +92313,7 @@ definitions:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down Expand Up @@ -92575,6 +92678,7 @@ definitions:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
rarimo.rarimocore.tokenmanager.OnChainItem:
type: object
Expand Down Expand Up @@ -92609,6 +92713,7 @@ definitions:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down Expand Up @@ -93366,6 +93471,7 @@ definitions:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down Expand Up @@ -93577,6 +93683,7 @@ definitions:
- Near
- Other
- Rarimo
- RarimoEVM
default: EVM
params:
type: array
Expand Down
27 changes: 27 additions & 0 deletions ethermint/utils/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package utils

import (
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
ethtypes "github.com/ethereum/go-ethereum/core/types"
)

// unpackLog copy-pasted from logic in generated s-c bindings.
func UnpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error {
if log.Topics[0] != contractAbi.Events[event].ID {
return fmt.Errorf("event signature mismatch")
}

if len(log.Data) > 0 {
if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil {
return err
}
}
var indexed abi.Arguments
for _, arg := range contractAbi.Events[event].Inputs {
if arg.Indexed {
indexed = append(indexed, arg)
}
}
return abi.ParseTopics(out, indexed, log.Topics[1:])
}
Loading

0 comments on commit 452e5e6

Please sign in to comment.