diff --git a/app/app.go b/app/app.go index 8f30df60..e15dcd5b 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -206,6 +209,8 @@ var ( vestingmintmodule.AppModuleBasic{}, identitymodule.AppModuleBasic{}, cscalistmodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -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 @@ -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) @@ -644,6 +654,15 @@ 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( @@ -651,7 +670,11 @@ func New( 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( @@ -737,6 +760,8 @@ func New( vestingmintModule, identityModule, cscaListModule, + rootupdaterModule, + // this line is used by starport scaffolding # stargate/app/appModule ) @@ -776,6 +801,8 @@ func New( vestingmintmoduletypes.ModuleName, identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, + // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -810,6 +837,8 @@ func New( vestingmintmoduletypes.ModuleName, identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, + // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -854,6 +883,7 @@ func New( identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -890,6 +920,8 @@ func New( multisigModule, evmModule, feeMarketModule, + rootupdaterModule, + // this line is used by starport scaffolding # stargate/app/appModule ) app.sm.RegisterStoreDecoders() @@ -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 diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 50567c09..304f1e0f 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -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 @@ -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 @@ -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 @@ -57544,6 +57598,7 @@ paths: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -58928,6 +58983,7 @@ paths: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -92211,6 +92313,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -92575,6 +92678,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM rarimo.rarimocore.tokenmanager.OnChainItem: type: object @@ -92609,6 +92713,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -93366,6 +93471,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -93577,6 +93683,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array diff --git a/ethermint/utils/events.go b/ethermint/utils/events.go new file mode 100644 index 00000000..325f34af --- /dev/null +++ b/ethermint/utils/events.go @@ -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:]) +} diff --git a/go.mod b/go.mod index 979e6d52..acb24bd7 100644 --- a/go.mod +++ b/go.mod @@ -39,11 +39,11 @@ require ( github.com/tidwall/gjson v1.14.4 github.com/tidwall/sjson v1.2.5 github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/net v0.24.0 - golang.org/x/text v0.15.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 - google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.1 + golang.org/x/net v0.26.0 + golang.org/x/text v0.17.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 + google.golang.org/grpc v1.64.1 + google.golang.org/protobuf v1.34.2 sigs.k8s.io/yaml v1.4.0 ) @@ -117,7 +117,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect @@ -195,16 +195,16 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect - golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.170.0 // indirect google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect @@ -222,4 +222,5 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24 google.golang.org/grpc => google.golang.org/grpc v1.55.0 + nhooyr.io/websocket => github.com/coder/websocket v1.8.6 ) diff --git a/go.sum b/go.sum index f6106b77..66c35e63 100644 --- a/go.sum +++ b/go.sum @@ -681,6 +681,8 @@ github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b80 github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coder/websocket v1.8.6 h1:OmNKdwUvLj7VvHnl5o8skaVghSPLjWdHGCnFbkWqs9w= +github.com/coder/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= @@ -1045,8 +1047,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1152,6 +1154,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= @@ -1276,6 +1279,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= @@ -1529,6 +1533,7 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= @@ -1671,8 +1676,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1803,8 +1808,8 @@ golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1832,8 +1837,8 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1850,8 +1855,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1967,8 +1972,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1977,8 +1982,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1993,8 +1998,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2075,7 +2080,7 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2294,10 +2299,10 @@ google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be h1:g4aX8SUFA8V5F4LrSY5EclyGYw1OZN4HS1jTyjB9ZDc= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be/go.mod h1:FeSdT5fk+lkxatqJP38MsUicGqHax5cLtmy/6TAuxO4= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2317,8 +2322,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -2398,8 +2403,6 @@ modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= -nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= -nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/proto/rarimocore/op_passport_root_update.proto b/proto/rarimocore/op_passport_root_update.proto new file mode 100644 index 00000000..00136478 --- /dev/null +++ b/proto/rarimocore/op_passport_root_update.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package rarimo.rarimocore.rarimocore; + +option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; + +message PassportRootUpdate { + string root = 1; + string contract_address = 2; + int64 timestamp = 3; + uint64 block_height = 4; +} + + diff --git a/proto/rarimocore/operation.proto b/proto/rarimocore/operation.proto index a8e91451..b940dea3 100644 --- a/proto/rarimocore/operation.proto +++ b/proto/rarimocore/operation.proto @@ -17,6 +17,7 @@ enum OpType { WORLDCOIN_IDENTITY_TRANSFER = 8; CSCA_ROOT_UPDATE = 9; ARBITRARY = 10; + PASSPORT_ROOT_UPDATE = 11; } enum OpStatus { diff --git a/proto/rootupdater/genesis.proto b/proto/rootupdater/genesis.proto new file mode 100644 index 00000000..76633ec8 --- /dev/null +++ b/proto/rootupdater/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package rarimo.rarimocore.rootupdater; + +import "gogoproto/gogo.proto"; +import "rootupdater/params.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// GenesisState defines the rootupdater module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto new file mode 100644 index 00000000..95a1058a --- /dev/null +++ b/proto/rootupdater/params.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package rarimo.rarimocore.rootupdater; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Params defines the parameters for the module. +message Params { + string contract_address = 1; + string root = 2; + string last_signed_root = 3; + string last_signed_root_index = 4; + string event_name = 5; + int64 root_timestamp = 6; + uint64 block_height = 7; +} diff --git a/proto/rootupdater/query.proto b/proto/rootupdater/query.proto new file mode 100644 index 00000000..53899607 --- /dev/null +++ b/proto/rootupdater/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package rarimo.rarimocore.rootupdater; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "rootupdater/params.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/rarimo/rarimo-core/rootupdater/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/rootupdater/tx.proto b/proto/rootupdater/tx.proto new file mode 100644 index 00000000..c8863367 --- /dev/null +++ b/proto/rootupdater/tx.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package rarimo.rarimocore.rootupdater; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Msg defines the Msg service. +service Msg { + +} + +// this line is used by starport scaffolding # proto/tx/message diff --git a/x/evm/keeper/hooks.go b/x/evm/keeper/hooks.go index 8ecbffbe..be7c1cac 100644 --- a/x/evm/keeper/hooks.go +++ b/x/evm/keeper/hooks.go @@ -35,10 +35,12 @@ func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks { // PostTxProcessing delegate the call to underlying hooks func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { + var errBunch error + for i := range mh { if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil { - return errorsmod.Wrapf(err, "EVM hook %T failed", mh[i]) + errBunch = errorsmod.Wrapf(errorsmod.Wrap(errBunch, err.Error()), "EVM hook %T failed", mh[i]) } } - return nil + return errBunch } diff --git a/x/identity/keeper/keeper.go b/x/identity/keeper/keeper.go index 3e8d984f..6e4a4a8e 100644 --- a/x/identity/keeper/keeper.go +++ b/x/identity/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "fmt" + "github.com/rarimo/rarimo-core/ethermint/utils" "strings" "github.com/cosmos/cosmos-sdk/codec" @@ -104,7 +105,13 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } // Validating message receiver address (should be our state smart contract) - if msg.To() == nil || bytes.Compare(msg.To().Bytes(), hexutil.MustDecode(params.IdentityContractAddress)) != 0 { + addressBytes, err := hexutil.Decode(params.IdentityContractAddress) + if err != nil { + k.Logger(ctx).Debug("failed to decode contract address") + return nil + } + + if msg.To() == nil || bytes.Compare(msg.To().Bytes(), addressBytes) != 0 { return nil } @@ -122,7 +129,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } eventBody := state.StateStateTransited{} - if err := unpackLog(stateV2, &eventBody, event.Name, log); err != nil { + if err := utils.UnpackLog(stateV2, &eventBody, event.Name, log); err != nil { return err } @@ -134,23 +141,3 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth return nil } - -// 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:]) -} diff --git a/x/rarimocore/crypto/operation/op_passport_root_update.go b/x/rarimocore/crypto/operation/op_passport_root_update.go new file mode 100644 index 00000000..ea6cc0e4 --- /dev/null +++ b/x/rarimocore/crypto/operation/op_passport_root_update.go @@ -0,0 +1,26 @@ +package operation + +import ( + "bytes" + + eth "github.com/ethereum/go-ethereum/crypto" + merkle "github.com/rarimo/go-merkle" +) + +type PassportRootUpdateContent struct { + ContractAddress []byte + Root []byte + RootTimestamp []byte +} + +const hashPassportRootUpdatePrefix = "Rarimo passport root" + +var _ merkle.Content = PassportRootUpdateContent{} + +func (c PassportRootUpdateContent) CalculateHash() []byte { + return eth.Keccak256([]byte(hashPassportRootUpdatePrefix), c.ContractAddress, c.Root, c.RootTimestamp) +} + +func (c PassportRootUpdateContent) Equals(other merkle.Content) bool { + return bytes.Equal(other.CalculateHash(), c.CalculateHash()) +} diff --git a/x/rarimocore/crypto/pkg/content/main.go b/x/rarimocore/crypto/pkg/content/main.go index 412f9b8d..aed3dc1d 100644 --- a/x/rarimocore/crypto/pkg/content/main.go +++ b/x/rarimocore/crypto/pkg/content/main.go @@ -106,6 +106,15 @@ func GetContents(client *grpc.ClientConn, operations ...*types.Operation) ([]mer return nil, err } + if content != nil { + contents = append(contents, content) + } + case types.OpType_PASSPORT_ROOT_UPDATE: + content, err := GetPassportRootUpdateContent(op) + if err != nil { + return nil, err + } + if content != nil { contents = append(contents, content) } @@ -270,3 +279,13 @@ func GetArbitraryContent(op *types.Operation) (merkle.Content, error) { content, err := pkg.GetArbitraryContent(update) return content, errors.Wrap(err, "error creating content") } + +func GetPassportRootUpdateContent(op *types.Operation) (merkle.Content, error) { + update, err := pkg.GetPassportRootUpdate(*op) + if err != nil { + return nil, errors.Wrap(err, "error parsing operation details") + } + + content, err := pkg.GetPassportRootUpdateContent(update) + return content, errors.Wrap(err, "error creating content") +} diff --git a/x/rarimocore/crypto/pkg/op_passport_root_update.go b/x/rarimocore/crypto/pkg/op_passport_root_update.go new file mode 100644 index 00000000..11c76428 --- /dev/null +++ b/x/rarimocore/crypto/pkg/op_passport_root_update.go @@ -0,0 +1,26 @@ +package pkg + +import ( + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/gogo/protobuf/proto" + "github.com/rarimo/rarimo-core/x/rarimocore/crypto/operation" + "github.com/rarimo/rarimo-core/x/rarimocore/types" +) + +func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate, error) { + if operation.OperationType == types.OpType_PASSPORT_ROOT_UPDATE { + op := new(types.PassportRootUpdate) + return op, proto.Unmarshal(operation.Details.Value, op) + } + return nil, errors.Wrap(sdkerrors.ErrInvalidType, "invalid operation type") +} + +func GetPassportRootUpdateContent(op *types.PassportRootUpdate) (*operation.PassportRootUpdateContent, error) { + return &operation.PassportRootUpdateContent{ + ContractAddress: operation.To32Bytes(hexutil.MustDecode(op.ContractAddress)), + Root: operation.To32Bytes(hexutil.MustDecode(op.Root)), + RootTimestamp: operation.IntTo32Bytes(int(op.Timestamp)), + }, nil +} diff --git a/x/rarimocore/keeper/keeper.go b/x/rarimocore/keeper/keeper.go index 3f31ac31..90e44fad 100644 --- a/x/rarimocore/keeper/keeper.go +++ b/x/rarimocore/keeper/keeper.go @@ -577,6 +577,44 @@ func (k Keeper) CreateArbitraryOperation(ctx sdk.Context, creator string, arbitr return nil } +func (k Keeper) CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.PassportRootUpdate) (string, error) { + details, err := cosmostypes.NewAnyWithValue(update) + if err != nil { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error parsing details: %s", err.Error()) + } + + content, err := pkg.GetPassportRootUpdateContent(update) + if err != nil { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error creating content: %s", err.Error()) + } + + operation := types.Operation{ + Index: hexutil.Encode(content.CalculateHash()), + OperationType: types.OpType_PASSPORT_ROOT_UPDATE, + Details: details, + Status: types.OpStatus_INITIALIZED, + Creator: creator, + Timestamp: uint64(ctx.BlockTime().Unix()), + } + + if _, ok := k.GetOperation(ctx, operation.Index); ok { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "that operation can not be changed") + } + k.SetOperation(ctx, operation) + + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeNewOperation, + sdk.NewAttribute(types.AttributeKeyOperationId, operation.Index), + sdk.NewAttribute(types.AttributeKeyOperationType, operation.OperationType.String()), + )) + + // Operation is auto-approved (cause created by EndBlock) + if err = k.ApproveOperation(ctx, operation); err != nil { + return "", errors.Wrap(err, "failed to auto-approve operation") + } + + return operation.Index, nil +} + func (k Keeper) GetTransfer(ctx sdk.Context, msg *oracletypes.MsgCreateTransferOp) (*types.Transfer, error) { hash := origin.NewDefaultOriginBuilder(). SetTxHash(msg.Tx). diff --git a/x/rarimocore/keeper/msg_server_confirmation.go b/x/rarimocore/keeper/msg_server_confirmation.go index 72956f7c..34a1e670 100644 --- a/x/rarimocore/keeper/msg_server_confirmation.go +++ b/x/rarimocore/keeper/msg_server_confirmation.go @@ -229,6 +229,12 @@ func (k Keeper) getContent(ctx sdk.Context, op types.Operation) (merkle.Content, return nil, fmt.Errorf("%w: failed to unmarshal details: %s", sdkerrors.ErrInvalidRequest, err.Error()) } return pkg.GetCSCARootUpdateContent(update) + case types.OpType_PASSPORT_ROOT_UPDATE: + update, err := pkg.GetPassportRootUpdate(op) + if err != nil { + return nil, fmt.Errorf("%w: failed to unmarshal details: %s", sdkerrors.ErrInvalidRequest, err.Error()) + } + return pkg.GetPassportRootUpdateContent(update) case types.OpType_ARBITRARY: arbitrary, err := pkg.GetArbitrary(op) if err != nil { diff --git a/x/rarimocore/types/codec.go b/x/rarimocore/types/codec.go index 5a44d6d3..a40f8996 100644 --- a/x/rarimocore/types/codec.go +++ b/x/rarimocore/types/codec.go @@ -33,6 +33,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&DropPartiesProposal{}, "rarimocore/DropPartiesProposal", nil) cdc.RegisterConcrete(&ArbitrarySigningProposal{}, "rarimocore/ArbitrarySigningProposal", nil) cdc.RegisterConcrete(&Arbitrary{}, "rarimocore/Arbitrary", nil) + cdc.RegisterConcrete(&PassportRootUpdate{}, "rarimocore/PassportRootUpdate", nil) // this line is used by starport scaffolding # 2 } @@ -151,6 +152,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { (*proto.Message)(nil), &Arbitrary{}, ) + + registry.RegisterInterface( + "rarimo.rarimocore.rarimocore.PassportRootUpdate", + (*proto.Message)(nil), + &PassportRootUpdate{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rarimocore/types/op_passport_root_update.pb.go b/x/rarimocore/types/op_passport_root_update.pb.go new file mode 100644 index 00000000..b3837831 --- /dev/null +++ b/x/rarimocore/types/op_passport_root_update.pb.go @@ -0,0 +1,443 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rarimocore/op_passport_root_update.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PassportRootUpdate struct { + Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + BlockHeight uint64 `protobuf:"varint,4,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` +} + +func (m *PassportRootUpdate) Reset() { *m = PassportRootUpdate{} } +func (m *PassportRootUpdate) String() string { return proto.CompactTextString(m) } +func (*PassportRootUpdate) ProtoMessage() {} +func (*PassportRootUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_f6416f25faf40b9e, []int{0} +} +func (m *PassportRootUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PassportRootUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PassportRootUpdate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PassportRootUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_PassportRootUpdate.Merge(m, src) +} +func (m *PassportRootUpdate) XXX_Size() int { + return m.Size() +} +func (m *PassportRootUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_PassportRootUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_PassportRootUpdate proto.InternalMessageInfo + +func (m *PassportRootUpdate) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (m *PassportRootUpdate) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *PassportRootUpdate) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *PassportRootUpdate) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func init() { + proto.RegisterType((*PassportRootUpdate)(nil), "rarimo.rarimocore.rarimocore.PassportRootUpdate") +} + +func init() { + proto.RegisterFile("rarimocore/op_passport_root_update.proto", fileDescriptor_f6416f25faf40b9e) +} + +var fileDescriptor_f6416f25faf40b9e = []byte{ + // 246 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc4, 0x30, + 0x10, 0x86, 0x1b, 0xb7, 0x08, 0x1b, 0x05, 0x25, 0xa7, 0x1e, 0x96, 0x50, 0x3d, 0xd5, 0x83, 0xad, + 0xe0, 0x13, 0xe8, 0x49, 0x3c, 0x49, 0xc1, 0x8b, 0x97, 0x90, 0xa6, 0x61, 0x5b, 0x34, 0x4e, 0x98, + 0xcc, 0x82, 0xbe, 0x85, 0x07, 0x1f, 0xca, 0xe3, 0x1e, 0x3d, 0x4a, 0xfb, 0x22, 0x62, 0xba, 0xb2, + 0x3d, 0xe5, 0xe7, 0xcb, 0xfc, 0x03, 0xf3, 0xf1, 0x02, 0x35, 0xf6, 0x0e, 0x0c, 0xa0, 0xad, 0xc0, + 0x2b, 0xaf, 0x43, 0xf0, 0x80, 0xa4, 0x10, 0x80, 0xd4, 0xc6, 0xb7, 0x9a, 0x6c, 0xe9, 0x11, 0x08, + 0xc4, 0x6a, 0x9a, 0x2c, 0xf7, 0x85, 0x59, 0x3c, 0xff, 0x64, 0x5c, 0x3c, 0xec, 0xca, 0x35, 0x00, + 0x3d, 0xc6, 0xaa, 0x10, 0x3c, 0xfd, 0xdb, 0x94, 0xb1, 0x9c, 0x15, 0xcb, 0x3a, 0x66, 0x71, 0xc1, + 0x4f, 0x0d, 0xbc, 0x12, 0x6a, 0x43, 0x4a, 0xb7, 0x2d, 0xda, 0x10, 0xb2, 0x83, 0xf8, 0x7f, 0xf2, + 0xcf, 0x6f, 0x26, 0x2c, 0x56, 0x7c, 0x49, 0xbd, 0xb3, 0x81, 0xb4, 0xf3, 0xd9, 0x22, 0x67, 0xc5, + 0xa2, 0xde, 0x03, 0x71, 0xc6, 0x8f, 0x9b, 0x17, 0x30, 0xcf, 0xaa, 0xb3, 0xfd, 0xba, 0xa3, 0x2c, + 0xcd, 0x59, 0x91, 0xd6, 0x47, 0x91, 0xdd, 0x45, 0x74, 0x7b, 0xff, 0x35, 0x48, 0xb6, 0x1d, 0x24, + 0xfb, 0x19, 0x24, 0xfb, 0x18, 0x65, 0xb2, 0x1d, 0x65, 0xf2, 0x3d, 0xca, 0xe4, 0xe9, 0x6a, 0xdd, + 0x53, 0xb7, 0x69, 0x4a, 0x03, 0xae, 0x9a, 0xee, 0xd8, 0x3d, 0x97, 0xd1, 0xc5, 0x5b, 0x35, 0x13, + 0x43, 0xef, 0xde, 0x86, 0xe6, 0x30, 0x7a, 0xb8, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x2b, + 0x93, 0x79, 0x33, 0x01, 0x00, 0x00, +} + +func (m *PassportRootUpdate) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PassportRootUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PassportRootUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeight != 0 { + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x20 + } + if m.Timestamp != 0 { + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOpPassportRootUpdate(dAtA []byte, offset int, v uint64) int { + offset -= sovOpPassportRootUpdate(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PassportRootUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Root) + if l > 0 { + n += 1 + l + sovOpPassportRootUpdate(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovOpPassportRootUpdate(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovOpPassportRootUpdate(uint64(m.Timestamp)) + } + if m.BlockHeight != 0 { + n += 1 + sovOpPassportRootUpdate(uint64(m.BlockHeight)) + } + return n +} + +func sovOpPassportRootUpdate(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOpPassportRootUpdate(x uint64) (n int) { + return sovOpPassportRootUpdate(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PassportRootUpdate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PassportRootUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PassportRootUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOpPassportRootUpdate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOpPassportRootUpdate(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOpPassportRootUpdate + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOpPassportRootUpdate + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOpPassportRootUpdate + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOpPassportRootUpdate = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOpPassportRootUpdate = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOpPassportRootUpdate = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rarimocore/types/operation.pb.go b/x/rarimocore/types/operation.pb.go index b4ab3860..bdf247d2 100644 --- a/x/rarimocore/types/operation.pb.go +++ b/x/rarimocore/types/operation.pb.go @@ -37,6 +37,7 @@ const ( OpType_WORLDCOIN_IDENTITY_TRANSFER OpType = 8 OpType_CSCA_ROOT_UPDATE OpType = 9 OpType_ARBITRARY OpType = 10 + OpType_PASSPORT_ROOT_UPDATE OpType = 11 ) var OpType_name = map[int32]string{ @@ -51,6 +52,7 @@ var OpType_name = map[int32]string{ 8: "WORLDCOIN_IDENTITY_TRANSFER", 9: "CSCA_ROOT_UPDATE", 10: "ARBITRARY", + 11: "PASSPORT_ROOT_UPDATE", } var OpType_value = map[string]int32{ @@ -65,6 +67,7 @@ var OpType_value = map[string]int32{ "WORLDCOIN_IDENTITY_TRANSFER": 8, "CSCA_ROOT_UPDATE": 9, "ARBITRARY": 10, + "PASSPORT_ROOT_UPDATE": 11, } func (x OpType) String() string { @@ -201,40 +204,41 @@ func init() { func init() { proto.RegisterFile("rarimocore/operation.proto", fileDescriptor_4615e59ddf669d07) } var fileDescriptor_4615e59ddf669d07 = []byte{ - // 523 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6f, 0xda, 0x30, - 0x1c, 0xc5, 0x09, 0x85, 0x00, 0xdf, 0xfe, 0x98, 0x65, 0xa1, 0x2d, 0xa5, 0x2c, 0x43, 0xd3, 0x34, - 0xa1, 0x4a, 0x0b, 0x53, 0x77, 0x9f, 0xe4, 0x12, 0x93, 0xb9, 0xa3, 0x0e, 0x72, 0xdc, 0x4d, 0xed, - 0x25, 0x0a, 0x34, 0x63, 0x91, 0x0a, 0x89, 0x42, 0x90, 0xca, 0x7f, 0xb1, 0xcb, 0x2e, 0xfb, 0x8b, - 0x76, 0xec, 0x71, 0xc7, 0x09, 0xfe, 0x91, 0x89, 0xa4, 0x04, 0x76, 0xd9, 0x4e, 0x89, 0xfd, 0x3e, - 0x2f, 0xef, 0xd9, 0xb1, 0xa1, 0x11, 0x7b, 0x71, 0x30, 0x09, 0x47, 0x61, 0xec, 0x77, 0xc2, 0xc8, - 0x8f, 0xbd, 0x24, 0x08, 0xa7, 0x46, 0x14, 0x87, 0x49, 0x88, 0x9b, 0x99, 0x66, 0x6c, 0x91, 0x9d, - 0xd7, 0xc6, 0xf1, 0x38, 0x0c, 0xc7, 0x77, 0x7e, 0x27, 0x65, 0x87, 0xf3, 0x2f, 0x1d, 0x6f, 0xba, - 0xc8, 0x8c, 0x2f, 0xbf, 0x17, 0xa1, 0x66, 0x6f, 0x3e, 0x86, 0xeb, 0x50, 0x0e, 0xa6, 0xb7, 0xfe, - 0xbd, 0xa6, 0xb4, 0x94, 0x76, 0x4d, 0x64, 0x03, 0x7c, 0x01, 0x87, 0x79, 0x9e, 0x5c, 0x44, 0xbe, - 0x56, 0x6c, 0x29, 0xed, 0xa3, 0xb3, 0x57, 0xc6, 0xbf, 0x42, 0x0d, 0x3b, 0x5a, 0xb3, 0xe2, 0x6f, - 0x2b, 0x36, 0xa0, 0x72, 0xeb, 0x27, 0x5e, 0x70, 0x37, 0xd3, 0xf6, 0x5a, 0x4a, 0x7b, 0xff, 0xac, - 0x6e, 0x64, 0xe5, 0x8c, 0x4d, 0x39, 0x83, 0x4c, 0x17, 0x62, 0x03, 0xe1, 0xf7, 0xa0, 0xce, 0x12, - 0x2f, 0x99, 0xcf, 0xb4, 0x52, 0x1a, 0xfa, 0xfa, 0x7f, 0xa1, 0x4e, 0x4a, 0x8b, 0x47, 0x17, 0xd6, - 0xa0, 0x32, 0x8a, 0x7d, 0x2f, 0x09, 0x63, 0xad, 0x9c, 0xae, 0x69, 0x33, 0xc4, 0x4d, 0xa8, 0x25, - 0xc1, 0xc4, 0x9f, 0x25, 0xde, 0x24, 0xd2, 0xd4, 0x96, 0xd2, 0x2e, 0x89, 0xed, 0xc4, 0xe9, 0x8f, - 0x22, 0xa8, 0xd9, 0x0a, 0xf0, 0x01, 0x54, 0xa5, 0x20, 0xdc, 0xe9, 0x51, 0x81, 0x0a, 0x18, 0xc3, - 0x51, 0xf7, 0x03, 0xe1, 0x16, 0x75, 0x07, 0x44, 0x48, 0x46, 0x1d, 0xa4, 0x60, 0x0d, 0xea, 0x3d, - 0x4a, 0x5d, 0x69, 0x7f, 0xa4, 0xdc, 0xbd, 0x24, 0x9c, 0x58, 0xf4, 0x92, 0x72, 0x89, 0x8a, 0xb8, - 0x0e, 0xa8, 0x6b, 0x73, 0x29, 0x48, 0x57, 0xba, 0x57, 0x03, 0x4b, 0x10, 0x93, 0xa2, 0x3d, 0xfc, - 0x1c, 0x8e, 0x99, 0x49, 0xb9, 0x64, 0xf2, 0xda, 0x35, 0x69, 0x8f, 0x5c, 0xf5, 0xa5, 0x9b, 0x47, - 0x94, 0x70, 0x0b, 0x9a, 0xb9, 0x4c, 0x2c, 0x4b, 0x50, 0x8b, 0x48, 0x6a, 0x6e, 0x89, 0x32, 0x6e, - 0xc0, 0xd3, 0x9c, 0xb0, 0x98, 0xb3, 0xe3, 0x56, 0xf1, 0x09, 0x3c, 0xcb, 0x35, 0x47, 0x12, 0x49, - 0xb7, 0x62, 0x05, 0xbf, 0x80, 0x93, 0xcf, 0xb6, 0xe8, 0x9b, 0x5d, 0x9b, 0x71, 0x37, 0xc7, 0x72, - 0xa0, 0x9a, 0x16, 0x76, 0xba, 0xc4, 0x15, 0xb6, 0xbd, 0x6e, 0x6c, 0x12, 0x49, 0x51, 0x0d, 0x1f, - 0x42, 0x8d, 0x88, 0x73, 0x26, 0x05, 0x11, 0xd7, 0x08, 0x4e, 0x2d, 0xa8, 0x6e, 0x36, 0x1a, 0x3f, - 0x81, 0x7d, 0xc6, 0x99, 0x64, 0xa4, 0xcf, 0x6e, 0xa8, 0x89, 0x0a, 0xeb, 0xed, 0x22, 0x83, 0x81, - 0xb0, 0x3f, 0x51, 0x13, 0x29, 0x18, 0xc1, 0x01, 0xb7, 0xa5, 0x9b, 0xcf, 0x14, 0x31, 0x80, 0xea, - 0x30, 0x8b, 0x53, 0x13, 0xed, 0x9d, 0x5f, 0xfc, 0x5c, 0xea, 0xca, 0xc3, 0x52, 0x57, 0x7e, 0x2f, - 0x75, 0xe5, 0xdb, 0x4a, 0x2f, 0x3c, 0xac, 0xf4, 0xc2, 0xaf, 0x95, 0x5e, 0xb8, 0x79, 0x3b, 0x0e, - 0x92, 0xaf, 0xf3, 0xa1, 0x31, 0x0a, 0x27, 0x9d, 0xec, 0xff, 0x3e, 0x3e, 0xde, 0xa4, 0xe7, 0xff, - 0xbe, 0xb3, 0x73, 0x19, 0x92, 0x45, 0xe4, 0xcf, 0x86, 0x6a, 0x7a, 0x80, 0xde, 0xfd, 0x09, 0x00, - 0x00, 0xff, 0xff, 0x73, 0x87, 0x50, 0xfd, 0x27, 0x03, 0x00, 0x00, + // 537 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0xda, 0x4c, + 0x14, 0xc5, 0x31, 0x7f, 0x0c, 0x5c, 0x92, 0x7c, 0xd6, 0x08, 0x7d, 0x75, 0x08, 0x75, 0x51, 0x55, + 0x55, 0x28, 0x52, 0x4d, 0x95, 0xee, 0x2b, 0x4d, 0xf0, 0xe0, 0x3a, 0x25, 0x33, 0xd6, 0x78, 0xd2, + 0x2a, 0xd9, 0x58, 0x86, 0xb8, 0xd4, 0x52, 0xc0, 0x96, 0x31, 0x52, 0x78, 0x8b, 0x6e, 0xfa, 0x26, + 0x7d, 0x88, 0x2e, 0xb3, 0xec, 0xb2, 0x82, 0x17, 0xa9, 0xb0, 0x83, 0x21, 0x9b, 0x76, 0x65, 0xcf, + 0xdc, 0xdf, 0xf1, 0x39, 0xd7, 0x33, 0x17, 0x5a, 0xb1, 0x17, 0x07, 0xd3, 0x70, 0x1c, 0xc6, 0x7e, + 0x2f, 0x8c, 0xfc, 0xd8, 0x4b, 0x82, 0x70, 0xa6, 0x47, 0x71, 0x98, 0x84, 0xa8, 0x9d, 0xd5, 0xf4, + 0x1d, 0xb2, 0xf7, 0xda, 0x3a, 0x9e, 0x84, 0xe1, 0xe4, 0xce, 0xef, 0xa5, 0xec, 0x68, 0xf1, 0xa5, + 0xe7, 0xcd, 0x96, 0x99, 0xf0, 0xe5, 0xf7, 0x22, 0xd4, 0xd9, 0xf6, 0x63, 0xa8, 0x09, 0x95, 0x60, + 0x76, 0xeb, 0xdf, 0xab, 0x52, 0x47, 0xea, 0xd6, 0x79, 0xb6, 0x40, 0x17, 0x70, 0x98, 0xfb, 0x89, + 0x65, 0xe4, 0xab, 0xc5, 0x8e, 0xd4, 0x3d, 0x3a, 0x7b, 0xa5, 0xff, 0xcd, 0x54, 0x67, 0xd1, 0x86, + 0xe5, 0x4f, 0xa5, 0x48, 0x87, 0xea, 0xad, 0x9f, 0x78, 0xc1, 0xdd, 0x5c, 0x2d, 0x75, 0xa4, 0x6e, + 0xe3, 0xac, 0xa9, 0x67, 0xe1, 0xf4, 0x6d, 0x38, 0x1d, 0xcf, 0x96, 0x7c, 0x0b, 0xa1, 0xf7, 0x20, + 0xcf, 0x13, 0x2f, 0x59, 0xcc, 0xd5, 0x72, 0x6a, 0xfa, 0xfa, 0x5f, 0xa6, 0x4e, 0x4a, 0xf3, 0x47, + 0x15, 0x52, 0xa1, 0x3a, 0x8e, 0x7d, 0x2f, 0x09, 0x63, 0xb5, 0x92, 0xf6, 0xb4, 0x5d, 0xa2, 0x36, + 0xd4, 0x93, 0x60, 0xea, 0xcf, 0x13, 0x6f, 0x1a, 0xa9, 0x72, 0x47, 0xea, 0x96, 0xf9, 0x6e, 0xe3, + 0xf4, 0x47, 0x11, 0xe4, 0xac, 0x03, 0x74, 0x00, 0x35, 0xc1, 0x31, 0x75, 0x06, 0x84, 0x2b, 0x05, + 0x84, 0xe0, 0xa8, 0xff, 0x01, 0x53, 0x93, 0xb8, 0x36, 0xe6, 0xc2, 0x22, 0x8e, 0x22, 0x21, 0x15, + 0x9a, 0x03, 0x42, 0x5c, 0xc1, 0x3e, 0x12, 0xea, 0x5e, 0x62, 0x8a, 0x4d, 0x72, 0x49, 0xa8, 0x50, + 0x8a, 0xa8, 0x09, 0x4a, 0x9f, 0x51, 0xc1, 0x71, 0x5f, 0xb8, 0x57, 0xb6, 0xc9, 0xb1, 0x41, 0x94, + 0x12, 0x7a, 0x0e, 0xc7, 0x96, 0x41, 0xa8, 0xb0, 0xc4, 0xb5, 0x6b, 0x90, 0x01, 0xbe, 0x1a, 0x0a, + 0x37, 0xb7, 0x28, 0xa3, 0x0e, 0xb4, 0xf3, 0x32, 0x36, 0x4d, 0x4e, 0x4c, 0x2c, 0x88, 0xb1, 0x23, + 0x2a, 0xa8, 0x05, 0xff, 0xe7, 0x84, 0x69, 0x39, 0x7b, 0x6a, 0x19, 0x9d, 0xc0, 0xb3, 0xbc, 0xe6, + 0x08, 0x2c, 0xc8, 0xae, 0x58, 0x45, 0x2f, 0xe0, 0xe4, 0x33, 0xe3, 0x43, 0xa3, 0xcf, 0x2c, 0xea, + 0xe6, 0x58, 0x0e, 0xd4, 0xd2, 0xc0, 0x4e, 0x1f, 0xbb, 0x9c, 0xb1, 0x4d, 0x62, 0x03, 0x0b, 0xa2, + 0xd4, 0xd1, 0x21, 0xd4, 0x31, 0x3f, 0xb7, 0x04, 0xc7, 0xfc, 0x5a, 0x81, 0x4d, 0xbf, 0x36, 0x76, + 0x1c, 0x9b, 0x71, 0xf1, 0x04, 0x6c, 0x9c, 0x9a, 0x50, 0xdb, 0x1e, 0x01, 0xfa, 0x0f, 0x1a, 0x16, + 0xb5, 0x84, 0x85, 0x87, 0xd6, 0x0d, 0x31, 0x94, 0xc2, 0xe6, 0x47, 0x62, 0xdb, 0xe6, 0xec, 0x13, + 0x31, 0x14, 0x09, 0x29, 0x70, 0x40, 0x99, 0x70, 0xf3, 0x9d, 0x22, 0x02, 0x90, 0x1d, 0xcb, 0xa4, + 0xc4, 0x50, 0x4a, 0xe7, 0x17, 0x3f, 0x57, 0x9a, 0xf4, 0xb0, 0xd2, 0xa4, 0xdf, 0x2b, 0x4d, 0xfa, + 0xb6, 0xd6, 0x0a, 0x0f, 0x6b, 0xad, 0xf0, 0x6b, 0xad, 0x15, 0x6e, 0xde, 0x4e, 0x82, 0xe4, 0xeb, + 0x62, 0xa4, 0x8f, 0xc3, 0x69, 0x2f, 0x3b, 0xf9, 0xc7, 0xc7, 0x9b, 0x74, 0x32, 0xee, 0x7b, 0x7b, + 0x63, 0x92, 0x2c, 0x23, 0x7f, 0x3e, 0x92, 0xd3, 0xab, 0xf5, 0xee, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x78, 0xd6, 0x3b, 0x89, 0x41, 0x03, 0x00, 0x00, } func (m *Operation) Marshal() (dAtA []byte, err error) { diff --git a/x/rootupdater/client/cli/query.go b/x/rootupdater/client/cli/query.go new file mode 100644 index 00000000..67f6caec --- /dev/null +++ b/x/rootupdater/client/cli/query.go @@ -0,0 +1,32 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group rootupdater queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} + diff --git a/x/rootupdater/client/cli/query_params.go b/x/rootupdater/client/cli/query_params.go new file mode 100644 index 00000000..b478c3e9 --- /dev/null +++ b/x/rootupdater/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rootupdater/client/cli/tx.go b/x/rootupdater/client/cli/tx.go new file mode 100644 index 00000000..9a8e026b --- /dev/null +++ b/x/rootupdater/client/cli/tx.go @@ -0,0 +1,23 @@ +package cli + +import ( + "fmt" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + return cmd +} diff --git a/x/rootupdater/genesis.go b/x/rootupdater/genesis.go new file mode 100644 index 00000000..6431e8cc --- /dev/null +++ b/x/rootupdater/genesis.go @@ -0,0 +1,23 @@ +package rootupdater + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/rootupdater/keeper/abci.go b/x/rootupdater/keeper/abci.go new file mode 100644 index 00000000..22dd46ae --- /dev/null +++ b/x/rootupdater/keeper/abci.go @@ -0,0 +1,32 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + rarimocoremoduletypes "github.com/rarimo/rarimo-core/x/rarimocore/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func (k Keeper) EndBlocker(ctx sdk.Context) { + params := k.GetParams(ctx) + + if params.Root == params.LastSignedRoot && params.Root != "" { + return + } + + // Creating operation to be signed by TSS parties + index, err := k.rarimo.CreateRootUpdateOperation(ctx, types.ModuleName, &rarimocoremoduletypes.PassportRootUpdate{ + ContractAddress: params.ContractAddress, + Root: params.Root, + Timestamp: params.RootTimestamp, + BlockHeight: params.BlockHeight, + }) + + if err != nil { + k.Logger(ctx).Error("Failed to create identity aggregated transfer: " + err.Error()) + return + } + + params.LastSignedRoot = params.Root + params.LastSignedRootIndex = index + k.SetParams(ctx, params) +} diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go new file mode 100644 index 00000000..82748759 --- /dev/null +++ b/x/rootupdater/keeper/keeper.go @@ -0,0 +1,108 @@ +package keeper + +import ( + "bytes" + "fmt" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/rarimo/rarimo-core/ethermint/utils" + "github.com/rarimo/rarimo-core/x/rootupdater/pkg/state" + "github.com/tendermint/tendermint/libs/log" + "strings" + + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + rarimo types.RarimocoreKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + rarimo types.RarimocoreKeeper, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + rarimo: rarimo, + } +} + +// PostTxProcessing is used to listen EVM smart contract events, +// filter and process `RootUpdated` events emitted by configured in module params contract address. +// Will be called by EVM module as hook. +func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { + params := k.GetParams(ctx) + + stateV2, err := abi.JSON(strings.NewReader(state.PoseidonSMTABI)) + if err != nil { + return err + } + + contractAddress, err := hexutil.Decode(params.ContractAddress) + if err != nil { + // If return an error here, the whole EVM module won't work + k.Logger(ctx).Debug("failed to decode contract address") + return nil + } + + // Validating message receiver address (should be our state smart contract) + if msg.To() == nil || bytes.Compare(msg.To().Bytes(), contractAddress) != 0 { + return nil + } + + // https://docs.evmos.org/protocol/modules/evm#posttxprocessing + for _, log := range receipt.Logs { + eventId := log.Topics[0] + + event, err := stateV2.EventByID(eventId) + if err != nil { + continue + } + + if event.Name != params.EventName { + continue + } + + eventBody := state.PoseidonSMTRootUpdated{} + if err := utils.UnpackLog(stateV2, &eventBody, event.Name, log); err != nil { + return err + } + + params.Root = hexutil.Encode(eventBody.Root[:]) + params.RootTimestamp = ctx.BlockTime().Unix() + params.BlockHeight = log.BlockNumber + + k.Logger(ctx).Info(fmt.Sprintf("Received PostTxProcessing event in %s module: %v", types.ModuleName, eventBody)) + k.SetParams(ctx, params) + } + + return nil +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/rootupdater/keeper/msg_server.go b/x/rootupdater/keeper/msg_server.go new file mode 100644 index 00000000..dbd464bf --- /dev/null +++ b/x/rootupdater/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/rootupdater/keeper/params.go b/x/rootupdater/keeper/params.go new file mode 100644 index 00000000..0a5bbb04 --- /dev/null +++ b/x/rootupdater/keeper/params.go @@ -0,0 +1,29 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + b := store.Get(types.KeyPrefix(types.ParamsKey)) + if b == nil { + return types.DefaultParams() + } + + k.cdc.MustUnmarshal(b, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + if err := params.Validate(); err != nil { + panic("failed to set params: " + err.Error()) + } + + b := k.cdc.MustMarshal(¶ms) + ctx.KVStore(k.storeKey).Set(types.KeyPrefix(types.ParamsKey), b) +} diff --git a/x/rootupdater/keeper/query.go b/x/rootupdater/keeper/query.go new file mode 100644 index 00000000..8fe66cb0 --- /dev/null +++ b/x/rootupdater/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/rootupdater/keeper/query_params.go b/x/rootupdater/keeper/query_params.go new file mode 100644 index 00000000..d73dc71b --- /dev/null +++ b/x/rootupdater/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/rootupdater/module.go b/x/rootupdater/module.go new file mode 100644 index 00000000..833b64b2 --- /dev/null +++ b/x/rootupdater/module.go @@ -0,0 +1,156 @@ +package rootupdater + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/rarimo/rarimo-core/x/rootupdater/client/cli" + "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Deprecated: use RegisterServices +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// Deprecated: use RegisterServices +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlocker(ctx) + return []abci.ValidatorUpdate{} +} diff --git a/x/rootupdater/module_simulation.go b/x/rootupdater/module_simulation.go new file mode 100644 index 00000000..8629bacd --- /dev/null +++ b/x/rootupdater/module_simulation.go @@ -0,0 +1,65 @@ +package rootupdater + +import ( + "math/rand" + + "github.com/rarimo/rarimo-core/testutil/sample" + rootupdatersimulation "github.com/rarimo/rarimo-core/x/rootupdater/simulation" + "github.com/rarimo/rarimo-core/x/rootupdater/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = rootupdatersimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( + // this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + rootupdaterGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rootupdaterGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + + return []simtypes.ParamChange{ + } +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/rootupdater/pkg/state/state.go b/x/rootupdater/pkg/state/state.go new file mode 100644 index 00000000..7db05cb9 --- /dev/null +++ b/x/rootupdater/pkg/state/state.go @@ -0,0 +1,1517 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package state + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// SparseMerkleTreeNode is an auto generated low-level Go binding around an user-defined struct. +type SparseMerkleTreeNode struct { + NodeType uint8 + ChildLeft uint64 + ChildRight uint64 + NodeHash [32]byte + Key [32]byte + Value [32]byte +} + +// SparseMerkleTreeProof is an auto generated low-level Go binding around an user-defined struct. +type SparseMerkleTreeProof struct { + Root [32]byte + Siblings [][32]byte + Existence bool + Key [32]byte + Value [32]byte + AuxExistence bool + AuxKey [32]byte + AuxValue [32]byte +} + +// PoseidonSMTMetaData contains all meta data concerning the PoseidonSMT contract. +var PoseidonSMTMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"}],\"name\":\"RootUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAGIC_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"P\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROOT_VALIDITY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer_\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"chainName_\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"stateKeeper_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"treeHeight_\",\"type\":\"uint256\"}],\"name\":\"__PoseidonSMT_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"element_\",\"type\":\"bytes32\"}],\"name\":\"add\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"chainName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"newSignerPubKey_\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"changeSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key_\",\"type\":\"bytes32\"}],\"name\":\"getNodeByKey\",\"outputs\":[{\"components\":[{\"internalType\":\"enumSparseMerkleTree.NodeType\",\"name\":\"nodeType\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"childLeft\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"childRight\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"nodeHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"value\",\"type\":\"bytes32\"}],\"internalType\":\"structSparseMerkleTree.Node\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"methodId_\",\"type\":\"uint8\"}],\"name\":\"getNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key_\",\"type\":\"bytes32\"}],\"name\":\"getProof\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bool\",\"name\":\"existence\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"value\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"auxExistence\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"auxKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"auxValue\",\"type\":\"bytes32\"}],\"internalType\":\"structSparseMerkleTree.Proof\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"isRootLatest\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"isRootValid\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proxiableUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"}],\"name\":\"remove\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"signer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stateKeeper\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"newElement_\",\"type\":\"bytes32\"}],\"name\":\"update\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"proof_\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data_\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCallWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"proof_\",\"type\":\"bytes\"}],\"name\":\"upgradeToWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// PoseidonSMTABI is the input ABI used to generate the binding from. +// Deprecated: Use PoseidonSMTMetaData.ABI instead. +var PoseidonSMTABI = PoseidonSMTMetaData.ABI + +// PoseidonSMT is an auto generated Go binding around an Ethereum contract. +type PoseidonSMT struct { + PoseidonSMTCaller // Read-only binding to the contract + PoseidonSMTTransactor // Write-only binding to the contract + PoseidonSMTFilterer // Log filterer for contract events +} + +// PoseidonSMTCaller is an auto generated read-only Go binding around an Ethereum contract. +type PoseidonSMTCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PoseidonSMTTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PoseidonSMTFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PoseidonSMTSession struct { + Contract *PoseidonSMT // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoseidonSMTCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PoseidonSMTCallerSession struct { + Contract *PoseidonSMTCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PoseidonSMTTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PoseidonSMTTransactorSession struct { + Contract *PoseidonSMTTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoseidonSMTRaw is an auto generated low-level Go binding around an Ethereum contract. +type PoseidonSMTRaw struct { + Contract *PoseidonSMT // Generic contract binding to access the raw methods on +} + +// PoseidonSMTCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PoseidonSMTCallerRaw struct { + Contract *PoseidonSMTCaller // Generic read-only contract binding to access the raw methods on +} + +// PoseidonSMTTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PoseidonSMTTransactorRaw struct { + Contract *PoseidonSMTTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPoseidonSMT creates a new instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMT(address common.Address, backend bind.ContractBackend) (*PoseidonSMT, error) { + contract, err := bindPoseidonSMT(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PoseidonSMT{PoseidonSMTCaller: PoseidonSMTCaller{contract: contract}, PoseidonSMTTransactor: PoseidonSMTTransactor{contract: contract}, PoseidonSMTFilterer: PoseidonSMTFilterer{contract: contract}}, nil +} + +// NewPoseidonSMTCaller creates a new read-only instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTCaller(address common.Address, caller bind.ContractCaller) (*PoseidonSMTCaller, error) { + contract, err := bindPoseidonSMT(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PoseidonSMTCaller{contract: contract}, nil +} + +// NewPoseidonSMTTransactor creates a new write-only instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTTransactor(address common.Address, transactor bind.ContractTransactor) (*PoseidonSMTTransactor, error) { + contract, err := bindPoseidonSMT(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PoseidonSMTTransactor{contract: contract}, nil +} + +// NewPoseidonSMTFilterer creates a new log filterer instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTFilterer(address common.Address, filterer bind.ContractFilterer) (*PoseidonSMTFilterer, error) { + contract, err := bindPoseidonSMT(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PoseidonSMTFilterer{contract: contract}, nil +} + +// bindPoseidonSMT binds a generic wrapper to an already deployed contract. +func bindPoseidonSMT(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PoseidonSMTMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoseidonSMT *PoseidonSMTRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoseidonSMT.Contract.PoseidonSMTCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoseidonSMT *PoseidonSMTRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoseidonSMT *PoseidonSMTRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoseidonSMT *PoseidonSMTCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoseidonSMT.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoseidonSMT *PoseidonSMTTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoseidonSMT.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoseidonSMT *PoseidonSMTTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoseidonSMT.Contract.contract.Transact(opts, method, params...) +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTCaller) MAGICID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "MAGIC_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTSession) MAGICID() (uint8, error) { + return _PoseidonSMT.Contract.MAGICID(&_PoseidonSMT.CallOpts) +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTCallerSession) MAGICID() (uint8, error) { + return _PoseidonSMT.Contract.MAGICID(&_PoseidonSMT.CallOpts) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) P(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "P") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) P() (*big.Int, error) { + return _PoseidonSMT.Contract.P(&_PoseidonSMT.CallOpts) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) P() (*big.Int, error) { + return _PoseidonSMT.Contract.P(&_PoseidonSMT.CallOpts) +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) ROOTVALIDITY(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "ROOT_VALIDITY") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) ROOTVALIDITY() (*big.Int, error) { + return _PoseidonSMT.Contract.ROOTVALIDITY(&_PoseidonSMT.CallOpts) +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) ROOTVALIDITY() (*big.Int, error) { + return _PoseidonSMT.Contract.ROOTVALIDITY(&_PoseidonSMT.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTCaller) ChainName(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "chainName") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTSession) ChainName() (string, error) { + return _PoseidonSMT.Contract.ChainName(&_PoseidonSMT.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTCallerSession) ChainName() (string, error) { + return _PoseidonSMT.Contract.ChainName(&_PoseidonSMT.CallOpts) +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCaller) GetNodeByKey(opts *bind.CallOpts, key_ [32]byte) (SparseMerkleTreeNode, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getNodeByKey", key_) + + if err != nil { + return *new(SparseMerkleTreeNode), err + } + + out0 := *abi.ConvertType(out[0], new(SparseMerkleTreeNode)).(*SparseMerkleTreeNode) + + return out0, err + +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTSession) GetNodeByKey(key_ [32]byte) (SparseMerkleTreeNode, error) { + return _PoseidonSMT.Contract.GetNodeByKey(&_PoseidonSMT.CallOpts, key_) +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetNodeByKey(key_ [32]byte) (SparseMerkleTreeNode, error) { + return _PoseidonSMT.Contract.GetNodeByKey(&_PoseidonSMT.CallOpts, key_) +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) GetNonce(opts *bind.CallOpts, methodId_ uint8) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getNonce", methodId_) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) GetNonce(methodId_ uint8) (*big.Int, error) { + return _PoseidonSMT.Contract.GetNonce(&_PoseidonSMT.CallOpts, methodId_) +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetNonce(methodId_ uint8) (*big.Int, error) { + return _PoseidonSMT.Contract.GetNonce(&_PoseidonSMT.CallOpts, methodId_) +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCaller) GetProof(opts *bind.CallOpts, key_ [32]byte) (SparseMerkleTreeProof, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getProof", key_) + + if err != nil { + return *new(SparseMerkleTreeProof), err + } + + out0 := *abi.ConvertType(out[0], new(SparseMerkleTreeProof)).(*SparseMerkleTreeProof) + + return out0, err + +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTSession) GetProof(key_ [32]byte) (SparseMerkleTreeProof, error) { + return _PoseidonSMT.Contract.GetProof(&_PoseidonSMT.CallOpts, key_) +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetProof(key_ [32]byte) (SparseMerkleTreeProof, error) { + return _PoseidonSMT.Contract.GetProof(&_PoseidonSMT.CallOpts, key_) +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCaller) GetRoot(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getRoot") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTSession) GetRoot() ([32]byte, error) { + return _PoseidonSMT.Contract.GetRoot(&_PoseidonSMT.CallOpts) +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetRoot() ([32]byte, error) { + return _PoseidonSMT.Contract.GetRoot(&_PoseidonSMT.CallOpts) +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) Implementation(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "implementation") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) Implementation() (common.Address, error) { + return _PoseidonSMT.Contract.Implementation(&_PoseidonSMT.CallOpts) +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) Implementation() (common.Address, error) { + return _PoseidonSMT.Contract.Implementation(&_PoseidonSMT.CallOpts) +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCaller) IsRootLatest(opts *bind.CallOpts, root_ [32]byte) (bool, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "isRootLatest", root_) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTSession) IsRootLatest(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootLatest(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCallerSession) IsRootLatest(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootLatest(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCaller) IsRootValid(opts *bind.CallOpts, root_ [32]byte) (bool, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "isRootValid", root_) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTSession) IsRootValid(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootValid(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCallerSession) IsRootValid(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootValid(&_PoseidonSMT.CallOpts, root_) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCaller) ProxiableUUID(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "proxiableUUID") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTSession) ProxiableUUID() ([32]byte, error) { + return _PoseidonSMT.Contract.ProxiableUUID(&_PoseidonSMT.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCallerSession) ProxiableUUID() ([32]byte, error) { + return _PoseidonSMT.Contract.ProxiableUUID(&_PoseidonSMT.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) Signer(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "signer") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) Signer() (common.Address, error) { + return _PoseidonSMT.Contract.Signer(&_PoseidonSMT.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) Signer() (common.Address, error) { + return _PoseidonSMT.Contract.Signer(&_PoseidonSMT.CallOpts) +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) StateKeeper(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "stateKeeper") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) StateKeeper() (common.Address, error) { + return _PoseidonSMT.Contract.StateKeeper(&_PoseidonSMT.CallOpts) +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) StateKeeper() (common.Address, error) { + return _PoseidonSMT.Contract.StateKeeper(&_PoseidonSMT.CallOpts) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) PoseidonSMTInit(opts *bind.TransactOpts, signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "__PoseidonSMT_init", signer_, chainName_, stateKeeper_, treeHeight_) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTSession) PoseidonSMTInit(signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTInit(&_PoseidonSMT.TransactOpts, signer_, chainName_, stateKeeper_, treeHeight_) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) PoseidonSMTInit(signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTInit(&_PoseidonSMT.TransactOpts, signer_, chainName_, stateKeeper_, treeHeight_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Add(opts *bind.TransactOpts, keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "add", keyOfElement_, element_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Add(keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Add(&_PoseidonSMT.TransactOpts, keyOfElement_, element_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Add(keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Add(&_PoseidonSMT.TransactOpts, keyOfElement_, element_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) ChangeSigner(opts *bind.TransactOpts, newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "changeSigner", newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.ChangeSigner(&_PoseidonSMT.TransactOpts, newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.ChangeSigner(&_PoseidonSMT.TransactOpts, newSignerPubKey_, signature_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Remove(opts *bind.TransactOpts, keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "remove", keyOfElement_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Remove(keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Remove(&_PoseidonSMT.TransactOpts, keyOfElement_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Remove(keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Remove(&_PoseidonSMT.TransactOpts, keyOfElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Update(opts *bind.TransactOpts, keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "update", keyOfElement_, newElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Update(keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Update(&_PoseidonSMT.TransactOpts, keyOfElement_, newElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Update(keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Update(&_PoseidonSMT.TransactOpts, keyOfElement_, newElement_) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeTo(opts *bind.TransactOpts, newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeTo", newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeTo(&_PoseidonSMT.TransactOpts, newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeTo(&_PoseidonSMT.TransactOpts, newImplementation) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToAndCall(opts *bind.TransactOpts, newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToAndCall", newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCall(&_PoseidonSMT.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCall(&_PoseidonSMT.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToAndCallWithProof(opts *bind.TransactOpts, newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToAndCallWithProof", newImplementation_, proof_, data_) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToAndCallWithProof(newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCallWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_, data_) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToAndCallWithProof(newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCallWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_, data_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToWithProof(opts *bind.TransactOpts, newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToWithProof", newImplementation_, proof_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToWithProof(newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToWithProof(newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_) +} + +// PoseidonSMTAdminChangedIterator is returned from FilterAdminChanged and is used to iterate over the raw logs and unpacked data for AdminChanged events raised by the PoseidonSMT contract. +type PoseidonSMTAdminChangedIterator struct { + Event *PoseidonSMTAdminChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTAdminChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTAdminChanged represents a AdminChanged event raised by the PoseidonSMT contract. +type PoseidonSMTAdminChanged struct { + PreviousAdmin common.Address + NewAdmin common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAdminChanged is a free log retrieval operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterAdminChanged(opts *bind.FilterOpts) (*PoseidonSMTAdminChangedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return &PoseidonSMTAdminChangedIterator{contract: _PoseidonSMT.contract, event: "AdminChanged", logs: logs, sub: sub}, nil +} + +// WatchAdminChanged is a free log subscription operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchAdminChanged(opts *bind.WatchOpts, sink chan<- *PoseidonSMTAdminChanged) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTAdminChanged) + if err := _PoseidonSMT.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAdminChanged is a log parse operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseAdminChanged(log types.Log) (*PoseidonSMTAdminChanged, error) { + event := new(PoseidonSMTAdminChanged) + if err := _PoseidonSMT.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTBeaconUpgradedIterator is returned from FilterBeaconUpgraded and is used to iterate over the raw logs and unpacked data for BeaconUpgraded events raised by the PoseidonSMT contract. +type PoseidonSMTBeaconUpgradedIterator struct { + Event *PoseidonSMTBeaconUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTBeaconUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTBeaconUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTBeaconUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTBeaconUpgraded represents a BeaconUpgraded event raised by the PoseidonSMT contract. +type PoseidonSMTBeaconUpgraded struct { + Beacon common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBeaconUpgraded is a free log retrieval operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterBeaconUpgraded(opts *bind.FilterOpts, beacon []common.Address) (*PoseidonSMTBeaconUpgradedIterator, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return &PoseidonSMTBeaconUpgradedIterator{contract: _PoseidonSMT.contract, event: "BeaconUpgraded", logs: logs, sub: sub}, nil +} + +// WatchBeaconUpgraded is a free log subscription operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchBeaconUpgraded(opts *bind.WatchOpts, sink chan<- *PoseidonSMTBeaconUpgraded, beacon []common.Address) (event.Subscription, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTBeaconUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBeaconUpgraded is a log parse operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseBeaconUpgraded(log types.Log) (*PoseidonSMTBeaconUpgraded, error) { + event := new(PoseidonSMTBeaconUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the PoseidonSMT contract. +type PoseidonSMTInitializedIterator struct { + Event *PoseidonSMTInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTInitialized represents a Initialized event raised by the PoseidonSMT contract. +type PoseidonSMTInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterInitialized(opts *bind.FilterOpts) (*PoseidonSMTInitializedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &PoseidonSMTInitializedIterator{contract: _PoseidonSMT.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *PoseidonSMTInitialized) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTInitialized) + if err := _PoseidonSMT.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseInitialized(log types.Log) (*PoseidonSMTInitialized, error) { + event := new(PoseidonSMTInitialized) + if err := _PoseidonSMT.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTRootUpdatedIterator is returned from FilterRootUpdated and is used to iterate over the raw logs and unpacked data for RootUpdated events raised by the PoseidonSMT contract. +type PoseidonSMTRootUpdatedIterator struct { + Event *PoseidonSMTRootUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTRootUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTRootUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTRootUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTRootUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTRootUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTRootUpdated represents a RootUpdated event raised by the PoseidonSMT contract. +type PoseidonSMTRootUpdated struct { + Root [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRootUpdated is a free log retrieval operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterRootUpdated(opts *bind.FilterOpts) (*PoseidonSMTRootUpdatedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "RootUpdated") + if err != nil { + return nil, err + } + return &PoseidonSMTRootUpdatedIterator{contract: _PoseidonSMT.contract, event: "RootUpdated", logs: logs, sub: sub}, nil +} + +// WatchRootUpdated is a free log subscription operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchRootUpdated(opts *bind.WatchOpts, sink chan<- *PoseidonSMTRootUpdated) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "RootUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTRootUpdated) + if err := _PoseidonSMT.contract.UnpackLog(event, "RootUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRootUpdated is a log parse operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseRootUpdated(log types.Log) (*PoseidonSMTRootUpdated, error) { + event := new(PoseidonSMTRootUpdated) + if err := _PoseidonSMT.contract.UnpackLog(event, "RootUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the PoseidonSMT contract. +type PoseidonSMTUpgradedIterator struct { + Event *PoseidonSMTUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTUpgraded represents a Upgraded event raised by the PoseidonSMT contract. +type PoseidonSMTUpgraded struct { + Implementation common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUpgraded is a free log retrieval operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterUpgraded(opts *bind.FilterOpts, implementation []common.Address) (*PoseidonSMTUpgradedIterator, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return &PoseidonSMTUpgradedIterator{contract: _PoseidonSMT.contract, event: "Upgraded", logs: logs, sub: sub}, nil +} + +// WatchUpgraded is a free log subscription operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchUpgraded(opts *bind.WatchOpts, sink chan<- *PoseidonSMTUpgraded, implementation []common.Address) (event.Subscription, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "Upgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUpgraded is a log parse operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseUpgraded(log types.Log) (*PoseidonSMTUpgraded, error) { + event := new(PoseidonSMTUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "Upgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/x/rootupdater/simulation/helpers.go b/x/rootupdater/simulation/helpers.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/rootupdater/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/rootupdater/types/codec.go b/x/rootupdater/types/codec.go new file mode 100644 index 00000000..09dd9f18 --- /dev/null +++ b/x/rootupdater/types/codec.go @@ -0,0 +1,22 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/rootupdater/types/errors.go b/x/rootupdater/types/errors.go new file mode 100644 index 00000000..0d126001 --- /dev/null +++ b/x/rootupdater/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/rootupdater module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + +) diff --git a/x/rootupdater/types/expected_keepers.go b/x/rootupdater/types/expected_keepers.go new file mode 100644 index 00000000..e731e16a --- /dev/null +++ b/x/rootupdater/types/expected_keepers.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rarimocore/types" +) + +type RarimocoreKeeper interface { + CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.PassportRootUpdate) (string, error) +} diff --git a/x/rootupdater/types/genesis.go b/x/rootupdater/types/genesis.go new file mode 100644 index 00000000..c41be074 --- /dev/null +++ b/x/rootupdater/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/rootupdater/types/genesis.pb.go b/x/rootupdater/types/genesis.pb.go new file mode 100644 index 00000000..54df8037 --- /dev/null +++ b/x/rootupdater/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the rootupdater module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_9aceb595c789c725, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "rarimo.rarimocore.rootupdater.GenesisState") +} + +func init() { proto.RegisterFile("rootupdater/genesis.proto", fileDescriptor_9aceb595c789c725) } + +var fileDescriptor_9aceb595c789c725 = []byte{ + // 199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xca, 0xcf, 0x2f, + 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x2d, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x83, 0x50, + 0xc9, 0xf9, 0x45, 0xa9, 0x7a, 0x48, 0x8a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x2a, 0xf5, + 0x41, 0x2c, 0x88, 0x26, 0x29, 0x09, 0x64, 0xf3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xc6, 0x29, + 0x05, 0x73, 0xf1, 0xb8, 0x43, 0xcc, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x72, 0xe6, 0x62, 0x83, + 0xc8, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xa9, 0xea, 0xe1, 0xb5, 0x4f, 0x2f, 0x00, 0xac, + 0xd8, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x56, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, + 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, + 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, + 0xcf, 0xd5, 0x87, 0x98, 0x08, 0xa5, 0x74, 0x41, 0x26, 0xeb, 0x57, 0xe8, 0x23, 0x3b, 0xb4, 0xa4, + 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x50, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb2, + 0xb4, 0x39, 0x26, 0x14, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rootupdater/types/genesis_test.go b/x/rootupdater/types/genesis_test.go new file mode 100644 index 00000000..f9ef03ee --- /dev/null +++ b/x/rootupdater/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/rootupdater/types/keys.go b/x/rootupdater/types/keys.go new file mode 100644 index 00000000..eceb4eb1 --- /dev/null +++ b/x/rootupdater/types/keys.go @@ -0,0 +1,22 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "rootupdater" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_rootupdater" + + // ParamsKey defines the store key for module params entry + ParamsKey = "params" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/rootupdater/types/params.go b/x/rootupdater/types/params.go new file mode 100644 index 00000000..4f3215e3 --- /dev/null +++ b/x/rootupdater/types/params.go @@ -0,0 +1,32 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go new file mode 100644 index 00000000..8383ca09 --- /dev/null +++ b/x/rootupdater/types/params.pb.go @@ -0,0 +1,600 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` + LastSignedRoot string `protobuf:"bytes,3,opt,name=last_signed_root,json=lastSignedRoot,proto3" json:"last_signed_root,omitempty"` + LastSignedRootIndex string `protobuf:"bytes,4,opt,name=last_signed_root_index,json=lastSignedRootIndex,proto3" json:"last_signed_root_index,omitempty"` + EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + RootTimestamp int64 `protobuf:"varint,6,opt,name=root_timestamp,json=rootTimestamp,proto3" json:"root_timestamp,omitempty"` + BlockHeight uint64 `protobuf:"varint,7,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_31e4e5f76db9f10e, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *Params) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (m *Params) GetLastSignedRoot() string { + if m != nil { + return m.LastSignedRoot + } + return "" +} + +func (m *Params) GetLastSignedRootIndex() string { + if m != nil { + return m.LastSignedRootIndex + } + return "" +} + +func (m *Params) GetEventName() string { + if m != nil { + return m.EventName + } + return "" +} + +func (m *Params) GetRootTimestamp() int64 { + if m != nil { + return m.RootTimestamp + } + return 0 +} + +func (m *Params) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "rarimo.rarimocore.rootupdater.Params") +} + +func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4e5f76db9f10e) } + +var fileDescriptor_31e4e5f76db9f10e = []byte{ + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xc1, 0x4a, 0x03, 0x31, + 0x10, 0x86, 0x9b, 0xb6, 0x56, 0x1a, 0xb5, 0x96, 0x28, 0x12, 0x84, 0x2e, 0x55, 0x10, 0xd6, 0x83, + 0xbb, 0x48, 0x9f, 0x40, 0x4f, 0x8a, 0x20, 0xb2, 0x7a, 0xf2, 0xb2, 0xa4, 0xbb, 0x61, 0x1b, 0x6c, + 0x36, 0x4b, 0x32, 0x95, 0xfa, 0x14, 0xfa, 0x58, 0x1e, 0x7b, 0xf4, 0x28, 0xed, 0x8b, 0x48, 0x66, + 0x2d, 0x54, 0x4f, 0x33, 0x7c, 0xff, 0x97, 0x39, 0xfc, 0xa1, 0xdc, 0x1a, 0x03, 0xb3, 0x2a, 0x17, + 0x20, 0x6d, 0x5c, 0x09, 0x2b, 0xb4, 0x8b, 0x2a, 0x6b, 0xc0, 0xb0, 0x81, 0x15, 0x56, 0x69, 0x13, + 0xd5, 0x23, 0x33, 0x56, 0x46, 0x1b, 0xee, 0xf1, 0x61, 0x61, 0x0a, 0x83, 0x66, 0xec, 0xb7, 0xfa, + 0xd1, 0xe9, 0x7b, 0x93, 0x76, 0x1e, 0xf0, 0x0a, 0x3b, 0xa7, 0xfd, 0xcc, 0x94, 0x60, 0x45, 0x06, + 0xa9, 0xc8, 0x73, 0x2b, 0x9d, 0xe3, 0x64, 0x48, 0xc2, 0x6e, 0xb2, 0xbf, 0xe6, 0x57, 0x35, 0x66, + 0x8c, 0xb6, 0xfd, 0x69, 0xde, 0xc4, 0x18, 0x77, 0x16, 0xd2, 0xfe, 0x54, 0x38, 0x48, 0x9d, 0x2a, + 0x4a, 0x99, 0xa7, 0x98, 0xb7, 0x30, 0xef, 0x79, 0xfe, 0x88, 0x38, 0xf1, 0xe6, 0x88, 0x1e, 0xfd, + 0x37, 0x53, 0x55, 0xe6, 0x72, 0xce, 0xdb, 0xe8, 0x1f, 0xfc, 0xf5, 0x6f, 0x7d, 0xc4, 0x06, 0x94, + 0xca, 0x57, 0x59, 0x42, 0x5a, 0x0a, 0x2d, 0xf9, 0x16, 0x8a, 0x5d, 0x24, 0xf7, 0x42, 0x4b, 0x76, + 0x46, 0x7b, 0x78, 0x07, 0x94, 0x96, 0x0e, 0x84, 0xae, 0x78, 0x67, 0x48, 0xc2, 0x56, 0xb2, 0xe7, + 0xe9, 0xd3, 0x1a, 0xb2, 0x13, 0xba, 0x3b, 0x9e, 0x9a, 0xec, 0x25, 0x9d, 0x48, 0x55, 0x4c, 0x80, + 0x6f, 0x0f, 0x49, 0xd8, 0x4e, 0x76, 0x90, 0xdd, 0x20, 0xba, 0xbe, 0xfb, 0x5c, 0x06, 0x64, 0xb1, + 0x0c, 0xc8, 0xf7, 0x32, 0x20, 0x1f, 0xab, 0xa0, 0xb1, 0x58, 0x05, 0x8d, 0xaf, 0x55, 0xd0, 0x78, + 0xbe, 0x2c, 0x14, 0x4c, 0x66, 0xe3, 0x28, 0x33, 0x3a, 0xae, 0x4b, 0xfe, 0x1d, 0x17, 0xbe, 0xec, + 0x78, 0x1e, 0x6f, 0x7e, 0x0d, 0xbc, 0x55, 0xd2, 0x8d, 0x3b, 0xd8, 0xf2, 0xe8, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x0e, 0x6b, 0x5d, 0x49, 0xb6, 0x01, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeight != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x38 + } + if m.RootTimestamp != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RootTimestamp)) + i-- + dAtA[i] = 0x30 + } + if len(m.EventName) > 0 { + i -= len(m.EventName) + copy(dAtA[i:], m.EventName) + i = encodeVarintParams(dAtA, i, uint64(len(m.EventName))) + i-- + dAtA[i] = 0x2a + } + if len(m.LastSignedRootIndex) > 0 { + i -= len(m.LastSignedRootIndex) + copy(dAtA[i:], m.LastSignedRootIndex) + i = encodeVarintParams(dAtA, i, uint64(len(m.LastSignedRootIndex))) + i-- + dAtA[i] = 0x22 + } + if len(m.LastSignedRoot) > 0 { + i -= len(m.LastSignedRoot) + copy(dAtA[i:], m.LastSignedRoot) + i = encodeVarintParams(dAtA, i, uint64(len(m.LastSignedRoot))) + i-- + dAtA[i] = 0x1a + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintParams(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0x12 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.Root) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.LastSignedRoot) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.LastSignedRootIndex) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.EventName) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.RootTimestamp != 0 { + n += 1 + sovParams(uint64(m.RootTimestamp)) + } + if m.BlockHeight != 0 { + n += 1 + sovParams(uint64(m.BlockHeight)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastSignedRoot", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastSignedRoot = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastSignedRootIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastSignedRootIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EventName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RootTimestamp", wireType) + } + m.RootTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RootTimestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rootupdater/types/query.pb.go b/x/rootupdater/types/query.pb.go new file mode 100644 index 00000000..53f102dc --- /dev/null +++ b/x/rootupdater/types/query.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3408f22fd1bb339b, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3408f22fd1bb339b, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "rarimo.rarimocore.rootupdater.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "rarimo.rarimocore.rootupdater.QueryParamsResponse") +} + +func init() { proto.RegisterFile("rootupdater/query.proto", fileDescriptor_3408f22fd1bb339b) } + +var fileDescriptor_3408f22fd1bb339b = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xc1, 0x4a, 0xf3, 0x40, + 0x10, 0xc7, 0xb3, 0x1f, 0x9f, 0x3d, 0xac, 0xb7, 0xb5, 0x60, 0x29, 0xba, 0x4a, 0x40, 0x29, 0x82, + 0xbb, 0x24, 0xbe, 0x41, 0x3d, 0x7a, 0xd1, 0x1e, 0x7b, 0xdb, 0xc4, 0x65, 0x0d, 0x98, 0xcc, 0x76, + 0x77, 0x23, 0xf6, 0xea, 0x13, 0x08, 0x3e, 0x80, 0x67, 0xdf, 0xa4, 0xc7, 0x82, 0x17, 0x4f, 0x22, + 0x89, 0x0f, 0x22, 0xc9, 0xe6, 0xd0, 0x52, 0x51, 0x3c, 0x4d, 0x98, 0xfc, 0x7f, 0xbf, 0x9d, 0x19, + 0xbc, 0x6b, 0x00, 0x5c, 0xa9, 0xaf, 0x85, 0x93, 0x86, 0xcf, 0x4a, 0x69, 0xe6, 0x4c, 0x1b, 0x70, + 0x40, 0xf6, 0x8d, 0x30, 0x59, 0x0e, 0xcc, 0x97, 0x14, 0x8c, 0x64, 0x2b, 0xd1, 0x61, 0x5f, 0x81, + 0x82, 0x36, 0xc9, 0x9b, 0x2f, 0x0f, 0x0d, 0xf7, 0x14, 0x80, 0xba, 0x95, 0x5c, 0xe8, 0x8c, 0x8b, + 0xa2, 0x00, 0x27, 0x5c, 0x06, 0x85, 0xed, 0xfe, 0x9e, 0xa4, 0x60, 0x73, 0xb0, 0x3c, 0x11, 0x56, + 0xfa, 0xb7, 0xf8, 0x5d, 0x94, 0x48, 0x27, 0x22, 0xae, 0x85, 0xca, 0x8a, 0x36, 0xdc, 0x65, 0x07, + 0xab, 0x73, 0x69, 0x61, 0x44, 0xde, 0x59, 0xc2, 0x3e, 0x26, 0x57, 0x0d, 0x7b, 0xd9, 0x36, 0x27, + 0x72, 0x56, 0x4a, 0xeb, 0xc2, 0x29, 0xde, 0x59, 0xeb, 0x5a, 0x0d, 0x85, 0x95, 0xe4, 0x1c, 0xf7, + 0x3c, 0x3c, 0x40, 0x87, 0x68, 0xb4, 0x1d, 0x1f, 0xb1, 0x1f, 0xd7, 0x62, 0x1e, 0x1f, 0xff, 0x5f, + 0xbc, 0x1f, 0x04, 0x93, 0x0e, 0x8d, 0x5f, 0x10, 0xde, 0x6a, 0xe5, 0xe4, 0x19, 0xe1, 0x9e, 0x8f, + 0x90, 0xe8, 0x17, 0xd3, 0xe6, 0x8c, 0xc3, 0xf8, 0x2f, 0x88, 0x5f, 0x20, 0x64, 0x0f, 0xaf, 0x9f, + 0x4f, 0xff, 0x46, 0xe4, 0x98, 0x7b, 0xa8, 0x2b, 0xa7, 0x0d, 0xcc, 0x37, 0x6f, 0x34, 0xbe, 0x58, + 0x54, 0x14, 0x2d, 0x2b, 0x8a, 0x3e, 0x2a, 0x8a, 0x1e, 0x6b, 0x1a, 0x2c, 0x6b, 0x1a, 0xbc, 0xd5, + 0x34, 0x98, 0x46, 0x2a, 0x73, 0x37, 0x65, 0xc2, 0x52, 0xc8, 0xbf, 0x73, 0xdd, 0xaf, 0xd9, 0xdc, + 0x5c, 0x4b, 0x9b, 0xf4, 0xda, 0x8b, 0x9f, 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x4b, 0x45, + 0xb2, 0x25, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/rarimo.rarimocore.rootupdater.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rarimo.rarimocore.rootupdater.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rarimo.rarimocore.rootupdater.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rootupdater/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rootupdater/types/query.pb.gw.go b/x/rootupdater/types/query.pb.gw.go new file mode 100644 index 00000000..3ae4ed08 --- /dev/null +++ b/x/rootupdater/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: rootupdater/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"rarimo", "rarimo-core", "rootupdater", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/rootupdater/types/tx.pb.go b/x/rootupdater/types/tx.pb.go new file mode 100644 index 00000000..b0c59f37 --- /dev/null +++ b/x/rootupdater/types/tx.pb.go @@ -0,0 +1,81 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("rootupdater/tx.proto", fileDescriptor_72679a1b23c83bcf) } + +var fileDescriptor_72679a1b23c83bcf = []byte{ + // 133 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0xca, 0xcf, 0x2f, + 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x92, 0x2d, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x83, 0x50, 0xc9, 0xf9, 0x45, 0xa9, 0x7a, + 0x48, 0xea, 0x8c, 0x58, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x9d, 0xbc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, + 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, + 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x30, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x1f, 0x62, 0x06, 0x94, 0xd2, 0x05, 0x99, 0xa5, 0x5f, 0xa1, 0x8f, 0x62, 0x6b, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x66, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x6c, 0x08, + 0x7a, 0x91, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rarimo.rarimocore.rootupdater.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "rootupdater/tx.proto", +} diff --git a/x/rootupdater/types/types.go b/x/rootupdater/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/rootupdater/types/types.go @@ -0,0 +1 @@ +package types